summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng8
-rw-r--r--sw/source/filter/xml/xmlexp.hxx3
-rw-r--r--sw/source/filter/xml/xmlfmte.cxx77
3 files changed, 88 insertions, 0 deletions
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index 4606e1cc282c..98e6015ad23f 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -3285,6 +3285,14 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
</rng:optional>
</rng:element>
</rng:define>
+
+ <!-- TODO no proposal -->
+ <rng:define name="style-style" combine="interleave">
+ <rng:optional>
+ <rng:ref name="loext-theme"/>
+ </rng:optional>
+ </rng:define>
+
<rng:define name="style-master-page" combine="choice">
<rng:element name="style:master-page">
<rng:ref name="style-master-page-attlist"/>
diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx
index f8cef9c40f76..1da84af86f03 100644
--- a/sw/source/filter/xml/xmlexp.hxx
+++ b/sw/source/filter/xml/xmlexp.hxx
@@ -90,6 +90,9 @@ class SwXMLExport : public SvXMLExport
SwXMLTableInfo_Impl& rTableInfo,
sal_uInt32 nHeaderRows = 0 );
+ void ExportThemeElement(const css::uno::Reference<css::drawing::XDrawPage>& xDrawPage);
+
+
virtual void ExportMeta_() override;
virtual void ExportFontDecls_() override;
virtual void ExportStyles_( bool bUsed ) override;
diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx
index 7dc23bb11b54..f3c4ca04ddfd 100644
--- a/sw/source/filter/xml/xmlfmte.cxx
+++ b/sw/source/filter/xml/xmlfmte.cxx
@@ -34,9 +34,20 @@
#include <pagedesc.hxx>
#include <cellatr.hxx>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/Color.hpp>
#include "xmlexp.hxx"
#include <SwStyleNameMapper.hxx>
#include <osl/diagnose.h>
+#include <comphelper/sequenceashashmap.hxx>
+#include <sax/tools/converter.hxx>
+
+#include <o3tl/enumrange.hxx>
+#include <svx/ColorSets.hxx>
+#include <svx/unoapi.hxx>
+#include <svx/svdpage.hxx>
+#include <docmodel/theme/ThemeColor.hxx>
+
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::uno;
@@ -169,6 +180,72 @@ void SwXMLExport::ExportStyles_( bool bUsed )
GetShapeExport()->GetShapeTableExport()->exportTableStyles();
//page defaults
GetPageExport()->exportDefaultStyle();
+
+ // Theme
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(GetModel(), UNO_QUERY);
+ if (xDrawPageSupplier.is())
+ {
+ uno::Reference<drawing::XDrawPage> xPage = xDrawPageSupplier->getDrawPage();
+ if (xPage.is())
+ ExportThemeElement(xPage);
+ }
+}
+
+void SwXMLExport::ExportThemeElement(const uno::Reference<drawing::XDrawPage>& xDrawPage)
+{
+ if ((getSaneDefaultVersion() & SvtSaveOptions::ODFSVER_EXTENDED) == 0)
+ {
+ // Do not export in standard ODF 1.3 or older.
+ return;
+ }
+
+ SdrPage* pPage = GetSdrPageFromXDrawPage(xDrawPage);
+ SAL_WARN_IF(!pPage, "oox", "Can't get SdrPage from XDrawPage");
+
+ if (!pPage)
+ return;
+
+ auto* pTheme = pPage->getSdrPageProperties().GetTheme();
+ if (!pTheme)
+ return;
+
+ if (!pTheme->GetName().isEmpty())
+ AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, pTheme->GetName());
+ SvXMLElementExport aTheme(*this, XML_NAMESPACE_LO_EXT, XML_THEME, true, true);
+
+ auto* pColorSet = pTheme->GetColorSet();
+ if (!pColorSet->getName().isEmpty())
+ AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, pColorSet->getName());
+ SvXMLElementExport aColorTable(*this, XML_NAMESPACE_LO_EXT, XML_COLOR_TABLE, true, true);
+
+ static const XMLTokenEnum aColorTokens[] =
+ {
+ XML_DK1, // Text 1
+ XML_LT1, // Background 1
+ XML_DK2, // Text 2
+ XML_LT2, // Background 2
+ XML_ACCENT1,
+ XML_ACCENT2,
+ XML_ACCENT3,
+ XML_ACCENT4,
+ XML_ACCENT5,
+ XML_ACCENT6,
+ XML_HLINK, // Hyperlink
+ XML_FOLHLINK, // Followed hyperlink
+ };
+
+ for (auto eThemeColorType : o3tl::enumrange<model::ThemeColorType>())
+ {
+ if (eThemeColorType == model::ThemeColorType::Unknown)
+ continue;
+
+ auto nColor = size_t(eThemeColorType);
+ AddAttribute(XML_NAMESPACE_LO_EXT, XML_NAME, GetXMLToken(aColorTokens[nColor]));
+ OUStringBuffer sValue;
+ sax::Converter::convertColor(sValue, pColorSet->getColor(eThemeColorType));
+ AddAttribute(XML_NAMESPACE_LO_EXT, XML_COLOR, sValue.makeStringAndClear());
+ SvXMLElementExport aColor(*this, XML_NAMESPACE_LO_EXT, XML_COLOR, true, true);
+ }
}
void SwXMLExport::collectAutoStyles()