diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2018-11-26 21:14:39 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-12-09 22:15:24 +0100 |
commit | 323d12f278d3b0a51c7c2b8d3a362a27a6a232d3 (patch) | |
tree | 9f7254587d00fa19781cb7bf98960c35a5f73feb /sd | |
parent | ca0cd6985adc7b321b9bc4affe79c4f26eab1722 (diff) |
tdf#120527 svx GraphicObjectShape: 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.
The case is similar to the Writer images, which was handled in commit
587803ba46055d43b5b108be744fdde17aeabc7c (sw TextGraphicObject: handle
XBitmap for GraphicURL, 2018-08-08) already.
(cherry picked from commit e30f3e76a9350e2b027d99bba5a46aa0a0ff8256)
Conflicts:
sd/qa/unit/misc-tests.cxx
Change-Id: I3740a68989b306425d0d6c4d4e350ac163cb4170
Reviewed-on: https://gerrit.libreoffice.org/64643
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/tdf120527.jpg | bin | 0 -> 1136 bytes | |||
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 44 |
2 files changed, 44 insertions, 0 deletions
diff --git a/sd/qa/unit/data/tdf120527.jpg b/sd/qa/unit/data/tdf120527.jpg Binary files differnew file mode 100644 index 000000000000..12b393569efb --- /dev/null +++ b/sd/qa/unit/data/tdf120527.jpg diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index ace77cdcc96e..445129b4ece7 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -62,6 +62,7 @@ public: void testFillGradient(); void testTdf44774(); void testTdf38225(); + void testTdf120527(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf96206); @@ -71,6 +72,7 @@ public: CPPUNIT_TEST(testFillGradient); CPPUNIT_TEST(testTdf44774); CPPUNIT_TEST(testTdf38225); + CPPUNIT_TEST(testTdf120527); CPPUNIT_TEST_SUITE_END(); private: @@ -361,6 +363,48 @@ void SdMiscTest::testTdf38225() CPPUNIT_ASSERT(pStyle); } +void SdMiscTest::testTdf120527() +{ + sd::DrawDocShellRef xDocShRef + = new sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false, DocumentType::Draw); + uno::Reference<frame::XLoadable> xLoadable(xDocShRef->GetModel(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xLoadable.is()); + xLoadable->initNew(); + + // Load a bitmap into the bitmap table. + uno::Reference<lang::XMultiServiceFactory> xFactory(xDocShRef->GetModel(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xFactory.is()); + uno::Reference<container::XNameContainer> xBitmaps( + xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xBitmaps.is()); + OUString aGraphicURL = m_directories.getURLFromSrc("/sd/qa/unit/data/tdf120527.jpg"); + xBitmaps->insertByName("test", uno::makeAny(aGraphicURL)); + + // Create a graphic. + uno::Reference<drawing::XShape> xShape( + xFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShape.is()); + uno::Reference<beans::XPropertySet> xShapeProperySet(xShape, uno::UNO_QUERY); + CPPUNIT_ASSERT(xShapeProperySet.is()); + xShapeProperySet->setPropertyValue("GraphicURL", xBitmaps->getByName("test")); + + // Insert it. + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xDocShRef->GetModel(), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xDrawPagesSupplier.is()); + uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages(); + CPPUNIT_ASSERT(xDrawPages.is()); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xDrawPage.is()); + // This failed with a lang.IllegalArgumentException. + xDrawPage->add(xShape); + + // Verify that the graphic was actually consumed. + uno::Reference<graphic::XGraphic> xGraphic; + xShapeProperySet->getPropertyValue("Graphic") >>= xGraphic; + CPPUNIT_ASSERT(xGraphic.is()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest); CPPUNIT_PLUGIN_IMPLEMENT(); |