lib

stringelement.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Alfredo Beaumont Sainz <alfredo.beaumont@gmail.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "textelement.h"
00021 #include "stringelement.h"
00022 
00023 KFORMULA_NAMESPACE_BEGIN
00024 
00025 StringElement::StringElement( BasicElement* parent ) : TokenElement( parent ) 
00026 {
00027 }
00028 
00029 bool StringElement::readAttributesFromMathMLDom(const QDomElement& element)
00030 {
00031     if ( ! BasicElement::readAttributesFromMathMLDom( element ) ) {
00032         return false;
00033     }
00034 
00035     if ( ! inherited::readAttributesFromMathMLDom( element ) ) {
00036         return false;
00037     }
00038 
00039     m_lquote = element.attribute( "lquote" );
00040     if ( ! m_lquote.isNull() ) {
00041         m_customLquote = true;
00042     }
00043     m_rquote = element.attribute( "rquote" );
00044     if ( ! m_rquote.isNull() ) {
00045         m_customRquote = true;
00046     }
00047 
00048     return true;
00049 }
00050 
00051 int StringElement::buildChildrenFromMathMLDom(QPtrList<BasicElement>& list, QDomNode n) 
00052 {
00053     int count = inherited::buildChildrenFromMathMLDom( list, n );
00054     if ( count == -1 )
00055         return -1;
00056     TextElement* child = new TextElement( '"' );
00057     child->setParent( this );
00058     child->setCharFamily( charFamily() );
00059     child->setCharStyle( charStyle() );
00060     insert( 0, child );
00061     child = new TextElement( '"' );
00062     child->setParent( this );
00063     child->setCharFamily( charFamily() );
00064     child->setCharStyle( charStyle() );
00065     insert( countChildren(), child );
00066     return count;
00067 }
00068 
00069 void StringElement::writeMathMLAttributes( QDomElement& element ) const
00070 {
00071     inherited::writeMathMLAttributes( element );
00072     if ( m_customLquote ) {
00073         element.setAttribute( "lquote", m_lquote );
00074     }
00075     if ( m_customRquote ) {
00076         element.setAttribute( "rquote", m_rquote );
00077     }
00078 }
00079 
00080 void StringElement::writeMathMLContent( QDomDocument& doc, QDomElement& element, bool oasisFormat ) const
00081 {
00082     for ( uint i = 1; i < countChildren() - 1; ++i ) {
00083         const BasicElement* e = getChild( i );
00084         e->writeMathML( doc, element, oasisFormat );
00085     }
00086 }
00087 
00088 KFORMULA_NAMESPACE_END
KDE Home | KDE Accessibility Home | Description of Access Keys