20#include "KoOdtFrameReportLine.h"
21#include "KReportRenderObjects.h"
23#include <KoXmlWriter.h>
24#include <KReportDpi.h>
25#include <KoOdfGraphicStyles.h>
26#include <KoGenStyle.h>
27#include <KoGenStyles.h>
28#include <KReportUnit.h>
31#include "kreport_debug.h"
33KoOdtFrameReportLine::KoOdtFrameReportLine(
OROLine *primitive)
34 : KoOdtFrameReportPrimitive(primitive)
38KoOdtFrameReportLine::~KoOdtFrameReportLine()
42OROLine *KoOdtFrameReportLine::line()
const
44 return static_cast<OROLine*
>(m_primitive);
47void KoOdtFrameReportLine::createStyle(KoGenStyles *coll)
49 KoGenStyle ps(KoGenStyle::ParagraphStyle,
"paragraph");
50 m_paragraphStyleName = coll->
insert(ps,
"P");
52 KoGenStyle gs(KoGenStyle::GraphicStyle,
"graphic");
53 gs.addProperty(
"draw:fill",
"none");
54 gs.addPropertyPt(
"fo:margin", 0);
55 gs.addProperty(
"style:horizontal-pos",
"from-left");
56 gs.addProperty(
"style:horizontal-rel",
"page");
57 gs.addProperty(
"style:vertical-pos",
"from-top");
58 gs.addProperty(
"style:vertical-rel",
"page");
59 gs.addProperty(
"style:wrap",
"dynamic");
60 gs.addPropertyPt(
"style:wrap-dynamic-threshold", 0);
63 qreal weight = line()->lineStyle().
weight;
68 pen.
setColor(line()->lineStyle().lineColor);
69 pen.
setStyle(line()->lineStyle().style);
70 KoOdfGraphicStyles::saveOdfStrokeStyle(gs, coll, pen);
72 m_frameStyleName = coll->
insert(gs,
"F");
76void KoOdtFrameReportLine::createBody(KoXmlWriter *bodyWriter)
const
79 qreal sx = INCH_TO_POINT(line()->startPoint().x() / KReportPrivate::dpiX());
80 qreal sy = INCH_TO_POINT(line()->startPoint().y() / KReportPrivate::dpiY());
81 qreal ex = INCH_TO_POINT(line()->endPoint().x() / KReportPrivate::dpiX());
82 qreal ey = INCH_TO_POINT(line()->endPoint().y() / KReportPrivate::dpiY());
83 qreal width = ex - sx;
84 qreal height = ey - sy;
88 bodyWriter->startElement(
"draw:rect");
89 bodyWriter->addAttribute(
"draw:id", itemName());
90 bodyWriter->addAttribute(
"xml:id", itemName());
91 bodyWriter->addAttribute(
"draw:name", itemName());
92 bodyWriter->addAttribute(
"text:anchor-type",
"page");
93 bodyWriter->addAttribute(
"text:anchor-page-number", pageNumber());
94 bodyWriter->addAttribute(
"draw:style-name", m_frameStyleName);
95 bodyWriter->addAttribute(
"draw:z-index",
"3");
97 if (height == 0.0 && width >= 0.0) {
99 bodyWriter->addAttributePt(
"svg:x", sx);
100 bodyWriter->addAttributePt(
"svg:y", sy);
101 bodyWriter->addAttributePt(
"svg:width", width);
102 bodyWriter->addAttributePt(
"svg:height", 0.0);
105 qreal l = sqrt(width*width + height*height);
106 bodyWriter->addAttributePt(
"svg:width", l);
107 bodyWriter->addAttributePt(
"svg:height", 0.0);
108 qreal sina = height / l;
109 qreal cosa = width / l;
110 QTransform rotate(cosa, sina, -sina, cosa, sx, sy);
111 bodyWriter->addAttribute(
"draw:transform", KoOdfGraphicStyles::saveTransformation(rotate));
114 bodyWriter->endElement();
Defines a line with a width/weight.
void setColor(const QColor &color)
void setStyle(Qt::PenStyle style)
void setWidthF(qreal width)
QString & insert(qsizetype position, QChar ch)