KReport

KReportPluginInterface.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2010 by Adam Pigg ([email protected])
3  Copyright (C) 2015 JarosÅ‚aw Staniek <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "KReportPluginInterface.h"
22 #include "KReportPluginMetaData.h"
23 #include "KReportUtils.h"
24 #include "kreport_debug.h"
25 
26 #include <QDomElement>
27 
28 class Q_DECL_HIDDEN KReportPluginInterface::Private
29 {
30 public:
31  Private() : metaData(nullptr) {}
32  ~Private() {}
33 
34  const KReportPluginMetaData *metaData;
35 };
36 
37 // ---
38 
39 KReportPluginInterface::KReportPluginInterface(QObject* parent, const QVariantList& args)
40  : QObject(parent), d(new Private)
41 {
42  Q_UNUSED(args);
43 }
44 
45 KReportPluginInterface::~KReportPluginInterface()
46 {
47  delete d;
48 }
49 
50 KReportElement KReportPluginInterface::createElement()
51 {
52  return KReportElement();
53 }
54 
56 {
57  return d->metaData;
58 }
59 
60 void KReportPluginInterface::setMetaData(KReportPluginMetaData* metaData)
61 {
62  d->metaData = metaData;
63 }
64 
65 bool KReportPluginInterface::loadElement(KReportElement *el, const QDomElement &dom, KReportDesignReadingStatus *status)
66 {
67  Q_ASSERT(el);
68  Q_UNUSED(status);
69  el->setName(KReportUtils::readNameAttribute(dom));
70  el->setRect(KReportUtils::readRectAttributes(dom, el->rect()));
71  el->setZ(KReportUtils::readZAttribute(dom, el->z()));
72 
73  const QDomElement textStyleDom
74  = dom.firstChildElement(QLatin1String("report:text-style"));
75  el->setForegroundColor(KReportUtils::attr(
76  textStyleDom, QLatin1String("fo:foreground-color"), el->foregroundColor()));
77  el->setBackgroundColor(KReportUtils::attr(
78  textStyleDom, QLatin1String("fo:background-color"), el->backgroundColor()));
79  el->setBackgroundOpacity(KReportUtils::attrPercent(
80  textStyleDom, QLatin1String("fo:background-opacity"), el->backgroundOpacity()));
81  return true;
82 }
The KReportDesignReadStatus represents status of reading a report design in .kreport format.
Definition: KReportDesign.h:35
const KReportPluginMetaData * metaData() const
Information about a KReport plugin.
QDomElement firstChildElement(const QString &tagName) const const
The KReportElement class represents a functional visual element of a report design.
An interface for plugins delivering KReport elements.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Aug 16 2022 04:04:13 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.