KReport

KoOdtFrameReportPrimitive.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2011, 2012 by Dag Andersen (danders@get2net.dk)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "KoOdtFrameReportPrimitive.h"
21#include "KReportRenderObjects.h"
22
23#include <KoXmlWriter.h>
24#include <KReportDpi.h>
25#include <KoGenStyle.h>
26#include <KoGenStyles.h>
27
28KoOdtFrameReportPrimitive::KoOdtFrameReportPrimitive(OROPrimitive *primitive)
29 : m_primitive(primitive)
30 , m_uid(0)
31{
32}
33
34KoOdtFrameReportPrimitive::~KoOdtFrameReportPrimitive()
35{
36}
37
38bool KoOdtFrameReportPrimitive::isValid() const
39{
40 return (bool)m_primitive;
41}
42
43void KoOdtFrameReportPrimitive::setPrimitive(OROPrimitive *primitive)
44{
45 m_primitive = primitive;
46}
47
48int KoOdtFrameReportPrimitive::pageNumber() const
49{
50 return isValid() && m_primitive->page() ? m_primitive->page()->pageNumber() + 1 : 0;
51}
52
53void KoOdtFrameReportPrimitive::setUID(int uid)
54{
55 m_uid = uid;
56}
57
58int KoOdtFrameReportPrimitive::uid() const
59{
60 return m_uid;
61}
62
63QString KoOdtFrameReportPrimitive::itemName() const
64{
65 return QString("Item_%1").arg(m_uid);
66}
67
68void KoOdtFrameReportPrimitive::createStyle(KoGenStyles *coll)
69{
70 KoGenStyle gs(KoGenStyle::GraphicStyle, "graphic");
71 gs.addProperty("draw:fill", "none");
72 gs.addPropertyPt("fo:margin", 0);
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("style:wrap", "dynamic");
78 gs.addPropertyPt("style:wrap-dynamic-threshold", 0);
79
80 m_frameStyleName = coll->insert(gs, "F");
81}
82
83void KoOdtFrameReportPrimitive::createBody(KoXmlWriter *bodyWriter) const
84{
85 Q_UNUSED(bodyWriter);
86}
87
88void KoOdtFrameReportPrimitive::commonAttributes(KoXmlWriter *bodyWriter) const
89{
90 // convert to inches
91 qreal x = m_primitive->position().x() / KReportPrivate::dpiX();
92 qreal y = m_primitive->position().y() / KReportPrivate::dpiX();
93 qreal w = m_primitive->size().width() / KReportPrivate::dpiX();
94 qreal h = m_primitive->size().height() / KReportPrivate::dpiY();
95
96 bodyWriter->addAttribute("svg:x", QString("%1in").arg(x));
97 bodyWriter->addAttribute("svg:y", QString("%1in").arg(y));
98 bodyWriter->addAttribute("svg:width", QString("%1in").arg(w));
99 bodyWriter->addAttribute("svg:height", QString("%1in").arg(h));
100 bodyWriter->addAttribute("draw:z-index", "3");
101}
102
103bool KoOdtFrameReportPrimitive::saveData(KoStore */*store*/, KoXmlWriter*) const
104{
105 return true;
106}
107
Represents the basic primitive with a position and type. Other primitives are subclasses with a defin...
qreal x() const const
qreal y() const const
qreal height() const const
qreal width() const const
QString arg(Args &&... args) const const
QString & insert(qsizetype position, QChar ch)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:21:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.