[Libreoffice-commits] core.git: 4 commits - sw/source

Michael Stahl mstahl at redhat.com
Tue Aug 20 03:11:03 PDT 2013


 sw/source/core/doc/docdesc.cxx     |   31 ++++++++++++++++++-------------
 sw/source/core/layout/pagedesc.cxx |    4 ++--
 2 files changed, 20 insertions(+), 15 deletions(-)

New commits:
commit e1a9a348a519a69f898c9c1e6d87a5837b8267f9
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 20 11:50:34 2013 +0200

    fdo#66145: fix copying of header/footer when un-sharing
    
    SwDoc::CopyMasterHeader/Footer(): this could result in sharing the
    first-page header/footer with the left-page (!) when un-sharing
    via the dialog; the reason is that what actually happens here is that
    the left-page header/footer was never changed but the master one
    was copied in SwDocStyleSheet::SetItemSet(), so it sort of worked
    by accident before the first-page header/footer was added...
    
    Change-Id: Ia24df6ad59cda484559f2ca48ecaa7563878120b

diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 6e04bb8..9571e0e 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -194,7 +194,11 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
                 const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetHeader() );
             }
-            else if( (*aRCnt.GetCntntIdx()) == (*aCnt.GetCntntIdx()) )
+            else if ((*aRCnt.GetCntntIdx() == *aCnt.GetCntntIdx()) ||
+                // The CntntIdx is _always_ different when called from
+                // SwDocStyleSheet::SetItemSet, because it deep-copies the
+                // PageDesc.  So check if it was previously shared.
+                 ((bLeft) ? pDesc->IsHeaderShared() : pDesc->IsFirstShared()))
             {
                 SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left header" : "First header"),
                                                 GetDfltFrmFmt() );
@@ -250,7 +254,11 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot,
                 const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetFooter() );
             }
-            else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) )
+            else if ((*aRCnt.GetCntntIdx() == *aLCnt.GetCntntIdx()) ||
+                // The CntntIdx is _always_ different when called from
+                // SwDocStyleSheet::SetItemSet, because it deep-copies the
+                // PageDesc.  So check if it was previously shared.
+                 ((bLeft) ? pDesc->IsHeaderShared() : pDesc->IsFirstShared()))
             {
                 SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left footer" : "First footer"),
                                                 GetDfltFrmFmt() );
@@ -344,8 +352,6 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
     CopyMasterHeader(rChged, rHead, pDesc, true); // Copy left header
     CopyMasterHeader(rChged, rHead, pDesc, false); // Copy first header
     pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
-    // there is just one first shared flag for both header and footer?
-    pDesc->ChgFirstShare( rChged.IsFirstShared() );
 
     // Synch Footer.
     const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter();
@@ -362,6 +368,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
     CopyMasterFooter(rChged, rFoot, pDesc, true); // Copy left footer
     CopyMasterFooter(rChged, rFoot, pDesc, false); // Copy first footer
     pDesc->ChgFooterShare( rChged.IsFooterShared() );
+    // there is just one first shared flag for both header and footer?
+    pDesc->ChgFirstShare( rChged.IsFirstShared() );
 
     if ( pDesc->GetName() != rChged.GetName() )
         pDesc->SetName( rChged.GetName() );
commit 0b7a823bb6df79384939dda4de3b7f28e5e52758
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 20 11:51:27 2013 +0200

    fdo#66145: fix Undo invalidation in SwDoc::ChgPageDesc()
    
    SwDoc::ChgPageDesc(): make the invalidation of the Undo stack on
    change of IsFirstShared work by delaying ChgFirstShare() until after
    the check.
    
    Change-Id: Ifbefe446df8b6d785ed1bb6394ec5beb803fb1fe

diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index f5df1d0..6e04bb8 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -324,7 +324,6 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
 
     // Take over orientation
     pDesc->SetLandscape( rChged.GetLandscape() );
-    pDesc->ChgFirstShare( rChged.IsFirstShared() );
 
     // #i46909# no undo if header or footer changed
     bool bHeaderFooterChanged = false;
@@ -345,6 +344,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
     CopyMasterHeader(rChged, rHead, pDesc, true); // Copy left header
     CopyMasterHeader(rChged, rHead, pDesc, false); // Copy first header
     pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
+    // there is just one first shared flag for both header and footer?
+    pDesc->ChgFirstShare( rChged.IsFirstShared() );
 
     // Synch Footer.
     const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter();
@@ -355,8 +356,7 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
         const SwFmtFooter &rOldFoot = pDesc->GetMaster().GetFooter();
         bHeaderFooterChanged |=
             ( rFoot.IsActive() != rOldFoot.IsActive() ||
-              rChged.IsFooterShared() != pDesc->IsFooterShared() ||
-              rChged.IsFirstShared() != pDesc->IsFirstShared() );
+              rChged.IsFooterShared() != pDesc->IsFooterShared() );
     }
     pDesc->GetMaster().SetFmtAttr( rFoot );
     CopyMasterFooter(rChged, rFoot, pDesc, true); // Copy left footer
commit 4df438c9a9d5e698c47c1e85903eb81880a5e6fa
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Aug 20 11:41:37 2013 +0200

    fdo#66145: do not check IsFirstShared() in SwPageDesc::GetLeftFmt()
    
    ... and GetRightFmt().  If the first format is requested it must be
    returned; the sharing works by copying the SwFmtHeader/Footer from
    aMaster to the other members.
    
    (regression from 4dc78aee9bcdb6ea5e9dc47ebb4a4b9e590c725a)
    
    Change-Id: I1708f01c18b155ae75c14fc407e52ccd2bd798d7

diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index fadd527..e53b135 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -349,14 +349,14 @@ sal_Bool SwPageDesc::IsFollowNextPageOfNode( const SwNode& rNd ) const
 SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst)
 {
     return (nsUseOnPage::PD_LEFT & eUse)
-            ? (bFirst && !IsFirstShared()) ? &aFirst : &aLeft
+            ? ((bFirst) ? &aFirst : &aLeft)
             : 0;
 }
 
 SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst)
 {
     return (nsUseOnPage::PD_RIGHT & eUse)
-            ? (bFirst && !IsFirstShared()) ? &aFirst : &aMaster
+            ? ((bFirst) ? &aFirst : &aMaster)
             : 0;
 }
 
commit bf206549228685a68e1504db05119d8fa1d354b3
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Aug 19 14:45:20 2013 +0200

    fdo#66145: revert change to CopyMasterHeader
    
    Not copying the nodes for first page is not an option; the real problem
    with the fdo45183.rtf is that flys in the header are not copied
    along with the nodes, like it is done in
    SwDoc::CopyPageDescHeaderFooterImpl.
    
    Also, the same problem may occur for footers too (CopyMasterFooter).
    
    Change-Id: I985a6b89f8cde96dc0fa0b489c44d77987f91a8a

diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index e1a0e25..f5df1d0 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -189,14 +189,7 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
             const SwFmtCntnt &aRCnt = pRight->GetCntnt();
             const SwFmtCntnt &aCnt = rFmtHead.GetHeaderFmt()->GetCntnt();
 
-            // In case "PROP_FIRST_IS_SHARED" (writefilter) is set and headerFmt has 'cntnt' node,
-            // Already anchored node is original fmt.
-            // But at this part, change startnode(below create new pSttNd).
-            // Because of this, fdo45183.rtf(sw/qa/extras/rtfimport/data/fdo45183.rtf) cannot draw picture.
-            // Compare module is sw/source/core/layout/frmtool.cxx : AppendObjs() function.
-            // In this function, because selected node index and anchored node index aren't equal, don't draw object.
-            // So, If (aCnt.GetCntntIdx() && !bLeft) - use the original headerFmt.
-            if( !aCnt.GetCntntIdx() || !bLeft )
+            if (!aCnt.GetCntntIdx())
             {
                 const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetHeader() );
@@ -215,6 +208,8 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
                             *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() );
                 aTmp = *pSttNd->EndOfSectionNode();
                 GetNodes()._Copy( aRange, aTmp, sal_False );
+                aTmp = *pSttNd;
+                CopyFlyInFlyImpl(aRange, 0, aTmp);
 
                 pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
                 rDescFrmFmt.SetFmtAttr( SwFmtHeader( pFmt ) );
@@ -269,6 +264,8 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot,
                             *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() );
                 aTmp = *pSttNd->EndOfSectionNode();
                 GetNodes()._Copy( aRange, aTmp, sal_False );
+                aTmp = *pSttNd;
+                CopyFlyInFlyImpl(aRange, 0, aTmp);
 
                 pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
                 rDescFrmFmt.SetFmtAttr( SwFmtFooter( pFmt ) );


More information about the Libreoffice-commits mailing list