summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/CppunitTest_sw_core_undo.mk74
-rw-r--r--sw/Module_sw.mk1
-rw-r--r--sw/qa/core/undo/data/textbox-cut-save.docxbin0 -> 7272 bytes
-rw-r--r--sw/qa/core/undo/undo.cxx55
-rw-r--r--sw/source/core/undo/undobj1.cxx13
5 files changed, 143 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_core_undo.mk b/sw/CppunitTest_sw_core_undo.mk
new file mode 100644
index 000000000000..11593cd9e604
--- /dev/null
+++ b/sw/CppunitTest_sw_core_undo.mk
@@ -0,0 +1,74 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_core_undo))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_undo))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_undo, \
+ sw/qa/core/undo/undo \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_core_undo, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ sfx \
+ svxcore \
+ sw \
+ swqahelper \
+ test \
+ unotest \
+ utl \
+ vcl \
+ svt \
+ tl \
+ svl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_core_undo,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_core_undo,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/source/uibase/inc \
+ -I$(SRCDIR)/sw/qa/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_core_undo,\
+ udkapi \
+ offapi \
+ oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_core_undo))
+$(eval $(call gb_CppunitTest_use_vcl,sw_core_undo))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_core_undo,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_undo,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_core_undo))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_undo, \
+ modules/swriter \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_undo))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 66d27573ec98..0df68e21a6f7 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -119,6 +119,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_core_objectpositioning \
CppunitTest_sw_core_unocore \
CppunitTest_sw_core_crsr \
+ CppunitTest_sw_core_undo \
))
ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/qa/core/undo/data/textbox-cut-save.docx b/sw/qa/core/undo/data/textbox-cut-save.docx
new file mode 100644
index 000000000000..a1a350d08aac
--- /dev/null
+++ b/sw/qa/core/undo/data/textbox-cut-save.docx
Binary files differ
diff --git a/sw/qa/core/undo/undo.cxx b/sw/qa/core/undo/undo.cxx
new file mode 100644
index 000000000000..aeacffc78e9b
--- /dev/null
+++ b/sw/qa/core/undo/undo.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <unotools/mediadescriptor.hxx>
+
+#include <unotxdoc.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <swdtflvr.hxx>
+
+char const DATA_DIRECTORY[] = "/sw/qa/core/undo/data/";
+
+/// Covers sw/source/core/undo/ fixes.
+class SwCoreUndoTest : public SwModelTestBase
+{
+};
+
+CPPUNIT_TEST_FIXTURE(SwCoreUndoTest, testTextboxCutSave)
+{
+ // Load the document and select all.
+ load(DATA_DIRECTORY, "textbox-cut-save.docx");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDocShell* pDocShell = pTextDoc->GetDocShell();
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ pWrtShell->SelAll();
+
+ // Cut.
+ rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+ pTransfer->Cut();
+
+ // Undo.
+ pWrtShell->Undo();
+
+ // Save.
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("Office Open XML Text");
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // void sax_fastparser::FastSaxSerializer::endDocument(): Assertion `mbMarkStackEmpty && maMarkStack.empty()' failed.
+ // i.e. failed to save because we tried to write not-well-formed XML.
+ xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index ea0f0f850d39..039180145d86 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -39,6 +39,7 @@
#include <ndtxt.hxx>
#include <ndole.hxx>
#include <frameformats.hxx>
+#include <svx/svdobj.hxx>
SwUndoFlyBase::SwUndoFlyBase( SwFrameFormat* pFormat, SwUndoId nUndoId )
: SwUndo(nUndoId, pFormat->GetDoc())
@@ -141,6 +142,18 @@ void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrame)
// recklessly assume that this thing will live longer than the
// SwUndoFlyBase - not sure what could be done if that isn't the case...
m_pFrameFormat->GetOtherTextBoxFormat()->SetOtherTextBoxFormat(m_pFrameFormat);
+
+ if (m_pFrameFormat->GetOtherTextBoxFormat()->Which() == RES_DRAWFRMFMT)
+ {
+ SdrObject* pSdrObject = m_pFrameFormat->GetOtherTextBoxFormat()->FindSdrObject();
+ if (pSdrObject)
+ {
+ // Make sure the old UNO wrapper is no longer cached after changing the shape +
+ // textframe pair. Otherwise we would have a wrapper which doesn't know about its
+ // textframe, even if it's there.
+ pSdrObject->setUnoShape(nullptr);
+ }
+ }
}
m_pFrameFormat->MakeFrames();