summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/ndtxt.hxx2
-rw-r--r--sw/qa/extras/uiwriter/data3/tdf100018-1.odtbin0 -> 18795 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx15
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx6
-rw-r--r--sw/source/core/docnode/ndcopy.cxx18
5 files changed, 36 insertions, 5 deletions
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 5733a5f2c3d6..7692dc5b6470 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -413,7 +413,7 @@ public:
/** Copy collection with all auto formats to dest-node.
The latter might be in another document!
(Method in ndcopy.cxx!!). */
- void CopyCollFormat( SwTextNode& rDestNd );
+ void CopyCollFormat(SwTextNode& rDestNd, bool bUndoForChgFormatColl = true);
// BEGIN OF BULLET/NUMBERING/OUTLINE STUFF:
diff --git a/sw/qa/extras/uiwriter/data3/tdf100018-1.odt b/sw/qa/extras/uiwriter/data3/tdf100018-1.odt
new file mode 100644
index 000000000000..5cd36efcee77
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data3/tdf100018-1.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 3f89bba3d171..7da4e05b03f9 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -2118,4 +2118,19 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf137964)
CPPUNIT_ASSERT_EQUAL(sal_Int32(3090), xShape->getPosition().Y);
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf138897)
+{
+ load(DATA_DIRECTORY, "tdf100018-1.odt");
+
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:Cut", {});
+ dispatchCommand(mxComponent, ".uno:Paste", {});
+ // this was crashing
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ Scheduler::ProcessEventsToIdle();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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 );