summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-12-19 23:29:17 +0100
committerMichael Stahl <mstahl@redhat.com>2015-12-20 00:56:06 +0100
commit9d0d41f0f3c5215770bc7246a089d54a7244df55 (patch)
treeeaba3086120ff72a2d2d896d5daa4120e32cae8c /oox
parent17662cd7d4e5a201ba85f8236d2f71f544b7931e (diff)
move saveInteropProperties from writerfilter to oox
Change-Id: I4f9769ad496198d2d002775dee4ee0a2f08d6f3b
Diffstat (limited to 'oox')
-rw-r--r--oox/source/ole/oleobjecthelper.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/oox/source/ole/oleobjecthelper.cxx b/oox/source/ole/oleobjecthelper.cxx
index f5d4df409748..5e6c057b0b56 100644
--- a/oox/source/ole/oleobjecthelper.cxx
+++ b/oox/source/ole/oleobjecthelper.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
#include <com/sun/star/embed/Aspects.hpp>
@@ -28,6 +29,7 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <osl/diagnose.h>
+#include <comphelper/sequenceashashmap.hxx>
#include "oox/helper/propertymap.hxx"
namespace oox {
@@ -72,6 +74,44 @@ OleObjectHelper::~OleObjectHelper()
}
}
+void SaveInteropProperties(uno::Reference<frame::XModel> const& xModel,
+ OUString const& rObjectName, OUString const*const pOldObjectName,
+ OUString const& rProgId, OUString const& rDrawAspect)
+{
+ static const char sEmbeddingsPropName[] = "EmbeddedObjects";
+
+ // get interop grab bag from document
+ uno::Reference<beans::XPropertySet> const xDocProps(xModel, uno::UNO_QUERY);
+ comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue("InteropGrabBag"));
+
+ // get EmbeddedObjects property inside grab bag
+ comphelper::SequenceAsHashMap objectsList;
+ if (aGrabBag.find(sEmbeddingsPropName) != aGrabBag.end())
+ objectsList << aGrabBag[sEmbeddingsPropName];
+
+ uno::Sequence< beans::PropertyValue > aGrabBagAttribute(2);
+ aGrabBagAttribute[0].Name = "ProgID";
+ aGrabBagAttribute[0].Value <<= rProgId;
+ aGrabBagAttribute[1].Name = "DrawAspect";
+ aGrabBagAttribute[1].Value <<= rDrawAspect;
+
+ // If we got an "old name", erase that first.
+ if (pOldObjectName)
+ {
+ comphelper::SequenceAsHashMap::iterator it = objectsList.find(*pOldObjectName);
+ if (it != objectsList.end())
+ objectsList.erase(it);
+ }
+
+ objectsList[rObjectName] = uno::Any( aGrabBagAttribute );
+
+ // put objects list back into the grab bag
+ aGrabBag[sEmbeddingsPropName] = uno::Any(objectsList.getAsConstPropertyValueList());
+
+ // put grab bag back into the document
+ xDocProps->setPropertyValue("InteropGrabBag", uno::Any(aGrabBag.getAsConstPropertyValueList()));
+}
+
bool OleObjectHelper::importOleObject( PropertyMap& rPropMap, const OleObjectInfo& rOleObject, const awt::Size& rObjSize )
{
bool bRet = false;