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 "KoReportDesignerItemBase.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 "KoReportItemBase.h"
42
#include <klocalizedstring.h>
47
KoReportDesignerItemBase::KoReportDesignerItemBase(KoReportDesigner* r)
52
void KoReportDesignerItemBase::buildXML(QGraphicsItem * item, QDomDocument & doc, QDomElement & parent)
54
KoReportDesignerItemBase *re = 0;
55
re = dynamic_cast<KoReportDesignerItemBase*>(item);
58
re->buildXML(doc, parent);
63
void KoReportDesignerItemBase::buildXMLRect(QDomDocument & doc, QDomElement & entity, KRPos *pos, KRSize *siz)
66
KoUnit unit = pos->unit();
68
entity.setAttribute("svg:x", QString::number(pos->toUnit().x()) + KoUnit::unitName(unit));
69
entity.setAttribute("svg:y", QString::number(pos->toUnit().y()) + KoUnit::unitName(unit));
70
entity.setAttribute("svg:width", QString::number(siz->toUnit().width()) + KoUnit::unitName(unit));
71
entity.setAttribute("svg:height", QString::number(siz->toUnit().height()) + KoUnit::unitName(unit));
74
void KoReportDesignerItemBase::buildXMLTextStyle(QDomDocument & doc, QDomElement & entity, KRTextStyleData ts)
76
QDomElement element = doc.createElement("report:text-style");
78
element.setAttribute("fo:background-color", ts.backgroundColor.name());
79
element.setAttribute("fo:foreground-color", ts.foregroundColor.name());
80
element.setAttribute("fo:background-opacity", QString::number(ts.backgroundOpacity) + '%');
81
KRUtils::writeFontAttributes(element, ts.font);
83
entity.appendChild(element);
86
void KoReportDesignerItemBase::buildXMLLineStyle(QDomDocument & doc, QDomElement & entity, KRLineStyleData ls)
88
QDomElement element = doc.createElement("report:line-style");
90
element.setAttribute("report:line-color", ls.lineColor.name());
91
element.setAttribute("report:line-weight", QString::number(ls.weight));
107
case Qt::DashDotLine:
110
case Qt::DashDotDotLine:
117
element.setAttribute("report:line-style", l);
119
entity.appendChild(element);
122
QString KoReportDesignerItemBase::dataSourceAndObjectTypeName(const QString& dataSource, const QString& objectTypeName)
124
return i18nc("<data-source>: <object>", "%1: %2", dataSource, objectTypeName);
128
void KoReportDesignerItemBase::addPropertyAsAttribute(QDomElement* e, KoProperty::Property* p)
130
switch (p->value().type()) {
132
e->setAttribute(QLatin1String("report:") + p->name().toLower(), p->value().toInt());
134
case QVariant::Double:
135
e->setAttribute(QLatin1String("report:") + p->name().toLower(), p->value().toDouble());
138
e->setAttribute(QLatin1String("report:") + p->name().toLower(), p->value().toInt());
141
e->setAttribute(QLatin1String("report:") + p->name().toLower(), p->value().toString());