diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-08-26 17:54:50 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-08-26 19:21:06 +0200 |
commit | 3341986547b69bcb4c38e4ccb2f0853a3a569bb5 (patch) | |
tree | c27f228f983fbe00a4e09c410bd44dee6eb29652 /svx | |
parent | 568eea45de027c418bffdb8b9886fe38f9de8d8f (diff) |
tdf#93998 toolkit: restore support for setting dialog background from shape
Regression from commit fb29e6eeeaad5255bb924ff59162a83ed80bfb0a (svx:
removing GraphicURL and OWN_ATTR_GRAFURL, fix writerfilter, 2018-03-08),
the problem was that an in-document macro tried to assign a bitmap shape
to a dialog background, which broke during the image handling rework.
Note that in this case the actual type of the "URL" is not interesting,
we can just return an XGraphic and then take it on the other side as
well, without re-introducing the intentionally removed graphic URLs
which point to memory addresses.
This also made it necessary to extend
UnoDialogControl::ImplModelPropertiesChanged(), so that in case a
graphic is assigned to the dialog model, then the dialog model -> dialog
sync code doesn't just copy over the empty image URL string. With this,
finally clicking on the button of the bugdoc makes the dialog show up
with the correct background.
Change-Id: Id78269643289efb435b96a6a0b9f8a93fa49ec04
Reviewed-on: https://gerrit.libreoffice.org/78153
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'svx')
-rw-r--r-- | svx/qa/unit/data/tdf93998.odp | bin | 0 -> 11308 bytes | |||
-rw-r--r-- | svx/qa/unit/unodraw.cxx | 33 | ||||
-rw-r--r-- | svx/source/unodraw/unoshap2.cxx | 10 |
3 files changed, 38 insertions, 5 deletions
diff --git a/svx/qa/unit/data/tdf93998.odp b/svx/qa/unit/data/tdf93998.odp Binary files differnew file mode 100644 index 000000000000..889aeeb0216f --- /dev/null +++ b/svx/qa/unit/data/tdf93998.odp diff --git a/svx/qa/unit/unodraw.cxx b/svx/qa/unit/unodraw.cxx index ee4b336b1a3d..b4e1b9c26b93 100644 --- a/svx/qa/unit/unodraw.cxx +++ b/svx/qa/unit/unodraw.cxx @@ -12,6 +12,10 @@ #include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> @@ -76,6 +80,35 @@ CPPUNIT_TEST_FIXTURE(UnodrawTest, testWriterGraphicExport) { "MediaType", uno::Any(OUString("image/jpeg")) } })); CPPUNIT_ASSERT(xExportFilter->filter(aProperties)); } + +CPPUNIT_TEST_FIXTURE(UnodrawTest, testTdf93998) +{ + mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf93998.odp"); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + CPPUNIT_ASSERT(xDrawPagesSupplier.is()); + + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xDrawPage.is()); + + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT(xShape.is()); + + uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory(); + uno::Reference<awt::XControlModel> xModel( + xFactory->createInstance("com.sun.star.awt.UnoControlDialogModel"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + + uno::Reference<beans::XPropertySet> xModelProps(xModel, uno::UNO_QUERY); + CPPUNIT_ASSERT(xModelProps.is()); + + // This resulted in a uno::RuntimeException, assigning a shape to a dialog model's image was + // broken. + xModelProps->setPropertyValue("ImageURL", xShape->getPropertyValue("GraphicURL")); + uno::Reference<graphic::XGraphic> xGraphic; + xModelProps->getPropertyValue("Graphic") >>= xGraphic; + CPPUNIT_ASSERT(xGraphic.is()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index 97935d68af4f..688fd1b29ee6 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -1487,13 +1487,13 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte } case OWN_ATTR_GRAPHIC_URL: - { - throw uno::RuntimeException("Getting from this property is not supported"); - break; - } - case OWN_ATTR_VALUE_GRAPHIC: { + if (pProperty->nWID == OWN_ATTR_GRAPHIC_URL) + { + SAL_WARN("svx", "Getting Graphic by URL is not supported, getting it by value"); + } + Reference<graphic::XGraphic> xGraphic; auto pSdrGraphicObject = static_cast<SdrGrafObj*>(GetSdrObject()); if (pSdrGraphicObject->GetGraphicObject().GetType() != GraphicType::NONE) |