summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-12-19 23:29:17 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-12 09:00:15 +0000
commitdf321f828b4dac343cc520ecb2d722f75c52efb7 (patch)
tree54e9dbe424bf81e3a65429caf7e20d1c4b9f94ce
parentad5489e994c9ccdbc54ccd0e3721adb64a1e77ba (diff)
move saveInteropProperties from writerfilter to oox
Change-Id: I4f9769ad496198d2d002775dee4ee0a2f08d6f3b (cherry picked from commit 9d0d41f0f3c5215770bc7246a089d54a7244df55) Reviewed-on: https://gerrit.libreoffice.org/21351 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--include/oox/ole/oleobjecthelper.hxx6
-rw-r--r--oox/source/ole/oleobjecthelper.cxx40
-rw-r--r--writerfilter/source/dmapper/OLEHandler.cxx44
-rw-r--r--writerfilter/source/dmapper/OLEHandler.hxx5
4 files changed, 51 insertions, 44 deletions
diff --git a/include/oox/ole/oleobjecthelper.hxx b/include/oox/ole/oleobjecthelper.hxx
index 868cd0c449bf..febd097ae546 100644
--- a/include/oox/ole/oleobjecthelper.hxx
+++ b/include/oox/ole/oleobjecthelper.hxx
@@ -26,6 +26,7 @@
namespace com { namespace sun { namespace star {
namespace awt { struct Size; }
namespace document { class XEmbeddedObjectResolver; }
+ namespace frame { class XModel; }
namespace lang { class XMultiServiceFactory; }
} } }
@@ -71,6 +72,11 @@ private:
};
+OOX_DLLPUBLIC void SaveInteropProperties(
+ css::uno::Reference<css::frame::XModel> const& xModel,
+ OUString const& rObjectName, OUString const* pOldObjectName,
+ OUString const& rProgId, OUString const& rDrawAspect);
+
} // namespace ole
} // namespace oox
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;
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
index d282c7b5bfde..0fe095504c63 100644
--- a/writerfilter/source/dmapper/OLEHandler.cxx
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -22,6 +22,7 @@
#include "GraphicHelpers.hxx"
#include <editeng/unoprnms.hxx>
+#include <oox/ole/oleobjecthelper.hxx>
#include <ooxml/resourceids.hxx>
#include <rtl/ustring.hxx>
#include <osl/diagnose.h>
@@ -179,43 +180,6 @@ void OLEHandler::lcl_sprm(Sprm & rSprm)
}
}
-
-void OLEHandler::saveInteropProperties(uno::Reference<text::XTextDocument> const& xTextDocument, const OUString& sObjectName, const OUString& sOldObjectName)
-{
- static const char sEmbeddingsPropName[] = "EmbeddedObjects";
-
- // get interop grab bag from document
- uno::Reference< beans::XPropertySet > xDocProps( xTextDocument, uno::UNO_QUERY );
- comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue(UNO_NAME_MISC_OBJ_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 = uno::Any( m_sProgId );
- aGrabBagAttribute[1].Name = "DrawAspect";
- aGrabBagAttribute[1].Value = uno::Any( m_sDrawAspect );
-
- // If we got an "old name", erase that first.
- if (!sOldObjectName.isEmpty())
- {
- comphelper::SequenceAsHashMap::iterator it = objectsList.find(sOldObjectName);
- if (it != objectsList.end())
- objectsList.erase(it);
- }
-
- objectsList[sObjectName] = 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(UNO_NAME_MISC_OBJ_INTEROPGRABBAG, uno::Any(aGrabBag.getAsConstPropertyValueList()));
-}
-
void OLEHandler::importStream(uno::Reference<uno::XComponentContext> xComponentContext, uno::Reference<text::XTextDocument> xTextDocument, uno::Reference<text::XTextContent> xOLE)
{
OUString aFilterService;
@@ -248,7 +212,9 @@ void OLEHandler::importStream(uno::Reference<uno::XComponentContext> xComponentC
// Now that the data is imported, update the (typically) changed stream name.
uno::Reference<beans::XPropertySet> xPropertySet(xOLE, uno::UNO_QUERY);
- saveInteropProperties(xTextDocument, xPropertySet->getPropertyValue("StreamName").get<OUString>(), m_aURL);
+ ::oox::ole::SaveInteropProperties(xTextDocument,
+ xPropertySet->getPropertyValue("StreamName").get<OUString>(), &m_aURL,
+ m_sProgId, m_sDrawAspect);
}
OUString OLEHandler::getCLSID(uno::Reference<uno::XComponentContext> xComponentContext) const
@@ -305,7 +271,7 @@ OUString OLEHandler::copyOLEOStream(
}
}
- saveInteropProperties( xTextDocument, aURL );
+ ::oox::ole::SaveInteropProperties(xTextDocument, aURL, nullptr, m_sProgId, m_sDrawAspect);
static const char sProtocol[] = "vnd.sun.star.EmbeddedObject:";
OUString aPersistName( xEmbeddedResolver->resolveEmbeddedObjectURL( aURL ) );
diff --git a/writerfilter/source/dmapper/OLEHandler.hxx b/writerfilter/source/dmapper/OLEHandler.hxx
index 8e2cb1357aa2..8d6fbd6ac91b 100644
--- a/writerfilter/source/dmapper/OLEHandler.hxx
+++ b/writerfilter/source/dmapper/OLEHandler.hxx
@@ -76,11 +76,6 @@ class OLEHandler : public LoggedProperties
virtual void lcl_attribute(Id Name, Value & val) override;
virtual void lcl_sprm(Sprm & sprm) override;
- // Interoperability
- void saveInteropProperties(css::uno::Reference<css::text::XTextDocument> const& xTextDocument,
- const OUString& sObjectName,
- const OUString& sOldObjectName = OUString());
-
public:
OLEHandler(DomainMapper& rDomainMapper);
virtual ~OLEHandler();