File indexing completed on 2024-05-12 16:29:19

0001 /* This file is part of the KDE project
0002 
0003    Copyright (C) 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 ODFTEXTREADERBACKEND_H
0022 #define ODFTEXTREADERBACKEND_H
0023 
0024 // Calligra
0025 #include <KoXmlStreamReader.h>
0026 #include <KoFilter.h>
0027 
0028 // this library
0029 #include "koodfreader_export.h"
0030 #include "OdfTextReader.h"
0031 
0032 
0033 class OdfReaderContext;
0034 
0035 
0036 /** @brief A default backend for the OdfTextReader class.
0037  *
0038  * This class defines an interface and the default behaviour for the
0039  * backend to the ODF text reader (@see OdfTextReader). When the
0040  * reader is called upon to traverse a certain XML tree, there will
0041  * be two parameters to the root traverse function: a pointer to a
0042  * backend object and a pointer to a context object.
0043  *
0044  * The reader will traverse (read) the XML tree and for every element
0045  * it comes across it will call a specific function in the backend and
0046  * every call will pass the pointer to the context object.
0047  *
0048  * Each supported XML tag has a corresponding callback function. This
0049  * callback function will be called twice: once when the tag is first
0050  * encountered anc once when the tag is closed.  This means that an
0051  * element with no child elements will be called twice in succession.
0052  */
0053 class KOODFREADER_EXPORT OdfTextReaderBackend
0054 {
0055  public:
0056     explicit OdfTextReaderBackend();
0057     virtual ~OdfTextReaderBackend();
0058 
0059     // ----------------------------------------------------------------
0060     // Text level functions: paragraphs, headings, sections, frames, objects, etc
0061 
0062     DECLARE_BACKEND_FUNCTION(OfficeAnnotation);
0063     DECLARE_BACKEND_FUNCTION(OfficeAnnotationEnd);
0064     DECLARE_BACKEND_FUNCTION(DcCreator);
0065     DECLARE_BACKEND_FUNCTION(DcDate);
0066 
0067     DECLARE_BACKEND_FUNCTION(TextH);
0068     DECLARE_BACKEND_FUNCTION(TextP);
0069     DECLARE_BACKEND_FUNCTION(TextList);
0070 
0071     DECLARE_BACKEND_FUNCTION(TableTable);
0072     DECLARE_BACKEND_FUNCTION(TableTableColumnGroup);
0073     DECLARE_BACKEND_FUNCTION(TableTableColumn);
0074     DECLARE_BACKEND_FUNCTION(TableTableColumns);
0075     DECLARE_BACKEND_FUNCTION(TableTableHeaderColumns);
0076     DECLARE_BACKEND_FUNCTION(TableTableHeaderRows);
0077     DECLARE_BACKEND_FUNCTION(TableTableRowGroup);
0078     DECLARE_BACKEND_FUNCTION(TableTableRow);
0079     DECLARE_BACKEND_FUNCTION(TableTableRows);
0080     DECLARE_BACKEND_FUNCTION(TableTableCell);
0081     DECLARE_BACKEND_FUNCTION(TableCoveredTableCell);
0082 
0083     // ----------------------------------------------------------------
0084     // Paragraph level functions: spans, annotations, notes, etc.
0085     // This includes text content itself.
0086 
0087     DECLARE_BACKEND_FUNCTION(TextA);
0088     DECLARE_BACKEND_FUNCTION(TextLineBreak);
0089     DECLARE_BACKEND_FUNCTION(TextSpan);
0090     DECLARE_BACKEND_FUNCTION(TextS);
0091 
0092     // ----------------------------------------------------------------
0093     // List level functions: list-header and list-item.
0094 
0095     DECLARE_BACKEND_FUNCTION(TextListHeader);
0096     DECLARE_BACKEND_FUNCTION(TextListItem);
0097     DECLARE_BACKEND_FUNCTION(TextSoftPageBreak);
0098 
0099     // ----------------------------------------------------------------
0100     // Some special functions
0101     virtual void characterData(KoXmlStreamReader &reader, OdfReaderContext *context);
0102     virtual void textVariable(const QString &name, const QString &value);
0103 
0104  private:
0105     class Private;
0106     Private * const d;
0107 };
0108 
0109 
0110 #endif // ODFTEXTREADERBACKEND_H