sw/source/filter/ww8/docxexport.cxx | 44 ++++++++++++++++++++++++++++++++++++ sw/source/filter/ww8/docxexport.hxx | 3 ++ 2 files changed, 47 insertions(+)
New commits: commit b4380022a664b86bcd29aa5a8ffe27f83afe763f Author: Miguel Gomez <mago...@igalia.com> Date: Mon Sep 16 15:02:34 2013 +0200 fdo#64491: Export theme file when saving Export the theme dom tree that has been parsed when loading the file. This is necessary in order to properly reopen docx files that contain SmartArt diagrams. Change-Id: If8712352e7c70373afb542b450a69bd634632092 Reviewed-on: https://gerrit.libreoffice.org/6005 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index ff45180..3abb546 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -25,6 +25,9 @@ #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/xml/dom/XDocument.hpp> +#include <com/sun/star/xml/sax/XSAXSerializable.hpp> +#include <com/sun/star/xml/sax/Writer.hpp> #include <oox/token/tokens.hxx> #include <oox/export/drawingml.hxx> @@ -46,6 +49,7 @@ #include <ftninfo.hxx> #include <pagedesc.hxx> +#include <editeng/unoprnms.hxx> #include <editeng/editobj.hxx> #include <editeng/outlobj.hxx> #include <editeng/brushitem.hxx> @@ -345,6 +349,8 @@ void DocxExport::ExportDocument_Impl() WriteSettings(); + WriteTheme(); + delete pStyles, pStyles = NULL; delete m_pSections, m_pSections = NULL; } @@ -738,6 +744,44 @@ void DocxExport::WriteSettings() pFS->endElementNS( XML_w, XML_settings ); } +void DocxExport::WriteTheme() +{ + 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> themeDom; + uno::Sequence< beans::PropertyValue > propList; + xPropSet->getPropertyValue( pName ) >>= propList; + for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp ) + { + OUString propName = propList[nProp].Name; + if ( propName == "OOXTheme" ) + { + propList[nProp].Value >>= themeDom; + break; + } + } + + // no theme dom to write + if ( !themeDom.is() ) + return; + + m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", + "theme/theme1.xml" ); + + uno::Reference< xml::sax::XSAXSerializable > serializer( themeDom, uno::UNO_QUERY ); + uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() ); + writer->setOutputStream( GetFilter().openFragmentStream( "word/theme/theme1.xml", + "application/vnd.openxmlformats-officedocument.theme+xml" ) ); + serializer->serialize( uno::Reference< xml::sax::XDocumentHandler >( writer, uno::UNO_QUERY_THROW ), + uno::Sequence< beans::StringPair >() ); +} + VMLExport& DocxExport::VMLExporter() { return *m_pVMLExport; diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index c7a2b28..6080cbc 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -204,6 +204,9 @@ private: /// Write word/settings.xml void WriteSettings(); + /// Write word/theme/theme1.xml + void WriteTheme(); + /// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...) sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits