File indexing completed on 2025-01-12 10:34:38

0001 /* This file is part of the KDE project
0002 
0003    SPDX-FileCopyrightText: 2012-2013 Inge Wallin <inge@lysator.liu.se>
0004 
0005    SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef ODFTEXTREADER_H
0009 #define ODFTEXTREADER_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 
0024 class OdfReader;
0025 class OdfReaderContext;
0026 class OdfTextReaderBackend;
0027 
0028 
0029 /** @brief Read the XML tree of the content of an ODT file.
0030  *
0031  * The OdfTextReader is used to traverse (read) the text contents of
0032  * an ODF file using an XML stream reader.  For every XML element that
0033  * the reading process comes across it will call a specific function
0034  * in a backend class: @see OdfTextReaderBackend.  The OdfTextReader
0035  * is used as a common way to reat text content and is called from all
0036  * readers for different ODF formats.  @see OdtReader, @see OdsReader,
0037  * @see OdpReader.
0038  */
0039 class KOODFREADER_EXPORT OdfTextReader
0040 {
0041  public:
0042     OdfTextReader();
0043     ~OdfTextReader();
0044 
0045     // Read all common text level elements like text:p, text:h, draw:frame, etc.
0046     // This is the main entry point for text reading.
0047     void readTextLevelElement(KoXmlStreamReader &reader);
0048     void readElementTableTable(KoXmlStreamReader &reader);
0049 
0050     void setParent(OdfReader *parent);
0051     void setBackend(OdfTextReaderBackend *backend);
0052     void setContext(OdfReaderContext *context);
0053 
0054     // All readElement*() are named after the full qualifiedName of
0055     // the element in ODF that they handle.
0056 
0057     // ----------------------------------------------------------------
0058     // Text level functions: paragraphs, headings, sections, frames, objects, etc
0059 
0060     DECLARE_READER_FUNCTION(OfficeAnnotation);
0061     DECLARE_READER_FUNCTION(OfficeAnnotationEnd);
0062 
0063     DECLARE_READER_FUNCTION(DcCreator);
0064     DECLARE_READER_FUNCTION(DcDate);
0065 
0066     DECLARE_READER_FUNCTION(TextH);
0067     DECLARE_READER_FUNCTION(TextP);
0068     DECLARE_READER_FUNCTION(TextList);
0069     DECLARE_READER_FUNCTION(TextA);
0070 
0071     DECLARE_READER_FUNCTION(TableTableColumnGroup);
0072     DECLARE_READER_FUNCTION(TableTableColumn);
0073     DECLARE_READER_FUNCTION(TableTableColumns);
0074     DECLARE_READER_FUNCTION(TableTableHeaderColumns);
0075     DECLARE_READER_FUNCTION(TableTableHeaderRows);
0076     DECLARE_READER_FUNCTION(TableTableRowGroup);
0077     DECLARE_READER_FUNCTION(TableTableRow);
0078     DECLARE_READER_FUNCTION(TableTableRows);
0079     DECLARE_READER_FUNCTION(TableTableCell);
0080     DECLARE_READER_FUNCTION(TableCoveredTableCell);
0081 
0082     // ----------------------------------------------------------------
0083     // Paragraph level functions: spans, annotations, notes, text content itself, etc.
0084 
0085     void readParagraphContents(KoXmlStreamReader &reader);
0086 
0087     DECLARE_READER_FUNCTION(TextLineBreak);
0088     DECLARE_READER_FUNCTION(TextS);
0089     DECLARE_READER_FUNCTION(TextSpan);
0090 
0091     // ----------------------------------------------------------------
0092     // List level functions: list-item and list header.
0093 
0094     DECLARE_READER_FUNCTION(TextListItem);
0095     DECLARE_READER_FUNCTION(TextListHeader);
0096 
0097     // ----------------------------------------------------------------
0098     // Other functions
0099 
0100     DECLARE_READER_FUNCTION(TextSoftPageBreak);
0101 
0102     void readUnknownElement(KoXmlStreamReader &reader);
0103 
0104 
0105  private:
0106     OdfReader             *m_parent;  // The OdfReader controlling this one.
0107 
0108     OdfTextReaderBackend  *m_backend;
0109     OdfReaderContext      *m_context;
0110 };
0111 
0112 #endif // ODFTEXTREADER_H