summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-12-17 19:48:22 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-12-18 09:39:28 +0100
commit6c1e6b188eeb5868cafe3f1605f4213d627a452c (patch)
tree82c0692b4cc5a4939c82024a19f80e6f988ad322 /sw/source
parent8e6ec5ebcc523a189238a90fd9237872d67085f9 (diff)
tdf#138897 sw: avoid creating SwUndoResetAttr in CopyImplImpl()
The problem is that SwTextNode::CopyCollFormat() both creates the SwTextFormatColl with undo and applies it with undo. The first is desirable, the second causes a problem because it necessarily happens after SplitNode() and currently happens before copying the non-start/end nodes, so the node-index may not match in Undo, regardless if it runs before or after SwUndoCpyDoc. But SwUndoInserts restores the SwTextFormatColl on the node itself, so it can just be suppressed, which looks easier than refactoring this to call SplitNode() with Undo enabled. (regression from b4365b985178e1866c74afd757a104aad1d405a9) Change-Id: I4d15fb88cd5ae4cc53d9afb3397dec8fcf7635fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107921 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx6
-rw-r--r--sw/source/core/docnode/ndcopy.cxx18
2 files changed, 20 insertions, 4 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index ea18f8717509..19701083ba38 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4888,7 +4888,8 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
{
if (bCopyCollFormat)
{
- pSttTextNd->CopyCollFormat( *pDestTextNd );
+ // tdf#138897 no Undo for applying style, SwUndoInserts does it
+ pSttTextNd->CopyCollFormat(*pDestTextNd, false);
POP_NUMRULE_STATE
}
@@ -4987,7 +4988,8 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
// Also copy all format templates
if( bCopyCollFormat && ( bOneNode || bEmptyDestNd ))
{
- pEndTextNd->CopyCollFormat( *pDestTextNd );
+ // tdf#138897 no Undo for applying style, SwUndoInserts does it
+ pEndTextNd->CopyCollFormat(*pDestTextNd, false);
if ( bOneNode )
{
POP_NUMRULE_STATE
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index 6ccc17003f53..5b3c9edbd9db 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -18,6 +18,7 @@
*/
#include <doc.hxx>
#include <IDocumentFieldsAccess.hxx>
+#include <IDocumentUndoRedo.hxx>
#include <node.hxx>
#include <frmfmt.hxx>
#include <swtable.hxx>
@@ -330,7 +331,7 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc& rDoc, const SwNodeIndex& rIdx ) const
return pTableNd;
}
-void SwTextNode::CopyCollFormat( SwTextNode& rDestNd )
+void SwTextNode::CopyCollFormat(SwTextNode& rDestNd, bool const bUndoForChgFormatColl)
{
// Copy the formats into the other document:
// Special case for PageBreak/PageDesc/ColBrk
@@ -350,10 +351,23 @@ void SwTextNode::CopyCollFormat( SwTextNode& rDestNd )
aPgBrkSet.Put( *pAttr );
}
- rDestNd.ChgFormatColl( rDestDoc.CopyTextColl( *GetTextColl() ));
+ // this may create undo action SwUndoFormatCreate
+ auto const pCopy( rDestDoc.CopyTextColl( *GetTextColl() ) );
+ if (bUndoForChgFormatColl)
+ {
+ rDestNd.ChgFormatColl(pCopy);
+ }
+ else // tdf#138897
+ {
+ ::sw::UndoGuard const ug(rDestDoc.GetIDocumentUndoRedo());
+ rDestNd.ChgFormatColl(pCopy);
+ }
pSet = GetpSwAttrSet();
if( nullptr != pSet )
+ {
+ // note: this may create undo actions but not for setting the items
pSet->CopyToModify( rDestNd );
+ }
if( aPgBrkSet.Count() )
rDestNd.SetAttr( aPgBrkSet );