summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-03-15 22:25:17 +0100
committerMichael Stahl <mstahl@redhat.com>2013-03-15 22:54:06 +0100
commit4dc78aee9bcdb6ea5e9dc47ebb4a4b9e590c725a (patch)
tree405736850c0c8e7e85db61f02fddf80e28ca5975
parent859e94294bdfd8595c88dd7f14da09ead8b32a45 (diff)
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
-rw-r--r--sw/inc/pagedesc.hxx39
-rw-r--r--sw/source/core/layout/flowfrm.cxx7
-rw-r--r--sw/source/core/layout/frmtool.cxx9
-rw-r--r--sw/source/core/layout/pagechg.cxx28
-rw-r--r--sw/source/core/layout/pagedesc.cxx14
-rw-r--r--sw/source/ui/docvw/HeaderFooterWin.cxx9
6 files changed, 43 insertions, 63 deletions
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index dbf314481ca2..45ca5dfa2167 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -118,9 +118,8 @@ namespace nsUseOnPage
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 @@ public:
/** 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 @@ inline void SwPageDesc::ResetAllLeftAttr()
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 a71f8163ca69..d115bb488412 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -927,9 +927,10 @@ sal_Bool SwFrm::WrongPageDesc( SwPageFrm* pNew )
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 56ad6a5823ec..e6a443382ba6 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2720,7 +2720,6 @@ SwPageFrm * InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
{
SwPageFrm *pRet;
SwDoc *pDoc = ((SwLayoutFrm*)pUpper)->GetFmt()->GetDoc();
- SwFrmFmt *pFmt = 0;
if (bFirst)
{
if (rDesc.IsFirstShared())
@@ -2740,14 +2739,8 @@ SwPageFrm * InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
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 fb81f2da1338..8b95ee6738c3 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1094,11 +1094,8 @@ void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields )
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
@@ -1191,8 +1188,6 @@ void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields )
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 )
@@ -1310,19 +1305,17 @@ SwPageFrm *SwFrm::InsertPage( SwPageFrm *pPrevPage, sal_Bool bFtn )
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
@@ -1340,11 +1333,10 @@ SwPageFrm *SwFrm::InsertPage( SwPageFrm *pPrevPage, sal_Bool bFtn )
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 5aef6a3c60aa..33aecbff3536 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -345,6 +345,20 @@ sal_Bool SwPageDesc::IsFollowNextPageOfNode( const SwNode& rNd ) const
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 7b0f5bf195cb..79d16eed9874 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -394,11 +394,10 @@ bool SwHeaderFooterWin::IsEmptyHeaderFooter( )
// 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 )
{