summaryrefslogtreecommitdiff
path: root/writerfilter/source
diff options
context:
space:
mode:
authorsushil_shinde <sushil.shinde@synerzip.com>2013-11-07 10:45:03 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-11-13 10:27:28 +0100
commit52ee03760e26e2ac7eb2561e96ab557ad287de58 (patch)
tree6d2cfbb823dee012397eb9055c86e0462e64cd2e /writerfilter/source
parent97747499b26314bb308b12cd331bf0d99f21c96c (diff)
[docx] CustomXml relationship files saved in InteropGrabBag and exported.
The XDocuments representing the DOM of an OOXML's customxml property document is stored as the PropertyValue "OOXCustomXmlProps" into the "InteropGraBag". Added mxCustomXmlDomPropList object which holds xDocument for each itemProps.xml from relationship of item.xml. Exporting all itemprops files from customxml. Reviewed on: https://gerrit.libreoffice.org/6603 Change-Id: I3973e6ce40382bbc4da247b5b27d99b03e851744
Diffstat (limited to 'writerfilter/source')
-rw-r--r--writerfilter/source/filter/ImportFilter.cxx7
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx77
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.hxx5
-rw-r--r--writerfilter/source/ooxml/OOXMLStreamImpl.cxx4
4 files changed, 86 insertions, 7 deletions
diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx
index 36bbbc7274d9..e9a429cc515e 100644
--- a/writerfilter/source/filter/ImportFilter.cxx
+++ b/writerfilter/source/filter/ImportFilter.cxx
@@ -167,13 +167,18 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes
// We want to keep the previous items
xDocProps->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
sal_Int32 length = aGrabBag.getLength();
- aGrabBag.realloc(length+1);
+ aGrabBag.realloc(length+2);
beans::PropertyValue* pValue = aGrabBag.getArray();
pValue[length].Name = "OOXCustomXml";
pValue[length].Value = uno::makeAny( pDocument->getCustomXmlDomList() );
+ pValue[length+1].Name = "OOXCustomXmlProps";
+ pValue[length+1].Value = uno::makeAny( pDocument->getCustomXmlDomPropsList() );
+
xDocProps->setPropertyValue( aGrabBagPropName, uno::Any( aGrabBag ) );
+
+
}
}
}
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index 776344779ae1..c29ac5d18617 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -149,9 +149,59 @@ uno::Reference<xml::dom::XDocument> OOXMLDocumentImpl::importSubStream(OOXMLStre
}
}
+ if(OOXMLStream::CUSTOMXML == nType)
+ {
+ importSubStreamRelations(pStream, OOXMLStream::CUSTOMXMLPROPS);
+ }
+
return xRet;
}
+
+void OOXMLDocumentImpl::importSubStreamRelations(OOXMLStream::Pointer_t pStream, OOXMLStream::StreamType_t nType)
+{
+ // imporing itemprops files for item.xml from customXml.
+ if(OOXMLStream::CUSTOMXMLPROPS == nType)
+ {
+ uno::Reference<xml::dom::XDocument> xCustomProps;
+ OOXMLStream::Pointer_t cStream;
+ try
+ {
+ cStream = OOXMLDocumentFactory::createStream(pStream, OOXMLStream::CUSTOMXMLPROPS);
+ }
+ catch (uno::Exception const& e)
+ {
+ SAL_WARN("writerfilter", "importSubStreamRelations: exception while "
+ "importing stream " << nType << " : " << e.Message);
+ mxCustomXmlProsDom = xCustomProps;
+ }
+
+ uno::Reference<io::XInputStream> xcpInputStream =
+ cStream->getDocumentStream();
+
+ if (xcpInputStream.is())
+ {
+ try
+ {
+ uno::Reference<uno::XComponentContext> xcpContext(pStream->getContext());
+ uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder(xml::dom::DocumentBuilder::create(xcpContext));
+ xCustomProps = xDomBuilder->parse(xcpInputStream);
+ }
+ catch (uno::Exception const& e)
+ {
+ SAL_WARN("writerfilter", "importSubStream: exception while "
+ "parsing stream " << nType << " : " << e.Message);
+ mxCustomXmlProsDom = xCustomProps;
+ }
+ }
+
+ if(xCustomProps.is())
+ {
+ mxCustomXmlProsDom = xCustomProps;
+ }
+ }
+}
+
void OOXMLDocumentImpl::setXNoteId(const sal_Int32 nId)
{
mnXNoteId = nId;
@@ -416,10 +466,11 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
OUString sCustomType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml");
OUString sTarget("Target");
bool bFound = false;
- sal_Int32 counter = 1;
+ sal_Int32 counter = 0;
uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs =
mxRelationshipAccess->getAllRelationships();
uno::Sequence<uno::Reference<xml::dom::XDocument> > mxCustomXmlDomListTemp(aSeqs.getLength());
+ uno::Sequence<uno::Reference<xml::dom::XDocument> > mxCustomXmlDomPropsListTemp(aSeqs.getLength());
for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
{
uno::Sequence< beans::StringPair > aSeq = aSeqs[j];
@@ -439,15 +490,24 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
}
if(bFound)
{
- uno::Reference<xml::dom::XDocument> temp = importSubStream(OOXMLStream::CUSTOMXML);
- mxCustomXmlDomListTemp[counter] = temp;
- counter++;
- resolveFastSubStream(rStream, OOXMLStream::CUSTOMXML);
+ uno::Reference<xml::dom::XDocument> customXmlTemp = importSubStream(OOXMLStream::CUSTOMXML);
+ // This will add all item[n].xml with it's relationship file i.e itemprops.xml to
+ // grabbag list.
+ if(mxCustomXmlProsDom.is() && customXmlTemp.is())
+ {
+ mxCustomXmlDomListTemp[counter] = customXmlTemp;
+ mxCustomXmlDomPropsListTemp[counter] = mxCustomXmlProsDom;
+ counter++;
+ resolveFastSubStream(rStream, OOXMLStream::CUSTOMXML);
+ }
bFound = false;
}
}
- mxCustomXmlDomListTemp.realloc(counter+1);
+
+ mxCustomXmlDomListTemp.realloc(counter);
+ mxCustomXmlDomPropsListTemp.realloc(counter);
mxCustomXmlDomList = mxCustomXmlDomListTemp;
+ mxCustomXmlDomPropsList = mxCustomXmlDomPropsListTemp;
}
}
@@ -518,6 +578,11 @@ uno::Sequence<uno::Reference<xml::dom::XDocument> > OOXMLDocumentImpl::getCustom
return mxCustomXmlDomList;
}
+uno::Sequence<uno::Reference<xml::dom::XDocument> > OOXMLDocumentImpl::getCustomXmlDomPropsList( )
+{
+ return mxCustomXmlDomPropsList;
+}
+
OOXMLDocument *
OOXMLDocumentFactory::createDocument
(OOXMLStream::Pointer_t pStream)
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
index 2ec5033a7ead..07511331e8fe 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
@@ -43,6 +43,8 @@ class OOXMLDocumentImpl : public OOXMLDocument
uno::Reference<xml::sax::XFastShapeContextHandler> mxShapeContext;
uno::Reference<xml::dom::XDocument> mxThemeDom;
uno::Sequence<uno::Reference<xml::dom::XDocument> > mxCustomXmlDomList;
+ uno::Sequence<uno::Reference<xml::dom::XDocument> > mxCustomXmlDomPropsList;
+ uno::Reference<xml::dom::XDocument> mxCustomXmlProsDom;
bool mbIsSubstream;
protected:
@@ -55,6 +57,8 @@ protected:
uno::Reference<xml::dom::XDocument> importSubStream(OOXMLStream::StreamType_t nType);
+ void importSubStreamRelations(OOXMLStream::Pointer_t pStream, OOXMLStream::StreamType_t nType);
+
writerfilter::Reference<Stream>::Pointer_t
getSubStream(const OUString & rId);
@@ -112,6 +116,7 @@ public:
virtual void setThemeDom(uno::Reference<xml::dom::XDocument> xThemeDom);
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();
};
}}
#endif // OOXML_DOCUMENT_IMPL_HXX
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index c1cb79811ea9..333df28b2242 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -111,6 +111,7 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
static OUString sCommentsType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments");
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 sSettingsType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings");
static OUString sTarget("Target");
static OUString sTargetMode("TargetMode");
@@ -151,6 +152,9 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
case CUSTOMXML:
sStreamType = sCustomType;
break;
+ case CUSTOMXMLPROPS:
+ sStreamType = sCustomPropsType;
+ break;
case SETTINGS:
sStreamType = sSettingsType;
break;