File indexing completed on 2024-05-12 16:34:02
0001 /* This file is part of the KDE project 0002 Copyright (C) 2006 Martin Pfeiffer <hubipete@gmx.net> 0003 2009 Jeremias Epperlein <jeeree@web.de> 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KOFORMULASHAPE_H 0021 #define KOFORMULASHAPE_H 0022 0023 #include <KoShape.h> 0024 #define KoFormulaShapeId "FormulaShapeID" 0025 #include <KoFrameShape.h> 0026 0027 class KoStore; 0028 class KoDocumentResourceManager; 0029 class KoOdfLoadingContext; 0030 0031 class BasicElement; 0032 class FormulaRenderer; 0033 class FormulaData; 0034 class FormulaDocument; 0035 0036 /** 0037 * @short The flake shape for a formula 0038 * 0039 * This class is basically the container for the formula and has also methods to paint, 0040 * load and save the formula. The formulaRenderer instance that is part of this class 0041 * serves to paint and layout the formula. The actual formula data means the tree of 0042 * elements is accessible through the root element which is constructed and destroyed 0043 * by this class that holds a pointer to it. Everything that goes into the area of 0044 * editing the formula data is implemented in KoFormulaTool respectively FormulaCursor. 0045 * 0046 * @author Martin Pfeiffer <hubipete@gmx.net> 0047 */ 0048 class KoFormulaShape : public KoShape, public KoFrameShape { 0049 public: 0050 /// The basic constructor 0051 explicit KoFormulaShape(KoDocumentResourceManager *documentResourceManager); 0052 //KoFormulaShape(); 0053 0054 /// The basic destructor 0055 ~KoFormulaShape() override; 0056 0057 /// inherited from KoShape 0058 void paint( QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &paintcontext) override; 0059 0060 void updateLayout(); 0061 0062 /// @return The element at the point @p p 0063 BasicElement* elementAt( const QPointF& p ); 0064 0065 /// Resize the shape. 0066 void resize( const QSizeF &size ); 0067 0068 /// @return Get the bounding box of the shape. 0069 // QRectF boundingRect() const; 0070 0071 /// @return the data shown by the shape 0072 FormulaData* formulaData() const; 0073 0074 /// @return the formularenderer used to paint this shape 0075 FormulaRenderer* formulaRenderer() const; 0076 0077 /** 0078 * Load a shape from odf - reimplemented from KoShape 0079 * @param context the KoShapeLoadingContext used for loading 0080 * @param element element which represents the shape in odf 0081 * @return false if loading failed 0082 */ 0083 bool loadOdf( const KoXmlElement& element, KoShapeLoadingContext& context ) override; 0084 0085 bool loadOdfFrameElement(const KoXmlElement& element, KoShapeLoadingContext& context) override; 0086 bool loadOdfEmbedded(const KoXmlElement &mathElement, KoShapeLoadingContext &context); 0087 0088 /** 0089 * @brief store the shape data as ODF XML. - reimplemented from KoShape 0090 * This is the method that will be called when saving a shape as a described in 0091 * OpenDocument 9.2 Drawing Shapes. 0092 * @see saveOdfAttributes 0093 */ 0094 void saveOdf( KoShapeSavingContext& context ) const override; 0095 0096 KoDocumentResourceManager *resourceManager() const; 0097 0098 private: 0099 bool loadEmbeddedDocument(KoStore *store,const KoXmlElement &objectElement, 0100 const KoOdfLoadingContext &odfLoadingContext); 0101 0102 /// The data this shape displays 0103 FormulaData* m_formulaData; 0104 0105 /// The renderer that takes care of painting the shape's formula 0106 FormulaRenderer* m_formulaRenderer; 0107 0108 /// True if this formula is inline, i.e. not embedded in a formula document. 0109 bool m_isInline; 0110 0111 FormulaDocument *m_document; 0112 KoDocumentResourceManager *m_resourceManager; 0113 }; 0114 0115 #endif // KOFORMULASHAPE_H