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