summaryrefslogtreecommitdiff
path: root/sw/qa/extras/unowriter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-08-07 11:06:30 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-08-07 12:45:46 +0200
commitbba0ccd743a3d023e4829155571cdf0318fcb81c (patch)
treea6c286027b54e5abdcfee29556af49376280b0fa /sw/qa/extras/unowriter
parentc57191e0c45f9735a33953d6b95d54b0e10c876f (diff)
sw TextGraphicObject: fix GraphicURL handling in the descriptor
Commit dfee7d93b4e863d673c45921f79bb876b5738ea6 (sw: get rid of FN_UNO_GRAPHIC_U_R_L and "GraphicURL" property, 2018-03-08) removed support for string-based graphic references, then a later commit restored the setter. But one scenario (when setting the graphic URL before inserting the text graphic object) was still unsupported for real URL setter; restore that as well. Change-Id: I52a7f96e820f614d9d031df3ba03c794984ad68b Reviewed-on: https://gerrit.libreoffice.org/58669 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras/unowriter')
-rw-r--r--sw/qa/extras/unowriter/data/test.jpgbin0 -> 1136 bytes
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx35
2 files changed, 35 insertions, 0 deletions
diff --git a/sw/qa/extras/unowriter/data/test.jpg b/sw/qa/extras/unowriter/data/test.jpg
new file mode 100644
index 000000000000..12b393569efb
--- /dev/null
+++ b/sw/qa/extras/unowriter/data/test.jpg
Binary files differ
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index 59a045586423..cde8b9b9c47d 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -9,15 +9,23 @@
#include <swmodeltestbase.hxx>
#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+
+namespace
+{
+char const DATA_DIRECTORY[] = "/sw/qa/extras/unowriter/data/";
+}
/// Test to assert UNO API call results of Writer.
class SwUnoWriter : public SwModelTestBase
{
public:
void testDefaultCharStyle();
+ void testGraphicDesciptorURL();
CPPUNIT_TEST_SUITE(SwUnoWriter);
CPPUNIT_TEST(testDefaultCharStyle);
+ CPPUNIT_TEST(testGraphicDesciptorURL);
CPPUNIT_TEST_SUITE_END();
};
@@ -47,6 +55,33 @@ void SwUnoWriter::testDefaultCharStyle()
getProperty<awt::FontSlant>(xCursorProps, "CharPosture"));
}
+void SwUnoWriter::testGraphicDesciptorURL()
+{
+ loadURL("private:factory/swriter", nullptr);
+
+ // Create a graphic object, but don't insert it yet.
+ uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xTextGraphic(
+ xFactory->createInstance("com.sun.star.text.TextGraphicObject"), uno::UNO_QUERY);
+
+ // Set an URL on it.
+ OUString aGraphicURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "test.jpg";
+ xTextGraphic->setPropertyValue("GraphicURL", uno::makeAny(aGraphicURL));
+ xTextGraphic->setPropertyValue("AnchorType",
+ uno::makeAny(text::TextContentAnchorType_AT_CHARACTER));
+
+ // Insert it.
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XText> xBodyText(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<text::XTextCursor> xCursor(xBodyText->createTextCursor());
+ uno::Reference<text::XTextContent> xTextContent(xTextGraphic, uno::UNO_QUERY);
+ xBodyText->insertTextContent(xCursor, xTextContent, false);
+
+ // This failed, the graphic object had no graphic.
+ auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(getShape(1), "Graphic");
+ CPPUNIT_ASSERT(xGraphic.is());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUnoWriter);
CPPUNIT_PLUGIN_IMPLEMENT();