This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch AOO50X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 4de62358be9e68a659009d3e8e4f8abdbd41d639
Author: Jim Jagielski <[email protected]>
AuthorDate: Wed Nov 4 03:39:22 2026 -0500

    xmloff: write header and footer fills as style:background-fill in ODF 1.4 
Extended
---
 main/xmloff/inc/xmloff/xmltoken.hxx                |  1 +
 main/xmloff/source/core/xmltoken.cxx               |  1 +
 .../xmloff/source/style/PagePropertySetContext.cxx | 16 +++++++
 .../xmloff/source/style/PagePropertySetContext.hxx |  3 ++
 main/xmloff/source/style/xmlexppr.cxx              | 56 +++++++++++++++++++++-
 5 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/main/xmloff/inc/xmloff/xmltoken.hxx 
b/main/xmloff/inc/xmloff/xmltoken.hxx
index 46f3a003a6..65f24b6b38 100644
--- a/main/xmloff/inc/xmloff/xmltoken.hxx
+++ b/main/xmloff/inc/xmloff/xmltoken.hxx
@@ -3159,6 +3159,7 @@ namespace xmloff { namespace token {
         XML_HANDLE_POLAR_POLE_Y,
         XML_HANDLE_POLAR_RADIUS,
         XML_HANDLE_POLAR_ANGLE,
+        XML_BACKGROUND_FILL,
 
         XML_TOKEN_END
     };
diff --git a/main/xmloff/source/core/xmltoken.cxx 
b/main/xmloff/source/core/xmltoken.cxx
index b2f2b93607..a1e0ba8724 100644
--- a/main/xmloff/source/core/xmltoken.cxx
+++ b/main/xmloff/source/core/xmltoken.cxx
@@ -3159,6 +3159,7 @@ namespace xmloff { namespace token {
         TOKEN( "handle-polar-pole-y",          XML_HANDLE_POLAR_POLE_Y ),
         TOKEN( "handle-polar-radius",          XML_HANDLE_POLAR_RADIUS ),
         TOKEN( "handle-polar-angle",           XML_HANDLE_POLAR_ANGLE ),
+        TOKEN( "background-fill",              XML_BACKGROUND_FILL ),
 
 #if OSL_DEBUG_LEVEL > 0
         { 0, NULL, NULL,                       XML_TOKEN_END }
diff --git a/main/xmloff/source/style/PagePropertySetContext.cxx 
b/main/xmloff/source/style/PagePropertySetContext.cxx
index ca77cdf6ae..a0c7eb73db 100644
--- a/main/xmloff/source/style/PagePropertySetContext.cxx
+++ b/main/xmloff/source/style/PagePropertySetContext.cxx
@@ -25,6 +25,8 @@
 #include "precompiled_xmloff.hxx"
 #include <tools/debug.hxx>
 #include "PagePropertySetContext.hxx"
+#include <xmloff/xmltoken.hxx>
+#include "xmloff/xmlnmspe.hxx"
 #include "XMLBackgroundImageContext.hxx"
 #include "XMLTextColumnsContext.hxx"
 #ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX
@@ -36,6 +38,7 @@ using ::rtl::OUString;
 
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star;
+using namespace ::xmloff::token;
 
 PagePropertySetContext::PagePropertySetContext(
                                 SvXMLImport& rImport, sal_uInt16 nPrfx,
@@ -56,6 +59,19 @@ PagePropertySetContext::~PagePropertySetContext()
 {
 }
 
+SvXMLImportContext *PagePropertySetContext::CreateChildContext(
+                                  sal_uInt16 nPrefix,
+                                  const OUString& rLocalName,
+                                  const Reference< xml::sax::XAttributeList > 
& xAttrList )
+{
+       if( aType != Page && XML_NAMESPACE_STYLE == nPrefix && IsXMLToken( 
rLocalName, XML_BACKGROUND_FILL ) )
+               return new SvXMLPropertySetContext( GetImport(), nPrefix, 
rLocalName, xAttrList,
+                                                                               
        mnFamily, mrProperties, mxMapper,
+                                                                               
        mnStartIdx, mnEndIdx );
+
+       return SvXMLPropertySetContext::CreateChildContext( nPrefix, 
rLocalName, xAttrList );
+}
+
 SvXMLImportContext *PagePropertySetContext::CreateChildContext(
                                   sal_uInt16 nPrefix,
                                   const OUString& rLocalName,
diff --git a/main/xmloff/source/style/PagePropertySetContext.hxx 
b/main/xmloff/source/style/PagePropertySetContext.hxx
index 1deb2dae17..332ee0427c 100644
--- a/main/xmloff/source/style/PagePropertySetContext.hxx
+++ b/main/xmloff/source/style/PagePropertySetContext.hxx
@@ -51,6 +51,9 @@ public:
        virtual ~PagePropertySetContext();
 
     using SvXMLPropertySetContext::CreateChildContext;
+       virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
+                                                                  const 
::rtl::OUString& rLocalName,
+                                                                  const 
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& 
xAttrList );
        virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
                                                                   const 
::rtl::OUString& rLocalName,
                                                                   const 
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& 
xAttrList,
diff --git a/main/xmloff/source/style/xmlexppr.cxx 
b/main/xmloff/source/style/xmlexppr.cxx
index 8d96192272..5abe5efb5a 100644
--- a/main/xmloff/source/style/xmlexppr.cxx
+++ b/main/xmloff/source/style/xmlexppr.cxx
@@ -866,8 +866,48 @@ void SvXMLExportPropertyMapper::exportXML(
                {
                        SvUShorts aIndexArray;
 
+                       // ODF 1.4 Extended: header and footer fills go into a 
style:background-fill child
+                       ::std::vector< XMLPropertyState > aMainProps, 
aFillProps;
+                       const ::std::vector< XMLPropertyState >* pMainProps = 
&rProperties;
+                       SvXMLAttributeList* pFillAttrs = 0;
+                       uno::Reference< xml::sax::XAttributeList > xFillAttrs;
+                       if( aPropTokens[i].eToken == 
XML_HEADER_FOOTER_PROPERTIES &&
+                               SvtSaveOptions().GetODFDefaultVersion() == 
SvtSaveOptions::ODFVER_014_EXT )
+                       {
+                               aMainProps = rProperties;
+                               aFillProps = rProperties;
+                               bool bFill = false;
+                               for( size_t n = 0; n < rProperties.size(); ++n )
+                               {
+                                       const sal_Int32 nIdx = 
rProperties[n].mnIndex;
+                                       if( nIdx == -1 )
+                                               continue;
+                                       if( maPropMapper->GetEntryNameSpace( 
nIdx ) == XML_NAMESPACE_DRAW ||
+                                               ( 
maPropMapper->GetEntryNameSpace( nIdx ) == XML_NAMESPACE_STYLE &&
+                                                 IsXMLToken( 
maPropMapper->GetEntryXMLName( nIdx ), XML_REPEAT ) ) )
+                                       {
+                                               aMainProps[n].mnIndex = -1;
+                                               bFill = true;
+                                       }
+                                       else
+                                               aFillProps[n].mnIndex = -1;
+                               }
+                               if( bFill )
+                               {
+                                       pMainProps = &aMainProps;
+                                       pFillAttrs = new SvXMLAttributeList;
+                                       xFillAttrs = pFillAttrs;
+                                       sal_uInt16 nFillTypeFlags = 0;
+                                       _exportXML( nPropType, nFillTypeFlags, 
*pFillAttrs, aFillProps,
+                                                               
rExport.GetMM100UnitConverter(),
+                                                               
rExport.GetNamespaceMap(),
+                                                               nFlags, 0,
+                                                               
nPropMapStartIdx, nPropMapEndIdx );
+                               }
+                       }
+
                        _exportXML( nPropType, nPropTypeFlags,
-                                               rExport.GetAttrList(), 
rProperties,
+                                               rExport.GetAttrList(), 
*pMainProps,
                                                rExport.GetMM100UnitConverter(),
                                                rExport.GetNamespaceMap(),
                                                nFlags, &aIndexArray,
@@ -875,7 +915,8 @@ void SvXMLExportPropertyMapper::exportXML(
 
                        if( rExport.GetAttrList().getLength() > 0L ||
                                (nFlags & XML_EXPORT_FLAG_EMPTY) != 0 ||
-                               aIndexArray.Count() != 0 )
+                               aIndexArray.Count() != 0 ||
+                               ( pFillAttrs && pFillAttrs->getLength() > 0 ) )
                        {
                                sal_uInt16 nElemPrefix = XML_NAMESPACE_STYLE;
                                // ODF 1.4 Extended: paragraph fills are not 
valid in style:graphic-properties
@@ -896,6 +937,17 @@ void SvXMLExportPropertyMapper::exportXML(
                                                                  sal_False );
 
                                exportElementItems( rExport, rProperties, 
nFlags, aIndexArray );
+
+                               if( pFillAttrs && pFillAttrs->getLength() > 0 )
+                               {
+                                       for( sal_Int16 n = 0; n < 
pFillAttrs->getLength(); ++n )
+                                               rExport.AddAttribute( 
pFillAttrs->getNameByIndex( n ),
+                                                                               
          pFillAttrs->getValueByIndex( n ) );
+                                       SvXMLElementExport aFillElem( rExport, 
XML_NAMESPACE_STYLE,
+                                                                         
XML_BACKGROUND_FILL,
+                                                                         
(nFlags & XML_EXPORT_FLAG_IGN_WS) != 0,
+                                                                         
sal_False );
+                               }
                        }
                }
        }

Reply via email to