Warning, file /libraries/kreport/src/renderer/odtframe/KoOdtFrameReportPrimitive.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002    Copyright (C) 2011, 2012 by Dag Andersen (danders@get2net.dk)
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2.1 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017    Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #include "KoOdtFrameReportPrimitive.h"
0021 #include "KReportRenderObjects.h"
0022 
0023 #include <KoXmlWriter.h>
0024 #include <KReportDpi.h>
0025 #include <KoGenStyle.h>
0026 #include <KoGenStyles.h>
0027 
0028 KoOdtFrameReportPrimitive::KoOdtFrameReportPrimitive(OROPrimitive *primitive)
0029     : m_primitive(primitive)
0030     , m_uid(0)
0031 {
0032 }
0033 
0034 KoOdtFrameReportPrimitive::~KoOdtFrameReportPrimitive()
0035 {
0036 }
0037 
0038 bool KoOdtFrameReportPrimitive::isValid() const
0039 {
0040     return (bool)m_primitive;
0041 }
0042 
0043 void KoOdtFrameReportPrimitive::setPrimitive(OROPrimitive *primitive)
0044 {
0045     m_primitive = primitive;
0046 }
0047 
0048 int KoOdtFrameReportPrimitive::pageNumber() const
0049 {
0050     return isValid() && m_primitive->page() ? m_primitive->page()->pageNumber() + 1 : 0;
0051 }
0052 
0053 void KoOdtFrameReportPrimitive::setUID(int uid)
0054 {
0055     m_uid = uid;
0056 }
0057 
0058 int KoOdtFrameReportPrimitive::uid() const
0059 {
0060     return m_uid;
0061 }
0062 
0063 QString KoOdtFrameReportPrimitive::itemName() const
0064 {
0065     return QString("Item_%1").arg(m_uid);
0066 }
0067 
0068 void KoOdtFrameReportPrimitive::createStyle(KoGenStyles *coll)
0069 {
0070     KoGenStyle gs(KoGenStyle::GraphicStyle, "graphic");
0071     gs.addProperty("draw:fill", "none");
0072     gs.addPropertyPt("fo:margin", 0);
0073     gs.addProperty("style:horizontal-pos", "from-left");
0074     gs.addProperty("style:horizontal-rel", "page");
0075     gs.addProperty("style:vertical-pos", "from-top");
0076     gs.addProperty("style:vertical-rel", "page");
0077     gs.addProperty("style:wrap", "dynamic");
0078     gs.addPropertyPt("style:wrap-dynamic-threshold", 0);
0079 
0080     m_frameStyleName = coll->insert(gs, "F");
0081 }
0082 
0083 void KoOdtFrameReportPrimitive::createBody(KoXmlWriter *bodyWriter) const
0084 {
0085     Q_UNUSED(bodyWriter);
0086 }
0087 
0088 void KoOdtFrameReportPrimitive::commonAttributes(KoXmlWriter *bodyWriter) const
0089 {
0090     // convert to inches
0091     qreal x = m_primitive->position().x() / KReportPrivate::dpiX();
0092     qreal y = m_primitive->position().y() / KReportPrivate::dpiX();
0093     qreal w = m_primitive->size().width() / KReportPrivate::dpiX();
0094     qreal h = m_primitive->size().height() / KReportPrivate::dpiY();
0095 
0096     bodyWriter->addAttribute("svg:x", QString("%1in").arg(x));
0097     bodyWriter->addAttribute("svg:y", QString("%1in").arg(y));
0098     bodyWriter->addAttribute("svg:width", QString("%1in").arg(w));
0099     bodyWriter->addAttribute("svg:height", QString("%1in").arg(h));
0100     bodyWriter->addAttribute("draw:z-index", "3");
0101 }
0102 
0103 bool KoOdtFrameReportPrimitive::saveData(KoStore */*store*/, KoXmlWriter*) const
0104 {
0105     return true;
0106 }
0107