actionelement.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "creationstrategy.h"
21#include "actionelement.h"
22
23KFORMULA_NAMESPACE_BEGIN
24
25ActionElement::ActionElement( BasicElement* parent ) : SequenceElement( parent ),
26 m_selection( 0 )
27{
28}
29
30bool ActionElement::readAttributesFromMathMLDom(const TQDomElement& element)
31{
33 return false;
34 }
35
36 m_actionType = element.attribute( "actiontype" );
37 TQString selectionStr = element.attribute( "selection" );
38 if ( ! selectionStr.isNull() ) {
39 bool ok;
40 m_selection = selectionStr.toUInt( &ok );
41 if ( ! ok ) m_selection = 0;
42 }
43
44 return true;
45}
46
47int ActionElement::buildChildrenFromMathMLDom(TQPtrList<BasicElement>& list, TQDomNode n)
48{
49 if ( ! n.isElement() )
50 return -1;
51 TQDomElement e = n.toElement();
52 TQString tag = e.tagName().lower();
53 BasicElement* child = getCreationStrategy()->createElement( tag, e );
54 if ( child == 0 )
55 return -1;
56 child->setParent( this );
57 if ( child->buildFromMathMLDom( e ) == -1 ) {
58 delete child;
59 return -1;
60 }
61 list.append( child );
62 parse();
63 return 1;
64}
65
66void ActionElement::writeMathMLAttributes( TQDomElement& element ) const
67{
68 if ( ! m_actionType.isNull() ) {
69 element.setAttribute( "actiontype", m_actionType );
70 }
71 if ( m_selection ) {
72 element.setAttribute( "selection", TQString( "%1" ).arg( m_selection ) );
73 }
74}
75
76
77KFORMULA_NAMESPACE_END
Basis of every formula element.
virtual bool readAttributesFromMathMLDom(const TQDomElement &element)
Reads our attributes from the MathML element.
int buildFromMathMLDom(TQDomElement element)
Set this element attribute, build children and call their builFromMathMLDom.
The element that contains a number of children.
virtual void parse()
Parses the sequence and generates a new syntax tree.