KReport
20 #include "KoOdtFrameReportCheckBox.h"
21 #include <KoXmlWriter.h>
22 #include <KoOdfGraphicStyles.h>
23 #include <KoGenStyle.h>
24 #include <KoGenStyles.h>
25 #include <KReportUnit.h>
27 #include <KoStoreDevice.h>
29 #include "KReportRenderObjects.h"
34 #include "kreport_debug.h"
35 #include <QMimeDatabase>
38 KoOdtFrameReportCheckBox::KoOdtFrameReportCheckBox(
OROCheckBox *primitive)
39 : KoOdtFrameReportPrimitive(primitive)
43 KoOdtFrameReportCheckBox::~KoOdtFrameReportCheckBox()
47 OROCheckBox *KoOdtFrameReportCheckBox::checkBox()
const
52 void KoOdtFrameReportCheckBox::createStyle(KoGenStyles *coll)
54 KoGenStyle gs(KoGenStyle::GraphicStyle,
"graphic");
55 gs.addProperty(
"draw:fill",
"none");
56 gs.addPropertyPt(
"fo:margin", 0);
57 gs.addProperty(
"style:horizontal-pos",
"from-left");
58 gs.addProperty(
"style:horizontal-rel",
"page");
59 gs.addProperty(
"style:vertical-pos",
"from-top");
60 gs.addProperty(
"style:vertical-rel",
"page");
61 gs.addProperty(
"style:wrap",
"dynamic");
62 gs.addPropertyPt(
"style:wrap-dynamic-threshold", 0);
65 qreal weight = checkBox()->lineStyle().weight;
70 pen.
setColor(checkBox()->lineStyle().lineColor);
71 pen.
setStyle(checkBox()->lineStyle().style);
72 KoOdfGraphicStyles::saveOdfStrokeStyle(gs, coll, pen);
74 m_frameStyleName = coll->insert(gs,
"F");
77 void KoOdtFrameReportCheckBox::createBody(KoXmlWriter *bodyWriter)
const
79 bodyWriter->startElement(
"draw:frame");
80 bodyWriter->addAttribute(
"draw:id", itemName());
81 bodyWriter->addAttribute(
"xml:id", itemName());
82 bodyWriter->addAttribute(
"draw:name", itemName());
83 bodyWriter->addAttribute(
"text:anchor-type",
"page");
84 bodyWriter->addAttribute(
"text:anchor-page-number", pageNumber());
85 bodyWriter->addAttribute(
"draw:style-name", m_frameStyleName);
87 commonAttributes(bodyWriter);
89 bodyWriter->startElement(
"draw:image");
90 bodyWriter->addAttribute(
"xlink:href",
"Pictures/" + imageName());
91 bodyWriter->addAttribute(
"xlink:type",
"simple");
92 bodyWriter->addAttribute(
"xlink:show",
"embed");
93 bodyWriter->addAttribute(
"xlink:actuate",
"onLoad");
94 bodyWriter->endElement();
96 bodyWriter->endElement();
99 QString KoOdtFrameReportCheckBox::imageName()
const
104 bool KoOdtFrameReportCheckBox::saveData(KoStore* store, KoXmlWriter* manifestWriter)
const
107 if (!store->open(name)) {
113 if (chk->lineStyle().style ==
Qt::NoPen || chk->lineStyle().
weight <= 0) {
116 fpen =
QPen(chk->lineStyle().lineColor, chk->lineStyle().
weight, chk->lineStyle().style);
124 painter.
begin(&image);
128 qreal ox = sz.
width() / 5;
129 qreal oy = sz.
height() / 5;
132 if (chk->checkType() ==
"Cross") {
137 lp.
setColor(chk->foregroundColor());
140 QRectF r = rc.
adjusted(ox + ps.x(), oy + ps.y(), -(ox + ps.x()), -(oy + ps.y()));
144 }
else if (chk->checkType() ==
"Dot") {
149 QBrush lb(chk->foregroundColor());
160 lp.
setColor(chk->foregroundColor());
169 KoStoreDevice device(store);
170 bool ok = image.save(&device,
"PNG");
174 manifestWriter->addManifestEntry(name, mimetype);
177 bool cl = store->close();
qreal height() const const
qreal widthF() const const
void setPen(const QColor &color)
void setBackgroundMode(Qt::BGMode mode)
void drawEllipse(const QRectF &rectangle)
QRectF adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const const
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
void setWidthF(qreal width)
bool begin(QPaintDevice *device)
void setColor(const QColor &color)
QPointF bottomLeft() const const
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)
QPointF topLeft() const const
QPointF bottomRight() const const
QSize toSize() const const
void setBrush(const QBrush &brush)
QPointF center() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString name(StandardShortcut id)
void drawLine(const QLineF &line)
QMimeType mimeTypeForFile(const QString &fileName, QMimeDatabase::MatchMode mode) const const
QSizeF size() const const
void setStyle(Qt::PenStyle style)
void setRenderHint(QPainter::RenderHint hint, bool on)
QPointF topRight() const const
qreal width() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:17:37 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.