Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportDocument.cpp
Show All 14 Lines | |||||
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "KReportDocument.h" | 18 | #include "KReportDocument.h" | ||
19 | #include "KReportUnit.h" | 19 | #include "KReportUnit.h" | ||
20 | #include "KReportDetailSectionData.h" | 20 | #include "KReportDetailSectionData.h" | ||
21 | #include "KReportItemBase.h" | 21 | #include "KReportItemBase.h" | ||
22 | #include "KReportDpi.h" | 22 | #include "KReportDpi.h" | ||
23 | #include "KReportPageSize.h" | ||||
23 | 24 | | |||
24 | #include <QDomElement> | 25 | #include <QDomElement> | ||
25 | #include <QApplication> | 26 | #include <QApplication> | ||
26 | #include "kreport_debug.h" | 27 | #include "kreport_debug.h" | ||
27 | 28 | | |||
28 | class Q_DECL_HIDDEN KReportDocument::Private | 29 | class Q_DECL_HIDDEN KReportDocument::Private | ||
29 | { | 30 | { | ||
30 | public: | 31 | public: | ||
31 | bool valid; | 32 | bool valid; | ||
32 | QString title; | 33 | QString title; | ||
33 | QString name; | 34 | QString name; | ||
34 | QString query; | 35 | QString query; | ||
35 | #ifdef KREPORT_SCRIPTING | 36 | #ifdef KREPORT_SCRIPTING | ||
36 | QString script; | 37 | QString script; | ||
37 | QString interpreter; | 38 | QString interpreter; | ||
38 | #endif | 39 | #endif | ||
39 | bool externalData; | 40 | bool externalData; | ||
40 | KReportPageOptions page; | 41 | QPageLayout page; | ||
42 | QString pageSize; | ||||
43 | QString labelType; | ||||
41 | }; | 44 | }; | ||
42 | 45 | | |||
43 | void KReportDocument::init() | 46 | void KReportDocument::init() | ||
44 | { | 47 | { | ||
45 | m_pageHeaderFirst = m_pageHeaderOdd = m_pageHeaderEven = m_pageHeaderLast = m_pageHeaderAny = 0; | 48 | m_pageHeaderFirst = m_pageHeaderOdd = m_pageHeaderEven = m_pageHeaderLast = m_pageHeaderAny = 0; | ||
staniek: Will be moved later to dptr, right? | |||||
piggz: Ok, i'll do that in a separate commit | |||||
46 | m_pageFooterFirst = m_pageFooterOdd = m_pageFooterEven = m_pageFooterLast = m_pageFooterAny = 0; | 49 | m_pageFooterFirst = m_pageFooterOdd = m_pageFooterEven = m_pageFooterLast = m_pageFooterAny = 0; | ||
47 | m_reportHeader = m_reportFooter = 0; | 50 | m_reportHeader = m_reportFooter = 0; | ||
48 | } | 51 | } | ||
49 | 52 | | |||
50 | KReportDocument::KReportDocument(QObject *parent) | 53 | KReportDocument::KReportDocument(QObject *parent) | ||
51 | : QObject(parent), | 54 | : QObject(parent), | ||
52 | m_detailSection(0), | 55 | m_detailSection(0), | ||
53 | d(new Private()) | 56 | d(new Private()) | ||
Show All 26 Lines | 81 | for (int nodeCounter = 0; nodeCounter < sections.count(); nodeCounter++) { | |||
80 | if (elemThis.tagName() == QLatin1String("report:title")) { | 83 | if (elemThis.tagName() == QLatin1String("report:title")) { | ||
81 | d->title = elemThis.text(); | 84 | d->title = elemThis.text(); | ||
82 | #ifdef KREPORT_SCRIPTING | 85 | #ifdef KREPORT_SCRIPTING | ||
83 | } else if (elemThis.tagName() == QLatin1String("report:script")) { | 86 | } else if (elemThis.tagName() == QLatin1String("report:script")) { | ||
84 | d->script = elemThis.text(); | 87 | d->script = elemThis.text(); | ||
85 | d->interpreter = elemThis.attribute(QLatin1String("report:script-interpreter")); | 88 | d->interpreter = elemThis.attribute(QLatin1String("report:script-interpreter")); | ||
86 | #endif | 89 | #endif | ||
87 | } else if (elemThis.tagName() == QLatin1String("report:page-style")) { | 90 | } else if (elemThis.tagName() == QLatin1String("report:page-style")) { | ||
88 | QString pagetype = elemThis.firstChild().nodeValue(); | 91 | QString pagetype = elemThis.firstChild().nodeValue(); | ||
staniek: --8x-- | |||||
89 | 92 | | |||
90 | if (pagetype == QLatin1String("predefined")) { | 93 | if (pagetype == QLatin1String("predefined")) { | ||
91 | d->page.setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); | 94 | setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); | ||
95 | d->page.setPageSize(QPageSize(KReportPageSize::pageSize(pageSize()))); | ||||
92 | } else if (pagetype == QLatin1String("custom")) { | 96 | } else if (pagetype == QLatin1String("custom")) { | ||
93 | d->page.setCustomWidth(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()))) * dpiX); | 97 | QPageSize custom(QSize(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()).toFloat() , elemThis.attribute(QLatin1String("report:custom-page-height"), QString()).toFloat()), QLatin1String("Custom")); | ||
94 | d->page.setCustomHeight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-height"), QString()))) * dpiY); | 98 | | ||
95 | d->page.setPageSize(QLatin1String("Custom")); | 99 | //d->page.setCustomWidth(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()))) * dpiX); | ||
100 | //d->page.setCustomHeight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-height"), QString()))) * dpiY); | ||||
101 | d->page.setPageSize(custom); | ||||
96 | } else if (pagetype == QLatin1String("label")) { | 102 | } else if (pagetype == QLatin1String("label")) { | ||
103 | #if 0 | ||||
97 | d->page.setLabelType(elemThis.firstChild().nodeValue()); | 104 | d->page.setLabelType(elemThis.firstChild().nodeValue()); | ||
105 | #endif | ||||
98 | } | 106 | } | ||
99 | //! @todo add config for default margins or add within templates support | 107 | //! @todo add config for default margins or add within templates support | ||
100 | d->page.setMarginBottom(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))) * dpiY); | 108 | //d->page.setMarginBottom(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))) * dpiY); | ||
staniek: --8X-- | |||||
staniek: please remove the !Page Layout==== | |||||
101 | d->page.setMarginTop(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))) * dpiY); | 109 | //d->page.setMarginTop(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))) * dpiY); | ||
102 | d->page.setMarginLeft(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))) * dpiX); | 110 | //d->page.setMarginLeft(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))) * dpiX); | ||
103 | d->page.setMarginRight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))) * dpiX); | 111 | //d->page.setMarginRight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))) * dpiX); | ||
104 | 112 | | |||
105 | d->page.setPortrait(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait")); | 113 | //d->page.setPortrait(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait")); | ||
106 | 114 | | |||
115 | d->page.setUnits(QPageLayout::Point); | ||||
116 | d->page.setLeftMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))); | ||||
117 | d->page.setRightMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))); | ||||
118 | d->page.setTopMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))); | ||||
119 | d->page.setBottomMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))); | ||||
120 | d->page.setOrientation(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait") ? QPageLayout::Portrait : QPageLayout::Landscape); | ||||
107 | } else if (elemThis.tagName() == QLatin1String("report:body")) { | 121 | } else if (elemThis.tagName() == QLatin1String("report:body")) { | ||
108 | QDomNodeList sectionlist = elemThis.childNodes(); | 122 | QDomNodeList sectionlist = elemThis.childNodes(); | ||
109 | QDomNode sec; | 123 | QDomNode sec; | ||
110 | 124 | | |||
111 | for (int s = 0; s < sectionlist.count(); ++s) { | 125 | for (int s = 0; s < sectionlist.count(); ++s) { | ||
112 | sec = sectionlist.item(s); | 126 | sec = sectionlist.item(s); | ||
113 | if (sec.isElement()) { | 127 | if (sec.isElement()) { | ||
114 | QString sn = sec.nodeName().toLower(); | 128 | QString sn = sec.nodeName().toLower(); | ||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Line(s) | 323 | case KReportSectionData::ReportFooter: | |||
310 | sec = m_reportFooter; | 324 | sec = m_reportFooter; | ||
311 | break; | 325 | break; | ||
312 | default: | 326 | default: | ||
313 | sec = 0; | 327 | sec = 0; | ||
314 | } | 328 | } | ||
315 | return sec; | 329 | return sec; | ||
316 | } | 330 | } | ||
317 | 331 | | |||
318 | KReportPageOptions KReportDocument::pageOptions() const | 332 | QPageLayout KReportDocument::pageLayout() const | ||
319 | { | 333 | { | ||
320 | return d->page; | 334 | return d->page; | ||
321 | } | 335 | } | ||
322 | 336 | | |||
323 | bool KReportDocument::isValid() const | 337 | bool KReportDocument::isValid() const | ||
324 | { | 338 | { | ||
325 | return d->valid; | 339 | return d->valid; | ||
326 | } | 340 | } | ||
Show All 27 Lines | |||||
354 | { | 368 | { | ||
355 | return d->query; | 369 | return d->query; | ||
356 | } | 370 | } | ||
357 | 371 | | |||
358 | QString KReportDocument::script() const | 372 | QString KReportDocument::script() const | ||
359 | { | 373 | { | ||
360 | return d->script; | 374 | return d->script; | ||
361 | } | 375 | } | ||
376 | | ||||
377 | QString KReportDocument::pageSize() | ||||
378 | { | ||||
379 | return d->pageSize; | ||||
380 | } | ||||
381 | | ||||
382 | void KReportDocument::setPageSize(const QString& size) | ||||
383 | { | ||||
384 | d->pageSize = size; | ||||
385 | } | ||||
386 | | ||||
387 | QString KReportDocument::labelType() | ||||
388 | { | ||||
389 | return d->labelType; | ||||
390 | } | ||||
391 | | ||||
392 | void KReportDocument::setLabelType(const QString& label) | ||||
393 | { | ||||
394 | d->labelType = label; | ||||
395 | } | ||||
396 | |
Will be moved later to dptr, right?