Bug 155218 - Printing: selecting different page orientation does not relayout printed content
Summary: Printing: selecting different page orientation does not relayout printed content
Status: REOPENED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Printing and PDF export (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Tibor Nagy
URL:
Whiteboard: target:24.8.0
Keywords:
Depends on:
Blocks: Print-Dialog
  Show dependency treegraph
 
Reported: 2023-05-09 15:51 UTC by Gabor Kelemen (allotropia)
Modified: 2024-04-17 14:14 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Excel (8.71 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2023-05-09 15:51 UTC, Gabor Kelemen (allotropia)
Details
The example file in Excel and Calc print preview: as portrait (98.16 KB, image/png)
2023-05-09 15:52 UTC, Gabor Kelemen (allotropia)
Details
The example file in Excel and Calc print preview: as landscape (95.24 KB, image/png)
2023-05-09 15:52 UTC, Gabor Kelemen (allotropia)
Details
Example of a print area proplem (10.29 MB, video/mp4)
2024-02-10 19:18 UTC, Vladislav Tarakanov
Details
Example of a print area proplem 2 (5.78 MB, video/mp4)
2024-02-11 21:13 UTC, Vladislav Tarakanov
Details
Example of a problem with the "Distance" input field (18.19 MB, video/mp4)
2024-03-11 17:30 UTC, Vladislav Tarakanov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2023-05-09 15:51:27 UTC
Created attachment 187170 [details]
Example file from Excel

If you have a lot of contents in a document trying to print, in the print dialog preview (and in the result) the content is not relayouted, leading to paper waste.

1. Open the attached document in Calc and in Excel (for reference).
2. File - Print, notice in both Excel and Calc there is a bit of content flowing to the second page with Portrait orientation and Letter size.
2. Select Landscape orientation (but I think selecting a different paper size gives similarly flawed results)
-> In Excel the print layout is changed, there is more content put on a single landscape page, so the document will be printed to one sheet.
In Calc, the layout stays the same, even if more content could be fitted to a landscape sheet.

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 83b1f6b58a30bdb589e9ce73deef39f021aebde1
CPU threads: 14; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: threaded

It has been like this since 3.5 times - likely inherited.
There was some behavior change in 6.3 with the Print dialog rework - before that the first row of the sheet was visible in the preview area, since then it is also lost.

Yes, all this could be prevented by first selecting Format - Page Style - Page - Landscape but let's be able to do the sane thing from the Print dialog alone.
Comment 1 Gabor Kelemen (allotropia) 2023-05-09 15:52:16 UTC
Created attachment 187171 [details]
The example file in Excel and Calc print preview: as portrait
Comment 2 Gabor Kelemen (allotropia) 2023-05-09 15:52:45 UTC
Created attachment 187172 [details]
The example file in Excel and Calc print preview: as landscape
Comment 3 Mike Kaganski 2023-05-09 16:26:56 UTC
Hmm, we always kept print settings separate from page styles. Print settings never changed those.

In MS, both Word and Excel, there is *no* print styles; and all page settings are applied ad hoc.

In Calc, where all the page settings are managed through styles, one style can be applied to several different sheets; if you allow such a method of modifying styles, then printing a selection, you would be surprised to learn that page settings have changed where you didn't expect.
Comment 4 Mike Kaganski 2023-05-09 16:49:33 UTC
(In reply to Mike Kaganski from comment #3)
> In MS, both Word and Excel, there is *no* print styles

I am sorry for the typo; I meant "there is no *page* styles".
Comment 5 Stéphane Guillou (stragu) 2023-05-09 20:44:35 UTC
Calc is a component where users can be surprised to learn that page style exists and has to be tweaked to print as expected. Writer, Draw and Impress clearly have page and slide settings that are directly visible on canvas, whereas Calc has no visual hint of it.

So I can see how many might expect to see the print ranges' content automatically adapt to whatever paper size is chosen in the Print dialog, seeing a sheet as just a number of cells that can expand at will in both directions, virtually without limits.

Backward compatibility + PDF export means we can't just do away with the Page Style dialog's settings that can also be found in the Print dialog, nor add a "[from printer settings]" option for Paper Format like there is for Paper Tray.

How about an option in the print dialog, something like "Ignore Page Style's paper format", which could be on by default?
Comment 6 Mike Kaganski 2023-05-09 20:56:38 UTC
(In reply to Stéphane Guillou (stragu) from comment #5)
> How about an option in the print dialog, something like "Ignore Page Style's
> paper format", which could be on by default?

I do not see how stacking "ignore this", "ignore that" could be a good option whatsoever.

IMO, the original expectation that the layout should change is wrong -> WF.
Or add a button leading to page style dialog, with some note that "chosen page layout doesn't match the layout of the page style - do you want to fix that?" or the like.
Comment 7 Mike Kaganski 2023-05-09 20:58:41 UTC
Also:

(In reply to Stéphane Guillou (stragu) from comment #5)
> Calc is a component where users can be surprised to learn that page style
> exists and has to be tweaked to print as expected.

This is *SO MUCH* distant from the reality! The page settings in Calc are VERY important, and applying them to ranges of sheets is very useful thing. Only the most basic usage can avoid that.
Comment 8 Heiko Tietze 2023-05-10 07:11:12 UTC
I assume many user will preview the printout first. And without digging too deep, I find "Format Page" on the context menu which allows to change the orientation, for example. We do much better than competitors in this case, IMO.
Comment 9 Stéphane Guillou (stragu) 2023-05-10 08:21:57 UTC
(In reply to Mike Kaganski from comment #7)
> This is *SO MUCH* distant from the reality! The page settings in Calc are
> VERY important, and applying them to ranges of sheets is very useful thing.
> Only the most basic usage can avoid that.

(In reply to Heiko Tietze from comment #8)
> I assume many user will preview the printout first. And without digging too
> deep, I find "Format Page" on the context menu which allows to change the
> orientation, for example. We do much better than competitors in this case,
> IMO.

OK, point taken. My observation was based on personal experience + first-hand accounts from people switching from MS Office.

(In reply to Mike Kaganski from comment #6)
> Or add a button leading to page style dialog, with some note that "chosen
> page layout doesn't match the layout of the page style - do you want to fix
> that?" or the like.

A hint/link to the dialog could be sufficient. What do you think Heiko? Too busy a dialog?
Comment 10 Heiko Tietze 2023-05-10 08:36:26 UTC
(In reply to Stéphane Guillou (stragu) from comment #9)
> A hint/link to the dialog could be sufficient. 

Well, the documentation would be the right place to explain what we are discussing here.
Comment 11 Mike Kaganski 2023-05-10 09:04:57 UTC
PDF export has "Whole sheet export" feature. Indeed, this is not what is discussed here. But my idea is: can we possibly introduce something called "draft" print mode here, to address the issue?

The context: the printout depends on:

1. Selection in the Print dialog (Range: All pages / defined pages; More -> Print All Sheets / Selected Sheets / Selected Cells);
2. Print styles of the sheets to print, which define virtual page size, and scaling when outputting to that virtual page;
3. Print ranges (menu Format) on each of the sheet;
4. The physical page and its layout selected in Print dialog, on which the virtual page is placed.

The printing is really complex; and I believe we should not introduce *more* complexity by adding (default or not) settings to override specific properties of styles in the Print dialog.

But something *temporary*, clearly targeting a printout for quick-n-dirty analysis, which would use some simple setup, but *does not* change any document settings, would IMO be a reasonable thing to add. Which would, as asked here, ignore page orientation - but not only that: page size; margins; maybe header/footer; page borders; scaling; maybe print ranges ... so that it would not create impression that it replaces the proper setup for publishing.

What do you think?
Comment 12 Gabor Kelemen (allotropia) 2023-05-12 10:04:42 UTC
(In reply to Mike Kaganski from comment #11)
> PDF export has "Whole sheet export" feature. Indeed, this is not what is
> discussed here. But my idea is: can we possibly introduce something called
> "draft" print mode here, to address the issue?
> 
> The context: the printout depends on:
> 
> 1. Selection in the Print dialog (Range: All pages / defined pages; More ->
> Print All Sheets / Selected Sheets / Selected Cells);
> 2. Print styles of the sheets to print, which define virtual page size, and
> scaling when outputting to that virtual page;
> 3. Print ranges (menu Format) on each of the sheet;
> 4. The physical page and its layout selected in Print dialog, on which the
> virtual page is placed.
> 
> The printing is really complex; and I believe we should not introduce *more*
> complexity by adding (default or not) settings to override specific
> properties of styles in the Print dialog.
> 
> But something *temporary*, clearly targeting a printout for quick-n-dirty
> analysis, which would use some simple setup, but *does not* change any
> document settings, would IMO be a reasonable thing to add. Which would, as
> asked here, ignore page orientation - but not only that: page size; margins;
> maybe header/footer; page borders; scaling; maybe print ranges ... so that
> it would not create impression that it replaces the proper setup for
> publishing.
> 
> What do you think?

Yes, that makes sense. No need to change style from the Print dialog - just make the Paper size and Orientation dropdowns "work" - i.e. align the virtual page size / print range and the physical page selected by the user.

Having styles and using them is nice when you understand them in depth, but in larger organizations it's common that not everyone is like that. It's also common to have a document made by experts (of some area, also Office) be printed & tweaked by a less expert colleague.
For such use cases overriding the style settings on a "just do it, NOW!!!" base makes sense.
Comment 13 Heiko Tietze 2023-05-23 12:36:59 UTC
(In reply to Mike Kaganski from comment #11)
> But something *temporary*, clearly targeting a printout for quick-n-dirty
> analysis, which would use some simple setup, but *does not* change any
> document settings, would IMO be a reasonable thing to add.

(In reply to Gabor Kelemen (allotropia) from comment #12)
> Yes, that makes sense...
> Having styles and using them is nice when you understand them in depth, but
> in larger organizations it's common that not everyone is like that. It's
> also common to have a document made by experts (of some area, also Office)
> be printed & tweaked by a less expert colleague.
> For such use cases overriding the style settings on a "just do it, NOW!!!"
> base makes sense.

Sounds wrong to me. I'd rather hint how to do things properly. Could be, for example, an icon-only button with the tooltip "Change page style" next to the print orientation option. But likely not much more to discuss here as the doers decide - and you have to listen to the customers while I can stipulate education.
Comment 14 Commit Notification 2024-02-09 11:06:45 UTC
Tibor Nagy committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a67cd7b3cf03163f87811f7080cabc49750c4fd5

tdf#155218 sc: fix different page orientation in print dialog

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Vladislav Tarakanov 2024-02-10 19:17:31 UTC
It seems that after changing the orientation in the print dialog there is 1 side effect. After closing the print dialog and scrolling the mouse wheel in the main Calc window, you will notice that the borders displaying the print area do not correspond to the orientation specified in the page style. The problem seems to persist until another preview is opened.
Comment 16 Vladislav Tarakanov 2024-02-10 19:18:29 UTC
Created attachment 192501 [details]
Example of a print area proplem
Comment 17 Amin Irgaliev 2024-02-11 11:32:10 UTC
Since we are also interested in this patch and there is still no response from the developer, we will fix the problem with this side effect ourselves.
Comment 18 Tibor Nagy 2024-02-11 11:58:49 UTC
(In reply to Vladislav Tarakanov from comment #15)
> It seems that after changing the orientation in the print dialog there is 1
> side effect. After closing the print dialog and scrolling the mouse wheel in
> the main Calc window, you will notice that the borders displaying the print
> area do not correspond to the orientation specified in the page style. The
> problem seems to persist until another preview is opened.

Thank you for the feedback!
I was careless! I didn't notice this problem, but I know what causes it.
I'll fix it quickly.
Comment 19 Commit Notification 2024-02-11 17:52:53 UTC
Tibor Nagy committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5ccee13baa29c9899c88519ad71ed18c3fe944c1

tdf#155218 sc: fix incorrect print area

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 20 Vladislav Tarakanov 2024-02-11 21:12:56 UTC
I can still reproduce this problem using other steps:

1. Open the print dialog
2. Change orientation
3. Select Printer "Print to file..." and click the "Print to file..." button
4. Cancel saving
5. Scroll the mouse wheel in the main Calc window

Information that may be useful:
VCL plugin: gtk3
OS: Linux
DE: KDE
Comment 21 Vladislav Tarakanov 2024-02-11 21:13:38 UTC
Created attachment 192510 [details]
Example of a print area proplem 2
Comment 22 Vladislav Tarakanov 2024-02-17 11:42:45 UTC
It seems the first patch has 1 more side effect. When running with the gtk3 VCL plugin, the window dialog may increase in size if the "Pages" and "All pages" radio buttons are toggled many times. The problem is not reproduced with the kf5 and gen plugin.

The issue is reproducible after commit "a67cd7b3cf03163f87811f7080cabc49750c4fd5", but not reproducible after the previous commit ("7327752ef5d1fa2239cdd8355fb78da41c282717")
Comment 23 Vladislav Tarakanov 2024-02-19 20:21:46 UTC
(In reply to Vladislav Tarakanov from comment #22)
> It seems the first patch has 1 more side effect. When running with the gtk3
> VCL plugin, the window dialog may increase in size if the "Pages" and "All
> pages" radio buttons are toggled many times. The problem is not reproduced
> with the kf5 and gen plugin.
> 
> The issue is reproducible after commit
> "a67cd7b3cf03163f87811f7080cabc49750c4fd5", but not reproducible after the
> previous commit ("7327752ef5d1fa2239cdd8355fb78da41c282717")

This appears to be a side effect of the "setupOptionalUI" method call from the "updatePageRange" method (vcl/source/window/printdlg.cxx:1018). After calling this method, duplicate drop-down lists for "Include:" and "From which:" appear in the "Collation and paper size" submenu. It looks like gtk3 doesn't remove old widgets in this case, unlike kf5.

Also, after each call, the size of maExtraControls increases by 4. The problem occurs for all VCL plugins. This does not waste RAM much, but it is probably better not to allow this. This fact also suggests that the method was originally created not for updating the GUI, but for one-time generation. At least the "else if ( aCtrlType == "List")" part (vcl/source/window/printdlg.cxx:1623) does not remove existing widgets with VCL gtk3.
Comment 24 Commit Notification 2024-02-29 00:36:23 UTC
Tibor Nagy committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/364f0bb1cac0e12f5f926857f61c2f329a353ec7

tdf#155218 sc: fix regression page orientation in print dialog

It will be available in 24.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 25 Buovjaga 2024-03-11 10:03:15 UTC
Can the status be fixed now?
Comment 26 Vladislav Tarakanov 2024-03-11 17:30:51 UTC
Created attachment 193066 [details]
Example of a problem with the "Distance" input field

During testing, another small problem was noticed. If the page size is changed in the print dialog and if the "Custom" option is selected in "Pages per Sheet", then the maximum value in the "Distance" and "Margin" input fields is not updated. As a result, the behavior when setting page sizes in page styles is different from the behavior when setting directly in the print dialog.
Comment 27 Vladislav Tarakanov 2024-03-14 10:46:09 UTC
There is 1 more problem. If landscape orientation is selected in the page styles, then in the print dialog, under certain actions, it can be replaced with portrait.

Steps to Reproduce:
1. Open the calc table
2. Set the landscape orientation in page styles
3. Open the print dialog
4. Change the printer "Generic Printer" to "Print to File..."

Expected Results:
The number of pages and their orientation will not change

Actual Results:
1. The number of pages will change to match the number of pages in portrait orientation.
2. Starting from the second page (or any other that was not previously viewed in the preview), the page orientation will be portrait.
3. The first page (or any other that has already been viewed in the preview) will remain in landscape orientation. Perhaps this has something to do with caching pages in the preview, but we haven’t checked it in detail.

___

The problem was first reproduced after commit a67cd7b3cf03163f87811f7080cabc49750c4fd5. It's still reproduced on the daily build from 2024-Mar-14 02:49 (Build: c8b8a2c2cb34a1ae0b0aeee0564b39260258f184)