lib
actionelement.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "creationstrategy.h"
00021 #include "actionelement.h"
00022
00023 KFORMULA_NAMESPACE_BEGIN
00024
00025 ActionElement::ActionElement( BasicElement* parent ) : SequenceElement( parent ),
00026 m_selection( 0 )
00027 {
00028 }
00029
00030 bool ActionElement::readAttributesFromMathMLDom(const QDomElement& element)
00031 {
00032 if ( ! BasicElement::readAttributesFromMathMLDom( element ) ) {
00033 return false;
00034 }
00035
00036 m_actionType = element.attribute( "actiontype" );
00037 QString selectionStr = element.attribute( "selection" );
00038 if ( ! selectionStr.isNull() ) {
00039 bool ok;
00040 m_selection = selectionStr.toUInt( &ok );
00041 if ( ! ok ) m_selection = 0;
00042 }
00043
00044 return true;
00045 }
00046
00047 int ActionElement::buildChildrenFromMathMLDom(QPtrList<BasicElement>& list, QDomNode n)
00048 {
00049 if ( ! n.isElement() )
00050 return -1;
00051 QDomElement e = n.toElement();
00052 QString tag = e.tagName().lower();
00053 BasicElement* child = getCreationStrategy()->createElement( tag, e );
00054 if ( child == 0 )
00055 return -1;
00056 child->setParent( this );
00057 if ( child->buildFromMathMLDom( e ) == -1 ) {
00058 delete child;
00059 return -1;
00060 }
00061 list.append( child );
00062 parse();
00063 return 1;
00064 }
00065
00066 void ActionElement::writeMathMLAttributes( QDomElement& element ) const
00067 {
00068 if ( ! m_actionType.isNull() ) {
00069 element.setAttribute( "actiontype", m_actionType );
00070 }
00071 if ( m_selection ) {
00072 element.setAttribute( "selection", QString( "%1" ).arg( m_selection ) );
00073 }
00074 }
00075
00076
00077 KFORMULA_NAMESPACE_END
|