Kaydet (Commit) b4380022 authored tarafından Miguel Gomez's avatar Miguel Gomez Kaydeden (comit) Miklos Vajna

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/6005Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 2232781a
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/frame/XModel.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/token/tokens.hxx>
#include <oox/export/drawingml.hxx> #include <oox/export/drawingml.hxx>
...@@ -46,6 +49,7 @@ ...@@ -46,6 +49,7 @@
#include <ftninfo.hxx> #include <ftninfo.hxx>
#include <pagedesc.hxx> #include <pagedesc.hxx>
#include <editeng/unoprnms.hxx>
#include <editeng/editobj.hxx> #include <editeng/editobj.hxx>
#include <editeng/outlobj.hxx> #include <editeng/outlobj.hxx>
#include <editeng/brushitem.hxx> #include <editeng/brushitem.hxx>
...@@ -345,6 +349,8 @@ void DocxExport::ExportDocument_Impl() ...@@ -345,6 +349,8 @@ void DocxExport::ExportDocument_Impl()
WriteSettings(); WriteSettings();
WriteTheme();
delete pStyles, pStyles = NULL; delete pStyles, pStyles = NULL;
delete m_pSections, m_pSections = NULL; delete m_pSections, m_pSections = NULL;
} }
...@@ -738,6 +744,44 @@ void DocxExport::WriteSettings() ...@@ -738,6 +744,44 @@ void DocxExport::WriteSettings()
pFS->endElementNS( XML_w, XML_settings ); 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() VMLExport& DocxExport::VMLExporter()
{ {
return *m_pVMLExport; return *m_pVMLExport;
......
...@@ -204,6 +204,9 @@ private: ...@@ -204,6 +204,9 @@ private:
/// Write word/settings.xml /// Write word/settings.xml
void WriteSettings(); 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,...) /// 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 ); sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment