Add support for custom page sizes, specified in user units/points
Details
- Reviewers
staniek - Commits
- R14:d5194fc276c6: Add support for custom page width/height
Created report with 10x10cm size. Displays ok in designer and viewer
Printed report from Kexi with custom size to PDF. Seems to work ok.
Diff Detail
- Repository
- R14 KReport
- Branch
- customsize-piggz
- Lint
No Linters Available - Unit
No Unit Test Coverage
@piggz What's the status for this commit?
src/common/KReportPageOptions.cpp | ||
---|---|---|
214 ↗ | (On Diff #3024) | Lines 214, 215 to long, break them. |
src/wrtembed/KReportDesigner.cpp | ||
298–300 | Line too long | |
729 | Let's use QPrinterInfo::defaultPrinter().defaultPageSize() as the default. | |
729 | Lines too long.. | |
730 | Let's have custom-page-size property (tr("Custom Page Size")) of type SizeF. | |
731 | TODO: later let's have this default unit defined somewhere in a single place. | |
793 | TODO future idea: If p is page size or custom page size or margin, and the margin is too big let's change margin (one or both) so the effective page area is at least 5mmx5mm. LibreOffice Writer does this: | |
865 | remove debug.. | |
874 | remove or disable debug here and elsewhere.. | |
src/wrtembed/KReportDesignerSection.cpp | ||
285 | Do we want this to prevent calling KReportDesigner::changeSet() and emitting the propertySetChanged() signal? If so can't we change: void KReportDesigner::changeSet(KPropertySet *s) { ... d->itmset = s; emit propertySetChanged(); } to void KReportDesigner::changeSet(KPropertySet *s) { ... if (d->itmset != s) { d->itmset = s; emit propertySetChanged(); } } And we're done? |
src/wrtembed/KReportDesigner.cpp | ||
---|---|---|
729 | at least on my system, defaultPageSize() returns an invalid size; |
When changing page CustomPageSize->Width property in the KReportExample's property editor, it is interpreted as Height. And coversely, Height is interpreted as Width.
Well ... that is maybe me trying to be too clever ... because the orientation is portrait, it tries to interpret the width/height appropriately. Thoughts about how this should work?
I guessed that may be the case. Pre-3.1 is the last chance to reconsider the logic. I am browsing the QPageLayout docs and noticed the following:
QPageLayout::pageSize() const
Returns the page size of the page layout. Note that the QPageSize is always defined in a Portrait orientation. To obtain a size that takes the set orientation into account you must use fullRect().
So how about the customSize property be like that? Orientation could be taken into account just prior to drawing/event handling.
So comparing pageWidth with pageHeight in order to modify orientation would be not needed. If user changes orientation, effective page size changes too regardless the size being custom or A4 or whatever. Probably most of the logic is in place already since we're using QPageLayout already?
On loading from XML we're calling d->pageLayout.setPageSize(custom) which really assumes size is a logical size regardless orientation.
src/wrtembed/KReportDesigner.cpp | ||
---|---|---|
873 | Do we need toSize() here? QSizeF is accepted in the ctor. |
- Add size to printed page
- Get custom size to work in kreportexample
- Address comments
- Remove unused code
- Fix class enum
src/wrtembed/KReportDesigner.cpp | ||
---|---|---|
873 | QSize is used to gice size in POints .. QSizeF is used when units are specified. The ctors are different. |
src/wrtembed/KReportDesigner.cpp | ||
---|---|---|
873 | I am looking at accuracy here. Do you think QPageSize(customSize, |
Looks good!
One warning to remove
kreport/src/wrtembed/KReportDesigner.cpp:860: warning: variable ‘pageHeight’ set but not used [-Wunused-but-set-variable] int pageHeight; ^~~~~~~~~~