[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sw/inc sw/source

Michael Stahl mstahl at redhat.com
Mon Mar 18 02:01:21 PDT 2013


 sw/inc/pagedesc.hxx                    |   39 ++++++++-------------------------
 sw/source/core/layout/flowfrm.cxx      |    7 +++--
 sw/source/core/layout/frmtool.cxx      |    9 -------
 sw/source/core/layout/pagechg.cxx      |   28 ++++++++---------------
 sw/source/core/layout/pagedesc.cxx     |   14 +++++++++++
 sw/source/ui/docvw/HeaderFooterWin.cxx |    9 +++----
 6 files changed, 43 insertions(+), 63 deletions(-)

New commits:
commit 75d6eec4be88194126d31fc0f235cd3a303936bd
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 15 22:25:17 2013 +0100

    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)
    Reviewed-on: https://gerrit.libreoffice.org/2764
    Tested-by: Miklos Vajna <vmiklos at suse.cz>
    Reviewed-by: Miklos Vajna <vmiklos at suse.cz>

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 @@ 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 8e6c686..1b98de2 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 bdc6138..73d891b 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2732,7 +2732,6 @@ SwPageFrm * InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
 {
     SwPageFrm *pRet;
     SwDoc *pDoc = ((SwLayoutFrm*)pUpper)->GetFmt()->GetDoc();
-    SwFrmFmt *pFmt = 0;
     if (bFirst)
     {
         if (rDesc.IsFirstShared())
@@ -2752,14 +2751,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 54b2f22..519b5cf 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1097,11 +1097,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
@@ -1194,8 +1191,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 )
@@ -1313,19 +1308,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
@@ -1343,11 +1336,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 37a8d9b..7e8586b 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 25e2913..03f3b95 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 )
     {


More information about the Libreoffice-commits mailing list