summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorRohit Deshmukh <rohit.deshmukh@synerzip.com>2013-11-27 13:53:12 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-12-13 11:19:42 +0100
commit88b9e7f391910e534b0faf7378ec4c6929d4d44a (patch)
tree5036c66e584eae48a74f4cb3393edf40b19a2281 /writerfilter
parente9c08cfed475a61ef5612262a43eab27c96fc9bd (diff)
fdo#71786 : Implemented Glossary folder
1. Glosary folder is imported as Intrograb and exported. 2. Added unit test case Reviewed on: https://gerrit.libreoffice.org/6825 Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx writerfilter/source/filter/ImportFilter.cxx Change-Id: Ifd51a75a65e030d44d30e02cd7ab51fb088186b3
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/inc/ooxml/OOXMLDocument.hxx6
-rw-r--r--writerfilter/source/filter/ImportFilter.cxx8
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx116
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.hxx6
-rw-r--r--writerfilter/source/ooxml/OOXMLStreamImpl.cxx8
5 files changed, 140 insertions, 4 deletions
diff --git a/writerfilter/inc/ooxml/OOXMLDocument.hxx b/writerfilter/inc/ooxml/OOXMLDocument.hxx
index 97bb8764494c..13f365e93332 100644
--- a/writerfilter/inc/ooxml/OOXMLDocument.hxx
+++ b/writerfilter/inc/ooxml/OOXMLDocument.hxx
@@ -75,8 +75,8 @@ using namespace com::sun::star;
class WRITERFILTER_OOXML_DLLPUBLIC OOXMLStream
{
public:
- enum StreamType_t { UNKNOWN, DOCUMENT, STYLES, FONTTABLE, NUMBERING,
- FOOTNOTES, ENDNOTES, COMMENTS, THEME, CUSTOMXML, CUSTOMXMLPROPS, ACTIVEX, ACTIVEXBIN, SETTINGS, VBAPROJECT };
+ enum StreamType_t { UNKNOWN, DOCUMENT, STYLES, WEBSETTINGS, FONTTABLE, NUMBERING,
+ FOOTNOTES, ENDNOTES, COMMENTS, THEME, CUSTOMXML, CUSTOMXMLPROPS, ACTIVEX, ACTIVEXBIN, GLOSSARY, SETTINGS, VBAPROJECT };
typedef boost::shared_ptr<OOXMLStream> Pointer_t;
virtual ~OOXMLStream() {}
@@ -242,6 +242,8 @@ public:
virtual void setShapeContext( uno::Reference<xml::sax::XFastShapeContextHandler> xContext ) = 0;
virtual uno::Reference<xml::dom::XDocument> getThemeDom( ) = 0;
virtual void setThemeDom( uno::Reference<xml::dom::XDocument> xThemeDom ) = 0;
+ virtual uno::Reference<xml::dom::XDocument> getGlossaryDocDom( ) = 0;
+ virtual uno::Sequence<uno::Sequence< uno::Any> > getGlossaryDomList() = 0;
virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getCustomXmlDomList( ) = 0;
virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getCustomXmlDomPropsList( ) = 0;
virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getActiveXDomList( ) = 0;
diff --git a/writerfilter/source/filter/ImportFilter.cxx b/writerfilter/source/filter/ImportFilter.cxx
index 2854088a0d20..843e37a276bf 100644
--- a/writerfilter/source/filter/ImportFilter.cxx
+++ b/writerfilter/source/filter/ImportFilter.cxx
@@ -120,7 +120,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(6);
+ uno::Sequence<beans::PropertyValue> aGrabBagProperties(8);
// Adding the saved Theme DOM
aGrabBagProperties[0].Name = "OOXTheme";
@@ -142,6 +142,12 @@ sal_Bool WriterFilter::filter( const uno::Sequence< beans::PropertyValue >& aDes
aGrabBagProperties[5].Name = "ThemeFontLangProps";
aGrabBagProperties[5].Value = uno::makeAny( aDomainMapper->GetThemeFontLangProperties() );
+ // Adding the saved Glossary Documnet DOM to the document's grab bag
+ aGrabBagProperties[6].Name = "OOXGlossary";
+ aGrabBagProperties[6].Value = uno::makeAny( pDocument->getGlossaryDocDom() );
+ aGrabBagProperties[7].Name = "OOXGlossaryDom";
+ aGrabBagProperties[7].Value = uno::makeAny( pDocument->getGlossaryDomList() );
+
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 f272375b682a..2f5f28014e5f 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -438,6 +438,9 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
resolveFastSubStream(rStream, OOXMLStream::SETTINGS);
mxThemeDom = importSubStream(OOXMLStream::THEME);
resolveFastSubStream(rStream, OOXMLStream::THEME);
+ mxGlossaryDocDom = importSubStream(OOXMLStream::GLOSSARY);
+ if (mxGlossaryDocDom.is())
+ resolveGlossaryStream(rStream);
// Custom xml's are handled as part of grab bag.
resolveCustomXmlStream(rStream);
@@ -523,6 +526,109 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
}
}
+void OOXMLDocumentImpl::resolveGlossaryStream(Stream & /*rStream*/)
+{
+ static OUString sSettingsType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings");
+ static OUString sStylesWithEffects("http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects");
+ static OUString sStylesType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles");
+ static OUString sFonttableType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable");
+ static OUString sWebSettings("http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings");
+
+ OOXMLStream::Pointer_t pStream;
+ try
+ {
+ pStream = OOXMLDocumentFactory::createStream(mpStream, OOXMLStream::GLOSSARY);
+ }
+ catch (uno::Exception const& e)
+ {
+ SAL_INFO("writerfilter", "resolveGlossaryStream: exception while "
+ "createStream for glossary" << OOXMLStream::GLOSSARY << " : " << e.Message);
+ return;
+ }
+ uno::Reference<embed::XRelationshipAccess> mxRelationshipAccess;
+ mxRelationshipAccess.set((*dynamic_cast<OOXMLStreamImpl *>(pStream.get())).accessDocumentStream(), uno::UNO_QUERY_THROW);
+ if (mxRelationshipAccess.is())
+ {
+
+ uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs =
+ mxRelationshipAccess->getAllRelationships();
+ uno::Sequence<uno::Sequence< uno::Any> > mxGlossaryDomListTemp(aSeqs.getLength());
+ sal_Int32 counter = 0;
+ for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
+ {
+ OOXMLStream::Pointer_t gStream;
+ uno::Sequence< beans::StringPair > aSeq = aSeqs[j];
+ //Follows following aSeq[0] is Id, aSeq[1] is Type, aSeq[2] is Target
+ OUString gId(aSeq[0].Second);
+ OUString gType(aSeq[1].Second);
+ OUString gTarget(aSeq[2].Second);
+ OUString contentType;
+
+ OOXMLStream::StreamType_t nType;
+ bool bFound = true;
+ if(gType.compareTo(sSettingsType) == 0)
+ {
+ nType = OOXMLStream::SETTINGS;
+ contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
+ }
+ else if(gType.compareTo(sStylesType) == 0)
+ {
+ nType = OOXMLStream::STYLES;
+ contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";
+ }
+ else if(gType.compareTo(sWebSettings) == 0)
+ {
+ nType = OOXMLStream::WEBSETTINGS;
+ contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml";
+ }
+ else if(gType.compareTo(sFonttableType) == 0)
+ {
+ nType = OOXMLStream::FONTTABLE;
+ contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml";
+ }
+ else
+ {
+ bFound = false;
+ //"Unhandled content-type while grab bagging Glossary Folder");
+ }
+
+ if (bFound)
+ {
+ uno::Reference<xml::dom::XDocument> xDom;
+ try
+ {
+ gStream = OOXMLDocumentFactory::createStream(pStream, nType);
+ uno::Reference<io::XInputStream> xInputStream = gStream->getDocumentStream();
+ uno::Reference<uno::XComponentContext> xContext(pStream->getContext());
+ uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder(xml::dom::DocumentBuilder::create(xContext));
+ xDom = xDomBuilder->parse(xInputStream);
+ }
+ catch (uno::Exception const& e)
+ {
+ SAL_INFO("writerfilter glossary grab bag", "importSubStream: exception while "
+ "parsing stream of Type" << nType << " : " << e.Message);
+ return;
+ }
+
+ if (xDom.is())
+ {
+ uno::Sequence< uno::Any > glossaryTuple (5);
+ glossaryTuple[0] = uno::makeAny(xDom);
+ glossaryTuple[1] = uno::makeAny(gId);
+ glossaryTuple[2] = uno::makeAny(gType);
+ glossaryTuple[3] = uno::makeAny(gTarget);
+ glossaryTuple[4] = uno::makeAny(contentType);
+ mxGlossaryDomListTemp[counter] = glossaryTuple;
+ counter++;
+ }
+ }
+ }
+ mxGlossaryDomListTemp.realloc(counter);
+ mxGlossaryDomList = mxGlossaryDomListTemp;
+ }
+}
+
+
void OOXMLDocumentImpl::resolveActiveXStream(Stream & rStream)
{
// Resolving all ActiveX[n].xml files from ActiveX folder.
@@ -579,6 +685,16 @@ void OOXMLDocumentImpl::resolveActiveXStream(Stream & rStream)
}
}
+uno::Reference<xml::dom::XDocument> OOXMLDocumentImpl::getGlossaryDocDom( )
+{
+ return mxGlossaryDocDom;
+}
+
+uno::Sequence<uno::Sequence< uno::Any> > OOXMLDocumentImpl::getGlossaryDomList()
+{
+ return mxGlossaryDomList;
+}
+
uno::Reference<io::XInputStream> OOXMLDocumentImpl::getInputStreamForId(const OUString & rId)
{
OOXMLStream::Pointer_t pStream(OOXMLDocumentFactory::createStream(mpStream, rId));
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
index d7506cef7135..ae4d695dd1e0 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx
@@ -40,6 +40,8 @@ class OOXMLDocumentImpl : public OOXMLDocument
uno::Reference<frame::XModel> mxModel;
uno::Reference<drawing::XDrawPage> mxDrawPage;
+ uno::Reference<xml::dom::XDocument> mxGlossaryDocDom;
+ uno::Sequence < uno::Sequence< uno::Any > > mxGlossaryDomList;
uno::Reference<xml::sax::XFastShapeContextHandler> mxShapeContext;
uno::Reference<xml::dom::XDocument> mxThemeDom;
uno::Sequence<uno::Reference<xml::dom::XDocument> > mxCustomXmlDomList;
@@ -73,7 +75,7 @@ protected:
void setIsSubstream( bool bSubstream ) { mbIsSubstream = bSubstream; };
void resolveCustomXmlStream(Stream & rStream);
void resolveActiveXStream(Stream & rStream);
-
+ void resolveGlossaryStream(Stream & rStream);
public:
OOXMLDocumentImpl(OOXMLStream::Pointer_t pStream);
virtual ~OOXMLDocumentImpl();
@@ -123,6 +125,8 @@ public:
virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getCustomXmlDomPropsList();
virtual uno::Sequence<uno::Reference<xml::dom::XDocument> > getActiveXDomList();
virtual uno::Sequence<uno::Reference<io::XInputStream> > getActiveXBinList();
+ virtual uno::Reference<xml::dom::XDocument> getGlossaryDocDom();
+ virtual uno::Sequence<uno::Sequence< uno::Any> > getGlossaryDomList();
};
}}
#endif // OOXML_DOCUMENT_IMPL_HXX
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index dd6875426b33..c119cfb4f511 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -114,6 +114,8 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
static OUString sCustomPropsType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXmlProps");
static OUString sActiveXType("http://schemas.openxmlformats.org/officeDocument/2006/relationships/control");
static OUString sActiveXBinType("http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary");
+ 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 sTarget("Target");
static OUString sTargetMode("TargetMode");
@@ -166,6 +168,12 @@ bool OOXMLStreamImpl::lcl_getTarget(uno::Reference<embed::XRelationshipAccess>
case SETTINGS:
sStreamType = sSettingsType;
break;
+ case GLOSSARY:
+ sStreamType = sGlossaryType;
+ break;
+ case WEBSETTINGS:
+ sStreamType = sWebSettings;
+ break;
default:
break;
}