Bug 161646 - Let Page Number Wizard (optionally) insert headers/footers in the margin area
Summary: Let Page Number Wizard (optionally) insert headers/footers in the margin area
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Justin L
URL:
Whiteboard: target:25.2.0
Keywords:
Depends on:
Blocks: Writer-Header-Footer
  Show dependency treegraph
 
Reported: 2024-06-19 07:08 UTC by Mike Kaganski
Modified: 2024-07-20 04:01 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
161646_fitExistingMarginsPageNumbering.odt: testing document (35.19 KB, application/vnd.oasis.opendocument.text)
2024-06-21 23:47 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2024-06-19 07:08:05 UTC
Bug 86630 introduced a Page Number Wizard [1]. It allows to combine the tasks of creating / switching to the header/footer, and placing a relevant field there in a wanted position.

There is a very important (even if NOTABUG) tdf#33304, with very many users in CC list. My bug 33304 comment 54 there mentions, that a tool that would insert header/footer *and at the same time* change margins to keep the layout would be a solution for users.

The proposal here is to add a checkbox to the said Page Number Wizard, like "put it to the margin area", which would make it - in case when the header/footer didn't exist before - to do the relevant re-calculations, keeping the page body layout unchanged.

[1] https://wiki.documentfoundation.org/ReleaseNotes/7.6#Writer
Comment 1 V Stuart Foote 2024-06-19 11:06:39 UTC
+1, worthwhile enhancement to accommodate multiple requests to shift header/footer into margin space needed for bug 33304
Comment 2 Roman 2024-06-20 12:15:33 UTC
+1 wAIT
Comment 3 Justin L 2024-06-20 13:38:43 UTC
The page number wizard just combines things that the user could already do in other places. I suppose one could argue that the user could just change the page's top and bottom margin before... OK, +1 from me too.

Could it be done automatically (no option)?
* ultimately no: the difference between manual creation would be too jarring.

Could this be enabled by default?
* based on LO's fairly generous default margins, perhaps yes.
* but probably no - it wouldn't match page styles with manually created footers.

So for a footer, I expect that the calculation would be to reduce the bottom margin by the page style's footer spacing + the maximum(page style's default footer height, or height of Footer paragraph style font size).

Other considerations:
* a minimum margin should be observed: most printers can't print to paper edge.
** maybe 0.5cm minimum which is approximately the space needed for 12/14 pt.

possible wording
"fit into existing margins"
Comment 4 Justin L 2024-06-21 00:55:04 UTC
The code of course is in sw/source/uibase/shells/textfld.cxx.

The existing page margin is easy to get:
   aNewDesc.GetMaster().GetULSpace() with .GetUpper() or .GetLower()

"FooterBodyDistance" (Spacing) is forced here already. constTwips_5mm
"FooterHeight" (Height) is left at zero, but in the UI it shows up as 0.10cm which is the minimum allowed in the UI. When set (SID_ATTR_PAGE_SIZE), this includes the FooterBodyDistance.

The problem of course is going to be determining the height taken up by the Footer paragraph font size...


If you look at the page header/footer UI when they are off, both "Spacing" and "Height" are set to 0.5 cm because DEF_DIST_WRITER is 500
        tools::Long nDefaultDist = bIsCalc ? DEF_DIST_CALC : DEF_DIST_WRITER;
        SetMetricValue( *m_xDistEdit, nDefaultDist, MapUnit::Map100thMM );
        SetMetricValue( *m_xHeightEdit, 500, MapUnit::Map100thMM );
Comment 5 Justin L 2024-06-21 23:47:40 UTC
Created attachment 194904 [details]
161646_fitExistingMarginsPageNumbering.odt: testing document

The following implementation seems to work pretty good: https://gerrit.libreoffice.org/c/core/+/169349
Comment 6 Commit Notification 2024-07-03 14:45:01 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/433c4180acd5c5a699e71ab2f749713db36dc165

tdf#161646 sw page number wizard: fit into existing margins

It will be available in 25.2.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.