File indexing completed on 2024-04-28 04:42:09

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
0003  * Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2.1 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013  * Lesser General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Lesser General Public
0016  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #include "KReportDesignerItemBase.h"
0020 #include "KReportDesigner.h"
0021 #include "KReportItemBase.h"
0022 #include "KReportUtils.h"
0023 
0024 #include <QString>
0025 #include <QDomDocument>
0026 #include <QCheckBox>
0027 
0028 class Q_DECL_HIDDEN KReportDesignerItemBase::Private
0029 {
0030 public:
0031     Private();
0032     ~Private();
0033 
0034     KReportDesigner *reportDesigner;
0035     KReportItemBase *item;
0036     QString renderText;
0037 };
0038 
0039 KReportDesignerItemBase::Private::Private()
0040 {
0041 }
0042 
0043 KReportDesignerItemBase::Private::~Private()
0044 {
0045 }
0046 
0047 KReportDesignerItemBase::~KReportDesignerItemBase()
0048 {
0049     delete d;
0050 }
0051 
0052 KReportDesignerItemBase::KReportDesignerItemBase(KReportDesigner *r, KReportItemBase *b) : d(new Private())
0053 {
0054     d->reportDesigner = r;
0055     d->item = b;
0056     b->setUnit(r->pageUnit());
0057 }
0058 
0059 void KReportDesignerItemBase::buildXML(QGraphicsItem * item, QDomDocument *doc, QDomElement *parent)
0060 {
0061     KReportDesignerItemBase *re = dynamic_cast<KReportDesignerItemBase*>(item);
0062     if (re) {
0063         re->buildXML(doc, parent);
0064     }
0065 
0066 }
0067 
0068 void KReportDesignerItemBase::buildXMLRect(QDomDocument *doc, QDomElement *entity, KReportItemBase *i)
0069 {
0070     Q_UNUSED(doc);
0071     KReportUtils::buildXMLRect(entity, i->position(), i->size());
0072 }
0073 
0074 void KReportDesignerItemBase::buildXMLTextStyle(QDomDocument *doc, QDomElement *entity, const KReportTextStyleData &ts)
0075 {
0076     KReportUtils::buildXMLTextStyle(doc, entity, ts);
0077 }
0078 
0079 void KReportDesignerItemBase::buildXMLLineStyle(QDomDocument *doc, QDomElement *entity, const KReportLineStyle &ls)
0080 {
0081     KReportUtils::buildXMLLineStyle(doc, entity, ls);
0082 }
0083 
0084 QString KReportDesignerItemBase::dataSourceAndObjectTypeName(const QString& dataSource, const QString& objectTypeName) const
0085 {
0086     return QString::fromLatin1("%1: %2").arg(dataSource).arg(objectTypeName);
0087 }
0088 
0089 // static
0090 void KReportDesignerItemBase::addPropertyAsAttribute(QDomElement* e, KProperty* p)
0091 {
0092     KReportUtils::addPropertyAsAttribute(e, p);
0093 }
0094 
0095 KReportDesigner * KReportDesignerItemBase::designer() const
0096 {
0097     return d->reportDesigner;
0098 }
0099 
0100 void KReportDesignerItemBase::setDesigner(KReportDesigner* rd)
0101 {
0102     d->reportDesigner = rd;
0103 }
0104 
0105 KReportItemBase *KReportDesignerItemBase::item() const
0106 {
0107     return d->item;
0108 }
0109 
0110 QString KReportDesignerItemBase::renderText() const
0111 {
0112     return d->renderText;
0113 }
0114 
0115 void KReportDesignerItemBase::setRenderText(const QString& text)
0116 {
0117     d->renderText = text;
0118 }