summaryrefslogtreecommitdiff
path: root/svx/source/unodraw
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-02-01 15:28:53 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-02-01 11:54:22 +0100
commite02efb621fe672aa52e56caa916cf5c3fd0a9cb8 (patch)
tree725947b541b4774722d9d4a9d11a2ac58463a753 /svx/source/unodraw
parenta61747c2c375d1fe404c976d2a03125e4dc78d8f (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/source/unodraw')
-rw-r--r--svx/source/unodraw/XPropertyTable.cxx23
-rw-r--r--svx/source/unodraw/unobtabl.cxx5
2 files changed, 15 insertions, 13 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();
}
/**