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 /svx | |
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 'svx')
-rw-r--r-- | svx/source/unodraw/XPropertyTable.cxx | 23 | ||||
-rw-r--r-- | svx/source/unodraw/unobtabl.cxx | 5 | ||||
-rw-r--r-- | svx/source/xml/xmlxtexp.cxx | 5 | ||||
-rw-r--r-- | svx/source/xml/xmlxtimp.cxx | 12 |
4 files changed, 28 insertions, 17 deletions
diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx index 55ca9a09cc90..1765cee285ab 100644 --- a/svx/source/unodraw/XPropertyTable.cxx +++ b/svx/source/unodraw/XPropertyTable.cxx @@ -23,6 +23,8 @@ #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> #include <com/sun/star/drawing/LineDash.hpp> #include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> #include <com/sun/star/drawing/Hatch.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XNameContainer.hpp> @@ -613,28 +615,27 @@ uno::Reference< uno::XInterface > SvxUnoXBitmapTable_createInstance( XPropertyLi // SvxUnoXPropertyTable uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const { - OUString aURL( UNO_NAME_GRAPHOBJ_URLPREFIX); - const GraphicObject& rGraphicObject(static_cast<const XBitmapEntry*>(pEntry)->GetGraphicObject()); - aURL += OStringToOUString(rGraphicObject.GetUniqueID(), RTL_TEXTENCODING_ASCII_US); - - return uno::Any(aURL); + auto xBitmapEntry = static_cast<const XBitmapEntry*>(pEntry); + css::uno::Reference<css::awt::XBitmap> xBitmap(xBitmapEntry->GetGraphicObject().GetGraphic().GetXGraphic(), uno::UNO_QUERY); + return uno::Any(xBitmap); } std::unique_ptr<XPropertyEntry> SvxUnoXBitmapTable::createEntry(const OUString& rName, const uno::Any& rAny) const { - OUString aURL; - if(!(rAny >>= aURL)) + if (!rAny.has<uno::Reference<awt::XBitmap>>()) return std::unique_ptr<XPropertyEntry>(); - const GraphicObject aGrafObj(GraphicObject::CreateGraphicObjectFromURL(aURL)); - - return o3tl::make_unique<XBitmapEntry>(aGrafObj, rName); + auto xBitmap = rAny.get<uno::Reference<awt::XBitmap>>(); + uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY); + Graphic aGraphic(xGraphic); + GraphicObject aGraphicObject(aGraphic); + return o3tl::make_unique<XBitmapEntry>(aGraphicObject, rName); } // XElementAccess uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType() { - return ::cppu::UnoType<OUString>::get(); + return ::cppu::UnoType<awt::XBitmap>::get(); } // XServiceInfo diff --git a/svx/source/unodraw/unobtabl.cxx b/svx/source/unodraw/unobtabl.cxx index 5e8c4ad39def..ab1d48660d58 100644 --- a/svx/source/unodraw/unobtabl.cxx +++ b/svx/source/unodraw/unobtabl.cxx @@ -31,6 +31,7 @@ #include <editeng/unoprnms.hxx> #include <svx/unofill.hxx> #include <editeng/memberids.h> +#include <com/sun/star/awt/XBitmap.hpp> using namespace ::com::sun::star; using namespace ::cppu; @@ -52,7 +53,7 @@ public: }; SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw() -: SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_GRAFURL ) +: SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_BITMAP ) { } @@ -91,7 +92,7 @@ NameOrIndex* SvxUnoBitmapTable::createItem() const // XElementAccess uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( ) { - return ::cppu::UnoType<OUString>::get(); + return ::cppu::UnoType<awt::XBitmap>::get(); } /** diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx index 8162ff851112..2254de22e652 100644 --- a/svx/source/xml/xmlxtexp.cxx +++ b/svx/source/xml/xmlxtexp.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> #include <com/sun/star/drawing/LineDash.hpp> #include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/drawing/Hatch.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/embed/ElementModes.hpp> @@ -363,7 +364,7 @@ bool SvxXMLXTableExportComponent::exportTable() throw() pExporter.reset(new SvxXMLGradientEntryExporter(*this)); pEleName = "gradient-table"; } - else if( aExportType == cppu::UnoType<OUString>::get()) + else if( aExportType == cppu::UnoType<awt::XBitmap>::get()) { pExporter.reset(new SvxXMLBitmapEntryExporter(*this)); pEleName = "bitmap-table"; @@ -484,7 +485,7 @@ SvxXMLBitmapEntryExporter::SvxXMLBitmapEntryExporter( SvXMLExport& rExport ) void SvxXMLBitmapEntryExporter::exportEntry( const OUString& rStrName, const Any& rValue ) { - XMLImageStyle::exportXML( rStrName, rValue, mrExport ); + XMLImageStyle::exportXML(rStrName, rValue, mrExport); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx index 14b4156dd14b..5cfc80c7ced8 100644 --- a/svx/source/xml/xmlxtimp.cxx +++ b/svx/source/xml/xmlxtimp.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp> #include <com/sun/star/drawing/LineDash.hpp> #include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/XBitmap.hpp> #include <com/sun/star/drawing/Hatch.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/io/XSeekable.hpp> @@ -275,7 +276,14 @@ void SvxXMLTableImportContext::importBitmap( const uno::Reference< XAttributeLis { try { - XMLImageStyle::importXML( xAttrList, rAny, rName, GetImport() ); + uno::Any aGraphicAny; + XMLImageStyle::importXML(xAttrList, aGraphicAny, rName, GetImport()); + if (aGraphicAny.has<uno::Reference<graphic::XGraphic>>()) + { + auto xGraphic = aGraphicAny.get<uno::Reference<graphic::XGraphic>>(); + uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY_THROW); + rAny <<= xBitmap; + } } catch (const Exception&) { @@ -453,7 +461,7 @@ SvXMLImportContext *SvxXMLXTableImport::CreateDocumentContext( } else if ( rLocalName == "bitmap-table" ) { - if( aType == ::cppu::UnoType<OUString>::get()) + if( aType == ::cppu::UnoType<awt::XBitmap>::get()) return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, SvxXMLTableImportContextEnum::Bitmap, mrTable, bOOoFormat ); } } |