summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiguel Gomez <magomez@igalia.com>2013-09-16 15:02:34 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-09-20 09:23:05 +0000
commitb4380022a664b86bcd29aa5a8ffe27f83afe763f (patch)
tree1b2aade2e120a218dbbafd457e0eede44cd8d87f /sw
parent2232781ad303864b79a3973b5b0eec40a859a701 (diff)
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 <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxexport.cxx44
-rw-r--r--sw/source/filter/ww8/docxexport.hxx3
2 files changed, 47 insertions, 0 deletions
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index ff451807c0a4..3abb5467a97b 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 c7a2b2888c3e..6080cbc49637 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 );