summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-06-30 00:47:27 +0900
committerMiklos Vajna <vmiklos@collabora.com>2023-08-25 10:30:34 +0200
commit4d9bd4dbc1261d21e10f81942b2fcf9e4b283f38 (patch)
tree7fe966a8f4421afd141c540ef17d5522773dd9cf
parentaa64eff44b3b6d0bf5c96f851e5181ce1909d604 (diff)
sc: OOXML import and export the model::Theme properly
Change-Id: I76fc928a53d007a9f5e9174167e0594208a4b47a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153784 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 9a6cdc8a90cd32e8d9ecdae6fb6684cfa8aadbab) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156068 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sc/source/filter/excel/excdoc.cxx26
-rw-r--r--sc/source/filter/oox/workbookfragment.cxx8
2 files changed, 34 insertions, 0 deletions
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index c01dde32981c..cdee12a7c11c 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -53,6 +53,10 @@
#include <o3tl/safeint.hxx>
#include <oox/token/tokens.hxx>
#include <oox/token/namespaces.hxx>
+#include <oox/token/relationship.hxx>
+#include <oox/export/ThemeExport.hxx>
+#include <docmodel/theme/Theme.hxx>
+#include <svx/svdpage.hxx>
#include <memory>
using namespace oox;
@@ -861,6 +865,28 @@ void ExcDocument::WriteXml( XclExpXmlStream& rStrm )
{
InitializeSave();
+ auto* pDrawLayer = GetDoc().GetDrawLayer();
+ if (pDrawLayer)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(0);
+ if (pPage)
+ {
+ std::shared_ptr<model::Theme> pTheme = pPage->getSdrPageProperties().GetTheme();
+ if (pTheme)
+ {
+ OUString sThemeRelationshipPath = "theme/theme1.xml";
+ OUString sThemeDocumentPath = "xl/" + sThemeRelationshipPath;
+
+ oox::ThemeExport aThemeExport(&rStrm, oox::drawingml::DOCUMENT_XLSX);
+ aThemeExport.write(sThemeDocumentPath, *pTheme);
+
+ rStrm.addRelation(rStrm.GetCurrentStream()->getOutputStream(),
+ oox::getRelationship(Relationship::THEME),
+ sThemeRelationshipPath);
+ }
+ }
+ }
+
aHeader.WriteXml( rStrm );
for( size_t nTab = 0, nTabCount = maTableList.GetSize(); nTab < nTabCount; ++nTab )
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index b86c15def16b..08df44404eb4 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -64,6 +64,7 @@
#include <vcl/weld.hxx>
#include <oox/core/fastparser.hxx>
+#include <svx/svdpage.hxx>
#include <comphelper/threadpool.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
@@ -486,6 +487,12 @@ void WorkbookFragment::finalizeImport()
// load all worksheets
importSheetFragments(*this, aSheetFragments);
+ SdrPage* pPage = pModel->GetPage(0);
+ if (pPage && pTheme && !pTheme->GetName().isEmpty())
+ {
+ pPage->getSdrPageProperties().SetTheme(pTheme);
+ }
+
// assumes getTables().finalizeImport ( which creates the DatabaseRanges )
// has been called already
getTables().applyAutoFilters();
@@ -512,6 +519,7 @@ void WorkbookFragment::finalizeImport()
rxSheetGlob.reset();
}
+
getDocImport().finalize();
recalcFormulaCells();