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 | | |||
93 | //Full page mode is required to allow margins to be set to whatever the user has specified | ||||
94 | d->page.setMode(QPageLayout::FullPageMode); | ||||
95 | | ||||
90 | if (pagetype == QLatin1String("predefined")) { | 96 | if (pagetype == QLatin1String("predefined")) { | ||
91 | d->page.setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); | 97 | setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4"))); | ||
98 | d->page.setPageSize(QPageSize(KReportPageSize::pageSize(pageSize()))); | ||||
92 | } else if (pagetype == QLatin1String("custom")) { | 99 | } else if (pagetype == QLatin1String("custom")) { | ||
93 | d->page.setCustomWidth(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()))) * dpiX); | 100 | 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); | 101 | | ||
95 | d->page.setPageSize(QLatin1String("Custom")); | 102 | d->page.setPageSize(custom); | ||
96 | } else if (pagetype == QLatin1String("label")) { | 103 | } else if (pagetype == QLatin1String("label")) { | ||
97 | d->page.setLabelType(elemThis.firstChild().nodeValue()); | 104 | setLabelType(elemThis.firstChild().nodeValue()); | ||
98 | } | 105 | } | ||
99 | //! @todo add config for default margins or add within templates support | 106 | //! @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); | 107 | d->page.setUnits(QPageLayout::Point); | ||
101 | d->page.setMarginTop(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))) * dpiY); | 108 | d->page.setLeftMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))); | ||
102 | d->page.setMarginLeft(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm")))) * dpiX); | 109 | d->page.setRightMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))); | ||
103 | d->page.setMarginRight(POINT_TO_INCH(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm")))) * dpiX); | 110 | d->page.setTopMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm")))); | ||
104 | 111 | d->page.setBottomMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm")))); | |||
105 | d->page.setPortrait(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait")); | 112 | d->page.setOrientation(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait") ? QPageLayout::Portrait : QPageLayout::Landscape); | ||
staniek: --8X-- | |||||
staniek: please remove the !Page Layout==== | |||||
106 | | ||||
107 | } else if (elemThis.tagName() == QLatin1String("report:body")) { | 113 | } else if (elemThis.tagName() == QLatin1String("report:body")) { | ||
108 | QDomNodeList sectionlist = elemThis.childNodes(); | 114 | QDomNodeList sectionlist = elemThis.childNodes(); | ||
109 | QDomNode sec; | 115 | QDomNode sec; | ||
110 | 116 | | |||
111 | for (int s = 0; s < sectionlist.count(); ++s) { | 117 | for (int s = 0; s < sectionlist.count(); ++s) { | ||
112 | sec = sectionlist.item(s); | 118 | sec = sectionlist.item(s); | ||
113 | if (sec.isElement()) { | 119 | if (sec.isElement()) { | ||
114 | QString sn = sec.nodeName().toLower(); | 120 | QString sn = sec.nodeName().toLower(); | ||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Line(s) | 315 | case KReportSectionData::ReportFooter: | |||
310 | sec = m_reportFooter; | 316 | sec = m_reportFooter; | ||
311 | break; | 317 | break; | ||
312 | default: | 318 | default: | ||
313 | sec = 0; | 319 | sec = 0; | ||
314 | } | 320 | } | ||
315 | return sec; | 321 | return sec; | ||
316 | } | 322 | } | ||
317 | 323 | | |||
318 | KReportPageOptions KReportDocument::pageOptions() const | 324 | QPageLayout KReportDocument::pageLayout() const | ||
319 | { | 325 | { | ||
320 | return d->page; | 326 | return d->page; | ||
321 | } | 327 | } | ||
322 | 328 | | |||
323 | bool KReportDocument::isValid() const | 329 | bool KReportDocument::isValid() const | ||
324 | { | 330 | { | ||
325 | return d->valid; | 331 | return d->valid; | ||
326 | } | 332 | } | ||
Show All 27 Lines | |||||
354 | { | 360 | { | ||
355 | return d->query; | 361 | return d->query; | ||
356 | } | 362 | } | ||
357 | 363 | | |||
358 | QString KReportDocument::script() const | 364 | QString KReportDocument::script() const | ||
359 | { | 365 | { | ||
360 | return d->script; | 366 | return d->script; | ||
361 | } | 367 | } | ||
368 | | ||||
369 | QString KReportDocument::pageSize() | ||||
370 | { | ||||
371 | return d->pageSize; | ||||
372 | } | ||||
373 | | ||||
374 | void KReportDocument::setPageSize(const QString& size) | ||||
375 | { | ||||
376 | d->pageSize = size; | ||||
377 | } | ||||
378 | | ||||
379 | QString KReportDocument::labelType() const | ||||
380 | { | ||||
381 | return d->labelType; | ||||
382 | } | ||||
383 | | ||||
384 | void KReportDocument::setLabelType(const QString& label) | ||||
385 | { | ||||
386 | d->labelType = label; | ||||
387 | } | ||||
388 | |
Will be moved later to dptr, right?