diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-02-01 15:28:53 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-02-01 11:54:22 +0100 |
commit | e02efb621fe672aa52e56caa916cf5c3fd0a9cb8 (patch) | |
tree | 725947b541b4774722d9d4a9d11a2ac58463a753 /sd | |
parent | a61747c2c375d1fe404c976d2a03125e4dc78d8f (diff) |
Change bitmap table to store XBitmap instead of GraphicObject URL
As we want to get rid of GraphicObject URLs for the more robust
image life-cycle handling, it was necessary to change the way
bitmap table stores and handles images, so that they always
store a Graphic object (wrapped in UNO object that provides the
XGraphic and XBitmap interface).
In addition this changes loading and saving from ODF (xmloff) and
OOXML (oox) filters so they don't depend on GraphicObject URL
anymore, but load or save directly to / from XGraphic or XBitmap.
Change-Id: I2b88e10056e7d6c920249d59188f86b1a5a32d21
Reviewed-on: https://gerrit.libreoffice.org/49074
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 8bc274400520..b27c55b55ba8 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -144,6 +144,33 @@ public: }; +namespace +{ + +uno::Reference<awt::XBitmap> getBitmapFromTable(sd::DrawDocShellRef xDocShRef, OUString const & rName) +{ + uno::Reference<awt::XBitmap> xBitmap; + + uno::Reference<lang::XMultiServiceFactory> xFactory(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY); + + try + { + uno::Reference<container::XNameAccess> xBitmapTable(xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY); + uno::Any rValue = xBitmapTable->getByName(rName); + if (rValue.has<uno::Reference<awt::XBitmap>>()) + { + return rValue.get<uno::Reference<awt::XBitmap>>(); + } + } + catch (const uno::Exception & /*rEx*/) + { + } + + return xBitmap; +} + +} + void SdExportTest::testBackgroundImage() { // Initial bug: N821567 @@ -168,7 +195,10 @@ void SdExportTest::testBackgroundImage() aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName"); aAny >>= bgImageName; } - CPPUNIT_ASSERT_MESSAGE("Slide Background is not imported from PPTX correctly", !bgImageName.isEmpty()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not imported from PPTX correctly", OUString("msFillBitmap 1"), bgImageName); + + uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName); + CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when imported from PPTX", xBitmap.is()); } // Save as PPTX, reload and check again so we make sure exporting to PPTX is working correctly @@ -187,7 +217,10 @@ void SdExportTest::testBackgroundImage() aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName"); aAny >>= bgImageName; } - CPPUNIT_ASSERT_MESSAGE("Slide Background is not exported to PPTX correctly", !bgImageName.isEmpty()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not exported from PPTX correctly", OUString("msFillBitmap 1"), bgImageName); + + uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName); + CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when exported from PPTX", xBitmap.is()); } // Save as ODP, reload and check again so we make sure exporting and importing to ODP is working correctly @@ -206,7 +239,10 @@ void SdExportTest::testBackgroundImage() aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName"); aAny >>= bgImageName; } - CPPUNIT_ASSERT_MESSAGE("Slide Background is not exported or imported to ODP correctly", !bgImageName.isEmpty()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not exported or imported from ODP correctly", OUString("msFillBitmap 1"), bgImageName); + + uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(xDocShRef, bgImageName); + CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when exported or imported from ODP", xBitmap.is()); } xDocShRef->DoClose(); |