summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/oox/helper/graphichelper.hxx3
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/graphic/XGraphicProvider2.idl47
-rw-r--r--oox/source/helper/graphichelper.cxx29
-rw-r--r--svtools/source/graphic/provider.cxx20
5 files changed, 81 insertions, 19 deletions
diff --git a/include/oox/helper/graphichelper.hxx b/include/oox/helper/graphichelper.hxx
index 17f896683ab4..651e9407b4ec 100644
--- a/include/oox/helper/graphichelper.hxx
+++ b/include/oox/helper/graphichelper.hxx
@@ -31,6 +31,7 @@
#include <oox/helper/storagebase.hxx>
#include <rtl/ustring.hxx>
#include <sal/types.h>
+#include <com/sun/star/graphic/XGraphicProvider2.hpp>
struct WMF_EXTERNALHEADER;
@@ -161,7 +162,7 @@ private:
typedef ::std::map< OUString, css::uno::Reference< css::graphic::XGraphic > > EmbeddedGraphicMap;
css::uno::Reference< css::uno::XComponentContext > mxContext;
- css::uno::Reference< css::graphic::XGraphicProvider > mxGraphicProvider;
+ css::uno::Reference< css::graphic::XGraphicProvider2 > mxGraphicProvider;
css::uno::Reference< css::awt::XUnitConversion > mxUnitConversion;
css::awt::DeviceInfo maDeviceInfo; ///< Current output device info.
SystemPalette maSystemPalette; ///< Maps system colors (XML tokens) to RGB color values.
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 0e0a6cad8962..7a9c17af6601 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -2695,6 +2695,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/graphic,\
XGraphic \
XGraphicObject \
XGraphicProvider \
+ XGraphicProvider2 \
XGraphicRasterizer \
XGraphicRenderer \
XGraphicTransformer \
diff --git a/offapi/com/sun/star/graphic/XGraphicProvider2.idl b/offapi/com/sun/star/graphic/XGraphicProvider2.idl
new file mode 100644
index 000000000000..04b5f02589d5
--- /dev/null
+++ b/offapi/com/sun/star/graphic/XGraphicProvider2.idl
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef com_sun_star_graphic_XGraphicProvider2_idl
+#define com_sun_star_graphic_XGraphicProvider2_idl
+
+#include <com/sun/star/graphic/XGraphicProvider.idl>
+
+module com { module sun { module star { module graphic
+{
+
+/** This interface allows operations on multiple graphics with one method
+ call.
+ */
+interface XGraphicProvider2 : XGraphicProvider
+{
+ /** Calling this method returns XGraphic interfaces
+ that hold loaded graphics.
+
+ @param MediaPropertiesSeq
+ A sequence of sequence of property values to describe the location
+ of the graphics.
+
+ @returns
+ The XGraphic interfaces
+
+ @see XGraphicProvider::queryGraphic
+
+ @since LibreOffice 5.5
+ */
+ sequence< XGraphic > queryGraphics([in] sequence< com::sun::star::beans::PropertyValues> MediaPropertiesSeq)
+ raises( com::sun::star::io::IOException,
+ com::sun::star::lang::IllegalArgumentException,
+ com::sun::star::lang::WrappedTargetException );
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 7927daedd39e..692937baeb48 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -37,6 +37,7 @@
#include <vcl/svapp.hxx>
#include <tools/gen.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/sequence.hxx>
#include "oox/helper/containerhelper.hxx"
#include "oox/helper/propertyset.hxx"
#include "oox/token/properties.hxx"
@@ -68,7 +69,7 @@ GraphicHelper::GraphicHelper( const Reference< XComponentContext >& rxContext, c
{
OSL_ENSURE( mxContext.is(), "GraphicHelper::GraphicHelper - missing component context" );
if( mxContext.is() )
- mxGraphicProvider.set( graphic::GraphicProvider::create( mxContext ) );
+ mxGraphicProvider.set( graphic::GraphicProvider::create( mxContext ), uno::UNO_QUERY );
//! TODO: get colors from system
maSystemPalette[ XML_3dDkShadow ] = 0x716F64;
@@ -266,29 +267,25 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea
std::vector< uno::Reference<graphic::XGraphic> > GraphicHelper::importGraphics(const std::vector< uno::Reference<io::XInputStream> >& rStreams) const
{
- std::vector< uno::Reference<graphic::XGraphic> > aRet;
+ std::vector< uno::Sequence<beans::PropertyValue> > aArgsVec;
for (const auto& rStream : rStreams)
{
- uno::Reference<graphic::XGraphic> xGraphic;
- if (rStream.is() && mxGraphicProvider.is())
+ if (rStream.is())
{
- try
- {
- uno::Sequence<beans::PropertyValue > aArgs = comphelper::InitPropertySequence(
- {
- {"InputStream", uno::makeAny(rStream)}
- });
- xGraphic = mxGraphicProvider->queryGraphic(aArgs);
- }
- catch( const uno::Exception& rException)
+ uno::Sequence<beans::PropertyValue > aArgs = comphelper::InitPropertySequence(
{
- SAL_WARN("oox", "GraphicHelper::importGraphic: queryGraphics() failed: " << rException.Message);
- }
+ {"InputStream", uno::makeAny(rStream)}
+ });
+ aArgsVec.push_back(aArgs);
}
- aRet.push_back(xGraphic);
}
+ std::vector< uno::Reference<graphic::XGraphic> > aRet;
+
+ if (mxGraphicProvider.is())
+ aRet = comphelper::sequenceToContainer< std::vector< uno::Reference<graphic::XGraphic> > >(mxGraphicProvider->queryGraphics(comphelper::containerToSequence(aArgsVec)));
+
return aRet;
}
diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx
index 6106bef363a8..faec3fcd4d9b 100644
--- a/svtools/source/graphic/provider.cxx
+++ b/svtools/source/graphic/provider.cxx
@@ -34,7 +34,7 @@
#include <vcl/virdev.hxx>
#include <vcl/settings.hxx>
#include <com/sun/star/awt/XBitmap.hpp>
-#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/graphic/XGraphicProvider2.hpp>
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/text/GraphicCrop.hpp>
@@ -48,6 +48,7 @@
#include <rtl/ref.hxx>
#include <svtools/grfmgr.hxx>
#include <vcl/dibtools.hxx>
+#include <comphelper/sequence.hxx>
#include <memory>
using namespace com::sun::star;
@@ -56,7 +57,7 @@ namespace {
#define UNO_NAME_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
-class GraphicProvider : public ::cppu::WeakImplHelper< css::graphic::XGraphicProvider,
+class GraphicProvider : public ::cppu::WeakImplHelper< css::graphic::XGraphicProvider2,
css::lang::XServiceInfo >
{
public:
@@ -79,6 +80,9 @@ protected:
virtual css::uno::Reference< css::graphic::XGraphic > SAL_CALL queryGraphic( const css::uno::Sequence< css::beans::PropertyValue >& MediaProperties ) override;
virtual void SAL_CALL storeGraphic( const css::uno::Reference< css::graphic::XGraphic >& Graphic, const css::uno::Sequence< css::beans::PropertyValue >& MediaProperties ) override;
+ // XGraphicProvider2
+ uno::Sequence< uno::Reference<graphic::XGraphic> > SAL_CALL queryGraphics(const uno::Sequence< uno::Sequence<beans::PropertyValue> >& MediaPropertiesSeq ) override;
+
private:
static css::uno::Reference< css::graphic::XGraphic > implLoadMemory( const OUString& rResourceURL );
@@ -432,6 +436,18 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
return xRet;
}
+uno::Sequence< uno::Reference<graphic::XGraphic> > SAL_CALL GraphicProvider::queryGraphics(const uno::Sequence< uno::Sequence<beans::PropertyValue> >& rMediaPropertiesSeq)
+{
+ std::vector< uno::Reference<graphic::XGraphic> > aRet;
+
+ for (const auto& rMediaProperties : rMediaPropertiesSeq)
+ {
+ aRet.push_back(queryGraphic(rMediaProperties));
+ }
+
+ return comphelper::containerToSequence(aRet);
+}
+
void ImplCalculateCropRect( ::Graphic& rGraphic, const text::GraphicCrop& rGraphicCropLogic, tools::Rectangle& rGraphicCropPixel )
{
if ( rGraphicCropLogic.Left || rGraphicCropLogic.Top || rGraphicCropLogic.Right || rGraphicCropLogic.Bottom )