summaryrefslogtreecommitdiff
path: root/writerfilter/source
diff options
context:
space:
mode:
authorsushil_shinde <sushil.shinde@synerzip.com>2013-11-12 20:29:00 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-14 17:50:06 +0100
commitf4714220903cbd657fbb4d103fb5293f5b8f7cf8 (patch)
tree0108c5f195e3f2b22d09eebe14ff769828af7907 /writerfilter/source
parent8c586582d93a3aaefd9e800da87a0d1ea8a260f8 (diff)
[docx] activeX files saved in InteropGrabBag and exported.
The XDocuments representing the DOM of an OOXML's activex document is stored as the PropertyValue "OOXActiveX" into the "InteropGraBag". Added mxActiveXDomList object which holds xDocument for each activeX.xml from activeX folder. This changeset stores only activeX[n].xml files. Relationship files (example activeX.bin) from activex are not stored yet. (Working on it.) Reviewed on: https://gerrit.libreoffice.org/6654 Change-Id: I658e361211e1446ed095a73b0422da0c4f74df1c
Diffstat (limited to 'writerfilter/source')
-rw-r--r--writerfilter/source/filter/ImportFilter.cxx30
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx56
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.hxx3
-rw-r--r--writerfilter/source/ooxml/OOXMLStreamImpl.cxx6
4 files changed, 94 insertions, 1 deletions
diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx
index b7bcfb956f2e..f29e7ecac39a 100644
--- a/writerfilter/source/filter/ImportFilter.cxx
+++ b/writerfilter/source/filter/ImportFilter.cxx
@@ -187,6 +187,36 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes
SAL_WARN("writerfilter","Failed to save custom xml dom to documents grab bag");
}
+ // Adding the saved ActiveX DOM to the document's grab bag
+ 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 ) )
+ {
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+
+ // We want to keep the previous items
+ xDocProps->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
+ sal_Int32 length = aGrabBag.getLength();
+ aGrabBag.realloc(length+1);
+
+ beans::PropertyValue* pValue = aGrabBag.getArray();
+ pValue[length].Name = "OOXActiveX";
+ pValue[length].Value = uno::makeAny( pDocument->getActiveXDomList() );
+ xDocProps->setPropertyValue( aGrabBagPropName, uno::Any( aGrabBag ) );
+ }
+ }
+ }
+ catch(const uno::Exception&)
+ {
+ SAL_WARN("writerfilter","Failed to save ActiveX dom to documents grab bag");
+ }
+
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 ) );
if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() )
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index c29ac5d18617..d71c339bf274 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -431,6 +431,8 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
// Custom xml's are handled as part of grab bag.
resolveCustomXmlStream(rStream);
+ resolveActiveXStream(rStream);
+
resolveFastSubStream(rStream, OOXMLStream::FONTTABLE);
resolveFastSubStream(rStream, OOXMLStream::STYLES);
resolveFastSubStream(rStream, OOXMLStream::NUMBERING);
@@ -511,6 +513,55 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
}
}
+void OOXMLDocumentImpl::resolveActiveXStream(Stream & rStream)
+{
+ // Resolving all ActiveX[n].xml files from ActiveX folder.
+ uno::Reference<embed::XRelationshipAccess> mxRelationshipAccess;
+ mxRelationshipAccess.set((*dynamic_cast<OOXMLStreamImpl *>(mpStream.get())).accessDocumentStream(), uno::UNO_QUERY_THROW);
+ if (mxRelationshipAccess.is())
+ {
+ OUString sCustomType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/control");
+ OUString sTarget("Target");
+ bool bFound = false;
+ sal_Int32 counter = 0;
+ uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs =
+ mxRelationshipAccess->getAllRelationships();
+ uno::Sequence<uno::Reference<xml::dom::XDocument> > mxActiveXDomListTemp(aSeqs.getLength());
+ for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
+ {
+ uno::Sequence< beans::StringPair > aSeq = aSeqs[j];
+ for (sal_Int32 i = 0; i < aSeq.getLength(); i++)
+ {
+ beans::StringPair aPair = aSeq[i];
+ // Need to resolve only ActiveX files from document relationships.
+ // Skipping other files.
+ if (aPair.Second.compareTo(sCustomType) == 0)
+ bFound = true;
+ else if(aPair.First.compareTo(sTarget) == 0 && bFound)
+ {
+ // Adding value to extern variable customTarget. It will be used in ooxmlstreamimpl
+ // to ensure ActiveX.xml target is visited in lcl_getTarget.
+ customTarget = aPair.Second;
+ }
+ }
+ if(bFound)
+ {
+ uno::Reference<xml::dom::XDocument> activeXTemp = importSubStream(OOXMLStream::ACTIVEX);
+ // This will add all ActiveX[n].xml to grabbag list.
+ if(activeXTemp.is())
+ {
+ mxActiveXDomListTemp[counter] = activeXTemp;
+ counter++;
+ resolveFastSubStream(rStream, OOXMLStream::ACTIVEX);
+ }
+ bFound = false;
+ }
+ }
+ mxActiveXDomListTemp.realloc(counter);
+ mxActiveXDomList = mxActiveXDomListTemp;
+ }
+}
+
uno::Reference<io::XInputStream> OOXMLDocumentImpl::getInputStreamForId(const OUString & rId)
{
OOXMLStream::Pointer_t pStream(OOXMLDocumentFactory::createStream(mpStream, rId));
@@ -583,6 +634,11 @@ uno::Sequence<uno::Reference<xml::dom::XDocument> > OOXMLDocumentImpl::getCustom
return mxCustomXmlDomPropsList;
}
+uno::Sequence<uno::Reference<xml::dom::XDocument> > OOXMLDocumentImpl::getActiveXDomList( )
+{
+ return mxActiveXDomList;
+}
+
OOXMLDocument *
OOXMLDocumentFactory::createDocument
(OOXMLStream::Pointer_t pStream)
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
index 07511331e8fe..74c1006425eb 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
@@ -45,6 +45,7 @@ class OOXMLDocumentImpl : public OOXMLDocument
uno::Sequence<uno::Reference<xml::dom::XDocument> > mxCustomXmlDomList;
uno::Sequence<uno::Reference<xml::dom::XDocument> > mxCustomXmlDomPropsList;
uno::Reference<xml::dom::XDocument> mxCustomXmlProsDom;
+ uno::Sequence<uno::Reference<xml::dom::XDocument> > mxActiveXDomList;
bool mbIsSubstream;
protected:
@@ -69,6 +70,7 @@ protected:
void setIsSubstream( bool bSubstream ) { mbIsSubstream = bSubstream; };
void resolveCustomXmlStream(Stream & rStream);
+ void resolveActiveXStream(Stream & rStream);
public:
OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream);
@@ -117,6 +119,7 @@ public:
virtual uno::Reference<xml::dom::XDocument> getThemeDom();
virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getCustomXmlDomList();
virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getCustomXmlDomPropsList();
+ virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getActiveXDomList();
};
}}
#endif // OOXML_DOCUMENT_IMPL_HXX
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index 333df28b2242..8b658c51faeb 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -112,6 +112,7 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
static OUString sThemeType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme");
static OUString sCustomType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml");
static OUString sCustomPropsType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps");
+ static OUString sActiveXType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/control");
static OUString sSettingsType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings");
static OUString sTarget("Target");
static OUString sTargetMode("TargetMode");
@@ -155,6 +156,9 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
case CUSTOMXMLPROPS:
sStreamType = sCustomPropsType;
break;
+ case ACTIVEX:
+ sStreamType = sActiveXType;
+ break;
case SETTINGS:
sStreamType = sSettingsType;
break;
@@ -186,7 +190,7 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
else if (aPair.First.compareTo(sTarget) == 0)
{
// checking item[n].xml is not visited already.
- if(customTarget != aPair.Second && sStreamType == sCustomType)
+ if(customTarget != aPair.Second && (sStreamType == sCustomType || sStreamType == sActiveXType))
{
bFound = false;
}