summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2021-11-30 15:38:26 +0100
committerLászló Németh <nemeth@numbertext.org>2021-12-14 15:31:57 +0100
commit19394a924fdc486202ca27e318385287eb0df26f (patch)
treebe1971ce719960a8c139565c98f2fb76787b3a10 /sw/qa/extras
parente5650de86072b9db586a4532b5239acda77598c4 (diff)
tdf#143574 sw: textboxes in group shapes -- part 4
A new UNO property has been added and implemented for the filters. This provides the possibility of assigning textboxes in the filter at import time via UNO. Follow-up to commit e5650de86072b9db586a4532b5239acda77598c4 "tdf#143574 sw: textboxes in group shapes - part 3 take 2". Change-Id: I58c445cb7f6d865c1d82dbe68f985e4c11ff832e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126162 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/layout/data/TextBoxFrame.odtbin0 -> 9414 bytes
-rw-r--r--sw/qa/extras/layout/layout2.cxx41
2 files changed, 41 insertions, 0 deletions
diff --git a/sw/qa/extras/layout/data/TextBoxFrame.odt b/sw/qa/extras/layout/data/TextBoxFrame.odt
new file mode 100644
index 000000000000..a6155e34fdfb
--- /dev/null
+++ b/sw/qa/extras/layout/data/TextBoxFrame.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 10d01fa05e33..47403ea6a1da 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -1557,6 +1557,47 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf141220)
CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(15), nTextBoxTop - nShapeTop);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, TestTextBoxChangeViaUNO)
+{
+ CPPUNIT_ASSERT(createSwDoc(DATA_DIRECTORY, "TextBoxFrame.odt"));
+ // this file has a shape and a frame inside. Try to set up
+ // the frame for the shape as textbox. Before this was not
+ // implemented. This will be necesary for proper WPG import.
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("There must be a shape and a frame!", 2, getShapes());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("This must be a custom shape!",
+ OUString("com.sun.star.drawing.CustomShape"),
+ getShape(1)->getShapeType());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("This must be a frame shape!", OUString("FrameShape"),
+ getShape(2)->getShapeType());
+
+ CPPUNIT_ASSERT_MESSAGE("This is not supposed to be a textbox!",
+ !uno::Reference<beans::XPropertySet>(getShape(1), uno::UNO_QUERY_THROW)
+ ->getPropertyValue("TextBox")
+ .get<bool>());
+ // Without the fix it will crash at this line:
+ CPPUNIT_ASSERT_MESSAGE("This is not supposed to be a textbox!",
+ !uno::Reference<beans::XPropertySet>(getShape(1), uno::UNO_QUERY_THROW)
+ ->getPropertyValue("TextBoxContent")
+ .hasValue());
+
+ // So now set the frame as textbox for the shape!
+ uno::Reference<beans::XPropertySet>(getShape(1), uno::UNO_QUERY_THROW)
+ ->setPropertyValue("TextBoxContent", uno::Any(uno::Reference<text::XTextFrame>(
+ getShape(2), uno::UNO_QUERY_THROW)));
+
+ CPPUNIT_ASSERT_MESSAGE("This is supposed to be a textbox!",
+ uno::Reference<beans::XPropertySet>(getShape(1), uno::UNO_QUERY_THROW)
+ ->getPropertyValue("TextBox")
+ .get<bool>());
+
+ CPPUNIT_ASSERT_MESSAGE("This is supposed to be a textbox!",
+ uno::Reference<beans::XPropertySet>(getShape(1), uno::UNO_QUERY_THROW)
+ ->getPropertyValue("TextBoxContent")
+ .hasValue());
+}
+
CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf121509)
{
auto pDoc = createSwDoc(DATA_DIRECTORY, "Tdf121509.odt");