summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/source/xstor/owriteablestream.cxx4
-rw-r--r--sw/qa/extras/ooxmlexport/data/testGlossary.docxbin0 -> 25741 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx8
-rw-r--r--sw/source/filter/ww8/docxexport.cxx76
-rw-r--r--sw/source/filter/ww8/docxexport.hxx2
-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
10 files changed, 229 insertions, 5 deletions
diff --git a/package/source/xstor/owriteablestream.cxx b/package/source/xstor/owriteablestream.cxx
index 9d987a5fbe7b..bc7086ef5564 100644
--- a/package/source/xstor/owriteablestream.cxx
+++ b/package/source/xstor/owriteablestream.cxx
@@ -3104,6 +3104,10 @@ void SAL_CALL OWriteStream::setPropertyValue( const OUString& aPropertyName, con
else if ( m_pData->m_nStorageType == embed::StorageFormats::PACKAGE
&& ( aPropertyName == "IsEncrypted" || aPropertyName == "Encrypted" ) )
throw beans::PropertyVetoException(); // TODO
+ else if ( aPropertyName == "RelId" )
+ {
+ aValue >>= m_pImpl->m_nRelId;
+ }
else
throw beans::UnknownPropertyException(); // TODO
diff --git a/sw/qa/extras/ooxmlexport/data/testGlossary.docx b/sw/qa/extras/ooxmlexport/data/testGlossary.docx
new file mode 100644
index 000000000000..eb05758d2e59
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/testGlossary.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 726783889794..a7e28cf31b3c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2115,6 +2115,14 @@ DECLARE_OOXMLEXPORT_TEST(testcolumnbreak, "columnbreak.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[1]/w:br", "type", "column");
}
+DECLARE_OOXMLEXPORT_TEST(testGlossary, "testGlossary.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/glossary/document.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc, "/w:glossaryDocument", "Ignorable", "w14 wp14");
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 6c7a66b608ca..2edcf5654db8 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -64,7 +64,7 @@
#include "ww8par.hxx"
#include "ww8scan.hxx"
-
+#include <oox/token/properties.hxx>
#include <comphelper/string.hxx>
#include <rtl/ustrbuf.hxx>
#include <vcl/font.hxx>
@@ -361,6 +361,8 @@ void DocxExport::ExportDocument_Impl()
WriteTheme();
+ WriteGlossary();
+
WriteCustomXml();
WriteActiveX();
@@ -831,6 +833,78 @@ void DocxExport::WriteTheme()
uno::Sequence< beans::StringPair >() );
}
+void DocxExport::WriteGlossary()
+{
+ uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
+ OUString pName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
+ if ( !xPropSetInfo->hasPropertyByName( pName ) )
+ return;
+
+ uno::Reference<xml::dom::XDocument> glossaryDocDom;
+ uno::Sequence< uno::Sequence< uno::Any> > glossaryDomList;
+ uno::Sequence< beans::PropertyValue > propList;
+ xPropSet->getPropertyValue( pName ) >>= propList;
+ sal_Int32 collectedProperties = 0;
+ for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
+ {
+ OUString propName = propList[nProp].Name;
+ if ( propName == "OOXGlossary" )
+ {
+ propList[nProp].Value >>= glossaryDocDom;
+ collectedProperties++;
+ }
+ if (propName == "OOXGlossaryDom")
+ {
+ propList[nProp].Value >>= glossaryDomList;
+ collectedProperties++;
+ }
+ if (collectedProperties == 2)
+ break;
+ }
+
+ // no glossary dom to write
+ if ( !glossaryDocDom.is() )
+ return;
+
+ m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument",
+ "glossary/document.xml" );
+
+ uno::Reference< io::XOutputStream > xOutputStream = GetFilter().openFragmentStream( "word/glossary/document.xml",
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml" );
+
+ uno::Reference< xml::sax::XSAXSerializable > serializer( glossaryDocDom, uno::UNO_QUERY );
+ uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
+ writer->setOutputStream( xOutputStream );
+ serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
+ uno::Sequence< beans::StringPair >() );
+
+
+ sal_Int32 length = glossaryDomList.getLength();
+ for ( int i =0; i < length; i++)
+ {
+ uno::Sequence< uno::Any> glossaryElement = glossaryDomList[i];
+ OUString gTarget, gType, gId, contentType;
+ uno::Reference<xml::dom::XDocument> xDom;
+ glossaryElement[0] >>= xDom;
+ glossaryElement[1] >>= gId;
+ glossaryElement[2] >>= gType;
+ glossaryElement[3] >>= gTarget;
+ glossaryElement[4] >>= contentType;
+ gId = gId.copy(3); //"rId" only save the numeric value
+
+ PropertySet aProps(xOutputStream);
+ aProps.setAnyProperty( PROP_RelId, uno::makeAny( sal_Int32( gId.toInt32() )));
+ m_pFilter->addRelation( xOutputStream, gType, gTarget);
+ uno::Reference< xml::sax::XSAXSerializable > gserializer( xDom, uno::UNO_QUERY );
+ writer->setOutputStream(GetFilter().openFragmentStream( "word/glossary/" + gTarget, contentType ) );
+ gserializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ),
+ uno::Sequence< beans::StringPair >() );
+ }
+}
+
void DocxExport::WriteCustomXml()
{
uno::Reference< beans::XPropertySet > xPropSet( pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index 1eb75c24ea2c..cac754e0539c 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -210,6 +210,8 @@ private:
/// Write word/theme/theme1.xml
void WriteTheme();
+ void WriteGlossary();
+
/// Write customXml/item[n].xml and customXml/itemProps[n].xml
void WriteCustomXml();
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;
}