[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - include/xmloff xmloff/inc xmloff/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Fri May 29 10:21:57 UTC 2020


 include/xmloff/xmltypes.hxx                        |    1 
 xmloff/inc/PageMasterStyleMap.hxx                  |    2 
 xmloff/source/style/PageMasterExportPropMapper.cxx |   58 +++++++++++++++++++++
 xmloff/source/style/PageMasterPropHdlFactory.cxx   |    3 +
 xmloff/source/style/PageMasterStyleMap.cxx         |    4 +
 5 files changed, 67 insertions(+), 1 deletion(-)

New commits:
commit 4166cf43d2a56b0c2e9a3bf4c15d906be025ada6
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu May 28 14:28:29 2020 +0200
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Fri May 29 12:21:23 2020 +0200

    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 at cib.de>
    (cherry picked from commit 4d4404b79bf051de79f587bdafd82cc0addfc636)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95089

diff --git a/include/xmloff/xmltypes.hxx b/include/xmloff/xmltypes.hxx
index d3ffd809c90c..38c4b61a1085 100644
--- a/include/xmloff/xmltypes.hxx
+++ b/include/xmloff/xmltypes.hxx
@@ -291,6 +291,7 @@
 
 #define XML_TYPE_TEXT_RUBY_IS_ABOVE     (XML_TEXT_TYPES_START + 126)
 #define XML_TYPE_GRAPHIC                (XML_TEXT_TYPES_START + 127)
+#define XML_SW_TYPE_PRESPAGE_BACKSIZE   (XML_TEXT_TYPES_START + 128)
 
 #endif // INCLUDED_XMLOFF_XMLTYPES_HXX
 
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),


More information about the Libreoffice-commits mailing list