diff options
-rw-r--r-- | writerfilter/inc/ooxml/OOXMLDocument.hxx | 3 | ||||
-rw-r--r-- | writerfilter/source/filter/ImportFilter.cxx | 6 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 68 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLDocumentImpl.hxx | 4 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLStreamImpl.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLStreamImpl.hxx | 1 |
6 files changed, 91 insertions, 3 deletions
diff --git a/writerfilter/inc/ooxml/OOXMLDocument.hxx b/writerfilter/inc/ooxml/OOXMLDocument.hxx index 13f365e93332..4bbc31bacda1 100644 --- a/writerfilter/inc/ooxml/OOXMLDocument.hxx +++ b/writerfilter/inc/ooxml/OOXMLDocument.hxx @@ -76,7 +76,7 @@ class WRITERFILTER_OOXML_DLLPUBLIC OOXMLStream { public: enum StreamType_t { UNKNOWN, DOCUMENT, STYLES, WEBSETTINGS, FONTTABLE, NUMBERING, - FOOTNOTES, ENDNOTES, COMMENTS, THEME, CUSTOMXML, CUSTOMXMLPROPS, ACTIVEX, ACTIVEXBIN, GLOSSARY, SETTINGS, VBAPROJECT }; + FOOTNOTES, ENDNOTES, COMMENTS, THEME, CUSTOMXML, CUSTOMXMLPROPS, ACTIVEX, ACTIVEXBIN, GLOSSARY, CHARTS, EMBEDDINGS, SETTINGS, VBAPROJECT }; typedef boost::shared_ptr<OOXMLStream> Pointer_t; virtual ~OOXMLStream() {} @@ -248,6 +248,7 @@ public: virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getCustomXmlDomPropsList( ) = 0; virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getActiveXDomList( ) = 0; virtual uno::Sequence<uno::Reference<io::XInputStream> > getActiveXBinList() = 0; + virtual uno::Sequence<beans::PropertyValue > getEmbeddingsList() = 0; }; diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx index 90c4c98d1d38..ac2902d0e8c1 100644 --- a/writerfilter/source/filter/ImportFilter.cxx +++ b/writerfilter/source/filter/ImportFilter.cxx @@ -119,7 +119,7 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes pDocument->resolve(*pStream); // Adding some properties to the document's grab bag for interoperability purposes: - uno::Sequence<beans::PropertyValue> aGrabBagProperties(8); + uno::Sequence<beans::PropertyValue> aGrabBagProperties(9); // Adding the saved Theme DOM aGrabBagProperties[0].Name = "OOXTheme"; @@ -147,6 +147,10 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes aGrabBagProperties[7].Name = "OOXGlossaryDom"; aGrabBagProperties[7].Value = uno::makeAny( pDocument->getGlossaryDomList() ); + // Adding the saved embedding document to document's grab bag + aGrabBagProperties[8].Name = "OOXEmbeddings"; + aGrabBagProperties[8].Value = uno::makeAny( pDocument->getEmbeddingsList() ); + putPropertiesToDocumentGrabBag( aGrabBagProperties ); writerfilter::ooxml::OOXMLStream::Pointer_t pVBAProjectStream(writerfilter::ooxml::OOXMLDocumentFactory::createStream( pDocStream, writerfilter::ooxml::OOXMLStream::VBAPROJECT )); diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx index cf4de5cf2b05..05292a567631 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx @@ -35,6 +35,7 @@ // this extern variable is declared in OOXMLStreamImpl.hxx OUString customTarget; +OUString embeddingsTarget; using ::com::sun::star::xml::sax::SAXException; namespace writerfilter { namespace ooxml @@ -157,6 +158,10 @@ uno::Reference<xml::dom::XDocument> OOXMLDocumentImpl::importSubStream(OOXMLStre { importSubStreamRelations(pStream, OOXMLStream::ACTIVEXBIN); } + if(OOXMLStream::CHARTS == nType) + { + importSubStreamRelations(pStream, OOXMLStream::EMBEDDINGS); + } return xRet; } @@ -207,6 +212,11 @@ void OOXMLDocumentImpl::importSubStreamRelations(OOXMLStream::Pointer_t pStream, // imporing activex.bin files for activex.xml from activeX folder. mxActiveXBin = xcpInputStream; } + else if(OOXMLStream::EMBEDDINGS == nType) + { + // imporing activex.bin files for activex.xml from activeX folder. + mxEmbeddings = xcpInputStream; + } } @@ -441,6 +451,9 @@ void OOXMLDocumentImpl::resolve(Stream & rStream) mxGlossaryDocDom = importSubStream(OOXMLStream::GLOSSARY); if (mxGlossaryDocDom.is()) resolveGlossaryStream(rStream); + + resolveEmbeddingsStream(rStream); + // Custom xml's are handled as part of grab bag. resolveCustomXmlStream(rStream); @@ -627,6 +640,56 @@ void OOXMLDocumentImpl::resolveGlossaryStream(Stream & /*rStream*/) } } +void OOXMLDocumentImpl::resolveEmbeddingsStream(Stream & /*rStream*/) +{ + uno::Reference<embed::XRelationshipAccess> mxRelationshipAccess; + mxRelationshipAccess.set((*dynamic_cast<OOXMLStreamImpl *>(mpStream.get())).accessDocumentStream(), uno::UNO_QUERY_THROW); + if (mxRelationshipAccess.is()) + { + OUString sChartType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"); + OUString sTarget("Target"); + bool bFound = false; + sal_Int32 counter = 0; + uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs = + mxRelationshipAccess->getAllRelationships(); + uno::Sequence<beans::PropertyValue > mxEmbeddingsListTemp(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]; + if (aPair.Second.compareTo(sChartType) == 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 chart.xml target is visited in lcl_getTarget. + customTarget = aPair.Second; + } + } + if(bFound) + { + uno::Reference<xml::dom::XDocument> chartTemp = importSubStream(OOXMLStream::CHARTS); + beans::PropertyValue embeddingsTemp; + // This will add all ActiveX[n].xml to grabbag list. + if(chartTemp.is()) + { + if(mxEmbeddings.is()) + { + embeddingsTemp.Name = embeddingsTarget; + embeddingsTemp.Value = uno::makeAny(mxEmbeddings); + mxEmbeddingsListTemp[counter] = embeddingsTemp; + } + counter++; + } + bFound = false; + } + } + mxEmbeddingsListTemp.realloc(counter); + mxEmbeddingsList = mxEmbeddingsListTemp; + } +} void OOXMLDocumentImpl::resolveActiveXStream(Stream & rStream) { @@ -776,6 +839,11 @@ uno::Sequence<uno::Reference<io::XInputStream> > OOXMLDocumentImpl::getActiveXBi return mxActiveXBinList; } +uno::Sequence<beans::PropertyValue > OOXMLDocumentImpl::getEmbeddingsList( ) +{ + return mxEmbeddingsList; +} + OOXMLDocument * OOXMLDocumentFactory::createDocument (OOXMLStream::Pointer_t pStream) diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx index ae4d695dd1e0..0c4cd01b1049 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx @@ -50,6 +50,8 @@ class OOXMLDocumentImpl : public OOXMLDocument uno::Sequence<uno::Reference<xml::dom::XDocument> > mxActiveXDomList; uno::Sequence<uno::Reference<io::XInputStream> > mxActiveXBinList; uno::Reference<io::XInputStream> mxActiveXBin; + uno::Reference<io::XInputStream> mxEmbeddings; + uno::Sequence < beans::PropertyValue > mxEmbeddingsList; bool mbIsSubstream; protected: @@ -76,6 +78,7 @@ protected: void resolveCustomXmlStream(Stream & rStream); void resolveActiveXStream(Stream & rStream); void resolveGlossaryStream(Stream & rStream); + void resolveEmbeddingsStream(Stream & rStream); public: OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream); virtual ~OOXMLDocumentImpl(); @@ -127,6 +130,7 @@ public: virtual uno::Sequence<uno::Reference<io::XInputStream> > getActiveXBinList(); virtual uno::Reference<xml::dom::XDocument> getGlossaryDocDom(); virtual uno::Sequence<uno::Sequence< uno::Any> > getGlossaryDomList(); + virtual uno::Sequence<beans::PropertyValue > getEmbeddingsList(); }; }} #endif // OOXML_DOCUMENT_IMPL_HXX diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx index c119cfb4f511..d278805aa0eb 100644 --- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx @@ -117,6 +117,8 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> static OUString sGlossaryType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument"); static OUString sWebSettings("http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"); static OUString sSettingsType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"); + static OUString sChartType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"); + static OUString sEmbeddingsType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); static OUString sTarget("Target"); static OUString sTargetMode("TargetMode"); static OUString sExternal("External"); @@ -174,6 +176,12 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> case WEBSETTINGS: sStreamType = sWebSettings; break; + case CHARTS: + sStreamType = sChartType; + break; + case EMBEDDINGS: + sStreamType = sEmbeddingsType; + break; default: break; } @@ -202,7 +210,7 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> else if (aPair.First.compareTo(sTarget) == 0) { // checking item[n].xml or activex[n].xml is not visited already. - if(customTarget != aPair.Second && (sStreamType == sCustomType || sStreamType == sActiveXType)) + if(customTarget != aPair.Second && (sStreamType == sCustomType || sStreamType == sActiveXType || sStreamType == sChartType)) { bFound = false; } @@ -233,6 +241,8 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess> // path will start with the fragment separator. need to // remove that rDocumentTarget = rDocumentTarget.copy( 1 ); + if(sStreamType == sEmbeddingsType) + embeddingsTarget = rDocumentTarget; } break; diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.hxx b/writerfilter/source/ooxml/OOXMLStreamImpl.hxx index 8c0c21b9379f..4db03a29ada4 100644 --- a/writerfilter/source/ooxml/OOXMLStreamImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLStreamImpl.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/io/XStream.hpp> extern OUString customTarget; +extern OUString embeddingsTarget; namespace writerfilter { namespace ooxml |