Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/2764
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/64/2764/1
fdo#61952: sw: fix left/right-only page styles and first-page
- remove PD_FIRST and GetFirstFmt:
This flag makes no sense at all, since there are no "first-only"
page styles (while there are left-only/right-only).
- instead add a parameter to GetLeftFmt/GetRightFmt to request a
first page format, if such exists and is not shared
(regression from 02a934d03b101ce463a232f9cbb7b43e684de37e
and fa0f42bafbf24e9141ddee728b160b5ab47077f2)
Change-Id: I4d50c2c0cc4f3cf231eacba891df22d0bcf6c4df
(cherry picked from commit 4dc78aee9bcdb6ea5e9dc47ebb4a4b9e590c725a)
---
M sw/inc/pagedesc.hxx
M sw/source/core/layout/flowfrm.cxx
M sw/source/core/layout/frmtool.cxx
M sw/source/core/layout/pagechg.cxx
M sw/source/core/layout/pagedesc.cxx
M sw/source/ui/docvw/HeaderFooterWin.cxx
6 files changed, 43 insertions(+), 63 deletions(-)
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index dbf3144..45ca5df 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -118,9 +118,8 @@
const UseOnPage PD_NONE = 0x0000; ///< For internal use only.
const UseOnPage PD_LEFT = 0x0001;
const UseOnPage PD_RIGHT = 0x0002;
- const UseOnPage PD_FIRST = 0x0004;
- const UseOnPage PD_ALL = 0x0007;
- const UseOnPage PD_MIRROR = 0x000F;
+ const UseOnPage PD_ALL = 0x0003;
+ const UseOnPage PD_MIRROR = 0x0007;
const UseOnPage PD_HEADERSHARE = 0x0040;
const UseOnPage PD_FOOTERSHARE = 0x0080;
const UseOnPage PD_NOHEADERSHARE = 0xFFBF; ///< For internal use only.
@@ -204,12 +203,10 @@
/** Layout uses the following methods to obtain a format in order
to be able to create a page. */
- inline SwFrmFmt *GetRightFmt();
- inline const SwFrmFmt *GetRightFmt() const;
- inline SwFrmFmt *GetLeftFmt();
- inline const SwFrmFmt *GetLeftFmt() const;
- inline SwFrmFmt *GetFirstFmt();
- inline const SwFrmFmt *GetFirstFmt() const;
+ SwFrmFmt *GetRightFmt(bool const bFirst = false);
+ inline const SwFrmFmt *GetRightFmt(bool const bFirst = false) const;
+ SwFrmFmt *GetLeftFmt(bool const bFirst = false);
+ inline const SwFrmFmt *GetLeftFmt(bool const bFirst = false) const;
sal_uInt16 GetRegHeight() const { return nRegHeight; }
sal_uInt16 GetRegAscent() const { return nRegAscent; }
@@ -306,29 +303,13 @@
ResetAllAttr( sal_True );
}
-inline SwFrmFmt *SwPageDesc::GetRightFmt()
+inline const SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst) const
{
- return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
+ return const_cast<SwPageDesc*>(this)->GetRightFmt(bFirst);
}
-inline const SwFrmFmt *SwPageDesc::GetRightFmt() const
+inline const SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst) const
{
- return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
-}
-inline SwFrmFmt *SwPageDesc::GetLeftFmt()
-{
- return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
-}
-inline const SwFrmFmt *SwPageDesc::GetLeftFmt() const
-{
- return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
-}
-inline SwFrmFmt *SwPageDesc::GetFirstFmt()
-{
- return nsUseOnPage::PD_FIRST & eUse ? &aFirst : 0;
-}
-inline const SwFrmFmt *SwPageDesc::GetFirstFmt() const
-{
- return nsUseOnPage::PD_FIRST & eUse ? &aFirst : 0;
+ return const_cast<SwPageDesc*>(this)->GetLeftFmt(bFirst);
}
class SwPageDescExt
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 8e6c686..1b98de2 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -927,9 +927,10 @@
const SwPageDesc *pNewDesc= ( pNewFlow && !pNewFlow->IsFollow() )
? pNewFlow->GetFrm()->GetAttrSet()->GetPageDesc().GetPageDesc() : 0;
- return ( pNew->GetPageDesc() != pDesc || // own desc ?
- pNew->GetFmt() != (bFirst ? pDesc->GetFirstFmt() : (bOdd ? pDesc->GetRightFmt() :
pDesc->GetLeftFmt())) ||
- ( pNewDesc && pNewDesc == pDesc ) );
+ return (pNew->GetPageDesc() != pDesc) // own desc ?
+ || (pNew->GetFmt() !=
+ (bOdd ? pDesc->GetRightFmt(bFirst) : pDesc->GetLeftFmt(bFirst)))
+ || (pNewDesc && pNewDesc == pDesc);
}
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index bdc6138..73d891b 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2732,7 +2732,6 @@
{
SwPageFrm *pRet;
SwDoc *pDoc = ((SwLayoutFrm*)pUpper)->GetFmt()->GetDoc();
- SwFrmFmt *pFmt = 0;
if (bFirst)
{
if (rDesc.IsFirstShared())
@@ -2752,14 +2751,8 @@
rDesc.GetFirst().SetFmtAttr( rDesc.GetLeft().GetLRSpace() );
}
}
- pFmt = rDesc.GetFirstFmt();
- if (!pFmt)
- {
- pFmt = bOdd ? rDesc.GetRightFmt() : rDesc.GetLeftFmt();
- }
}
- else
- pFmt = bOdd ? rDesc.GetRightFmt() : rDesc.GetLeftFmt();
+ SwFrmFmt *pFmt(bOdd ? rDesc.GetRightFmt(bFirst) : rDesc.GetLeftFmt(bFirst));
//Wenn ich kein FrmFmt fuer die Seite gefunden habe, muss ich eben
//eine Leerseite einfuegen.
if ( !pFmt )
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 54b2f22..519b5cf 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1097,11 +1097,8 @@
sal_Bool bActOdd = pPage->OnRightPage();
sal_Bool bOdd = pPage->WannaRightPage();
bool bFirst = pPage->OnFirstPage();
- SwFrmFmt *pFmtWish = 0;
- if (bFirst)
- pFmtWish = pDesc->GetFirstFmt();
- else
- pFmtWish = bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
+ SwFrmFmt *pFmtWish = (bOdd)
+ ? pDesc->GetRightFmt(bFirst) : pDesc->GetLeftFmt(bFirst);
if ( bActOdd != bOdd ||
pDesc != pPage->GetPageDesc() || //falscher Desc
@@ -1194,8 +1191,6 @@
else if ( !pFmtWish ) //6.
{
//Format mit verdrehter Logic besorgen.
- if (bFirst)
- pFmtWish = bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
if (!pFmtWish)
pFmtWish = bOdd ? pDesc->GetLeftFmt() : pDesc->GetRightFmt();
if ( pPage->GetFmt() != pFmtWish )
@@ -1313,19 +1308,17 @@
OSL_ENSURE( pDesc, "Missing PageDesc" );
if( !(bWishedOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt()) )
bWishedOdd = !bWishedOdd;
- bool bWishedFirst = pDesc != pPrevPage->GetPageDesc();
- if (bWishedFirst && !pDesc->GetFirstFmt())
- bWishedFirst = false;
+ bool const bWishedFirst = pDesc != pPrevPage->GetPageDesc();
SwDoc *pDoc = pPrevPage->GetFmt()->GetDoc();
- SwFrmFmt *pFmt;
bool bCheckPages = false;
//Wenn ich kein FrmFmt fuer die Seite gefunden habe, muss ich eben eine
//Leerseite einfuegen.
if( bWishedOdd != bNextOdd )
- { pFmt = pDoc->GetEmptyPageFmt();
+ {
+ SwFrmFmt *const pEmptyFmt = pDoc->GetEmptyPageFmt();
SwPageDesc *pTmpDesc = pPrevPage->GetPageDesc();
- SwPageFrm *pPage = new SwPageFrm( pFmt, pRoot, pTmpDesc );
+ SwPageFrm *pPage = new SwPageFrm(pEmptyFmt, pRoot, pTmpDesc);
pPage->Paste( pRoot, pSibling );
pPage->PreparePage( bFtn );
//Wenn der Sibling keinen Bodytext enthaelt kann ich ihn vernichten
@@ -1343,11 +1336,10 @@
else
bCheckPages = true;
}
- if (bWishedFirst && !pDesc->IsFirstShared())
- pFmt = pDesc->GetFirstFmt();
- else
- pFmt = bWishedOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
- OSL_ENSURE( pFmt, "Descriptor without format." );
+ SwFrmFmt *const pFmt( (bWishedOdd)
+ ? pDesc->GetRightFmt(bWishedFirst)
+ : pDesc->GetLeftFmt(bWishedFirst) );
+ assert(pFmt);
SwPageFrm *pPage = new SwPageFrm( pFmt, pRoot, pDesc );
pPage->Paste( pRoot, pSibling );
pPage->PreparePage( bFtn );
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index 37a8d9b..7e8586b 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -345,6 +345,20 @@
return bRet;
}
+SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst)
+{
+ return (nsUseOnPage::PD_LEFT & eUse)
+ ? (bFirst && !IsFirstShared()) ? &aFirst : &aLeft
+ : 0;
+}
+
+SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst)
+{
+ return (nsUseOnPage::PD_RIGHT & eUse)
+ ? (bFirst && !IsFirstShared()) ? &aFirst : &aMaster
+ : 0;
+}
+
sal_Bool SwPageDesc::IsFirstShared() const
{
return eUse & nsUseOnPage::PD_FIRSTSHARE ? sal_True : sal_False;
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index 25e2913..03f3b95 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -394,11 +394,10 @@
// Actually check it
const SwPageDesc* pDesc = GetPageFrame()->GetPageDesc();
- const SwFrmFmt* pFmt = pDesc->GetLeftFmt();
- if ( GetPageFrame()->OnRightPage() )
- pFmt = pDesc->GetRightFmt();
- if ( GetPageFrame()->OnFirstPage() )
- pFmt = pDesc->GetFirstFmt();
+ bool const bFirst(GetPageFrame()->OnFirstPage());
+ const SwFrmFmt *const pFmt = (GetPageFrame()->OnRightPage())
+ ? pDesc->GetRightFmt(bFirst)
+ : pDesc->GetLeftFmt(bFirst);
if ( pFmt )
{
--
To view, visit https://gerrit.libreoffice.org/2764
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4d50c2c0cc4f3cf231eacba891df22d0bcf6c4df
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Michael Stahl <mstahl@redhat.com>
Context
- [PATCH libreoffice-4-0] fdo#61952: sw: fix left/right-only page styles and first-pag... · Michael Stahl (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.