[Libreoffice-commits] core.git: 3 commits - sw/inc sw/qa sw/source

Michael Stahl mstahl at redhat.com
Fri Mar 15 14:56:41 PDT 2013


 sw/inc/pagedesc.hxx                    |   39 ++++++++-------------------------
 sw/qa/extras/odfimport/odfimport.cxx   |   11 +++++++++
 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 +++----
 sw/source/ui/docvw/PostItMgr.cxx       |   10 +++++---
 8 files changed, 60 insertions(+), 67 deletions(-)

New commits:
commit 2832da0f5982f6b5d6d96346a5db9460d59b7e2e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 15 22:47:53 2013 +0100

    fdo#61952: add unit test
    
    Change-Id: Idef40ea4ad615fa5d09d2a5ed6eb3fe861f1b5ea

diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 37da317..3bef663 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -42,6 +42,7 @@ public:
     void testOdtBorders();
     void testPageStyleLayoutDefault();
     void testPageStyleLayoutRight();
+    void testFdo61952();
     void testFdo60842();
     void testFdo56272();
 
@@ -63,6 +64,7 @@ void Test::run()
         {"borders_ooo33.odt", &Test::testOdtBorders},
         {"hello.odt", &Test::testPageStyleLayoutDefault},
         {"hello.odt", &Test::testPageStyleLayoutRight},
+        {"hello.odt", &Test::testFdo61952},
         {"fdo60842.odt", &Test::testFdo60842},
         {"fdo56272.odt", &Test::testFdo56272},
     };
@@ -295,6 +297,15 @@ void Test::testPageStyleLayoutRight()
     xPropertySet->setPropertyValue("PageStyleLayout", uno::makeAny(style::PageStyleLayout_RIGHT));
 }
 
+void Test::testFdo61952()
+{
+    uno::Reference<beans::XPropertySet> xPara(getParagraph(0), uno::UNO_QUERY);
+    xPara->setPropertyValue("PageDescName", uno::makeAny(OUString("Left Page")));
+    xPara->setPropertyValue("PageDescName", uno::makeAny(OUString("Right Page")));
+    xPara->setPropertyValue("PageDescName", uno::makeAny(OUString("Left Page")));
+    xPara->setPropertyValue("PageDescName", uno::makeAny(OUString("Right Page")));
+}
+
 void Test::testFdo60842()
 {
     uno::Reference<text::XTextContent> const xTable(getParagraphOrTable(0));
commit 4dc78aee9bcdb6ea5e9dc47ebb4a4b9e590c725a
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

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 a71f816..d115bb4 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 56ad6a5..e6a4433 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 fb81f2d..8b95ee6 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 5aef6a3..33aecbf 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 7b0f5bf..79d16ee 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 )
     {
commit 859e94294bdfd8595c88dd7f14da09ead8b32a45
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Mar 15 12:49:21 2013 +0100

    fdo#34800 sw: small cleanup
    
    Change-Id: I4ed8ed485a36e02755614bd59f91539fa1fb9579

diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx
index 1a7c063..a4218d3 100644
--- a/sw/source/ui/docvw/PostItMgr.cxx
+++ b/sw/source/ui/docvw/PostItMgr.cxx
@@ -106,13 +106,15 @@ bool comp_pos(const SwSidebarItem* a, const SwSidebarItem* b)
     // if AnchorA is in footnote, and AnchorB isn't
     // we do not want to change over the position
     if( aAnchorAInFooter && !aAnchorBInFooter )
-        return 0;
+        return false;
     // if aAnchorA is not placed in a footnote, and aAnchorB is
     // force a change over
     else if( !aAnchorAInFooter && aAnchorBInFooter )
-        return 1;
-    // if none of both, or both are in the footer
-    // arrange them depending on the position
+        return true;
+    // If neither or both are in the footer, compare the positions.
+    // Since footnotes are in Inserts section of nodes array and footers
+    // in Autotext section, all footnotes precede any footers so no need
+    // to check that.
     else
         return aPosAnchorA < aPosAnchorB;
 }


More information about the Libreoffice-commits mailing list