[Libreoffice-commits] .: 2 commits - sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Mon Jul 9 05:48:29 PDT 2012


 sw/source/core/inc/frame.hxx      |    1 +
 sw/source/core/layout/flowfrm.cxx |    5 ++++-
 sw/source/core/layout/pagechg.cxx |   16 +++++++++++++---
 sw/source/core/layout/trvlfrm.cxx |   17 +++++++++++++++++
 4 files changed, 35 insertions(+), 4 deletions(-)

New commits:
commit 0c8190999b5d85d28ded9f1be9613f11427034d2
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 9 14:46:40 2012 +0200

    add SwFrm::OnFirstPage to avoid copy&paste
    
    Change-Id: Ib750b832f232495ec5f4139ca907931107f34294

diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index df4b0fe..716738b 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -671,6 +671,7 @@ public:
     sal_uInt16 GetVirtPageNum() const;  // page number with offset
     sal_Bool OnRightPage() const { return 0 != GetPhyPageNum() % 2; };
     sal_Bool WannaRightPage() const;
+    bool OnFirstPage() const;
 
     inline const  SwLayoutFrm *GetPrevLayoutLeaf() const;
     inline const  SwLayoutFrm *GetNextLayoutLeaf() const;
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 7ca7107..7281703 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -925,8 +925,7 @@ sal_Bool SwFrm::WrongPageDesc( SwPageFrm* pNew )
     if ( !pDesc )
         pDesc = pNew->FindPageDesc();
 
-    SwPageFrm* pPrevFrm = dynamic_cast<SwPageFrm*>(pNew->GetPrev());
-    bool bFirst = pPrevFrm && pPrevFrm->GetPageDesc() != pDesc && !pDesc->IsFirstShared();
+    bool bFirst = pNew->OnFirstPage();
 
     const SwFlowFrm *pNewFlow = pNew->FindFirstBodyCntnt();
     // Did we find ourselves?
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 7eaa58c..42f361e 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1105,8 +1105,7 @@ void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields )
         sal_Bool bCheckEmpty = pPage->IsEmptyPage();
         sal_Bool bActOdd = pPage->OnRightPage();
         sal_Bool bOdd = pPage->WannaRightPage();
-        SwPageFrm* pPrevFrm = dynamic_cast<SwPageFrm*>(pPage->GetPrev());
-        bool bFirst = pPrevFrm && pPrevFrm->GetPageDesc() != pPage->GetPageDesc() && !pDesc->IsFirstShared();
+        bool bFirst = pPage->OnFirstPage();
         SwFrmFmt *pFmtWish = 0;
         if (bFirst)
             pFmtWish = pDesc->GetFirstFmt();
diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 3c0b1e3..577705c 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1811,6 +1811,23 @@ sal_Bool SwFrm::WannaRightPage() const
     return bOdd;
 }
 
+bool SwFrm::OnFirstPage() const
+{
+    bool bRet = false;
+    const SwPageFrm *pPage = FindPageFrm();
+
+    if (pPage)
+    {
+        const SwPageFrm* pPrevFrm = dynamic_cast<const SwPageFrm*>(pPage->GetPrev());
+        if (pPrevFrm)
+        {
+            const SwPageDesc* pDesc = pPage->GetPageDesc();
+            bRet = pPrevFrm->GetPageDesc() != pDesc && !pDesc->IsFirstShared();
+        }
+    }
+    return bRet;
+}
+
 /*************************************************************************
 |*
 |*    SwFrm::GetVirtPageNum()
commit d1aaa23c53e705de8256206e5833c6629ce92108
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Jul 9 13:12:10 2012 +0200

    sw layout: fix first page header/footer insertion
    
    Change-Id: I1d0051d0b9db486326f1ac7908d29af63f1f1726

diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 51fa1be..7ca7107 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -924,6 +924,10 @@ sal_Bool SwFrm::WrongPageDesc( SwPageFrm* pNew )
                            : pNew->OnRightPage();
     if ( !pDesc )
         pDesc = pNew->FindPageDesc();
+
+    SwPageFrm* pPrevFrm = dynamic_cast<SwPageFrm*>(pNew->GetPrev());
+    bool bFirst = pPrevFrm && pPrevFrm->GetPageDesc() != pDesc && !pDesc->IsFirstShared();
+
     const SwFlowFrm *pNewFlow = pNew->FindFirstBodyCntnt();
     // Did we find ourselves?
     if( pNewFlow == pFlow )
@@ -934,7 +938,7 @@ sal_Bool SwFrm::WrongPageDesc( SwPageFrm* pNew )
             ? pNewFlow->GetFrm()->GetAttrSet()->GetPageDesc().GetPageDesc():0;
 
     return ( pNew->GetPageDesc() != pDesc ||   //  own desc ?
-        pNew->GetFmt() != (bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt()) ||
+        pNew->GetFmt() != (bFirst ? pDesc->GetFirstFmt() : (bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt())) ||
         ( pNewDesc && pNewDesc == pDesc ) );
 }
 
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 9a42d00..7eaa58c 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1105,8 +1105,13 @@ void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields )
         sal_Bool bCheckEmpty = pPage->IsEmptyPage();
         sal_Bool bActOdd = pPage->OnRightPage();
         sal_Bool bOdd = pPage->WannaRightPage();
-        SwFrmFmt *pFmtWish = bOdd ? pDesc->GetRightFmt()
-                                  : pDesc->GetLeftFmt();
+        SwPageFrm* pPrevFrm = dynamic_cast<SwPageFrm*>(pPage->GetPrev());
+        bool bFirst = pPrevFrm && pPrevFrm->GetPageDesc() != pPage->GetPageDesc() && !pDesc->IsFirstShared();
+        SwFrmFmt *pFmtWish = 0;
+        if (bFirst)
+            pFmtWish = pDesc->GetFirstFmt();
+        else
+            pFmtWish = bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
 
         if ( bActOdd != bOdd ||
              pDesc != pPage->GetPageDesc() ||       //falscher Desc
@@ -1315,6 +1320,9 @@ 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;
 
     SwDoc *pDoc = pPrevPage->GetFmt()->GetDoc();
     SwFrmFmt *pFmt;
@@ -1342,7 +1350,10 @@ SwPageFrm *SwFrm::InsertPage( SwPageFrm *pPrevPage, sal_Bool bFtn )
         else
             bCheckPages = sal_True;
     }
-    pFmt = bWishedOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
+    if (bWishedFirst && !pDesc->IsFirstShared())
+        pFmt = pDesc->GetFirstFmt();
+    else
+        pFmt = bWishedOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
     OSL_ENSURE( pFmt, "Descriptor without format." );
     SwPageFrm *pPage = new SwPageFrm( pFmt, pRoot, pDesc );
     pPage->Paste( pRoot, pSibling );


More information about the Libreoffice-commits mailing list