File indexing completed on 2025-01-19 10:49:27

0001 /* This file is part of the KDE project
0002 
0003    SPDX-FileCopyrightText: 2012-2014 Inge Wallin <inge@lysator.liu.se>
0004 
0005    SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef ODFDRAWREADER_H
0009 #define ODFDRAWREADER_H
0010 
0011 // Qt
0012 #include <QHash>
0013 #include <QString>
0014 
0015 // Calligra
0016 #include <KoXmlStreamReader.h>
0017 
0018 // this library
0019 #include "koodfreader_export.h"
0020 #include "OdfReaderInternals.h"
0021 
0022 
0023 class QSizeF;
0024 
0025 class OdfReader;
0026 class OdfDrawReaderBackend;
0027 class OdfReaderContext;
0028 
0029 
0030 /** @brief Read the XML tree of the content of an ODT file.
0031  *
0032  * The OdfDrawReader is used to traverse (read) the draw contents of
0033  * an ODF file using an XML stream reader.  For every XML element that
0034  * the reading process comes across it will call a specific function
0035  * in a backend class: @see OdfDrawReaderBackend.  The OdfDrawReader
0036  * is used as a common way to read draw content and is called from all
0037  * readers for different ODF formats.  @see OdtReader, @see OdsReader,
0038  * @see OdpReader.
0039  */
0040 class KOODFREADER_EXPORT OdfDrawReader
0041 {
0042  public:
0043     OdfDrawReader();
0044     ~OdfDrawReader();
0045 
0046     void setParent(OdfReader *parent);
0047     void setBackend(OdfDrawReaderBackend *backend);
0048     void setContext(OdfReaderContext *context);
0049 
0050     // ----------------------------------------------------------------
0051     // Dr3d elements
0052 
0053     DECLARE_READER_FUNCTION(Dr3dScene);   // ODF 1.2  10.5.2
0054     DECLARE_READER_FUNCTION(Dr3dLight);   // ODF 1.2  10.5.3
0055     DECLARE_READER_FUNCTION(Dr3dCube);    // ODF 1.2  10.5.4
0056     DECLARE_READER_FUNCTION(Dr3dSphere);  // ODF 1.2  10.5.5
0057     DECLARE_READER_FUNCTION(Dr3dExtrude); // ODF 1.2  10.5.6
0058     DECLARE_READER_FUNCTION(Dr3dRotate);  // ODF 1.2  10.5.7
0059 
0060     // ----------------------------------------------------------------
0061     // Draw elements
0062 
0063     // Read all common draw level elements like draw:p, draw:h, draw:frame, etc.
0064     // This is the main entry point for draw reading.
0065     void readCommonGraphicsElements(KoXmlStreamReader &reader);
0066 
0067  protected:
0068     // ----------------------------------------------------------------
0069     // Dr3d elements
0070 
0071 
0072     // ----------------------------------------------------------------
0073     // Draw functions: circle, rectangle, etc
0074 
0075     DECLARE_READER_FUNCTION(DrawA);
0076 
0077     DECLARE_READER_FUNCTION(DrawRect);            // ODF 1.2  10.3.2
0078     DECLARE_READER_FUNCTION(DrawLine);            // ODF 1.2  10.3.3
0079     DECLARE_READER_FUNCTION(DrawPolyline);        // ODF 1.2  10.3.4
0080     DECLARE_READER_FUNCTION(DrawPolygon);         // ODF 1.2  10.3.5
0081     DECLARE_READER_FUNCTION(DrawRegularPolygon);  // ODF 1.2  10.3.6
0082     DECLARE_READER_FUNCTION(DrawPath);            // ODF 1.2  10.3.7
0083     DECLARE_READER_FUNCTION(DrawCircle);          // ODF 1.2  10.3.8
0084     DECLARE_READER_FUNCTION(DrawEllipse);         // ODF 1.2  10.3.9
0085     DECLARE_READER_FUNCTION(DrawConnector);       // ODF 1.2  10.3.10
0086     DECLARE_READER_FUNCTION(DrawCaption);         // ODF 1.2  10.3.11
0087     DECLARE_READER_FUNCTION(DrawMeasure);         // ODF 1.2  10.3.12
0088 
0089     void readGraphicsObjectChildren(KoXmlStreamReader &reader);
0090 
0091     // ----------------------------------------------------------------
0092     // Frames
0093 
0094     DECLARE_READER_FUNCTION(DrawFrame);
0095     DECLARE_READER_FUNCTION(DrawObject);
0096     DECLARE_READER_FUNCTION(DrawObjectOle);
0097 
0098     // ----------------------------------------------------------------
0099     // Other functions
0100 
0101     // FIXME: Move this to a common file (OdfReaderUtils?)
0102     void readUnknownElement(KoXmlStreamReader &reader);
0103 
0104 
0105  private:
0106     OdfReader             *m_parent;  // The OdfReader controlling this one.
0107 
0108     OdfDrawReaderBackend  *m_backend;
0109     OdfReaderContext      *m_context;
0110 };
0111 
0112 #endif // ODFDRAWREADER_H