2
* OpenRPT report writer and rendering engine
3
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
4
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
20
#include "reportentities.h"
26
#include <qlineedit.h>
28
#include <qinputdialog.h>
30
#include <qdatastream.h>
31
#include <qcheckbox.h>
32
#include <qradiobutton.h>
33
#include <qsettings.h>
36
#include <koproperty/Property.h>
37
#include <koproperty/Set.h>
38
#include <koproperty/EditorView.h>
40
#include <krobjectdata.h>
43
#include "reportentitylabel.h"
44
#include "reportentityfield.h"
45
#include "reportentitytext.h"
46
#include "reportentityline.h"
47
#include "reportentitybarcode.h"
48
#include "reportentityimage.h"
49
#include "reportentitychart.h"
54
ReportEntity::ReportEntity(KoReportDesigner* r)
59
void ReportEntity::buildXML(QGraphicsItem * item, QDomDocument & doc, QDomElement & parent)
62
re = dynamic_cast<ReportEntity*>(item);
65
re->buildXML(doc, parent);
70
void ReportEntity::buildXMLRect(QDomDocument & doc, QDomElement & entity, KRPos *pos, KRSize *siz)
73
KoUnit unit = pos->unit();
75
entity.setAttribute("svg:x", QString::number(pos->toUnit().x()) + KoUnit::unitName(unit));
76
entity.setAttribute("svg:y", QString::number(pos->toUnit().y()) + KoUnit::unitName(unit));
77
entity.setAttribute("svg:width", QString::number(siz->toUnit().width()) + KoUnit::unitName(unit));
78
entity.setAttribute("svg:height", QString::number(siz->toUnit().height()) + KoUnit::unitName(unit));
81
void ReportEntity::buildXMLTextStyle(QDomDocument & doc, QDomElement & entity, KRTextStyleData ts)
83
QDomElement element = doc.createElement("report:text-style");
85
element.setAttribute("fo:background-color", ts.backgroundColor.name());
86
element.setAttribute("fo:foreground-color", ts.foregroundColor.name());
87
element.setAttribute("fo:background-opacity", QString::number(ts.backgroundOpacity) + '%');
88
KRUtils::writeFontAttributes(element, ts.font);
90
entity.appendChild(element);
93
void ReportEntity::buildXMLLineStyle(QDomDocument & doc, QDomElement & entity, KRLineStyleData ls)
95
QDomElement element = doc.createElement("report:line-style");
97
element.setAttribute("report:line-color", ls.lineColor.name());
98
element.setAttribute("report:line-weight", QString::number(ls.weight));
114
case Qt::DashDotLine:
117
case Qt::DashDotDotLine:
124
element.setAttribute("report:line-style", l);
126
entity.appendChild(element);
129
QString ReportEntity::dataSourceAndObjectTypeName(const QString& dataSource, const QString& objectTypeName)
131
return i18nc("<data-source>: <object>", "%1: %2", dataSource, objectTypeName);
135
void ReportEntity::addPropertyAsAttribute(QDomElement* e, KoProperty::Property* p)
137
switch (p->value().type()) {
139
e->setAttribute(QLatin1String("report:") + p->name().toLower(), p->value().toInt());
141
case QVariant::Double:
142
e->setAttribute(QLatin1String("report:") + p->name().toLower(), p->value().toDouble());
145
e->setAttribute(QLatin1String("report:") + p->name().toLower(), p->value().toInt());
148
e->setAttribute(QLatin1String("report:") + p->name().toLower(), p->value().toString());