File indexing completed on 2024-04-28 04:41:56
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2001-2007 by OpenMFG, LLC <info@openmfg.com> 0003 * Copyright (C) 2007-2010 by Adam Pigg <adam@piggz.co.uk> 0004 * Copyright (C) 2011-2015 Jarosław Staniek <staniek@kde.org> 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Lesser General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General Public 0017 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef KREPORTDESIGN_P_H 0021 #define KREPORTDESIGN_P_H 0022 0023 #include "KReportDesign.h" 0024 #include "KReportUtils_p.h" 0025 0026 #include <QPageSize> 0027 #include <QPageLayout> 0028 #include <QVarLengthArray> 0029 0030 class QDomDocument; 0031 class QDomElement; 0032 class KReportPluginInterface; 0033 0034 class Q_DECL_HIDDEN KReportDesign::Private 0035 { 0036 public: 0037 explicit Private(KReportDesign *design); 0038 0039 ~Private(); 0040 0041 QDomElement requiredChildElement(const QDomElement &parent, 0042 const char* childElementName, 0043 KReportDesignReadingStatus *status) const; 0044 0045 void unexpectedElement(const QDomElement &element, 0046 KReportDesignReadingStatus *status) const; 0047 0048 //! Processes document @a doc and sets status @a status 0049 bool processDocument(const QDomDocument &doc, KReportDesignReadingStatus *status); 0050 0051 //! Processes @a el, a child of /report:content element and sets status @a status 0052 bool processContentElementChild(const QDomElement &el, KReportDesignReadingStatus *status); 0053 0054 //! Processes @a el, a child of /report:content/report:body element and sets status @a status 0055 bool processBodyElementChild(const QDomElement &el, KReportDesignReadingStatus *status); 0056 0057 //! Processes @a el, a /report:content/report:body/report:section element and sets status @a status 0058 KReportSection processSectionElement(const QDomElement &el, KReportDesignReadingStatus *status); 0059 0060 //! Processes @a el, 0061 //! a child of /report:content/report:body/report:section element 0062 //! or a child of /report:content/report:body/report:detail/report:section element 0063 //! and sets status @a status. 0064 //! It is probably the lowest level in hierarchy and @a el refers to a single report element. 0065 KReportElement processSectionElementChild(const QDomElement &el, KReportDesignReadingStatus *status); 0066 0067 //! Processes @a el, a child of /report:content/report:body/report:detail element and sets status @a status 0068 bool processDetailElement(const QDomElement &el, KReportDesignReadingStatus *status); 0069 0070 //! Processes @a el, a /report:content/report:body/report:detail/report:group element and sets status @a status 0071 bool processGroupElement(const QDomElement &el, KReportDesignReadingStatus *status); 0072 0073 KReportPluginInterface* findPlugin(const QString &typeName, const QDomElement &el, 0074 KReportDesignReadingStatus *status); 0075 0076 KReportDesign * const q; 0077 0078 // Visual settings only 0079 bool showGrid; 0080 bool snapToGrid; 0081 int gridDivisions; 0082 KReportUnit pageUnit; 0083 // END OF: Visual settings only 0084 QString title; 0085 KReportPrivate::PageLayout pageLayout; 0086 QVarLengthArray<KReportSection*, static_cast<int>(KReportSection::Type::Detail)> sections; 0087 #ifdef KREPORT_SCRIPTING 0088 QString script; 0089 QString originalInterpreter; //!< used for backward-compatibility to save the original 0090 #endif 0091 }; 0092 0093 class KReportDesignGlobal 0094 { 0095 public: 0096 KReportDesignGlobal(); 0097 0098 static KReportDesignGlobal* self(); 0099 0100 struct SectionTypeInfo { 0101 KReportSection::Type type; 0102 const char *name; 0103 }; 0104 0105 KReportSection::Type sectionType(const QString& typeName); 0106 0107 QString sectionTypeName(KReportSection::Type sectionType); 0108 0109 KReportPrivate::PageLayout defaultPageLayout; 0110 qreal defaultSectionHeight; 0111 QColor defaultSectionBackgroundColor; 0112 0113 private: 0114 void initSectionTypes(); 0115 0116 static const SectionTypeInfo sectionTypes[]; 0117 QHash<QString, KReportSection::Type> sectionTypesForName; 0118 QHash<KReportSection::Type, QString> sectionTypeNames; 0119 }; 0120 0121 #endif