filter/source/msfilter/escherex.cxx             |    1 
 include/filter/msfilter/escherex.hxx            |    3 
 sw/inc/IDocumentDrawModelAccess.hxx             |    1 
 sw/inc/IDocumentSettingAccess.hxx               |    2 
 sw/qa/extras/layout/layout2.cxx                 |   18 ++---
 sw/qa/extras/ooxmlexport/ooxmlexport19.cxx      |    2 
 sw/source/core/doc/DocumentDrawModelManager.cxx |   13 +++-
 sw/source/core/doc/DocumentSettingManager.cxx   |   13 +++-
 sw/source/core/doc/notxtfrm.cxx                 |    2 
 sw/source/core/inc/DocumentDrawModelManager.hxx |    3 
 sw/source/core/inc/DocumentSettingManager.hxx   |    1 
 sw/source/core/inc/cellfrm.hxx                  |    2 
 sw/source/core/inc/flyfrm.hxx                   |    4 -
 sw/source/core/inc/frame.hxx                    |   10 ++-
 sw/source/core/inc/layfrm.hxx                   |    2 
 sw/source/core/inc/notxtfrm.hxx                 |    2 
 sw/source/core/inc/rootfrm.hxx                  |    2 
 sw/source/core/inc/tabfrm.hxx                   |    2 
 sw/source/core/inc/txtfrm.hxx                   |    2 
 sw/source/core/layout/fly.cxx                   |   26 ++++++--
 sw/source/core/layout/paintfrm.cxx              |   76 +++++++++++++++++++-----
 sw/source/core/layout/unusedf.cxx               |    2 
 sw/source/core/text/frmpaint.cxx                |    2 
 sw/source/core/unocore/unodraw.cxx              |    7 +-
 sw/source/core/unocore/unoframe.cxx             |   10 ++-
 sw/source/filter/ww8/docxsdrexport.cxx          |   11 +--
 sw/source/filter/ww8/wrtw8esh.cxx               |    2 
 sw/source/uibase/uno/SwXDocumentSettings.cxx    |   16 +++++
 writerfilter/source/dmapper/DomainMapper.cxx    |    2 
 writerfilter/source/filter/WriterFilter.cxx     |    2 
 30 files changed, 188 insertions(+), 53 deletions(-)

New commits:
commit ea1e37d9616383260551b8ac5789ccc185b2c0db
Author:     Oliver Specht <[email protected]>
AuthorDate: Wed Mar 13 13:04:18 2024 +0100
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Tue Jun 18 19:56:43 2024 +0200

    tdf#160198 Compatibility in background shapes/pictures
    
    Paint Word background shapes/pictures (wrapped through) above
    header and footer if the anchor is in the document body.
    
    Change-Id: Ic32ba8d64f82c64e502788007e49a9dce4c4c76f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164802
    Tested-by: Gabor Kelemen <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169085
    Tested-by: Thorsten Behrens <[email protected]>

diff --git a/filter/source/msfilter/escherex.cxx 
b/filter/source/msfilter/escherex.cxx
index caf07865941e..1b9b6cb745c7 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4867,6 +4867,7 @@ EscherEx::EscherEx(std::shared_ptr<EscherExGlobal> 
xGlobal, SvStream* pOutStrm,
     , mnCountOfs(0)
     , mnGroupLevel(0)
     , mnHellLayerId(SDRLAYER_NOTFOUND)
+    , mnHeaderFooterHellLayerId(SDRLAYER_NOTFOUND)
     , mbEscherSpgr(false)
     , mbEscherDg(false)
     , mbOOXML(bOOXML)
diff --git a/include/filter/msfilter/escherex.hxx 
b/include/filter/msfilter/escherex.hxx
index 48ed81d0ffd6..10e5dbe7fe5c 100644
--- a/include/filter/msfilter/escherex.hxx
+++ b/include/filter/msfilter/escherex.hxx
@@ -1062,6 +1062,7 @@ class MSFILTER_DLLPUBLIC EscherEx : public 
EscherPersistTable
 
         sal_uInt32                  mnGroupLevel;
         SdrLayerID                  mnHellLayerId;
+        SdrLayerID                  mnHeaderFooterHellLayerId;
 
         bool                        mbEscherSpgr;
         bool                        mbEscherDg;
@@ -1211,6 +1212,8 @@ public:
 
     void SetHellLayerId( SdrLayerID nId )       { mnHellLayerId = nId; }
     SdrLayerID GetHellLayerId() const           { return mnHellLayerId; }
+    void SetHeaderFooterHellLayerId( SdrLayerID nId )       { 
mnHeaderFooterHellLayerId = nId; }
+    SdrLayerID GetHeaderFooterHellLayerId() const           { return 
mnHeaderFooterHellLayerId; }
 
 private:
                         EscherEx( const EscherEx& ) = delete;
diff --git a/sw/inc/IDocumentDrawModelAccess.hxx 
b/sw/inc/IDocumentDrawModelAccess.hxx
index 3c1113cfe882..3a40da7881ec 100644
--- a/sw/inc/IDocumentDrawModelAccess.hxx
+++ b/sw/inc/IDocumentDrawModelAccess.hxx
@@ -37,6 +37,7 @@ public:
     virtual SwDrawModel* GetOrCreateDrawModel() = 0;
     virtual SdrLayerID GetHeavenId() const = 0;
     virtual SdrLayerID GetHellId() const = 0;
+    virtual SdrLayerID GetHeaderFooterHellId() const = 0;
     virtual SdrLayerID GetControlsId() const = 0;
     virtual SdrLayerID GetInvisibleHeavenId() const = 0;
     virtual SdrLayerID GetInvisibleHellId() const = 0;
diff --git a/sw/inc/IDocumentSettingAccess.hxx 
b/sw/inc/IDocumentSettingAccess.hxx
index 264860b854c4..39bcd7efcbeb 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -133,6 +133,8 @@ enum class DocumentSettingId
     DROP_CAP_PUNCTUATION,
     // render NBSP as standard-space-width (prettier when justified)
     USE_VARIABLE_WIDTH_NBSP,
+    // overlap background shapes if anchored in body
+    PAINT_HELL_OVER_HEADER_FOOTER,
 };
 
 /** Provides access to settings of a document
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 1ecdb6471052..aa652ed16539 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -1233,11 +1233,11 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf125300)
 
     // Keep line spacing before bottom cell border (it was 1892)
     sal_Int32 y1
-        = getXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[5]/polyline/point[1]"_ostr,
+        = getXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[7]/polyline/point[1]"_ostr,
                    "y"_ostr)
               .toInt32();
     sal_Int32 y2
-        = getXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[5]/polyline/point[2]"_ostr,
+        = getXPath(pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[7]/polyline/point[2]"_ostr,
                    "y"_ostr)
               .toInt32();
     CPPUNIT_ASSERT_DOUBLES_EQUAL(2092, y1, 7);
@@ -1490,13 +1490,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf115630)
     sal_Int32 nXRight
         = getXPath(
               pXmlDoc,
-              
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/polyline[1]/point[1]"_ostr,
+              
"/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[3]/polyline[1]/point[1]"_ostr,
               "x"_ostr)
               .toInt32();
     sal_Int32 nXLeft
         = getXPath(
               pXmlDoc,
-              
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/polyline[1]/point[2]"_ostr,
+              
"/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[3]/polyline[1]/point[2]"_ostr,
               "x"_ostr)
               .toInt32();
     CPPUNIT_ASSERT_DOUBLES_EQUAL(2895, nXRight - nXLeft, 50);
@@ -1876,13 +1876,13 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf129054)
     sal_Int32 nYTop
         = getXPath(
               pXmlDoc,
-              
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[4]/polyline[1]/point[1]"_ostr,
+              
"/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[4]/polyline[1]/point[1]"_ostr,
               "y"_ostr)
               .toInt32();
     sal_Int32 nYBottom
         = getXPath(
               pXmlDoc,
-              
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[4]/polyline[1]/point[31]"_ostr,
+              
"/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[4]/polyline[1]/point[31]"_ostr,
               "y"_ostr)
               .toInt32();
     CPPUNIT_ASSERT_DOUBLES_EQUAL(4615, nYTop - nYBottom, 5);
@@ -2079,7 +2079,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf130380)
     xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
     CPPUNIT_ASSERT(pXmlDoc);
     sal_Int32 nY = getXPath(pXmlDoc,
-                            
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[1]/polypolygon/"
+                            
"/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[1]/polypolygon/"
                             "polygon/point[1]"_ostr,
                             "y"_ostr)
                        .toInt32();
@@ -2267,12 +2267,12 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf116925)
     CPPUNIT_ASSERT(pXmlDoc);
 
     assertXPathContent(
-        pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/textarray/text"_ostr,
+        pXmlDoc, 
"/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[3]/textarray/text"_ostr,
         "hello");
     // This failed, text color was #000000.
     assertXPath(
         pXmlDoc,
-        
"/metafile/push[1]/push[1]/push[1]/push[4]/push[1]/push[3]/textcolor[@color='#ffffff']"_ostr,
+        
"/metafile/push[1]/push[1]/push[1]/push[6]/push[1]/push[3]/textcolor[@color='#ffffff']"_ostr,
         1);
 }
 
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
index 793ee8171a1a..1de9cb3e3f3f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport19.cxx
@@ -754,7 +754,7 @@ CPPUNIT_TEST_FIXTURE(Test, TestPuzzleExport)
     CPPUNIT_ASSERT(pMetaXml);
     // After parsing check that node...
     auto pXNode = getXPathNode(
-        pMetaXml, 
"/metafile/push/push/push/push[4]/push/push/polypolygon/polygon"_ostr);
+        pMetaXml, 
"/metafile/push/push/push/push[6]/push/push/polypolygon/polygon"_ostr);
     CPPUNIT_ASSERT(pXNode);
     auto pNode = pXNode->nodesetval->nodeTab[0];
     CPPUNIT_ASSERT(pNode);
diff --git a/sw/source/core/doc/DocumentDrawModelManager.cxx 
b/sw/source/core/doc/DocumentDrawModelManager.cxx
index 7f3098ef6672..2eb3902cb8f4 100644
--- a/sw/source/core/doc/DocumentDrawModelManager.cxx
+++ b/sw/source/core/doc/DocumentDrawModelManager.cxx
@@ -56,6 +56,7 @@ DocumentDrawModelManager::DocumentDrawModelManager(SwDoc& 
i_rSwdoc)
     : m_rDoc(i_rSwdoc)
     , mnHeaven(0)
     , mnHell(0)
+    , mnHeaderFooterHell(0)
     , mnControls(0)
     , mnInvisibleHeaven(0)
     , mnInvisibleHell(0)
@@ -86,6 +87,9 @@ void DocumentDrawModelManager::InitDrawModel()
     sLayerNm = "Hell";
     mnHell   = mpDrawModel->GetLayerAdmin().NewLayer( sLayerNm )->GetID();
 
+    sLayerNm = "HeaderFooterHell";
+    mnHeaderFooterHell = mpDrawModel->GetLayerAdmin().NewLayer( sLayerNm 
)->GetID();
+
     sLayerNm = "Heaven";
     mnHeaven = mpDrawModel->GetLayerAdmin().NewLayer( sLayerNm )->GetID();
 
@@ -204,6 +208,11 @@ SdrLayerID DocumentDrawModelManager::GetHellId() const
     return mnHell;
 }
 
+SdrLayerID DocumentDrawModelManager::GetHeaderFooterHellId() const
+{
+    return mnHeaderFooterHell;
+}
+
 SdrLayerID DocumentDrawModelManager::GetControlsId() const
 {
     return mnControls;
@@ -242,6 +251,7 @@ bool DocumentDrawModelManager::IsVisibleLayerId( SdrLayerID 
_nLayerId ) const
     bool bRetVal;
 
     if ( _nLayerId == GetHeavenId() ||
+         _nLayerId == GetHeaderFooterHellId() ||
          _nLayerId == GetHellId() ||
          _nLayerId == GetControlsId() )
     {
@@ -270,7 +280,8 @@ SdrLayerID 
DocumentDrawModelManager::GetInvisibleLayerIdByVisibleOne( SdrLayerID
     {
         nInvisibleLayerId = GetInvisibleHeavenId();
     }
-    else if ( _nVisibleLayerId == GetHellId() )
+    //TODO: do we need an InvisbleHeaderFooterHell?
+    else if ( _nVisibleLayerId == GetHellId() || _nVisibleLayerId == 
GetHeaderFooterHellId())
     {
         nInvisibleLayerId = GetInvisibleHellId();
     }
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index 14cfa5fd3c24..f3dfbef0e3c5 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -107,7 +107,8 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
&rDoc)
     mbAutoFirstLineIndentDisregardLineSpace(true),
     mbNoNumberingShowFollowBy(false),
     mbDropCapPunctuation(true),
-    mbUseVariableWidthNBSP(false)
+    mbUseVariableWidthNBSP(false),
+    mbPaintHellOverHeaderFooter(false)
 
     // COMPATIBILITY FLAGS END
 {
@@ -263,6 +264,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ 
DocumentSettingId id) const
         case DocumentSettingId::NO_NUMBERING_SHOW_FOLLOWBY: return 
mbNoNumberingShowFollowBy;
         case DocumentSettingId::DROP_CAP_PUNCTUATION: return 
mbDropCapPunctuation;
         case DocumentSettingId::USE_VARIABLE_WIDTH_NBSP: return 
mbUseVariableWidthNBSP;
+        case DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER: return 
mbPaintHellOverHeaderFooter;
         default:
             OSL_FAIL("Invalid setting id");
     }
@@ -480,6 +482,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ 
DocumentSettingId id, /*[in]*/ boo
             mbUseVariableWidthNBSP = value;
             break;
 
+        case DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER:
+            mbPaintHellOverHeaderFooter = value;
+            break;
+
         // COMPATIBILITY FLAGS END
 
         case DocumentSettingId::BROWSE_MODE: //can be used temporary 
(load/save) when no SwViewShell is available
@@ -1055,6 +1061,11 @@ void 
sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
                                 
BAD_CAST(OString::boolean(mbUseVariableWidthNBSP).getStr()));
     (void)xmlTextWriterEndElement(pWriter);
 
+    (void)xmlTextWriterStartElement(pWriter, 
BAD_CAST("mbPaintHellOverHeaderFooter"));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+                                
BAD_CAST(OString::boolean(mbPaintHellOverHeaderFooter).getStr()));
+    (void)xmlTextWriterEndElement(pWriter);
+
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbContinuousEndnotes"));
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
                                 
BAD_CAST(OString::boolean(mbContinuousEndnotes).getStr()));
diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx
index 14cb5680309b..fd001e1fe5f3 100644
--- a/sw/source/core/doc/notxtfrm.cxx
+++ b/sw/source/core/doc/notxtfrm.cxx
@@ -211,7 +211,7 @@ static void lcl_ClearArea( const SwFrame &rFrame,
     }
 }
 
-void SwNoTextFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const) const
+void SwNoTextFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const, PaintFrameMode) const
 {
     if ( getFrameArea().IsEmpty() )
         return;
diff --git a/sw/source/core/inc/DocumentDrawModelManager.hxx 
b/sw/source/core/inc/DocumentDrawModelManager.hxx
index 26fd603a67e9..36f03d1a22cb 100644
--- a/sw/source/core/inc/DocumentDrawModelManager.hxx
+++ b/sw/source/core/inc/DocumentDrawModelManager.hxx
@@ -46,6 +46,7 @@ public:
     virtual SwDrawModel* GetOrCreateDrawModel() override;
     virtual SdrLayerID GetHeavenId() const override;
     virtual SdrLayerID GetHellId() const override;
+    virtual SdrLayerID GetHeaderFooterHellId() const override;
     virtual SdrLayerID GetControlsId() const override;
     virtual SdrLayerID GetInvisibleHeavenId() const override;
     virtual SdrLayerID GetInvisibleHellId() const override;
@@ -70,10 +71,12 @@ private:
     /** Draw Model Layer IDs
      * LayerIds, Heaven == above document
      *           Hell   == below document
+     *           HeaderFooterHell = below document but above header/footer
      *         Controls == at the very top
      */
     SdrLayerID mnHeaven;
     SdrLayerID mnHell;
+    SdrLayerID mnHeaderFooterHell;
     SdrLayerID mnControls;
     SdrLayerID mnInvisibleHeaven;
     SdrLayerID mnInvisibleHell;
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx 
b/sw/source/core/inc/DocumentSettingManager.hxx
index 6599c9bf2ad0..5dfb4928b12f 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -184,6 +184,7 @@ class DocumentSettingManager final :
     bool mbNoNumberingShowFollowBy;
     bool mbDropCapPunctuation; // tdf#150200, tdf#150438
     bool mbUseVariableWidthNBSP : 1; // tdf#41652
+    bool mbPaintHellOverHeaderFooter : 1; // tdf#160198
 
 public:
 
diff --git a/sw/source/core/inc/cellfrm.hxx b/sw/source/core/inc/cellfrm.hxx
index 796cb1d3dfb3..9b693960aadb 100644
--- a/sw/source/core/inc/cellfrm.hxx
+++ b/sw/source/core/inc/cellfrm.hxx
@@ -43,7 +43,7 @@ public:
 
     virtual bool GetModelPositionForViewPoint( SwPosition *, Point&, 
SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
-                        SwPrintData const*const pPrintData = nullptr ) const 
override;
+                        SwPrintData const*const pPrintData = nullptr, 
PaintFrameMode mode = PAINT_ALL ) const override;
     virtual void CheckDirection( bool bVert ) override;
 
     // #i103961#
diff --git a/sw/source/core/inc/flyfrm.hxx b/sw/source/core/inc/flyfrm.hxx
index dfbd7e8daf58..5dcde8ce87dc 100644
--- a/sw/source/core/inc/flyfrm.hxx
+++ b/sw/source/core/inc/flyfrm.hxx
@@ -83,7 +83,7 @@ class SW_DLLPUBLIC SwFlyFrame : public SwLayoutFrame, public 
SwAnchoredObject
     friend void Notify( SwFlyFrame *, SwPageFrame *pOld, const SwRect &rOld,
                         const SwRect* pOldPrt );
 
-    void InitDrawObj(SwFrame const&); // these to methods are called in the
+    void InitDrawObj(SwFrame&); // these to methods are called in the
     void FinitDrawObj();    // constructors
 
     void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, 
SwFlyFrameInvFlags &,
@@ -171,7 +171,7 @@ protected:
 public:
     // #i26791#
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
-                        SwPrintData const*const pPrintData = nullptr ) const 
override;
+                        SwPrintData const*const pPrintData = nullptr, 
PaintFrameMode mode = PAINT_ALL ) const override;
     virtual Size ChgSize( const Size& aNewSize ) override;
     virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
                               SwCursorMoveState* = nullptr, bool 
bTestBackground = false ) const override;
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index a86358508182..4c4ba4cb1f2c 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -575,13 +575,17 @@ public:
         const SwRect&,
         const SwPageFrame* pPage,
         const SwBorderAttrs&) const;
+    enum PaintFrameMode { PAINT_ALL, PAINT_HEADER_FOOTER, 
PAINT_NON_HEADER_FOOTER };
+    static const SwFrame* SkipFrame(const SwFrame* pFrame, PaintFrameMode 
ePaintFrameMode );
     void PaintBaBo( const SwRect&, const SwPageFrame *pPage,
-                    const bool bOnlyTextBackground = false) const;
+                    const bool bOnlyTextBackground = false,
+                   PaintFrameMode eMode = PAINT_ALL ) const;
     void PaintSwFrameBackground( const SwRect&, const SwPageFrame *pPage,
                           const SwBorderAttrs &,
                           const bool bLowerMode = false,
                           const bool bLowerBorder = false,
-                          const bool bOnlyTextBackground = false ) const;
+                          const bool bOnlyTextBackground = false,
+                          PaintFrameMode eMode = PAINT_ALL ) const;
     void PaintBorderLine( const SwRect&, const SwRect&, const SwPageFrame*,
                           const Color *pColor,
                           const SvxBorderLineStyle = SvxBorderLineStyle::SOLID 
) const;
@@ -844,7 +848,7 @@ public:
     virtual bool    GetCharRect( SwRect &, const SwPosition&,
                                  SwCursorMoveState* = nullptr, bool 
bAllowFarAway = true ) const;
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
-                        SwPrintData const*const pPrintData = nullptr ) const;
+                        SwPrintData const*const pPrintData = nullptr, 
PaintFrameMode mode = PAINT_ALL ) const;
 
     // HACK: shortcut between frame and formatting
     // It's your own fault if you cast void* incorrectly! In any case check
diff --git a/sw/source/core/inc/layfrm.hxx b/sw/source/core/inc/layfrm.hxx
index 981fbb34f649..482313e8abc8 100644
--- a/sw/source/core/inc/layfrm.hxx
+++ b/sw/source/core/inc/layfrm.hxx
@@ -97,7 +97,7 @@ public:
     SwLayoutFrame( SwFrameFormat*, SwFrame* );
 
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
-                        SwPrintData const*const pPrintData = nullptr ) const 
override;
+                        SwPrintData const*const pPrintData = nullptr, 
PaintFrameMode mode = PAINT_ALL ) const override;
     const SwFrame *Lower() const { return m_pLower; }
           SwFrame *Lower()       { return m_pLower; }
     bool ContainsDeleteForbiddenLayFrame() const;
diff --git a/sw/source/core/inc/notxtfrm.hxx b/sw/source/core/inc/notxtfrm.hxx
index 50612e396ab5..a7b471d47401 100644
--- a/sw/source/core/inc/notxtfrm.hxx
+++ b/sw/source/core/inc/notxtfrm.hxx
@@ -83,7 +83,7 @@ public:
     virtual bool RightMargin(SwPaM *, bool bAPI = false) const override;
 
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
-                        SwPrintData const*const pPrintData = nullptr ) const 
override;
+                        SwPrintData const*const pPrintData = nullptr, 
PaintFrameMode mode = PAINT_ALL ) const override;
     virtual bool GetCharRect( SwRect &, const SwPosition&,
                               SwCursorMoveState* = nullptr, bool bAllowFarAway 
= true ) const override;
     virtual bool GetModelPositionForViewPoint(SwPosition* pPos, Point& aPoint,
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index 90d18fcf0ee4..19816b2f0a4b 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -241,7 +241,7 @@ public:
                                SwCursorMoveState* = nullptr, bool 
bTestBackground = false ) const override;
 
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
-                        SwPrintData const*const pPrintData = nullptr ) const 
override;
+                        SwPrintData const*const pPrintData = nullptr, 
PaintFrameMode mode = PAINT_ALL ) const override;
     virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = 
false ) override;
     virtual SwTwips GrowFrame  ( SwTwips, bool bTst = false, bool bInfo = 
false ) override;
 #ifdef DBG_UTIL
diff --git a/sw/source/core/inc/tabfrm.hxx b/sw/source/core/inc/tabfrm.hxx
index 08020de73489..ed2b034bfc41 100644
--- a/sw/source/core/inc/tabfrm.hxx
+++ b/sw/source/core/inc/tabfrm.hxx
@@ -145,7 +145,7 @@ public:
     SwTabFrame* FindMaster( bool bFirstMaster = false ) const;
 
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
-                        SwPrintData const*const pPrintData = nullptr ) const 
override;
+                        SwPrintData const*const pPrintData = nullptr, 
PaintFrameMode mode = PAINT_ALL ) const override;
     virtual void CheckDirection( bool bVert ) override;
 
     virtual void Cut() override;
diff --git a/sw/source/core/inc/txtfrm.hxx b/sw/source/core/inc/txtfrm.hxx
index df11ca589bc6..03559459c9e3 100644
--- a/sw/source/core/inc/txtfrm.hxx
+++ b/sw/source/core/inc/txtfrm.hxx
@@ -420,7 +420,7 @@ public:
     void   PaintExtraData( const SwRect & rRect ) const; /// Page number etc.
     SwRect GetPaintSwRect();
     virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect 
const&,
-                        SwPrintData const*const pPrintData = nullptr ) const 
override;
+                        SwPrintData const*const pPrintData = nullptr, 
PaintFrameMode mode = PAINT_ALL ) const override;
 
     /**
      * Layout oriented cursor travelling:
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index b454bd95917f..77b4f191c22a 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -426,17 +426,24 @@ void SwFlyFrame::DeleteCnt()
     InvalidatePage();
 }
 
-void SwFlyFrame::InitDrawObj(SwFrame const& rAnchorFrame)
+void SwFlyFrame::InitDrawObj(SwFrame& rAnchorFrame)
 {
     SetDrawObj(*SwFlyDrawContact::CreateNewRef(this, GetFormat(), 
rAnchorFrame));
 
     // Set the right Layer
+    const IDocumentSettingAccess& rIDSA = 
GetFormat()->getIDocumentSettingAccess();
+    bool isPaintHellOverHF = 
rIDSA.get(DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER);
     IDocumentDrawModelAccess& rIDDMA = 
GetFormat()->getIDocumentDrawModelAccess();
     SdrLayerID nHeavenId = rIDDMA.GetHeavenId();
     SdrLayerID nHellId = rIDDMA.GetHellId();
-    GetVirtDrawObj()->SetLayer( GetFormat()->GetOpaque().GetValue()
-                                ? nHeavenId
-                                : nHellId );
+    bool isOpaque = GetFormat()->GetOpaque().GetValue();
+    if (!isOpaque && isPaintHellOverHF)
+    {
+        if (!rAnchorFrame.FindFooterOrHeader())
+            nHellId = rIDDMA.GetHeaderFooterHellId();
+    }
+
+    GetVirtDrawObj()->SetLayer( isOpaque ? nHeavenId :nHellId );
 }
 
 static SwPosition ResolveFlyAnchor(SwFrameFormat const& rFlyFrame)
@@ -1034,9 +1041,18 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, 
const SfxPoolItem *pNew,
             if ( pSh )
                 pSh->InvalidateWindows( getFrameArea() );
             const IDocumentDrawModelAccess& rIDDMA = 
GetFormat()->getIDocumentDrawModelAccess();
+            const IDocumentSettingAccess& rIDSA = 
GetFormat()->getIDocumentSettingAccess();
+            bool isPaintHellOverHF = 
rIDSA.get(DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER);
+            SdrLayerID nHellId = rIDDMA.GetHellId();
+
+            if (isPaintHellOverHF && !GetAnchorFrame()->FindFooterOrHeader())
+            {
+                nHellId = rIDDMA.GetHeaderFooterHellId();
+            }
+
             const SdrLayerID nId = GetFormat()->GetOpaque().GetValue() ?
                              rIDDMA.GetHeavenId() :
-                             rIDDMA.GetHellId();
+                             nHellId;
             GetVirtDrawObj()->SetLayer( nId );
 
             if ( Lower() )
diff --git a/sw/source/core/layout/paintfrm.cxx 
b/sw/source/core/layout/paintfrm.cxx
index 5472695e9732..9f6cec5ea707 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3270,7 +3270,7 @@ namespace
  * 3. Paint the document content (text)
  * 4. Paint the draw layer that is above the document
 |*/
-void SwRootFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const pPrintData) const
+void SwRootFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const pPrintData, PaintFrameMode) const
 {
     OSL_ENSURE( Lower() && Lower()->IsPageFrame(), "Lower of root is no page." 
);
 
@@ -3294,6 +3294,8 @@ void SwRootFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect const&
     else
         SwRootFrame::s_isInPaint = bResetRootPaint = true;
 
+    const IDocumentSettingAccess& rIDSA = 
pSh->GetDoc()->getIDocumentSettingAccess();
+    bool isPaintHellOverHF = 
rIDSA.get(DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER) && 
pSh->Imp()->HasDrawView();
     std::unique_ptr<SwSavePaintStatics> pStatics;
     if ( gProp.pSGlobalShell )
         pStatics.reset(new SwSavePaintStatics());
@@ -3488,9 +3490,25 @@ void SwRootFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect const&
                     gProp.pSLines->LockLines( false );
                 }
 
-                if ( pSh->GetDoc()->GetDocumentSettingManager().get( 
DocumentSettingId::BACKGROUND_PARA_OVER_DRAWINGS ) )
-                    pPage->PaintBaBo( aPaintRect, pPage, 
/*bOnlyTextBackground=*/true );
+                if (isPaintHellOverHF)
+                {
+                    if ( pSh->GetDoc()->GetDocumentSettingManager().get( 
DocumentSettingId::BACKGROUND_PARA_OVER_DRAWINGS ) )
+                        pPage->PaintBaBo( aPaintRect, pPage, 
/*bOnlyTextBackground=*/true, PAINT_HEADER_FOOTER );
+                    pPage->PaintSwFrame(rRenderContext, aPaintRect, 
pPrintData, PAINT_HEADER_FOOTER);
+                    gProp.pSLines->LockLines( true );
+                    const IDocumentDrawModelAccess& rIDDMA = 
pSh->getIDocumentDrawModelAccess();
+                    pSh->Imp()->PaintLayer( rIDDMA.GetHeaderFooterHellId(),
+                                            pPrintData,
+                                            *pPage, pPage->getFrameArea(),
+                                            &aPageBackgrdColor,
+                                            pPage->IsRightToLeft(),
+                                            &aSwRedirector );
+                    gProp.pSLines->PaintLines( pSh->GetOut(), gProp );
+                    gProp.pSLines->LockLines( false );
+                }
 
+                if ( pSh->GetDoc()->GetDocumentSettingManager().get( 
DocumentSettingId::BACKGROUND_PARA_OVER_DRAWINGS ) )
+                    pPage->PaintBaBo( aPaintRect, pPage, 
/*bOnlyTextBackground=*/true, isPaintHellOverHF ? PAINT_NON_HEADER_FOOTER : 
PAINT_ALL );
                 if( pSh->GetWin() )
                 {
                     // collect sub-lines
@@ -3498,8 +3516,7 @@ void SwRootFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect const&
                     // paint special sub-lines
                     gProp.pSSpecSubsLines->PaintSubsidiary( pSh->GetOut(), 
nullptr, gProp );
                 }
-
-                pPage->PaintSwFrame( rRenderContext, aPaintRect );
+                pPage->PaintSwFrame( rRenderContext, aPaintRect, pPrintData, 
isPaintHellOverHF ? PAINT_NON_HEADER_FOOTER : PAINT_ALL);
 
                 // no paint of page border and shadow, if writer is in place 
mode.
                 if( pSh->GetWin() && pSh->GetDoc()->GetDocShell() &&
@@ -3701,11 +3718,14 @@ SwShortCut::SwShortCut( const SwFrame& rFrame, const 
SwRect& rRect )
     }
 }
 
-void SwLayoutFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const) const
+void SwLayoutFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const,
+    PaintFrameMode ePaintFrameMode) const
 {
     // #i16816# tagged pdf support
     Frame_Info aFrameInfo(*this, false);
-    SwTaggedPDFHelper aTaggedPDFHelper( nullptr, &aFrameInfo, nullptr, 
rRenderContext );
+    SwTaggedPDFHelper aTaggedPDFHelper( nullptr,
+        PAINT_HEADER_FOOTER == ePaintFrameMode ? nullptr : &aFrameInfo,
+        nullptr, rRenderContext );
     ::std::optional<SwTaggedPDFHelper> oTaggedLink;
     if (IsFlyFrame())
     {
@@ -3722,6 +3742,10 @@ void SwLayoutFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect cons
     if ( !pFrame )
         return;
 
+    pFrame = SkipFrame(pFrame, ePaintFrameMode);
+    if (!pFrame)
+        return;
+
     SwFrameDeleteGuard g(const_cast<SwLayoutFrame*>(this)); // lock because 
Calc() and recursion
     SwShortCut aShortCut( *pFrame, rRect );
     bool bCnt = pFrame->IsContentFrame();
@@ -3827,6 +3851,7 @@ void SwLayoutFrame::PaintSwFrame(vcl::RenderContext& 
rRenderContext, SwRect cons
             ::lcl_EmergencyFormatFootnoteCont( 
const_cast<SwFootnoteContFrame*>(static_cast<const 
SwFootnoteContFrame*>(pFrame->GetNext())) );
 
         pFrame = pFrame->GetNext();
+        pFrame = SkipFrame(pFrame, ePaintFrameMode);
 
         if ( pFrame )
         {
@@ -4224,7 +4249,7 @@ bool SwFlyFrame::IsPaint( SdrObject *pObj, const 
SwViewShell *pSh )
     return bPaint;
 }
 
-void SwCellFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const) const
+void SwCellFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const, PaintFrameMode) const
 {
     if ( GetLayoutRowSpan() >= 1 )
         SwLayoutFrame::PaintSwFrame( rRenderContext, rRect );
@@ -4263,7 +4288,7 @@ void SwFrame::SetDrawObjsAsDeleted( bool bDeleted )
     }
 }
 
-void SwFlyFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const) const
+void SwFlyFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const, PaintFrameMode) const
 {
     //optimize thumbnail generation and store procedure to improve odt saving 
performance, #i120030#
     SwViewShell *pShell = getRootFrame()->GetCurrShell();
@@ -4640,7 +4665,7 @@ void SwTextFrame::PaintOutlineContentVisibilityButton() 
const
         UpdateOutlineContentVisibilityButton(pWrtSh);
 }
 
-void SwTabFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const) const
+void SwTabFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const, PaintFrameMode) const
 {
     const SwViewOption* pViewOption = gProp.pSGlobalShell->GetViewOptions();
     if (pViewOption->IsTable())
@@ -6652,8 +6677,26 @@ SwRect SwPageFrame::GetBoundRect(OutputDevice const * 
pOutputDevice) const
     return nRet;
 }
 
+const SwFrame* SwFrame::SkipFrame(const SwFrame* pFrame, PaintFrameMode 
ePaintFrameMode )
+{
+    if (ePaintFrameMode != PAINT_ALL)
+    {
+        if (ePaintFrameMode == PAINT_NON_HEADER_FOOTER)
+        {
+            while (pFrame && (pFrame->IsHeaderFrame() || 
pFrame->IsFooterFrame()))
+                pFrame = pFrame->GetNext();
+        }
+        else
+        {
+            while ( pFrame && !pFrame->IsHeaderFrame() && 
!pFrame->IsFooterFrame())
+                pFrame = pFrame->GetNext();
+        }
+    }
+    return pFrame;
+}
+
 void SwFrame::PaintBaBo( const SwRect& rRect, const SwPageFrame *pPage,
-                         const bool bOnlyTextBackground ) const
+                         const bool bOnlyTextBackground, PaintFrameMode 
ePaintFrameMode ) const
 {
     if ( !pPage )
         pPage = FindPageFrame();
@@ -6679,7 +6722,7 @@ void SwFrame::PaintBaBo( const SwRect& rRect, const 
SwPageFrame *pPage,
 
     // paint background
     {
-        PaintSwFrameBackground( rRect, pPage, rAttrs, false, 
true/*bLowerBorder*/, bOnlyTextBackground );
+        PaintSwFrameBackground( rRect, pPage, rAttrs, false, 
true/*bLowerBorder*/, bOnlyTextBackground, ePaintFrameMode );
     }
 
     // paint border before painting background
@@ -6714,7 +6757,8 @@ void SwFrame::PaintSwFrameBackground( const SwRect 
&rRect, const SwPageFrame *pP
                              const SwBorderAttrs & rAttrs,
                              const bool bLowerMode,
                              const bool bLowerBorder,
-                             const bool bOnlyTextBackground ) const
+                             const bool bOnlyTextBackground,
+                             PaintFrameMode ePaintFrameMode) const
 {
     // #i1837# - no paint of table background, if corresponding option is 
*not* set.
     SwViewShell *pSh = gProp.pSGlobalShell;
@@ -6949,6 +6993,11 @@ void SwFrame::PaintSwFrameBackground( const SwRect 
&rRect, const SwPageFrame *pP
     SwRect aRect( GetPaintArea() );
     aRect.Intersection_( rRect );
     SwRect aBorderRect( aRect );
+
+    pFrame = SkipFrame(pFrame, ePaintFrameMode);
+    if (!pFrame)
+        return;
+
     SwShortCut aShortCut( *pFrame, aBorderRect );
     do
     {   if ( gProp.pSProgress )
@@ -6971,6 +7020,7 @@ void SwFrame::PaintSwFrameBackground( const SwRect 
&rRect, const SwPageFrame *pP
             }
         }
         pFrame = pFrame->GetNext();
+        pFrame = SkipFrame(pFrame, ePaintFrameMode);
     } while ( pFrame && pFrame->GetUpper() == this &&
               !aShortCut.Stop( aFrameRect ) );
 }
diff --git a/sw/source/core/layout/unusedf.cxx 
b/sw/source/core/layout/unusedf.cxx
index 25de7617c11d..dbb8a8f6c1fb 100644
--- a/sw/source/core/layout/unusedf.cxx
+++ b/sw/source/core/layout/unusedf.cxx
@@ -27,7 +27,7 @@ void SwFrame::Format( vcl::RenderContext* /*pRenderContext*/, 
const SwBorderAttr
     OSL_FAIL( "Format() of the base class called." );
 }
 
-void SwFrame::PaintSwFrame(vcl::RenderContext&, SwRect const&, SwPrintData 
const*const) const
+void SwFrame::PaintSwFrame(vcl::RenderContext&, SwRect const&, SwPrintData 
const*const, PaintFrameMode) const
 {
     OSL_FAIL( "PaintSwFrame() of the base class called." );
 }
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index 57458a021817..da4227d024e5 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -642,7 +642,7 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool 
bCheck ) const
     return false;
 }
 
-void SwTextFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const) const
+void SwTextFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect 
const& rRect, SwPrintData const*const, PaintFrameMode) const
 {
     ResetRepaint();
 
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index 5bb5621d9575..c587154287d7 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1499,9 +1499,12 @@ uno::Any SwXShape::getPropertyValue(const OUString& 
rPropertyName)
                     {
                         SdrObject* pObj = pSvxShape->GetSdrObject();
                         // consider invisible layers
+                        SdrLayerID nLayerId = pObj->GetLayer();
+                        const IDocumentDrawModelAccess& rIDMA = 
pFormat->GetDoc()->getIDocumentDrawModelAccess();
                         aRet <<=
-                            ( pObj->GetLayer() != 
pFormat->GetDoc()->getIDocumentDrawModelAccess().GetHellId() &&
-                              pObj->GetLayer() != 
pFormat->GetDoc()->getIDocumentDrawModelAccess().GetInvisibleHellId() );
+                            ( nLayerId != rIDMA.GetHellId() &&
+                              nLayerId != rIDMA.GetHeaderFooterHellId() &&
+                              nLayerId != rIDMA.GetInvisibleHellId() );
                     }
                 }
                 else if(FN_ANCHOR_POSITION == pEntry->nWID)
diff --git a/sw/source/core/unocore/unoframe.cxx 
b/sw/source/core/unocore/unoframe.cxx
index 62c4c76ac3ab..2becdd3751bf 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -46,6 +46,7 @@
 #include <IDocumentDrawModelAccess.hxx>
 #include <IDocumentLayoutAccess.hxx>
 #include <IDocumentStylePoolAccess.hxx>
+#include <IDocumentSettingAccess.hxx>
 #include <UndoAttribute.hxx>
 #include <docsh.hxx>
 #include <editsh.hxx>
@@ -1374,9 +1375,16 @@ SdrObject 
*SwXFrame::GetOrCreateSdrObject(SwFlyFrameFormat &rFormat)
         pObject = pContactObject->GetMaster();
 
         const ::SwFormatSurround& rSurround = rFormat.GetSurround();
+        const IDocumentSettingAccess& rIDSA = 
pDoc->getIDocumentSettingAccess();
+        bool isPaintHellOverHF = 
rIDSA.get(DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER);
+
+        //TODO: HeaderFooterHellId only appropriate if object is anchored in 
body
         pObject->SetLayer(
             ( css::text::WrapTextMode_THROUGH == rSurround.GetSurround() &&
-              !rFormat.GetOpaque().GetValue() ) ? 
pDoc->getIDocumentDrawModelAccess().GetHellId()
+              !rFormat.GetOpaque().GetValue() )
+                              ? isPaintHellOverHF
+                                    ? 
pDoc->getIDocumentDrawModelAccess().GetHeaderFooterHellId()
+                                    : 
pDoc->getIDocumentDrawModelAccess().GetHellId()
                                              : 
pDoc->getIDocumentDrawModelAccess().GetHeavenId() );
         SwDrawModel* pDrawModel = 
pDoc->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
         pDrawModel->GetPage(0)->InsertObject( pObject );
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index 5c746f6afe6e..485cdd5dfa99 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -844,12 +844,11 @@ void DocxSdrExport::startDMLAnchorInline(const 
SwFrameFormat* pFrameFormat, cons
         if (pObj)
         {
             // SdrObjects know their layer, consider that instead of the frame 
format.
-            bOpaque = pObj->GetLayer()
-                          != 
pFrameFormat->GetDoc()->getIDocumentDrawModelAccess().GetHellId()
-                      && pObj->GetLayer()
-                             != pFrameFormat->GetDoc()
-                                    ->getIDocumentDrawModelAccess()
-                                    .GetInvisibleHellId();
+            const IDocumentDrawModelAccess& iDocumentDrawModelAccess
+                = pFrameFormat->GetDoc()->getIDocumentDrawModelAccess();
+            bOpaque = pObj->GetLayer() != iDocumentDrawModelAccess.GetHellId()
+                      && pObj->GetLayer() != 
iDocumentDrawModelAccess.GetHeaderFooterHellId()
+                      && pObj->GetLayer() != 
iDocumentDrawModelAccess.GetInvisibleHellId();
         }
         attrList->add(XML_behindDoc, bOpaque ? "0" : "1");
 
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx 
b/sw/source/filter/ww8/wrtw8esh.cxx
index 272e3bd27735..ca5ef6f0d3df 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -2044,6 +2044,7 @@ sal_Int32 SwBasicEscherEx::WriteFlyFrameAttr(const 
SwFrameFormat& rFormat,
     const SdrObject* pObj = rFormat.FindRealSdrObject();
 
     if( pObj && (pObj->GetLayer() == GetHellLayerId() ||
+        pObj->GetLayer() == GetHeaderFooterHellLayerId() ||
         pObj->GetLayer() == GetInvisibleHellId() ) && !(bIsInHeader && 
bIsThrough))
     {
         rPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x200020 );
@@ -2135,6 +2136,7 @@ void SwBasicEscherEx::Init()
     mnEmuDiv = aFact.GetDenominator();
 
     SetHellLayerId(mrWrt.m_rDoc.getIDocumentDrawModelAccess().GetHellId());
+    
SetHeaderFooterHellLayerId(mrWrt.m_rDoc.getIDocumentDrawModelAccess().GetHeaderFooterHellId());
 }
 
 sal_Int32 SwBasicEscherEx::ToFract16(sal_Int32 nVal, sal_uInt32 nMax)
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx 
b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 3c0a8bbbf2a4..c07c6e448f12 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -161,6 +161,7 @@ enum SwDocumentSettingsPropertyHandles
     HANDLE_USE_VARIABLE_WIDTH_NBSP,
     HANDLE_APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH,
     HANDLE_DO_NOT_MIRROR_RTL_DRAW_OBJS,
+    HANDLE_PAINT_HELL_OVER_HEADER_FOOTER
 };
 
 }
@@ -268,6 +269,7 @@ static rtl::Reference<MasterPropertySetInfo> 
lcl_createSettingsInfo()
         { OUString("UseVariableWidthNBSP"), HANDLE_USE_VARIABLE_WIDTH_NBSP, 
cppu::UnoType<bool>::get(), 0 },
         { OUString("ApplyTextAttrToEmptyLineAtEndOfParagraph"), 
HANDLE_APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH, 
cppu::UnoType<bool>::get(), 0 },
         { OUString("DoNotMirrorRtlDrawObjs"), 
HANDLE_DO_NOT_MIRROR_RTL_DRAW_OBJS, cppu::UnoType<bool>::get(), 0 },
+        { OUString("PaintHellOverHeaderFooter"), 
HANDLE_PAINT_HELL_OVER_HEADER_FOOTER, cppu::UnoType<bool>::get(), 0 },
 
 /*
  * As OS said, we don't have a view when we need to set this, so I have to
@@ -1152,6 +1154,14 @@ void SwXDocumentSettings::_setSingleValue( const 
comphelper::PropertyInfo & rInf
                     DocumentSettingId::USE_VARIABLE_WIDTH_NBSP, bTmp);
         }
         break;
+        case HANDLE_PAINT_HELL_OVER_HEADER_FOOTER:
+        {
+            bool bTmp;
+            if (rValue >>= bTmp)
+                mpDoc->getIDocumentSettingAccess().set(
+                    DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER, bTmp);
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
@@ -1728,6 +1738,12 @@ void SwXDocumentSettings::_getSingleValue( const 
comphelper::PropertyInfo & rInf
                 DocumentSettingId::USE_VARIABLE_WIDTH_NBSP);
         }
         break;
+        case HANDLE_PAINT_HELL_OVER_HEADER_FOOTER:
+        {
+            rValue <<= mpDoc->getIDocumentSettingAccess().get(
+                DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER);
+        }
+        break;
         default:
             throw UnknownPropertyException(OUString::number(rInfo.mnHandle));
     }
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 879b8e35740a..1ab5521aef4f 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -143,6 +143,8 @@ DomainMapper::DomainMapper( const uno::Reference< 
uno::XComponentContext >& xCon
 
         // Enable only for new documents, since pasting from clipboard can 
influence existing doc
         m_pImpl->SetDocumentSettingsProperty("NoNumberingShowFollowBy", 
uno::Any(true));
+        //paint backgound frames after header/footer when anchored in body
+        
m_pImpl->SetDocumentSettingsProperty("PaintHellOverHeaderFooter",uno::Any(true));
     }
 
     // Initialize RDF metadata, to be able to add statements during the import.
diff --git a/writerfilter/source/filter/WriterFilter.cxx 
b/writerfilter/source/filter/WriterFilter.cxx
index 44efc0c42cfc..853e42982210 100644
--- a/writerfilter/source/filter/WriterFilter.cxx
+++ b/writerfilter/source/filter/WriterFilter.cxx
@@ -329,6 +329,8 @@ void WriterFilter::setTargetDocument(const 
uno::Reference<lang::XComponent>& xDo
     xSettings->setPropertyValue("DoNotCaptureDrawObjsOnPage", uno::Any(true));
     xSettings->setPropertyValue("DisableOffPagePositioning", uno::Any(true));
     xSettings->setPropertyValue("DropCapPunctuation", uno::Any(true));
+    xSettings->setPropertyValue("PaintHellOverHeaderFooter", uno::Any(true));
+
     // rely on default for HyphenateURLs=false
     // rely on default for 
APPLY_TEXT_ATTR_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH=true
     xSettings->setPropertyValue("DoNotMirrorRtlDrawObjs", uno::Any(true));

Reply via email to