summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2022-06-30 15:48:07 +0200
committerAndras Timar <andras.timar@collabora.com>2022-07-26 07:53:46 +0200
commitd018d6bb5b87224353b2056536abb84ad08ba028 (patch)
tree5d1115121783144836d5381a35d18189dfcf22c8 /sw/qa/extras/uiwriter
parent8c30612316820399762ed245c568992498447f43 (diff)
tdf#142715 sw: fix crash on exit when textbox inserted to table
This reverts commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653 "tdf#130805 SwTextBoxHelper::create: fix frame position in shape" which caused this regression. That fix is not necessary any more: synchronization does the same without crashing. Note: according to this, unit test of commit 06e2cbb31d0ea703df872b91eb8eacdcaced7653 wasn't removed. Change-Id: I45bc15d3cf6a5d93b8c54cb4e68018702e58efff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136674 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 9188d7389c06496905c351a936b85974c1ae516f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136982 Tested-by: Jenkins Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137047
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/data/tdf142715.odtbin0 -> 11275 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx34
2 files changed, 34 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf142715.odt b/sw/qa/extras/uiwriter/data/tdf142715.odt
new file mode 100644
index 000000000000..70682a54056c
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf142715.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index ce5d10e67f08..a1a1272ae23d 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <comphelper/propertysequence.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <fmtanchr.hxx>
@@ -3920,6 +3921,39 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf103612)
"Text after section");
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testCrashOnExit)
+{
+ // Load the bugdoc with a table and a textbox shape inside.
+ CPPUNIT_ASSERT(createSwDoc(DATA_DIRECTORY, "tdf142715.odt"));
+ // Get the textbox selected
+ CPPUNIT_ASSERT_EQUAL(1, getShapes());
+ auto xShape = getShape(1);
+ CPPUNIT_ASSERT(xShape);
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xModel);
+ uno::Reference<frame::XController> xController = xModel->getCurrentController();
+ CPPUNIT_ASSERT(xController);
+ uno::Reference<view::XSelectionSupplier> xSelection(xController, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xSelection);
+ CPPUNIT_ASSERT(xSelection->select(uno::Any(xShape)));
+ CPPUNIT_ASSERT(xSelection->getSelection().hasValue());
+ uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY);
+ // Check if the textbox is selected
+ CPPUNIT_ASSERT_EQUAL(true, xProperties->getPropertyValue("TextBox").get<bool>());
+ // Remove the textbox
+ dispatchCommand(mxComponent, ".uno:RemoveTextBox", {});
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(false, xProperties->getPropertyValue("TextBox").get<bool>());
+ // Readd the textbox (to run the textboxhelper::create() method)
+ dispatchCommand(mxComponent, ".uno:AddTextBox", {});
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(true, xProperties->getPropertyValue("TextBox").get<bool>());
+ // save and reload
+ reload("writer8", "tdf142715_.odt");
+ // Before the fix this crashed here and could not reopen.
+ CPPUNIT_ASSERT_MESSAGE("Crash on exit, isn't it?", mxComponent);
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf97899)
{
SwDoc* pDoc = createSwDoc();