kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0079-fdo-71429-sw-fix-crashes-when-changing-header-first-.patch

f0633d
From e94ab5aad124b888d524033abeaf212696779067 Mon Sep 17 00:00:00 2001
f0633d
From: Michael Stahl <mstahl@redhat.com>
f0633d
Date: Fri, 20 Dec 2013 21:24:37 +0100
f0633d
Subject: [PATCH 079/109] fdo#71429: sw: fix crashes when changing header first
f0633d
 sharing
f0633d
f0633d
Copy some nutso code in SwUndoPageDesc::ExchangeContentNodes() to
f0633d
work on the un-shared First header/footer too, which apparently avoids
f0633d
the crash.  It's not like Undo of header/footer isn't already a
f0633d
house of cards anyway.
f0633d
f0633d
Change-Id: Ie6593c4784ce9d368a5098ffb3aa4dec536d250e
f0633d
(cherry picked from commit 899538a155b0d58f3a864dbc26d0dc7c37386807)
f0633d
Reviewed-on: https://gerrit.libreoffice.org/7159
f0633d
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
f0633d
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
f0633d
---
f0633d
 sw/source/core/undo/SwUndoPageDesc.cxx | 42 ++++++++++++++++++++++++++++++++++
f0633d
 1 file changed, 42 insertions(+)
f0633d
f0633d
diff --git a/sw/source/core/undo/SwUndoPageDesc.cxx b/sw/source/core/undo/SwUndoPageDesc.cxx
f0633d
index b60c18b..5246c6f 100644
f0633d
--- a/sw/source/core/undo/SwUndoPageDesc.cxx
f0633d
+++ b/sw/source/core/undo/SwUndoPageDesc.cxx
f0633d
@@ -248,6 +248,27 @@ void SwUndoPageDesc::ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDes
f0633d
             pNewFmt->SetFmtAttr( SwFmtCntnt() );
f0633d
             delete pNewItem;
f0633d
         }
f0633d
+        if (!rDest.IsFirstShared())
f0633d
+        {
f0633d
+            // Same procedure for unshared header..
f0633d
+            const SwFmtHeader& rSourceFirstMasterHead = rSource.GetFirstMaster().GetHeader();
f0633d
+            rDest.GetFirstMaster().GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem );
f0633d
+            pNewItem = pItem->Clone();
f0633d
+            pNewFmt = ((SwFmtHeader*)pNewItem)->GetHeaderFmt();
f0633d
+#if OSL_DEBUG_LEVEL > 1
f0633d
+            const SwFmtCntnt& rSourceCntnt1 = rSourceFirstMasterHead.GetHeaderFmt()->GetCntnt();
f0633d
+            (void)rSourceCntnt1;
f0633d
+            const SwFmtCntnt& rDestCntnt1 = rDest.GetFirstMaster().GetHeader().GetHeaderFmt()->GetCntnt();
f0633d
+            (void)rDestCntnt1;
f0633d
+#endif
f0633d
+            pNewFmt->SetFmtAttr( rSourceFirstMasterHead.GetHeaderFmt()->GetCntnt() );
f0633d
+            delete pNewItem;
f0633d
+            rSource.GetFirstMaster().GetAttrSet().GetItemState( RES_HEADER, sal_False, &pItem );
f0633d
+            pNewItem = pItem->Clone();
f0633d
+            pNewFmt = ((SwFmtHeader*)pNewItem)->GetHeaderFmt();
f0633d
+            pNewFmt->SetFmtAttr( SwFmtCntnt() );
f0633d
+            delete pNewItem;
f0633d
+        }
f0633d
     }
f0633d
     // Same procedure for footers...
f0633d
     const SwFmtFooter& rDestFoot = rDest.GetMaster().GetFooter();
f0633d
@@ -294,6 +315,27 @@ void SwUndoPageDesc::ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDes
f0633d
             pNewFmt->SetFmtAttr( SwFmtCntnt() );
f0633d
             delete pNewItem;
f0633d
         }
f0633d
+        if (!rDest.IsFirstShared())
f0633d
+        {
f0633d
+            const SwFmtFooter& rSourceFirstMasterFoot = rSource.GetFirstMaster().GetFooter();
f0633d
+#if OSL_DEBUG_LEVEL > 1
f0633d
+            const SwFmtCntnt& rFooterSourceCntnt2 = rSourceFirstMasterFoot.GetFooterFmt()->GetCntnt();
f0633d
+            const SwFmtCntnt& rFooterDestCntnt2 =
f0633d
+                rDest.GetFirstMaster().GetFooter().GetFooterFmt()->GetCntnt();
f0633d
+            (void)rFooterSourceCntnt2;
f0633d
+            (void)rFooterDestCntnt2;
f0633d
+#endif
f0633d
+            rDest.GetFirstMaster().GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem );
f0633d
+            pNewItem = pItem->Clone();
f0633d
+            pNewFmt = ((SwFmtFooter*)pNewItem)->GetFooterFmt();
f0633d
+            pNewFmt->SetFmtAttr( rSourceFirstMasterFoot.GetFooterFmt()->GetCntnt() );
f0633d
+            delete pNewItem;
f0633d
+            rSource.GetFirstMaster().GetAttrSet().GetItemState( RES_FOOTER, sal_False, &pItem );
f0633d
+            pNewItem = pItem->Clone();
f0633d
+            pNewFmt = ((SwFmtFooter*)pNewItem)->GetFooterFmt();
f0633d
+            pNewFmt->SetFmtAttr( SwFmtCntnt() );
f0633d
+            delete pNewItem;
f0633d
+        }
f0633d
     }
f0633d
 }
f0633d
 
f0633d
-- 
f0633d
1.8.4.2
f0633d