summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-02-18 19:18:47 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-02-26 10:10:57 +0100
commitda4f9ff1cfeeeb4f04bb943e94db86887b5c9f58 (patch)
tree1b91b2f0bf3c70cbd439f04162926f7c34a86651
parenttdf#129553 sw_redlinehide: fix replace of paragraph breaks with $ (diff)
downloadcore-da4f9ff1cfeeeb4f04bb943e94db86887b5c9f58.tar.gz
core-da4f9ff1cfeeeb4f04bb943e94db86887b5c9f58.zip
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> (cherry picked from commit 509a02aa96f6d7620cb0bf06c20b3bfa0641be92) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89047 Tested-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit 2e909f572229c16ae86a17d5a6fc83b67e818f9b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89461
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx9
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport10.cxx8
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport4.cxx3
-rw-r--r--sw/qa/extras/ww8export/ww8export.cxx7
-rw-r--r--sw/source/core/inc/frmtool.hxx8
-rw-r--r--sw/source/core/layout/flowfrm.cxx18
-rw-r--r--sw/source/core/layout/frmtool.cxx25
-rw-r--r--sw/source/core/layout/laycache.cxx10
-rw-r--r--sw/source/core/layout/newfrm.cxx10
-rw-r--r--sw/source/core/layout/pagechg.cxx28
-rw-r--r--sw/source/core/layout/trvlfrm.cxx38
11 files changed, 86 insertions, 78 deletions
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 2264d25615c6..703de09ef7f7 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -876,14 +876,11 @@ DECLARE_ODFIMPORT_TEST(testTdf94882, "tdf94882.odt")
DECLARE_ODFIMPORT_TEST(testBlankBeforeFirstPage, "tdf94882.odt")
{
- // This document starts on page 50, which is even, so it should have a
+ // This document starts on page 50, which is even, but it should not have a
// blank page inserted before it to make it a left page
- CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 2 pages output",
- OUString("2"), parseDump("count(/root/page)")
- );
- CPPUNIT_ASSERT_EQUAL_MESSAGE("The first page should be blank",
- OUString("0"), parseDump("count(/root/page[1]/body)")
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 1 pages output",
+ OUString("1"), parseDump("count(/root/page)")
);
}
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 09666cdf3cc4..22d5fc6d742e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -172,13 +172,13 @@ DECLARE_OOXMLEXPORT_TEST(testWpgNested, "wpg-nested.docx")
// This failed, the right edge of the shape was outside the page
// boundaries.
xmlDocPtr pXmlDoc = parseLayoutDump();
- sal_Int32 nPageLeft = getXPath(pXmlDoc, "/root/page[2]/infos/bounds", "left").toInt32();
- sal_Int32 nPageWidth = getXPath(pXmlDoc, "/root/page[2]/infos/bounds", "width").toInt32();
+ sal_Int32 nPageLeft = getXPath(pXmlDoc, "/root/page[1]/infos/bounds", "left").toInt32();
+ sal_Int32 nPageWidth = getXPath(pXmlDoc, "/root/page[1]/infos/bounds", "width").toInt32();
sal_Int32 nShapeLeft
- = getXPath(pXmlDoc, "/root/page[2]/body/txt/anchored/SwAnchoredDrawObject/bounds", "left")
+ = getXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/SwAnchoredDrawObject/bounds", "left")
.toInt32();
sal_Int32 nShapeWidth
- = getXPath(pXmlDoc, "/root/page[2]/body/txt/anchored/SwAnchoredDrawObject/bounds", "width")
+ = getXPath(pXmlDoc, "/root/page[1]/body/txt/anchored/SwAnchoredDrawObject/bounds", "width")
.toInt32();
// Make sure the shape is within the page bounds.
CPPUNIT_ASSERT_GREATEREQUAL(nShapeLeft + nShapeWidth, nPageLeft + nPageWidth);
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index b26a8a737d4a..18b8c4824e35 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -229,7 +229,8 @@ DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx")
DECLARE_OOXMLEXPORT_TEST(testTestTitlePage, "testTitlePage.docx")
{
- CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[last()]/footer/txt/text()"));
+ // this has 2 pages in Word
+ CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[2]/footer/txt/text()"));
}
DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice,"table-row-data-displayed-twice.docx")
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index fbc504cb5d97..4804610a8900 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -594,11 +594,8 @@ DECLARE_WW8EXPORT_TEST(testBnc787942, "bnc787942.doc")
{
// The frame ended up on the second page instead of first.
- // Ensure that the anchor is on the same page as the text "Zelva Mana"
- // (Note that this can actually be the second physical page, since the
- // page number is set to 0 which is even so LO will insert a blank page
- // before it to make it a left page)
- parseDump("/root/page[body/txt/text()='Zelva Mana']/body/txt[4]/anchored");
+ // this is on page 1 in Word
+ parseDump("/root/page[1]/body/txt[4]/anchored");
}
DECLARE_WW8EXPORT_TEST(testLayoutHanging, "fdo68967.doc")
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index d2a5b7704cb1..9e9c0c8f25a5 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -150,8 +150,14 @@ extern bool bSetCompletePaintOnInvalidate;
SwTwips CalcRowRstHeight( SwLayoutFrame *pRow );
long CalcHeightWithFlys( const SwFrame *pFrame );
+namespace sw {
+
+bool IsRightPageByNumber(SwRootFrame const& rLayout, sal_uInt16 nPageNum);
+
+} // namespace sw
+
SwPageFrame *InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper,
- bool bOdd, bool bFirst, bool bInsertEmpty, bool bFootnote,
+ bool isRightPage, bool bFirst, bool bInsertEmpty, bool bFootnote,
SwFrame *pSibling );
// connect Flys with page
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index fb87c6025061..c84bc17f9359 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -847,7 +847,7 @@ bool SwFrame::WrongPageDesc( SwPageFrame* pNew )
//My Pagedesc doesn't count if I'm a follow!
const SwPageDesc *pDesc = nullptr;
- int nTmp = 0;
+ boost::optional<sal_uInt16> oTmp;
SwFlowFrame *pFlow = SwFlowFrame::CastFlowFrame( this );
if ( !pFlow || !pFlow->IsFollow() )
{
@@ -856,18 +856,18 @@ bool SwFrame::WrongPageDesc( SwPageFrame* pNew )
if( pDesc )
{
if( !pDesc->GetRightFormat() )
- nTmp = 2;
+ oTmp = 2;
else if( !pDesc->GetLeftFormat() )
- nTmp = 1;
+ oTmp = 1;
else if( rFormatDesc.GetNumOffset() )
- nTmp = rFormatDesc.GetNumOffset().get();
+ oTmp = rFormatDesc.GetNumOffset();
}
}
// Does the Content bring a Pagedesc or do we need the
// virtual page number of the new layout leaf?
// PageDesc isn't allowed with Follows
- const bool bOdd = nTmp ? (nTmp % 2) !=0 : pNew->OnRightPage();
+ const bool isRightPage = oTmp ? sw::IsRightPageByNumber(*mpRoot, *oTmp) : pNew->OnRightPage();
if ( !pDesc )
pDesc = pNew->FindPageDesc();
@@ -885,14 +885,14 @@ bool SwFrame::WrongPageDesc( SwPageFrame* pNew )
SAL_INFO( "sw.pageframe", "WrongPageDesc p: " << pNew << " phys: " << pNew->GetPhyPageNum() );
SAL_INFO( "sw.pageframe", "WrongPageDesc " << pNew->GetPageDesc() << " " << pDesc );
- SAL_INFO( "sw.pageframe", "WrongPageDesc odd: " << bOdd
+ SAL_INFO( "sw.pageframe", "WrongPageDesc right: " << isRightPage
<< " first: " << bFirst << " " << pNew->GetFormat() << " == "
- << (bOdd ? pDesc->GetRightFormat(bFirst) : pDesc->GetLeftFormat(bFirst)) << " "
- << (bOdd ? pDesc->GetLeftFormat(bFirst) : pDesc->GetRightFormat(bFirst)) );
+ << (isRightPage ? pDesc->GetRightFormat(bFirst) : pDesc->GetLeftFormat(bFirst)) << " "
+ << (isRightPage ? pDesc->GetLeftFormat(bFirst) : pDesc->GetRightFormat(bFirst)) );
return (pNew->GetPageDesc() != pDesc) // own desc ?
|| (pNew->GetFormat() !=
- (bOdd ? pDesc->GetRightFormat(bFirst) : pDesc->GetLeftFormat(bFirst)))
+ (isRightPage ? pDesc->GetRightFormat(bFirst) : pDesc->GetLeftFormat(bFirst)))
|| (pNewDesc && pNewDesc == pDesc);
}
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 65fe4546b5be..d9b9c98cb66a 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2867,10 +2867,27 @@ void RestoreContent( SwFrame *pSav, SwLayoutFrame *pParent, SwFrame *pSibling )
pParent->Grow( nGrowVal );
}
+namespace sw {
+
+bool IsRightPageByNumber(SwRootFrame const& rLayout, sal_uInt16 const nPageNum)
+{
+ assert(rLayout.GetLower());
+ // unfortunately can only get SwPageDesc, not SwFormatPageDesc here...
+ auto const nFirstVirtPageNum(rLayout.GetLower()->GetVirtPageNum());
+ bool const isFirstPageOfLayoutOdd(nFirstVirtPageNum % 2 == 1);
+ return ((nPageNum % 2) == 1) == isFirstPageOfLayoutOdd;
+}
+
+} // namespace sw
+
SwPageFrame * InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper,
- bool bOdd, bool bFirst, bool bInsertEmpty, bool bFootnote,
+ bool const isRightPage, bool const bFirst, bool bInsertEmpty,
+ bool const bFootnote,
SwFrame *pSibling )
{
+ assert(pUpper);
+ assert(pUpper->IsRootFrame());
+ assert(!pSibling || static_cast<SwLayoutFrame const*>(pUpper)->Lower() != pSibling); // currently no insert before 1st page
SwPageFrame *pRet;
SwDoc *pDoc = static_cast<SwLayoutFrame*>(pUpper)->GetFormat()->GetDoc();
if (bFirst)
@@ -2879,7 +2896,7 @@ SwPageFrame * InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper,
{
// We need to fallback to left or right page format, decide it now.
// FIXME: is this still needed?
- if (bOdd)
+ if (isRightPage)
{
rDesc.GetFirstMaster().SetFormatAttr( rDesc.GetMaster().GetHeader() );
rDesc.GetFirstMaster().SetFormatAttr( rDesc.GetMaster().GetFooter() );
@@ -2894,11 +2911,11 @@ SwPageFrame * InsertNewPage( SwPageDesc &rDesc, SwFrame *pUpper,
}
}
}
- SwFrameFormat *pFormat(bOdd ? rDesc.GetRightFormat(bFirst) : rDesc.GetLeftFormat(bFirst));
+ SwFrameFormat *pFormat(isRightPage ? rDesc.GetRightFormat(bFirst) : rDesc.GetLeftFormat(bFirst));
// If there is no FrameFormat for this page, add an empty page
if ( !pFormat )
{
- pFormat = bOdd ? rDesc.GetLeftFormat() : rDesc.GetRightFormat();
+ pFormat = isRightPage ? rDesc.GetLeftFormat() : rDesc.GetRightFormat();
OSL_ENSURE( pFormat, "Descriptor without any format?!" );
bInsertEmpty = !bInsertEmpty;
}
diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx
index e3860c885f76..8303b451c1fa 100644
--- a/sw/source/core/layout/laycache.cxx
+++ b/sw/source/core/layout/laycache.cxx
@@ -669,17 +669,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.get() % 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?" );
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index e4ae9a45c53e..1d1f4597fcf2 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -489,15 +489,9 @@ void SwRootFrame::Init( SwFrameFormat* pFormat )
if ( !pDesc )
pDesc = &pDoc->GetPageDesc( 0 );
- const bool bOdd = !oPgNum || 0 != ( oPgNum.get() % 2 );
- const bool bFirst = true;
- // Even page numbers are supposed to be printed as left pages. So if a
- // page number has been explicitly set for this first page, then we must
- // insert a blank page before it to make it a left page.
- const bool bInsertEmpty = !bOdd;
-
// Create a page and put it in the layout
- SwPageFrame *pPage = ::InsertNewPage( *pDesc, this, bOdd, bFirst, bInsertEmpty, false, nullptr );
+ // The first page is always a right-page and always a first-page
+ SwPageFrame *pPage = ::InsertNewPage(*pDesc, this, true, true, false, false, nullptr);
// Find the first page in the Bodytext section.
SwLayoutFrame *pLay = pPage->FindBodyCont();
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 284f92a97556..04c8fb0f08e9 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -993,7 +993,7 @@ void SwPageFrame::PrepareRegisterChg()
}
//FIXME: provide missing documentation
-/** Check all pages (starting from the given one) if they use the right frame format.
+/** Check all pages (starting from the given one) if they use the appropriate frame format.
*
* If "wrong" pages are found, try to fix this as simple as possible.
*
@@ -1293,8 +1293,8 @@ SwPageFrame *SwFrame::InsertPage( SwPageFrame *pPrevPage, bool bFootnote )
SwPageDesc *pDesc = nullptr;
// insert right (odd) or left (even) page?
- bool bNextOdd = !pPrevPage->OnRightPage();
- bool bWishedOdd = bNextOdd;
+ bool bNextRightPage = !pPrevPage->OnRightPage();
+ bool bWishedRightPage = bNextRightPage;
// Which PageDesc is relevant?
// For ContentFrame take the one from format if provided,
@@ -1306,7 +1306,7 @@ SwPageFrame *SwFrame::InsertPage( SwPageFrame *pPrevPage, bool bFootnote )
if ( rDesc.GetNumOffset() )
{
::boost::optional<sal_uInt16> oNumOffset = rDesc.GetNumOffset();
- bWishedOdd = oNumOffset && (oNumOffset.get() % 2) != 0;
+ bWishedRightPage = sw::IsRightPageByNumber(*pRoot, *oNumOffset);
// use the opportunity to set the flag at root
pRoot->SetVirtPageNum( true );
}
@@ -1315,20 +1315,20 @@ SwPageFrame *SwFrame::InsertPage( SwPageFrame *pPrevPage, bool bFootnote )
pDesc = pPrevPage->GetPageDesc()->GetFollow();
assert(pDesc && "Missing PageDesc");
- if( !(bWishedOdd ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()) )
- bWishedOdd = !bWishedOdd;
+ if( !(bWishedRightPage ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()) )
+ bWishedRightPage = !bWishedRightPage;
bool const bWishedFirst = pDesc != pPrevPage->GetPageDesc();
SwDoc *pDoc = pPrevPage->GetFormat()->GetDoc();
bool bCheckPages = false;
// If there is no FrameFormat for this page, create an empty page.
- if( bWishedOdd != bNextOdd )
+ if (bWishedRightPage != bNextRightPage)
{
if( doInsertPage( pRoot, &pSibling, pDoc->GetEmptyPageFormat(),
pPrevPage->GetPageDesc(), bFootnote, nullptr ) )
bCheckPages = true;
}
- SwFrameFormat *const pFormat( bWishedOdd
+ SwFrameFormat *const pFormat( bWishedRightPage
? pDesc->GetRightFormat(bWishedFirst)
: pDesc->GetLeftFormat(bWishedFirst) );
assert(pFormat);
@@ -1562,17 +1562,17 @@ void SwRootFrame::AssertFlyPages()
// and let the ::Notify mechanism newly evaluate
// m_bEmptyPage (see SwPageFrame::UpdateAttr_). Code is taken and
// adapted from ::InsertPage (used below), this needs previous page
- bool bWishedOdd(!pPrevPage->OnRightPage());
+ bool bWishedRightPage(!pPrevPage->OnRightPage());
SwPageDesc* pDesc(pPrevPage->GetPageDesc()->GetFollow());
assert(pDesc && "Missing PageDesc");
- if(!(bWishedOdd ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()))
+ if (!(bWishedRightPage ? pDesc->GetRightFormat() : pDesc->GetLeftFormat()))
{
- bWishedOdd = !bWishedOdd;
+ bWishedRightPage = !bWishedRightPage;
}
bool const bWishedFirst(pDesc != pPrevPage->GetPageDesc());
- SwFrameFormat* pFormat(bWishedOdd ? pDesc->GetRightFormat(bWishedFirst) : pDesc->GetLeftFormat(bWishedFirst));
+ SwFrameFormat* pFormat(bWishedRightPage ? pDesc->GetRightFormat(bWishedFirst) : pDesc->GetLeftFormat(bWishedFirst));
// set SwFrameFormat, this will trigger SwPageFrame::UpdateAttr_ and re-evaluate
// m_bEmptyPage, too
@@ -1616,9 +1616,9 @@ void SwRootFrame::AssertFlyPages()
if ( pPage )
{
SwPageDesc *pTmpDesc = pPage->FindPageDesc();
- bool bOdd = pPage->OnRightPage();
+ bool isRightPage = pPage->OnRightPage();
if ( pPage->GetFormat() !=
- (bOdd ? pTmpDesc->GetRightFormat() : pTmpDesc->GetLeftFormat()) )
+ (isRightPage ? pTmpDesc->GetRightFormat() : pTmpDesc->GetLeftFormat()) )
RemoveFootnotes( pPage, false, true );
}
}
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index ceb5f26a4564..3038bdc7a612 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1692,16 +1692,18 @@ sal_uInt16 SwFrame::GetPhyPageNum() const
return pPage ? pPage->GetPhyPageNum() : 0;
}
-/** Decides if the page want to be a rightpage or not.
+/** Decides if the page want to be a right page or not.
*
* If the first content of the page has a page descriptor, we take the follow
* of the page descriptor of the last not empty page. If this descriptor allows
- * only right(left) pages and the page isn't an empty page then it want to be
+ * only right(left) pages and the page isn't an empty page then it wants to be
* such right(left) page. If the descriptor allows right and left pages, we
* look for a number offset in the first content. If there is one, odd number
- * results right pages, even number results left pages.
+ * results right pages (or left pages if document starts with even number),
+ * even number results left pages (or right pages if document starts with even
+ * number).
* If there is no number offset, we take the physical page number instead,
- * but a previous empty page don't count.
+ * but a previous empty page doesn't count.
*/
bool SwFrame::WannaRightPage() const
{
@@ -1738,23 +1740,23 @@ bool SwFrame::WannaRightPage() const
}
}
OSL_ENSURE( pDesc, "No pagedescriptor" );
- bool bOdd;
+ bool isRightPage;
if( oPgNum )
- bOdd = (oPgNum.get() % 2) != 0;
+ isRightPage = sw::IsRightPageByNumber(*mpRoot, *oPgNum);
else
{
- bOdd = pPage->OnRightPage();
+ isRightPage = pPage->OnRightPage();
if( pPage->GetPrev() && static_cast<const SwPageFrame*>(pPage->GetPrev())->IsEmptyPage() )
- bOdd = !bOdd;
+ isRightPage = !isRightPage;
}
if( !pPage->IsEmptyPage() )
{
if( !pDesc->GetRightFormat() )
- bOdd = false;
+ isRightPage = false;
else if( !pDesc->GetLeftFormat() )
- bOdd = true;
+ isRightPage = true;
}
- return bOdd;
+ return isRightPage;
}
bool SwFrame::OnFirstPage() const
@@ -1767,17 +1769,9 @@ bool SwFrame::OnFirstPage() const
const SwPageFrame* pPrevFrame = dynamic_cast<const SwPageFrame*>(pPage->GetPrev());
if (pPrevFrame)
{
- if (pPrevFrame->IsEmptyPage() && pPrevFrame->GetPhyPageNum()==1)
- {
- // This was the first page of the document, but its page number
- // was set to an even number, so a blank page was automatically
- // inserted before it to make this be a "left" page.
- // We still use the first page format of the page style here.
- bRet = true;
- } else {
- const SwPageDesc* pDesc = pPage->GetPageDesc();
- bRet = pPrevFrame->GetPageDesc() != pDesc;
- }
+ // first page of layout may be empty page, but only if it starts with "Left Page" style
+ const SwPageDesc* pDesc = pPage->GetPageDesc();
+ bRet = pPrevFrame->GetPageDesc() != pDesc;
}
else
bRet = true;