Bug 405075 - Overlapping problem when printing header/footer lines
Summary: Overlapping problem when printing header/footer lines
Status: RESOLVED FIXED
Alias: None
Product: kdiagram
Classification: Applications
Component: KChart (show other bugs)
Version: 2.6.1
Platform: Other All
: NOR normal
Target Milestone: ---
Assignee: Dag Andersen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-04 14:41 UTC by Ralf Habacker
Modified: 2020-04-06 02:43 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 2.6.2


Attachments
printed file (partial fixed with mentioned patch) (6.32 KB, application/pdf)
2019-03-04 14:41 UTC, Ralf Habacker
Details
Screenshot from running kchart advanced header/footer example (70.59 KB, image/png)
2019-03-04 14:42 UTC, Ralf Habacker
Details
printed file (6.33 KB, application/pdf)
2019-03-04 15:01 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Habacker 2019-03-04 14:41:43 UTC
Created attachment 118535 [details]
printed file (partial fixed with mentioned patch)

When printing a diagram, the headers and footers do not appear at the expected positions.

STEPS TO REPRODUCE
1. create a kchart with headers and footers
2. print out the chart

OBSERVED RESULT
The header and footer are not in the expected positions (see attachment "generated file") 

EXPECTED RESULT
The header and footer should be at the expected locations (see appended screenshot)

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: openSUSE_Leap_42.3
KDE Frameworks Version: 5.54 
Qt Version: 5.11
Comment 1 Ralf Habacker 2019-03-04 14:42:19 UTC
Created attachment 118536 [details]
Screenshot from running kchart advanced header/footer example
Comment 2 Ralf Habacker 2019-03-04 15:01:06 UTC
Created attachment 118537 [details]
printed file

The overlapping header/footer issue showed with attachment 118535 [details] was generated with the following fix applied, which tries to fix a header offset issue.

commit 76a2b05015832fd903b8a760ba2aeb2e8f484864 (temp)
Author: Ralf Habacker <ralf.habacker@freenet.de>
Date:   Mon Mar 4 13:37:30 2019 +0100

    Fix geometry change in diagram header and footer
    
    When outputting to a printer, the geometry of a diagram changes,
    but a corresponding adjustment request was not passed on to the
    header and footer layout.
    
    CCBUG:405061

diff --git a/src/KChart/KChartChart.cpp b/src/KChart/KChartChart.cpp
index fa14b8a..6976e76 100644
--- a/src/KChart/KChartChart.cpp
+++ b/src/KChart/KChartChart.cpp
@@ -1382,6 +1382,10 @@ void Chart::paint( QPainter* painter, const QRect& target )
         d->isFloatingLegendsLayoutDirty = true;
         invalidateLayoutTree( d->dataAndLegendLayout );
         d->dataAndLegendLayout->setGeometry( QRect( QPoint(), target.size() ) );
+        invalidateLayoutTree( d->headerLayout );
+        d->headerLayout->setGeometry( QRect( QPoint(), target.size() ) );
+        invalidateLayoutTree( d->footerLayout );
+        d->footerLayout->setGeometry( QRect( QPoint(), target.size() ) );
     }
 
     d->overrideSize = target.size();
@@ -1391,6 +1395,10 @@ void Chart::paint( QPainter* painter, const QRect& target )
     if ( differentSize ) {
         invalidateLayoutTree( d->dataAndLegendLayout );
         d->dataAndLegendLayout->setGeometry( oldGeometry );
+        invalidateLayoutTree( d->headerLayout );
+        d->headerLayout->setGeometry( oldGeometry );
+        invalidateLayoutTree( d->footerLayout );
+        d->footerLayout->setGeometry( oldGeometry );
         d->isPlanesLayoutDirty = true;
         d->isFloatingLegendsLayoutDirty = true;
     }

While the patch fixes some of the offset issues, it seems to not be complete.

To be able to see the original state, a generated pdf file without this patch has been added with this comment.
Comment 3 Ralf Habacker 2019-03-04 15:05:24 UTC
For easier inspection I extended the advanced header/footer example with printing support (see https://phabricator.kde.org/D19516)
Comment 4 Ralf Habacker 2019-03-05 20:32:09 UTC
Git commit 455c23400dd3e679879a2d77d2259fc63e852247 by Ralf Habacker.
Committed on 05/03/2019 at 13:08.
Pushed by habacker into branch '4.8-staging'.

Reimplement Chart::paint() to fix printing issues

The implementation has been taken from AbstractArea::paintIntoRectArea()
FIXED-IN:2.6.2

M  +10   -45   libkdchart/src/KDChart/KDChartChart.cpp

https://commits.kde.org/kmymoney/455c23400dd3e679879a2d77d2259fc63e852247
Comment 5 Ralf Habacker 2019-03-06 07:33:16 UTC
This has been fixed for the KDE4 variant of KChart, which is embedded into kmymoney sources. For a proposed KF5 fix see https://phabricator.kde.org/D19541
Comment 6 Ralf Habacker 2019-03-09 14:20:46 UTC
Git commit 03a7211df61c570430d7f4e436772dbd54810ef5 by Ralf Habacker.
Committed on 09/03/2019 at 14:20.
Pushed by habacker into branch 'master'.

Extend advanded headers/footers example with printing support

Adding printer support helps to see the issues with misplaced
header/footer.
Reviewed By: danders
Differential Revision: https://phabricator.kde.org/D19516

M  +1    -1    examples/HeadersFooters/Advanced/CMakeLists.txt
M  +59   -20   examples/HeadersFooters/Advanced/mainwindow.cpp
M  +7    -0    examples/HeadersFooters/Advanced/mainwindow.h
M  +78   -42   examples/HeadersFooters/Advanced/mainwindow.ui

https://commits.kde.org/kdiagram/03a7211df61c570430d7f4e436772dbd54810ef5
Comment 7 Ralf Habacker 2019-03-26 23:23:46 UTC
Git commit 9a08e03fa8941c07af60144497855a323fc87a6b by Ralf Habacker.
Committed on 26/03/2019 at 23:20.
Pushed by habacker into branch '4.8'.

Reimplement Chart::paint() to fix printing issues

The implementation has been taken from AbstractArea::paintIntoRectArea()
and fixes incorrect header and footer locations.

See https://phabricator.kde.org/D19541 for details on differences compared
with the previous implementation.

M  +10   -45   libkdchart/src/KDChart/KDChartChart.cpp

https://commits.kde.org/kmymoney/9a08e03fa8941c07af60144497855a323fc87a6b
Comment 8 Ralf Habacker 2019-10-13 12:35:15 UTC
Git commit 347e5dda7b684f49afbfd63177f28e4754891eb7 by Ralf Habacker.
Committed on 13/10/2019 at 12:34.
Pushed by habacker into branch 'master'.

Reimplement Chart::paint() to fix printing issues

The previous implementation did not take the headers and footers
into account when resizing the diagram.

The implementation has been taken from AbstractArea::paintIntoRectArea().

This patch adds the method PrintingParameters::scaleFactor(), because
in branch 2.6 the class member PrintingParameters::scaleFactor was made
private.
FIXED-IN:2.6.2

Test Plan: tested on linux
Reviewed By: danders
Differential Revision: https://phabricator.kde.org/D19541

M  +12   -42   src/KChart/KChartChart.cpp
M  +2    -2    src/KChart/KChartChart.h
M  +11   -6    src/KChart/KChartPrintingParameters.cpp
M  +2    -1    src/KChart/KChartPrintingParameters.h

https://commits.kde.org/kdiagram/347e5dda7b684f49afbfd63177f28e4754891eb7
Comment 9 Ralf Habacker 2019-10-13 12:42:37 UTC
Git commit 17b914e037c03626c8085169bd2d2113cada353c by Ralf Habacker.
Committed on 13/10/2019 at 12:42.
Pushed by habacker into branch '2.6'.

Reimplement Chart::paint() to fix printing issues

The previous implementation did not take the headers and footers
into account when resizing the diagram.

The implementation has been taken from AbstractArea::paintIntoRectArea().

This patch adds the method PrintingParameters::scaleFactor(), because
in branch 2.6 the class member PrintingParameters::scaleFactor was made
private.
FIXED-IN:2.6.2

Test Plan: tested on linux
Reviewed By: danders
Differential Revision: https://phabricator.kde.org/D19541
(cherry picked from commit 347e5dda7b684f49afbfd63177f28e4754891eb7)

M  +14   -45   src/KChart/KChartChart.cpp
M  +2    -2    src/KChart/KChartChart.h
M  +11   -6    src/KChart/KChartPrintingParameters.cpp
M  +2    -1    src/KChart/KChartPrintingParameters.h

https://commits.kde.org/kdiagram/17b914e037c03626c8085169bd2d2113cada353c
Comment 10 Ralf Habacker 2020-04-06 02:43:39 UTC
Git commit dedf42deb88b2f89a749aba04bb1b7db52fae5c2 by Ralf Habacker.
Committed on 06/04/2020 at 02:42.
Pushed by habacker into branch 'master'.

Add print preview support to DrawIntoPainter and AdvancedHeaderFooter example

The print preview allows to check differences between printing
and display.
Reviewed By: danders
Differential Revision: https://phabricator.kde.org/D19680

M  +15   -0    examples/DrawIntoPainter/mainwindow.cpp
M  +3    -1    examples/DrawIntoPainter/mainwindow.h
M  +7    -0    examples/DrawIntoPainter/mainwindow.ui
M  +11   -6    examples/HeadersFooters/Advanced/mainwindow.cpp
M  +3    -1    examples/HeadersFooters/Advanced/mainwindow.h

https://commits.kde.org/kdiagram/dedf42deb88b2f89a749aba04bb1b7db52fae5c2