F:/KPlato/koffice/libs/kformula/FormulaShape.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) Martin Pfeiffer <hubipete@gmx.net>
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 "FormulaShape.h"
00021 #include "FormulaElement.h"
00022 #include <KoXmlWriter.h>
00023 
00024 namespace KFormula {
00025         
00026 FormulaShape::FormulaShape()
00027 {
00028     m_formulaElement = new FormulaElement();
00029 }
00030 
00031 FormulaShape::~FormulaShape()
00032 {
00033     delete m_formulaElement;
00034 }
00035 
00036 void FormulaShape::paint( QPainter &painter, KoViewConverter &converter ) 
00037 {
00038     applyConversion( painter, converter );   // apply zooming and coordinate translation
00039     m_formulaElement->paint( painter );      // paint the formula
00040 }
00041 
00042 BasicElement* FormulaShape::elementAt( const QPointF& p )
00043 {
00044     return m_formulaElement->childElementAt( p );
00045 }
00046 
00047 QSizeF FormulaShape::size() const
00048 {
00049     return m_formulaElement->boundingRect().size();
00050 }
00051 
00052 void FormulaShape::resize( const QSizeF& )
00053 {
00054     // do nothing as FormulaShape is fixed size
00055 }
00056 
00057 QRectF FormulaShape::boundingRect() const
00058 {
00059     return m_invMatrix.inverted().mapRect( m_formulaElement->boundingRect() );
00060 }
00061 
00062 BasicElement* FormulaShape::formulaElement() const
00063 {
00064     return m_formulaElement;
00065 }
00066 
00067 void FormulaShape::loadMathML( const QDomDocument &doc, bool )
00068 {
00069     delete m_formulaElement;                                // delete the old formula
00070     m_formulaElement = new FormulaElement();                // create a new root element
00071     m_formulaElement->readMathML( doc.documentElement() );  // and load the new formula
00072 }
00073 
00074 void FormulaShape::saveMathML( KoXmlWriter* writer, bool oasisFormat )
00075 {
00076     if( m_formulaElement->childElements().isEmpty() )  // if the formula is empty
00077         return;                                        // do not save it
00078     
00079     m_formulaElement->writeMathML( writer, oasisFormat );
00080 }
00081 
00082 } // namespace KFormula
00083 

Généré le Wed Nov 22 23:41:00 2006 pour KPlato par  doxygen 1.5.1-p1