diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-02-06 17:46:28 -0500 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-25 19:58:01 +0200 |
commit | e823a7a75fdd6bb58b894b58c27e71139e55b11c (patch) | |
tree | be28549d00ec840e28425527952e24200891b543 | |
parent | 999771edb5cd4d22c9a4d94d9475913b8ae18dcb (diff) |
oox: move putPropertiesToDocumentGrabBag to XmlFilterBase
Reviewed-on: https://gerrit.libreoffice.org/49235
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit e26a95360e60e0c17e70e72f36fb988bb664ddb5)
Change-Id: Ic3cbabc420c7856682b889528043563622997c14
-rw-r--r-- | include/oox/core/xmlfilterbase.hxx | 2 | ||||
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 30 | ||||
-rw-r--r-- | writerfilter/source/filter/WriterFilter.cxx | 38 |
3 files changed, 35 insertions, 35 deletions
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index 26948588e1dd..7621a0081a53 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -228,6 +228,8 @@ public: void exportDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xProperties ); void importDocumentProperties(); + static void putPropertiesToDocumentGrabBag(const css::uno::Reference<css::lang::XComponent>& xDstDoc, + const comphelper::SequenceAsHashMap& rProperties); static FastParser* createParser(); diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index c4e3d670d9c2..202c91ed1c4a 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -234,6 +234,36 @@ void XmlFilterBase::checkDocumentProperties(const Reference<XDocumentProperties> mbMSO2007 = true; } +void XmlFilterBase::putPropertiesToDocumentGrabBag(const css::uno::Reference<css::lang::XComponent>& xDstDoc, + const comphelper::SequenceAsHashMap& rProperties) +{ + try + { + uno::Reference<beans::XPropertySet> xDocProps(xDstDoc, uno::UNO_QUERY); + if (xDocProps.is()) + { + uno::Reference<beans::XPropertySetInfo> xPropsInfo = xDocProps->getPropertySetInfo(); + + static const OUString aGrabBagPropName = "InteropGrabBag"; + if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(aGrabBagPropName)) + { + // get existing grab bag + comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue(aGrabBagPropName)); + + // put the new items + aGrabBag.update(rProperties); + + // put it back to the document + xDocProps->setPropertyValue(aGrabBagPropName, uno::Any(aGrabBag.getAsConstPropertyValueList())); + } + } + } + catch (const uno::Exception&) + { + SAL_WARN("oox","Failed to save documents grab bag"); + } +} + void XmlFilterBase::importDocumentProperties() { MediaDescriptor aMediaDesc( getMediaDescriptor() ); diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx index 499ffa9df0dd..2953c6cc3f17 100644 --- a/writerfilter/source/filter/WriterFilter.cxx +++ b/writerfilter/source/filter/WriterFilter.cxx @@ -35,6 +35,7 @@ #include <cppuhelper/supportsservice.hxx> #include <dmapper/DomainMapperFactory.hxx> #include <oox/core/filterdetect.hxx> +#include <oox/core/xmlfilterbase.hxx> #include <oox/helper/graphichelper.hxx> #include <oox/ole/olestorage.hxx> #include <oox/ole/vbaproject.hxx> @@ -115,10 +116,6 @@ public: OUString SAL_CALL getImplementationName() override; sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override; uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; - -private: - void putPropertiesToDocumentGrabBag(const comphelper::SequenceAsHashMap& rProperties); - }; sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& rDescriptor) @@ -231,7 +228,7 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& rDesc // Adding the saved embedding document to document's grab bag aGrabBagProperties["OOXEmbeddings"] <<= pDocument->getEmbeddingsList(); - putPropertiesToDocumentGrabBag(aGrabBagProperties); + oox::core::XmlFilterBase::putPropertiesToDocumentGrabBag(m_xDstDoc, aGrabBagProperties); writerfilter::ooxml::OOXMLStream::Pointer_t pVBAProjectStream(writerfilter::ooxml::OOXMLDocumentFactory::createStream(pDocStream, writerfilter::ooxml::OOXMLStream::VBAPROJECT)); oox::StorageRef xVbaPrjStrg(new ::oox::ole::OleStorage(m_xContext, pVBAProjectStream->getDocumentStream(), false)); @@ -336,36 +333,7 @@ uno::Sequence<OUString> WriterFilter::getSupportedServiceNames() return aRet; } -void WriterFilter::putPropertiesToDocumentGrabBag(const comphelper::SequenceAsHashMap& rProperties) -{ - try - { - uno::Reference<beans::XPropertySet> xDocProps(m_xDstDoc, uno::UNO_QUERY); - if (xDocProps.is()) - { - uno::Reference<beans::XPropertySetInfo> xPropsInfo = xDocProps->getPropertySetInfo(); - - const OUString aGrabBagPropName = "InteropGrabBag"; - if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(aGrabBagPropName)) - { - // get existing grab bag - comphelper::SequenceAsHashMap aGrabBag(xDocProps->getPropertyValue(aGrabBagPropName)); - - // put the new items - aGrabBag.update(rProperties); - - // put it back to the document - xDocProps->setPropertyValue(aGrabBagPropName, uno::Any(aGrabBag.getAsConstPropertyValueList())); - } - } - } - catch (const uno::Exception&) - { - SAL_WARN("writerfilter","Failed to save documents grab bag"); - } -} - -extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL com_sun_star_comp_Writer_WriterFilter_get_implementation(uno::XComponentContext* component, uno::Sequence<uno::Any> const& /*rSequence*/) +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* com_sun_star_comp_Writer_WriterFilter_get_implementation(uno::XComponentContext* component, uno::Sequence<uno::Any> const& /*rSequence*/) { return cppu::acquire(new WriterFilter(component)); } |