stringelement.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 "textelement.h"
21#include "stringelement.h"
22
23KFORMULA_NAMESPACE_BEGIN
24
25StringElement::StringElement( BasicElement* parent ) : TokenElement( parent )
26{
27}
28
29bool StringElement::readAttributesFromMathMLDom(const TQDomElement& element)
30{
32 return false;
33 }
34
35 if ( ! inherited::readAttributesFromMathMLDom( element ) ) {
36 return false;
37 }
38
39 m_lquote = element.attribute( "lquote" );
40 if ( ! m_lquote.isNull() ) {
41 m_customLquote = true;
42 }
43 m_rquote = element.attribute( "rquote" );
44 if ( ! m_rquote.isNull() ) {
45 m_customRquote = true;
46 }
47
48 return true;
49}
50
51int StringElement::buildChildrenFromMathMLDom(TQPtrList<BasicElement>& list, TQDomNode n)
52{
53 int count = inherited::buildChildrenFromMathMLDom( list, n );
54 if ( count == -1 )
55 return -1;
56 TextElement* child = new TextElement( '"' );
57 child->setParent( this );
58 child->setCharFamily( charFamily() );
59 child->setCharStyle( charStyle() );
60 insert( 0, child );
61 child = new TextElement( '"' );
62 child->setParent( this );
63 child->setCharFamily( charFamily() );
64 child->setCharStyle( charStyle() );
65 insert( countChildren(), child );
66 return count;
67}
68
69void StringElement::writeMathMLAttributes( TQDomElement& element ) const
70{
71 inherited::writeMathMLAttributes( element );
72 if ( m_customLquote ) {
73 element.setAttribute( "lquote", m_lquote );
74 }
75 if ( m_customRquote ) {
76 element.setAttribute( "rquote", m_rquote );
77 }
78}
79
80void StringElement::writeMathMLContent( TQDomDocument& doc, TQDomElement& element, bool oasisFormat ) const
81{
82 for ( uint i = 1; i < countChildren() - 1; ++i ) {
83 const BasicElement* e = getChild( i );
84 e->writeMathML( doc, element, oasisFormat );
85 }
86}
87
88KFORMULA_NAMESPACE_END
Basis of every formula element.
virtual bool readAttributesFromMathMLDom(const TQDomElement &element)
Reads our attributes from the MathML element.
virtual void writeMathML(TQDomDocument &doc, TQDomNode &parent, bool oasisFormat=false) const
Same as above, just MathML.
An element that represents one char.
Definition textelement.h:37