20#include "KoOdtFrameReportTextBox.h"
21#include "KReportRenderObjects.h"
23#include <KoXmlWriter.h>
24#include <KoOdfGraphicStyles.h>
25#include <KoGenStyle.h>
26#include <KoGenStyles.h>
31KoOdtFrameReportTextBox::KoOdtFrameReportTextBox(
OROTextBox *primitive)
32 : KoOdtFrameReportPrimitive(primitive)
36KoOdtFrameReportTextBox::~KoOdtFrameReportTextBox()
40OROTextBox *KoOdtFrameReportTextBox::textBox()
const
45void KoOdtFrameReportTextBox::createStyle(KoGenStyles *coll)
47 QFont font = textBox()->textStyle().font;
49 KoGenStyle ps(KoGenStyle::ParagraphStyle,
"paragraph");
50 m_paragraphStyleName = coll->
insert(ps,
"P");
53 KoGenStyle ts(KoGenStyle::TextStyle,
"text");
54 ts.addProperty(
"fo:font-family", font.
family());
55 ts.addPropertyPt(
"fo:font-size", font.
pointSizeF());
56 ts.addProperty(
"fo:font-weight", font.
weight() * 10);
57 ts.addProperty(
"fo:color", textBox()->textStyle().foregroundColor.name());
59 switch (font.
style()) {
64 ts.addProperty(
"fo:font-style", fs);
65 m_textStyleName = coll->
insert(ts,
"T");
67 KoGenStyle gs(KoGenStyle::GraphicStyle,
"graphic");
69 pen.
setColor(textBox()->lineStyle().lineColor);
70 pen.
setWidthF(textBox()->lineStyle().weight);
71 pen.
setStyle(textBox()->lineStyle().style);
72 KoOdfGraphicStyles::saveOdfStrokeStyle(gs, coll, pen);
73 gs.addProperty(
"style:horizontal-pos",
"from-left");
74 gs.addProperty(
"style:horizontal-rel",
"page");
75 gs.addProperty(
"style:vertical-pos",
"from-top");
76 gs.addProperty(
"style:vertical-rel",
"page");
77 gs.addProperty(
"fo:background-color", textBox()->textStyle().backgroundColor.name());
78 m_frameStyleName = coll->
insert(gs,
"F");
81void KoOdtFrameReportTextBox::createBody(KoXmlWriter *bodyWriter)
const
83 bodyWriter->startElement(
"draw:frame");
84 bodyWriter->addAttribute(
"draw:id", itemName());
85 bodyWriter->addAttribute(
"xml:id", itemName());
86 bodyWriter->addAttribute(
"draw:name", itemName());
87 bodyWriter->addAttribute(
"text:anchor-type",
"page");
88 bodyWriter->addAttribute(
"text:anchor-page-number", pageNumber());
89 bodyWriter->addAttribute(
"draw:style-name", m_frameStyleName);
91 commonAttributes(bodyWriter);
93 bodyWriter->startElement(
"draw:text-box");
95 bodyWriter->startElement(
"text:p");
96 bodyWriter->addAttribute(
"text:style-name", m_paragraphStyleName);
97 bodyWriter->startElement(
"text:span");
98 bodyWriter->addAttribute(
"text:style-name", m_textStyleName);
99 bodyWriter->addTextNode(textBox()->text());
101 bodyWriter->endElement();
102 bodyWriter->endElement();
103 bodyWriter->endElement();
104 bodyWriter->endElement();
A text box primitive it defines a box region and text that will be rendered inside that region,...
QString family() const const
qreal pointSizeF() const const
Style style() const const
Weight weight() const const
void setColor(const QColor &color)
void setStyle(Qt::PenStyle style)
void setWidthF(qreal width)
QString & insert(qsizetype position, QChar ch)