diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-08-08 17:58:20 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-09-03 16:31:52 +0200 |
commit | 2fb37f232849db1f0ae852203fef4d4a40145755 (patch) | |
tree | 3d878cb815e936db63280eec962ac15347fcc15c /sw/qa | |
parent | d687d1bbba3f7226f3a533c31b2c84d833331755 (diff) |
sw TextGraphicObject: handle XBitmap for GraphicURL
This restores compatibility for API users who called getByName() on the
bitmap table and expected that the result can be set as a value for the
GraphicURL property.
Changing the property type to cppu::UnoType<css::uno::Any>::get() is
necessary, otherwise scripting languages figure out (via reflection)
that the type doesn't match, and SwXFrame::setPropertyValue() is not
called.
Change-Id: Idd62f109e91dbaebf1138b9038f66c6c648d780e
Reviewed-on: https://gerrit.libreoffice.org/58745
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
(cherry picked from commit 587803ba46055d43b5b108be744fdde17aeabc7c)
Reviewed-on: https://gerrit.libreoffice.org/59850
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/unowriter/unowriter.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx index 9b993618769f..ca1e8cab28fd 100644 --- a/sw/qa/extras/unowriter/unowriter.cxx +++ b/sw/qa/extras/unowriter/unowriter.cxx @@ -21,9 +21,11 @@ class SwUnoWriter : public SwModelTestBase { public: void testGraphicDesciptorURL(); + void testGraphicDesciptorURLBitmap(); CPPUNIT_TEST_SUITE(SwUnoWriter); CPPUNIT_TEST(testGraphicDesciptorURL); + CPPUNIT_TEST(testGraphicDesciptorURLBitmap); CPPUNIT_TEST_SUITE_END(); }; @@ -54,6 +56,37 @@ void SwUnoWriter::testGraphicDesciptorURL() CPPUNIT_ASSERT(xGraphic.is()); } +void SwUnoWriter::testGraphicDesciptorURLBitmap() +{ + loadURL("private:factory/swriter", nullptr); + + // Load a bitmap into the bitmap table. + uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XNameContainer> xBitmaps( + xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY); + OUString aGraphicURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "test.jpg"; + xBitmaps->insertByName("test", uno::makeAny(aGraphicURL)); + + // Create a graphic. + uno::Reference<beans::XPropertySet> xTextGraphic( + xFactory->createInstance("com.sun.star.text.TextGraphicObject"), uno::UNO_QUERY); + xTextGraphic->setPropertyValue("GraphicURL", xBitmaps->getByName("test")); + 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: setting GraphicURL to the result of getByName() did not + // work anymore. + auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(getShape(1), "Graphic"); + CPPUNIT_ASSERT(xGraphic.is()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUnoWriter); CPPUNIT_PLUGIN_IMPLEMENT(); |