File indexing completed on 2024-05-05 04:43:22

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
0003  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2.1 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  * Lesser General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Lesser General Public
0016  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #ifndef KREPORTPRERENDERER_H
0020 #define KREPORTPRERENDERER_H
0021 
0022 #include "config-kreport.h"
0023 #include "kreport_export.h"
0024 
0025 #include <QObject>
0026 
0027 #ifdef KREPORT_SCRIPTING
0028 class KReportScriptHandler;
0029 class KReportScriptSource;
0030 #else
0031 #define KReportScriptHandler void
0032 #endif
0033 class KReportPreRendererPrivate;
0034 class ORODocument;
0035 class KReportDataSource;
0036 class KReportDocument;
0037 class QDomElement;
0038 
0039 /*!
0040  * @brief Takes a report definition and prerenders the result to
0041  * an ORODocument that can be used to pass to any number of renderers.
0042  */
0043 class KREPORT_EXPORT KReportPreRenderer : public QObject
0044 {
0045     Q_OBJECT
0046 public:
0047     explicit KReportPreRenderer(const QDomElement& document);
0048 
0049     ~KReportPreRenderer() override;
0050 
0051     //! Sets data source to @a data, takes ownership
0052     void setDataSource(KReportDataSource* dataSource);
0053 
0054 #ifdef KREPORT_SCRIPTING
0055     //!Sets the script source to @a source, does NOT take ownership as it may be an application window
0056     void setScriptSource(KReportScriptSource* source);
0057 
0058     KReportScriptHandler *scriptHandler();
0059     void registerScriptObject(QObject *obj, const QString &name);
0060 #endif
0061 
0062     bool generateDocument();
0063 
0064     ORODocument *document();
0065 
0066     /**
0067     @brief Set the name of the report so that it can be used internally by the script engine
0068     */
0069     void setName(const QString &);
0070 
0071     bool isValid() const;
0072 
0073     const KReportDocument *reportData() const;
0074 
0075 Q_SIGNALS:
0076     void groupChanged(const QMap<QString, QVariant> &groupData);
0077     void finishedAllASyncItems();
0078 
0079 private:
0080     bool setDocument(const QDomElement &document);
0081 
0082     Q_DISABLE_COPY(KReportPreRenderer)
0083     KReportPreRendererPrivate *const d;
0084 };
0085 
0086 #endif // KREPORTPRERENDERER_H