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>
38KoOdtFrameReportCheckBox::KoOdtFrameReportCheckBox(
OROCheckBox *primitive)
39 : KoOdtFrameReportPrimitive(primitive)
43KoOdtFrameReportCheckBox::~KoOdtFrameReportCheckBox()
47OROCheckBox *KoOdtFrameReportCheckBox::checkBox()
const
49 return static_cast<OROCheckBox*
>(m_primitive);
52void 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");
77void 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();
99QString KoOdtFrameReportCheckBox::imageName()
const
101 return QString(
"Checkbox_%1.png").
arg(m_uid);
104bool KoOdtFrameReportCheckBox::saveData(KoStore* store, KoXmlWriter* manifestWriter)
const
106 QString
name =
"Pictures/" + imageName();
107 if (!store->open(name)) {
110 OROCheckBox * chk = checkBox();
111 QSizeF sz = chk->size();
113 if (chk->lineStyle().style ==
Qt::NoPen || chk->lineStyle().
weight <= 0) {
116 fpen = QPen(chk->lineStyle().lineColor, chk->lineStyle().
weight, chk->lineStyle().style);
119 QRectF rc = QRectF(0, 0, sz.
width() + (ps.x()*2), sz.
height() + (ps.y()*2));
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();
KIOCORE_EXPORT MimetypeJob * mimetype(const QUrl &url, JobFlags flags=DefaultFlags)
QString name(StandardAction id)
QMimeType mimeTypeForFile(const QFileInfo &fileInfo, MatchMode mode) const const
bool begin(QPaintDevice *device)
void drawEllipse(const QPoint ¢er, int rx, int ry)
void drawLine(const QLine &line)
void drawRoundedRect(const QRect &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)
void setBackgroundMode(Qt::BGMode mode)
void setBrush(Qt::BrushStyle style)
void setPen(Qt::PenStyle style)
void setRenderHint(RenderHint hint, bool on)
void setColor(const QColor &color)
void setStyle(Qt::PenStyle style)
void setWidthF(qreal width)
qreal widthF() const const
QRectF adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const const
QPointF bottomLeft() const const
QPointF bottomRight() const const
QPointF center() const const
QSizeF size() const const
QPointF topLeft() const const
QPointF topRight() const const
qreal height() const const
QSize toSize() const const
qreal width() const const
QString arg(Args &&... args) const const