diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-05-28 14:28:29 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2021-01-07 16:32:56 +0100 |
commit | 03f5747ff6d8fb72693f4e9c5a23c84a08324644 (patch) | |
tree | 2fa41f9edb84ea1bc105acefd5b291e96407c098 /xmloff | |
parent | 90bc7782050fc75ec560d4d157edcd91cff58773 (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>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/style/PageMasterExportPropMapper.cxx | 58 | ||||
-rw-r--r-- | xmloff/source/style/PageMasterPropHdlFactory.cxx | 3 | ||||
-rw-r--r-- | xmloff/source/style/PageMasterStyleMap.cxx | 4 |
3 files changed, 64 insertions, 1 deletions
diff --git a/xmloff/source/style/PageMasterExportPropMapper.cxx b/xmloff/source/style/PageMasterExportPropMapper.cxx index 377f76f4bc18..d364ebc9f796 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 <xmloff/PageMasterStyleMap.hxx> #include <rtl/ref.hxx> #include <comphelper/extract.hxx> @@ -324,6 +326,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 ) @@ -344,6 +349,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; @@ -540,6 +559,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 fc7fde3d9494..b3a18ebfed9c 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 232a2276bf2c..641b7471450d 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), |