File indexing completed on 2024-12-01 13:11:46
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2012-2013 Inge Wallin <inge@lysator.liu.se> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef ODFTEXTREADER_H 0022 #define ODFTEXTREADER_H 0023 0024 // Qt 0025 #include <QHash> 0026 #include <QString> 0027 0028 // Calligra 0029 #include <KoXmlStreamReader.h> 0030 0031 // this library 0032 #include "koodfreader_export.h" 0033 #include "OdfReaderInternals.h" 0034 0035 0036 0037 class OdfReader; 0038 class OdfReaderContext; 0039 class OdfTextReaderBackend; 0040 0041 0042 /** @brief Read the XML tree of the content of an ODT file. 0043 * 0044 * The OdfTextReader is used to traverse (read) the text contents of 0045 * an ODF file using an XML stream reader. For every XML element that 0046 * the reading process comes across it will call a specific function 0047 * in a backend class: @see OdfTextReaderBackend. The OdfTextReader 0048 * is used as a common way to reat text content and is called from all 0049 * readers for different ODF formats. @see OdtReader, @see OdsReader, 0050 * @see OdpReader. 0051 */ 0052 class KOODFREADER_EXPORT OdfTextReader 0053 { 0054 public: 0055 OdfTextReader(); 0056 ~OdfTextReader(); 0057 0058 // Read all common text level elements like text:p, text:h, draw:frame, etc. 0059 // This is the main entry point for text reading. 0060 void readTextLevelElement(KoXmlStreamReader &reader); 0061 void readElementTableTable(KoXmlStreamReader &reader); 0062 0063 void setParent(OdfReader *parent); 0064 void setBackend(OdfTextReaderBackend *backend); 0065 void setContext(OdfReaderContext *context); 0066 0067 // All readElement*() are named after the full qualifiedName of 0068 // the element in ODF that they handle. 0069 0070 // ---------------------------------------------------------------- 0071 // Text level functions: paragraphs, headings, sections, frames, objects, etc 0072 0073 DECLARE_READER_FUNCTION(OfficeAnnotation); 0074 DECLARE_READER_FUNCTION(OfficeAnnotationEnd); 0075 0076 DECLARE_READER_FUNCTION(DcCreator); 0077 DECLARE_READER_FUNCTION(DcDate); 0078 0079 DECLARE_READER_FUNCTION(TextH); 0080 DECLARE_READER_FUNCTION(TextP); 0081 DECLARE_READER_FUNCTION(TextList); 0082 DECLARE_READER_FUNCTION(TextA); 0083 0084 DECLARE_READER_FUNCTION(TableTableColumnGroup); 0085 DECLARE_READER_FUNCTION(TableTableColumn); 0086 DECLARE_READER_FUNCTION(TableTableColumns); 0087 DECLARE_READER_FUNCTION(TableTableHeaderColumns); 0088 DECLARE_READER_FUNCTION(TableTableHeaderRows); 0089 DECLARE_READER_FUNCTION(TableTableRowGroup); 0090 DECLARE_READER_FUNCTION(TableTableRow); 0091 DECLARE_READER_FUNCTION(TableTableRows); 0092 DECLARE_READER_FUNCTION(TableTableCell); 0093 DECLARE_READER_FUNCTION(TableCoveredTableCell); 0094 0095 // ---------------------------------------------------------------- 0096 // Paragraph level functions: spans, annotations, notes, text content itself, etc. 0097 0098 void readParagraphContents(KoXmlStreamReader &reader); 0099 0100 DECLARE_READER_FUNCTION(TextLineBreak); 0101 DECLARE_READER_FUNCTION(TextS); 0102 DECLARE_READER_FUNCTION(TextSpan); 0103 0104 // ---------------------------------------------------------------- 0105 // List level functions: list-item and list header. 0106 0107 DECLARE_READER_FUNCTION(TextListItem); 0108 DECLARE_READER_FUNCTION(TextListHeader); 0109 0110 // ---------------------------------------------------------------- 0111 // Other functions 0112 0113 DECLARE_READER_FUNCTION(TextSoftPageBreak); 0114 0115 void readUnknownElement(KoXmlStreamReader &reader); 0116 0117 0118 private: 0119 OdfReader *m_parent; // The OdfReader controlling this one. 0120 0121 OdfTextReaderBackend *m_backend; 0122 OdfReaderContext *m_context; 0123 }; 0124 0125 #endif // ODFTEXTREADER_H