sw/source/filter/ww8/docxexport.cxx |   37 ++++++++++--------------------------
 1 file changed, 11 insertions(+), 26 deletions(-)

New commits:
commit a3ca125a08973c8b41a7170c085dff64a89c5f07
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Jun 8 12:37:21 2023 +0900
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jun 13 15:03:32 2023 +0200

    sw: use ThemeExport instead of grab bag
    
    Change-Id: I68d300d58aaa1e5da374a8ddea4ff37e9a1e1819
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152723
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit fcccb8f8d67dd7deec772746661d2d6dff2c14a3)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152725
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/filter/ww8/docxexport.cxx 
b/sw/source/filter/ww8/docxexport.cxx
index b9c75140b7f6..7ad0f16eb6fb 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -48,11 +48,14 @@
 #include <oox/export/vmlexport.hxx>
 #include <oox/export/chartexport.hxx>
 #include <oox/export/shapes.hxx>
+#include <oox/export/ThemeExport.hxx>
 #include <oox/helper/propertyset.hxx>
 #include <oox/token/relationship.hxx>
 #include <oox/ole/olestorage.hxx>
 #include <oox/ole/olehelper.hxx>
 
+#include <svx/svdpage.hxx>
+
 #include <map>
 #include <algorithm>
 #include <condition_variable>
@@ -62,6 +65,7 @@
 #include <IDocumentSettingAccess.hxx>
 #include <IDocumentLayoutAccess.hxx>
 #include <IDocumentStylePoolAccess.hxx>
+#include <IDocumentDrawModelAccess.hxx>
 #include <docsh.hxx>
 #include <ndtxt.hxx>
 #include "wrtww8.hxx"
@@ -74,6 +78,7 @@
 #include <poolfmt.hxx>
 #include <redline.hxx>
 #include <swdbdata.hxx>
+#include <drawdoc.hxx>
 
 #include <editeng/unoprnms.hxx>
 #include <editeng/editobj.hxx>
@@ -1464,35 +1469,15 @@ void DocxExport::WriteSettings()
 
 void DocxExport::WriteTheme()
 {
-    uno::Reference< beans::XPropertySet > xPropSet( 
m_rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
-
-    uno::Reference< beans::XPropertySetInfo > xPropSetInfo = 
xPropSet->getPropertySetInfo();
-    OUString aName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
-    if ( !xPropSetInfo->hasPropertyByName( aName ) )
+    SdrPage* pPage = 
m_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+    auto const& pTheme = pPage->getSdrPageProperties().GetTheme();
+    if (!pTheme)
         return;
 
-    uno::Reference<xml::dom::XDocument> themeDom;
-    uno::Sequence< beans::PropertyValue > propList;
-    xPropSet->getPropertyValue( aName ) >>= propList;
-    auto pProp = std::find_if(std::cbegin(propList), std::cend(propList),
-        [](const beans::PropertyValue& rProp) { return rProp.Name == 
"OOXTheme"; });
-    if (pProp != std::cend(propList))
-        pProp->Value >>= themeDom;
-
-    // no theme dom to write
-    if ( !themeDom.is() )
-        return;
-
-    m_rFilter.addRelation( m_pDocumentFS->getOutputStream(),
-            oox::getRelationship(Relationship::THEME),
-            u"theme/theme1.xml" );
+    m_rFilter.addRelation(m_pDocumentFS->getOutputStream(), 
oox::getRelationship(Relationship::THEME), u"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 >() );
+    oox::ThemeExport aThemeExport(&m_rFilter, oox::drawingml::DOCUMENT_DOCX);
+    aThemeExport.write(u"word/theme/theme1.xml", *pTheme);
 }
 
 // See OOXMLDocumentImpl::resolveGlossaryStream

Reply via email to