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

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