summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-05-28 14:28:29 +0200
committerMichael Stahl <michael.stahl@cib.de>2020-05-29 12:21:23 +0200
commit4166cf43d2a56b0c2e9a3bf4c15d906be025ada6 (patch)
treefc404924a82c1b172e4c4200018510e73359326a /xmloff
parentc644b2b4abe3051c0e0fc91674154c796fd326f6 (diff)
tdf#103602 xmloff: ODF export: draw:background-size attribute
... on drawing-page style; no import because Writer doesn't have the property anyway. It looks like Writer paints color, gradient, hatch and bitmap with "repeat" on the entire page, and bitmap "scaled" or "no-repeat" within the borders. Change-Id: Ia32c800a6cb537bf9df57c6a6a77a5c1dcf52aa8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95040 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 4d4404b79bf051de79f587bdafd82cc0addfc636) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95089
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/PageMasterStyleMap.hxx2
-rw-r--r--xmloff/source/style/PageMasterExportPropMapper.cxx58
-rw-r--r--xmloff/source/style/PageMasterPropHdlFactory.cxx3
-rw-r--r--xmloff/source/style/PageMasterStyleMap.cxx4
4 files changed, 66 insertions, 1 deletions
diff --git a/xmloff/inc/PageMasterStyleMap.hxx b/xmloff/inc/PageMasterStyleMap.hxx
index a57acded8f9d..f27d4ce84bbd 100644
--- a/xmloff/inc/PageMasterStyleMap.hxx
+++ b/xmloff/inc/PageMasterStyleMap.hxx
@@ -96,6 +96,8 @@
#define CTF_PM_FILLBITMAPNAME (XML_PM_CTF_START + 0x0041)
#define CTF_PM_FILLTRANSNAME (XML_PM_CTF_START + 0x0042)
#define CTF_PM_FILLBITMAPMODE (XML_PM_CTF_START + 0x0043)
+#define CTF_PM_FILL (XML_PM_CTF_START + 0x0044)
+#define CTF_PM_BACKGROUNDSIZE (XML_PM_CTF_START + 0x0045)
#define CTF_PM_SCALETO (XML_PM_CTF_START + 0x0051) // calc specific
#define CTF_PM_SCALETOPAGES (XML_PM_CTF_START + 0x0052)
diff --git a/xmloff/source/style/PageMasterExportPropMapper.cxx b/xmloff/source/style/PageMasterExportPropMapper.cxx
index 3581c9d6a720..d4c6abbc356f 100644
--- a/xmloff/source/style/PageMasterExportPropMapper.cxx
+++ b/xmloff/source/style/PageMasterExportPropMapper.cxx
@@ -23,6 +23,8 @@
#include <comphelper/types.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/BitmapMode.hpp>
#include <PageMasterStyleMap.hxx>
#include <rtl/ref.hxx>
#include <comphelper/extract.hxx>
@@ -328,6 +330,9 @@ void XMLPageMasterExportPropMapper::ContextFilter(
XMLPropertyState* pFooterRepeatOffsetX = nullptr;
XMLPropertyState* pFooterRepeatOffsetY = nullptr;
+ XMLPropertyState* pFill = nullptr;
+ XMLPropertyState* pFillBitmapMode = nullptr;
+
rtl::Reference < XMLPropertySetMapper > aPropMapper(getPropertySetMapper());
for( auto& rProp : rPropState )
@@ -348,6 +353,20 @@ void XMLPageMasterExportPropMapper::ContextFilter(
switch( nSimpleId )
{
+ case CTF_PM_FILL: // tdf#103602: add background-size attribute to ODT
+ if (nFlag != CTF_PM_HEADERFLAG && nFlag != CTF_PM_FOOTERFLAG
+ && rProp.maValue.hasValue())
+ {
+ pFill = &rProp;
+ }
+ break;
+ case CTF_PM_FILLBITMAPMODE:
+ if (nFlag != CTF_PM_HEADERFLAG && nFlag != CTF_PM_FOOTERFLAG
+ && rProp.maValue.hasValue())
+ {
+ pFillBitmapMode = &rProp;
+ }
+ break;
case CTF_PM_MARGINALL: pBuffer->pPMMarginAll = pProp; break;
case CTF_PM_BORDERALL: pBuffer->pPMBorderAll = pProp; break;
case CTF_PM_BORDERTOP: pBuffer->pPMBorderTop = pProp; break;
@@ -544,6 +563,45 @@ void XMLPageMasterExportPropMapper::ContextFilter(
lcl_AddState(rPropState, aPropMapper->FindEntryIndex(CTF_PM_PRINT_ZEROVALUES), "PrintZeroValues", rPropSet);
}
+ if (pFill)
+ { // note: only drawing-page export should write this, because CTF_PM_FILL
+ uno::Any backgroundSize;
+ switch (pFill->maValue.get<drawing::FillStyle>())
+ {
+ case drawing::FillStyle_NONE:
+ break;
+ case drawing::FillStyle_SOLID:
+ case drawing::FillStyle_GRADIENT:
+ case drawing::FillStyle_HATCH:
+ backgroundSize <<= true;
+ break;
+ case drawing::FillStyle_BITMAP:
+ assert(pFillBitmapMode);
+ switch (pFillBitmapMode->maValue.get<drawing::BitmapMode>())
+ {
+ case drawing::BitmapMode_REPEAT:
+ backgroundSize <<= true;
+ break;
+ case drawing::BitmapMode_STRETCH:
+ case drawing::BitmapMode_NO_REPEAT:
+ backgroundSize <<= false;
+ break;
+ default:
+ assert(false);
+ }
+ break;
+ default:
+ assert(false);
+ }
+
+ if (backgroundSize.hasValue())
+ {
+ auto const nIndex(aPropMapper->FindEntryIndex(CTF_PM_BACKGROUNDSIZE));
+ assert(0 <= nIndex);
+ rPropState.emplace_back(nIndex, backgroundSize);
+ }
+ }
+
SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rPropState, rPropSet);
}
diff --git a/xmloff/source/style/PageMasterPropHdlFactory.cxx b/xmloff/source/style/PageMasterPropHdlFactory.cxx
index ae61a3026874..5be8cbff8667 100644
--- a/xmloff/source/style/PageMasterPropHdlFactory.cxx
+++ b/xmloff/source/style/PageMasterPropHdlFactory.cxx
@@ -131,6 +131,9 @@ const XMLPropertyHandler* XMLPageMasterPropHdlFactory::GetPropertyHandler( sal_I
case XML_SW_TYPE_FILLSTYLE:
pHdl = new XMLEnumPropertyHdl( aXML_FillStyle_EnumMap );
break;
+ case XML_SW_TYPE_PRESPAGE_BACKSIZE:
+ pHdl = new XMLNamedBoolPropertyHdl(GetXMLToken(XML_FULL), GetXMLToken(XML_BORDER));
+ break;
case XML_SW_TYPE_FILLBITMAPSIZE:
pHdl = new XMLFillBitmapSizePropertyHandler();
break;
diff --git a/xmloff/source/style/PageMasterStyleMap.cxx b/xmloff/source/style/PageMasterStyleMap.cxx
index 7ab1b46f9d2b..3e4b0350367a 100644
--- a/xmloff/source/style/PageMasterStyleMap.cxx
+++ b/xmloff/source/style/PageMasterStyleMap.cxx
@@ -273,7 +273,9 @@ XMLPropertyMapEntry const g_XMLPageMasterDrawingPageStyleMap[] =
{
// ODF 1.3 OFFICE-3937 style of family "drawing-page" referenced from style:master-page
// duplication of relevant part of aXMLPageMasterStyleMap but as DP type
- DPMAP("FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SW_TYPE_FILLSTYLE, 0),
+ DPMAP("FillStyle", XML_NAMESPACE_DRAW, XML_FILL, XML_SW_TYPE_FILLSTYLE, CTF_PM_FILL),
+ // this does not exist yet!
+ DPMAP("BackgroundFullSize", XML_NAMESPACE_DRAW, XML_BACKGROUND_SIZE, XML_SW_TYPE_PRESPAGE_BACKSIZE|MID_FLAG_NO_PROPERTY, CTF_PM_BACKGROUNDSIZE),
DPMAP("FillColor", XML_NAMESPACE_DRAW, XML_FILL_COLOR, XML_TYPE_COLOR, 0),
DPMAP("FillColor2", XML_NAMESPACE_DRAW, XML_SECONDARY_FILL_COLOR, XML_TYPE_COLOR, 0),
DPMAP("FillGradientName", XML_NAMESPACE_DRAW, XML_FILL_GRADIENT_NAME, XML_TYPE_STYLENAME|MID_FLAG_NO_PROPERTY_IMPORT, CTF_PM_FILLGRADIENTNAME),