diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-02-18 19:18:47 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-02-19 16:48:28 +0100 |
commit | 509a02aa96f6d7620cb0bf06c20b3bfa0641be92 (patch) | |
tree | facaac50f8f787613756e1339501a421f98e6700 /sw/source/core/layout/laycache.cxx | |
parent | 4d5c0eaf3e0d3d3bcd9e691fffee19b75f3d6631 (diff) |
tdf#125682 sw: don't insert empty page before first page with even number
This mostly reverts commit 14bb680949b47332d2921cc68f75340b31ad5c32 and
replaces it by a hopefully better approach: if the first page in the
document has an even number, it will become a right page, and "toggle"
the document so that even pages are right pages and odd pages are left
pages.
This is closer to what Word does; the tests adapted in the above commit
were actually regressions.
Add a new function IsRightPageByNumber() to determine how the page
number offsets should be interpreted.
Also make it explicit that even/odd and right/left page are no longer
synonymous by renaming various "Odd" variables.
Historically documents that start with even page number didn't work well
anyway; before the above commit you'd get a left page followed by a left
page followed by a right page, which is clearly nonsense if the page
style differs between left and right pages - so hopefully we can do
without a compat setting for those.
There is still one situation where an empty page is inserted before the
first page: if the page style is "Left Page"; this appears to be
impossible in Word so we'll have issues exporting that to Word formats
anyway.
Testing:
Writer pre-commit; LO 5.4/OOo 3.3:
1.odd -> right, 2.even -> left
1.even -> left, 2.odd -> right + inserts a blank page on the right
after reload:
1.even -> left, 2.odd -> left, no empty page
Writer w/ commit; LO 6.0+:
1.odd -> right, 2.even -> left
1.even -> left, 2.odd -> right + blank page as first page (right)
after reload:
1.even -> left, 2.odd -> right + blank page as first page (right)
Word:
1.odd -> right, 2.even -> left
1.even -> right but left style, 2.odd -> left but right style
[technically uses terminology even/odd instead of left/right, but if
mirrored, the "inner margin" is always the same and leads to
interpretation of left/right]
Writer and Word appear to agree on inserting empty pages on
SwFormatPageDesc items/Word section breaks: both even-ness of an
explicit page number and "Left Page" only page style or explicit
even/odd section break may insert empty page.
A useful improvement would be to detect in Word import filters that the
first page is even numbered and then invert the mapping of all of the
page styles, i.e. odd header/footer->left instead of right, and if
mirrorMargins, pgMar left -> inner instead of outer.
Change-Id: Ibed0dbf888c120a3a7d11892f40d07ffb5bc0b68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88978
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw/source/core/layout/laycache.cxx')
-rw-r--r-- | sw/source/core/layout/laycache.cxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index eb824827e4ac..a5da72128614 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -668,17 +668,19 @@ bool SwLayHelper::CheckInsertPage() if ( oPgNum ) static_cast<SwRootFrame*>(mrpPage->GetUpper())->SetVirtPageNum(true); } - bool bNextPageOdd = !mrpPage->OnRightPage(); + bool bNextPageRight = !mrpPage->OnRightPage(); bool bInsertEmpty = false; - if( oPgNum && bNextPageOdd != ( ( *oPgNum % 2 ) != 0 ) ) + assert(mrpPage->GetUpper()->GetLower()); + if (oPgNum && bNextPageRight != IsRightPageByNumber( + *static_cast<SwRootFrame*>(mrpPage->GetUpper()), *oPgNum)) { - bNextPageOdd = !bNextPageOdd; + bNextPageRight = !bNextPageRight; bInsertEmpty = true; } // If the page style is changing, we'll have a first page. bool bNextPageFirst = pDesc != mrpPage->GetPageDesc(); ::InsertNewPage( const_cast<SwPageDesc&>(*pDesc), mrpPage->GetUpper(), - bNextPageOdd, bNextPageFirst, bInsertEmpty, false, mrpPage->GetNext() ); + bNextPageRight, bNextPageFirst, bInsertEmpty, false, mrpPage->GetNext()); if ( bEnd ) { OSL_ENSURE( mrpPage->GetNext(), "No new page?" ); |