Blame SOURCES/0078-fdo-69065-sw-fix-mirrored-page-style-with-first-page.patch

f0633d
From 283b76abeafe28c335de2d7cdc2fde04a55d4192 Mon Sep 17 00:00:00 2001
f0633d
From: Michael Stahl <mstahl@redhat.com>
f0633d
Date: Fri, 20 Dec 2013 17:58:12 +0100
f0633d
Subject: [PATCH 078/109] fdo#69065: sw: fix mirrored page style with
f0633d
 first-page
f0633d
f0633d
If a mirrored page style is used with first-page on both a right page
f0633d
and a left page the current design cannot work because the margins in
f0633d
the SwPageDesc::aFirst cannot be right for both cases.
f0633d
f0633d
So split that up so we get a first-master and first-left format and
f0633d
copy the headers/footers and margins as appropriate... which is really
f0633d
adding epicycles to a flawed design; probably this would be better with
f0633d
just a single SwFrmFmt that has different items for master/left/first
f0633d
headers.
f0633d
f0633d
(cherry picked from commit e936ecc92a7e362f57ce72a955697840920636b8)
f0633d
f0633d
Conflicts:
f0633d
	sw/source/core/doc/docdesc.cxx
f0633d
	sw/source/core/doc/poolfmt.cxx
f0633d
f0633d
Change-Id: I0889a4ab5959b5a71172203bb64d185960a07d73
f0633d
Reviewed-on: https://gerrit.libreoffice.org/7158
f0633d
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
f0633d
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
f0633d
---
f0633d
 sw/inc/doc.hxx                         |  4 +-
f0633d
 sw/inc/pagedesc.hxx                    | 10 ++--
f0633d
 sw/source/core/doc/docdesc.cxx         | 97 ++++++++++++++++++++++++++--------
f0633d
 sw/source/core/doc/docfmt.cxx          | 20 +++++--
f0633d
 sw/source/core/doc/poolfmt.cxx         |  5 +-
f0633d
 sw/source/core/layout/frmtool.cxx      | 13 ++---
f0633d
 sw/source/core/layout/pagedesc.cxx     | 23 +++++---
f0633d
 sw/source/core/undo/SwUndoPageDesc.cxx |  4 +-
f0633d
 sw/source/core/unocore/unostyle.cxx    |  4 +-
f0633d
 sw/source/filter/ww8/wrtw8sty.cxx      |  2 +-
f0633d
 sw/source/filter/ww8/ww8atr.cxx        |  2 +-
f0633d
 sw/source/filter/ww8/ww8par.cxx        |  8 +--
f0633d
 sw/source/filter/ww8/ww8par6.cxx       |  8 +--
f0633d
 13 files changed, 142 insertions(+), 58 deletions(-)
f0633d
f0633d
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
f0633d
index 12ab476..ff372aa 100644
f0633d
--- a/sw/inc/doc.hxx
f0633d
+++ b/sw/inc/doc.hxx
f0633d
@@ -2080,9 +2080,9 @@ private:
f0633d
     /// method to set new graphics pool defaults, must only be called by SetDrawDefaults!
f0633d
     void UpdateDrawDefaults();
f0633d
     /// Copies master header to left / first one, if necessary - used by ChgPageDesc().
f0633d
-    void CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft);
f0633d
+    void CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft, bool bFirst);
f0633d
     /// Copies master footer to left / first one, if necessary - used by ChgPageDesc().
f0633d
-    void CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft);
f0633d
+    void CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft, bool bFirst);
f0633d
 
f0633d
     /** continue computing a chunk of document statistics
f0633d
       * \param nChars  number of characters to count before exiting
f0633d
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
f0633d
index 45ca5df..a4a74a2 100644
f0633d
--- a/sw/inc/pagedesc.hxx
f0633d
+++ b/sw/inc/pagedesc.hxx
f0633d
@@ -136,7 +136,9 @@ class SW_DLLPUBLIC SwPageDesc : public SwModify
f0633d
     SvxNumberType   aNumType;
f0633d
     SwFrmFmt    aMaster;
f0633d
     SwFrmFmt    aLeft;
f0633d
-    SwFrmFmt    aFirst;
f0633d
+    // FIXME epicycles growing here - page margins need to be stored differently
f0633d
+    SwFrmFmt    m_FirstMaster;
f0633d
+    SwFrmFmt    m_FirstLeft;
f0633d
     SwDepend    aDepend;    ///< Because of grid alignment (Registerhaltigkeit).
f0633d
     SwPageDesc *pFollow;
f0633d
     sal_uInt16  nRegHeight; ///< Sentence spacing and fontascent of style.
f0633d
@@ -191,10 +193,12 @@ public:
f0633d
 
f0633d
           SwFrmFmt &GetMaster() { return aMaster; }
f0633d
           SwFrmFmt &GetLeft()   { return aLeft; }
f0633d
-          SwFrmFmt &GetFirst()   { return aFirst; }
f0633d
+          SwFrmFmt &GetFirstMaster()   { return m_FirstMaster; }
f0633d
+          SwFrmFmt &GetFirstLeft()   { return m_FirstLeft; }
f0633d
     const SwFrmFmt &GetMaster() const { return aMaster; }
f0633d
     const SwFrmFmt &GetLeft()   const { return aLeft; }
f0633d
-    const SwFrmFmt &GetFirst()   const { return aFirst; }
f0633d
+    const SwFrmFmt &GetFirstMaster()   const { return m_FirstMaster; }
f0633d
+    const SwFrmFmt &GetFirstLeft()   const { return m_FirstLeft; }
f0633d
 
f0633d
     /** Reset all attrs of the format but keep the ones a pagedesc
f0633d
        cannot live without. */
f0633d
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
f0633d
index 7bbecfa..9694337 100644
f0633d
--- a/sw/source/core/doc/docdesc.cxx
f0633d
+++ b/sw/source/core/doc/docdesc.cxx
f0633d
@@ -59,7 +59,8 @@ using namespace com::sun::star;
f0633d
 static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId,
f0633d
                                 SwFrmFmt &rFmt1,
f0633d
                                 SwFrmFmt &rFmt2,
f0633d
-                                SwFrmFmt &rFmt3 )
f0633d
+                                SwFrmFmt &rFmt3,
f0633d
+                                SwFrmFmt &rFmt4)
f0633d
 {
f0633d
     // --> #i41075# Printer on demand
f0633d
     // This function does not require a printer anymore.
f0633d
@@ -115,6 +116,10 @@ static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId,
f0633d
     rFmt3.SetFmtAttr( aFrmSize );
f0633d
     rFmt3.SetFmtAttr( aLR );
f0633d
     rFmt3.SetFmtAttr( aUL );
f0633d
+
f0633d
+    rFmt4.SetFmtAttr( aFrmSize );
f0633d
+    rFmt4.SetFmtAttr( aLR );
f0633d
+    rFmt4.SetFmtAttr( aUL );
f0633d
 }
f0633d
 
f0633d
 static void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
f0633d
@@ -163,10 +168,21 @@ static void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
f0633d
     rDest.SetPoolHlpFileId( rSource.GetPoolHlpFileId() );
f0633d
 }
f0633d
 
f0633d
-void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft)
f0633d
+void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft, bool bFirst)
f0633d
 {
f0633d
-    SwFrmFmt& rDescFrmFmt = (bLeft ? pDesc->GetLeft() : pDesc->GetFirst());
f0633d
-    if ( (bLeft ? rChged.IsHeaderShared() : rChged.IsFirstShared() ) || !rHead.IsActive() )
f0633d
+    assert(bLeft || bFirst);
f0633d
+    SwFrmFmt& rDescFrmFmt = (bFirst)
f0633d
+            ? (bLeft) ? pDesc->GetFirstLeft() : pDesc->GetFirstMaster()
f0633d
+            : pDesc->GetLeft();
f0633d
+    if (bFirst && bLeft)
f0633d
+    {
f0633d
+        // special case: always shared with something
f0633d
+        rDescFrmFmt.SetFmtAttr( rChged.IsFirstShared()
f0633d
+                ? pDesc->GetLeft().GetHeader()
f0633d
+                : pDesc->GetFirstMaster().GetHeader());
f0633d
+    }
f0633d
+    else if ((bFirst ? rChged.IsFirstShared() : rChged.IsHeaderShared())
f0633d
+         || !rHead.IsActive())
f0633d
     {
f0633d
         // Left or first shares the header with the Master.
f0633d
         rDescFrmFmt.SetFmtAttr( pDesc->GetMaster().GetHeader() );
f0633d
@@ -191,16 +207,19 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
f0633d
             const SwFmtCntnt &aCnt = rFmtHead.GetHeaderFmt()->GetCntnt();
f0633d
             if( !aCnt.GetCntntIdx() )
f0633d
             {
f0633d
-                const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
f0633d
+                const SwFrmFmt& rChgedFrmFmt = (bFirst)
f0633d
+                    ? (bLeft) ? rChged.GetFirstLeft() : rChged.GetFirstMaster()
f0633d
+                    : rChged.GetLeft();
f0633d
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetHeader() );
f0633d
             }
f0633d
             else if ((*aRCnt.GetCntntIdx() == *aCnt.GetCntntIdx()) ||
f0633d
                 // The CntntIdx is _always_ different when called from
f0633d
                 // SwDocStyleSheet::SetItemSet, because it deep-copies the
f0633d
                 // PageDesc.  So check if it was previously shared.
f0633d
-                 ((bLeft) ? pDesc->IsHeaderShared() : pDesc->IsFirstShared()))
f0633d
+                 ((bFirst) ? pDesc->IsFirstShared() : pDesc->IsHeaderShared()))
f0633d
             {
f0633d
-                SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left header" : "First header"),
f0633d
+                SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(),
f0633d
+                        (bFirst) ? "First header" : "Left header",
f0633d
                                                 GetDfltFrmFmt() );
f0633d
                 ::lcl_DescSetAttr( *pRight, *pFmt, false );
f0633d
                 // The section which the right header attribute is pointing
f0633d
@@ -226,12 +245,25 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
f0633d
     }
f0633d
 }
f0633d
 
f0633d
-void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft)
f0633d
+void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft, bool bFirst)
f0633d
 {
f0633d
-    SwFrmFmt& rDescFrmFmt = (bLeft ? pDesc->GetLeft() : pDesc->GetFirst());
f0633d
-    if ( (bLeft ? rChged.IsFooterShared() : rChged.IsFirstShared() ) || !rFoot.IsActive() )
f0633d
+    assert(bLeft || bFirst);
f0633d
+    SwFrmFmt& rDescFrmFmt = (bFirst)
f0633d
+            ? (bLeft) ? pDesc->GetFirstLeft() : pDesc->GetFirstMaster()
f0633d
+            : pDesc->GetLeft();
f0633d
+    if (bFirst && bLeft)
f0633d
+    {
f0633d
+        // special case: always shared with something
f0633d
+        rDescFrmFmt.SetFmtAttr( rChged.IsFirstShared()
f0633d
+                ? pDesc->GetLeft().GetFooter()
f0633d
+                : pDesc->GetFirstMaster().GetFooter());
f0633d
+    }
f0633d
+    else if ((bFirst ? rChged.IsFirstShared() : rChged.IsFooterShared())
f0633d
+        || !rFoot.IsActive())
f0633d
+    {
f0633d
         // Left or first shares the Header with the Master.
f0633d
         rDescFrmFmt.SetFmtAttr( pDesc->GetMaster().GetFooter() );
f0633d
+    }
f0633d
     else if ( rFoot.IsActive() )
f0633d
     {   // Left or first gets its own Footer if the Format does not already have one.
f0633d
         // If the Format already has a Footer and it points to the same section as the Right one,
f0633d
@@ -252,16 +284,19 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot,
f0633d
             const SwFmtCntnt &aLCnt = rFmtFoot.GetFooterFmt()->GetCntnt();
f0633d
             if( !aLCnt.GetCntntIdx() )
f0633d
             {
f0633d
-                const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
f0633d
+                const SwFrmFmt& rChgedFrmFmt = (bFirst)
f0633d
+                    ? (bLeft) ? rChged.GetFirstLeft() : rChged.GetFirstMaster()
f0633d
+                    : rChged.GetLeft();
f0633d
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetFooter() );
f0633d
             }
f0633d
             else if ((*aRCnt.GetCntntIdx() == *aLCnt.GetCntntIdx()) ||
f0633d
                 // The CntntIdx is _always_ different when called from
f0633d
                 // SwDocStyleSheet::SetItemSet, because it deep-copies the
f0633d
                 // PageDesc.  So check if it was previously shared.
f0633d
-                 ((bLeft) ? pDesc->IsFooterShared() : pDesc->IsFirstShared()))
f0633d
+                 ((bFirst) ? pDesc->IsFirstShared() : pDesc->IsFooterShared()))
f0633d
             {
f0633d
-                SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left footer" : "First footer"),
f0633d
+                SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(),
f0633d
+                        (bFirst) ? "First footer" : "Left footer",
f0633d
                                                 GetDfltFrmFmt() );
f0633d
                 ::lcl_DescSetAttr( *pRight, *pFmt, false );
f0633d
                 // The section to which the right footer attribute is pointing
f0633d
@@ -310,7 +345,9 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
f0633d
                    const_cast<SwPageDesc&>(rChged).GetLeft());
f0633d
     }
f0633d
     ::lcl_DescSetAttr(rChged.GetMaster(),
f0633d
-                   const_cast<SwPageDesc&>(rChged).GetFirst());
f0633d
+                   const_cast<SwPageDesc&>(rChged).GetFirstMaster());
f0633d
+    ::lcl_DescSetAttr(rChged.GetLeft(),
f0633d
+                   const_cast<SwPageDesc&>(rChged).GetFirstLeft());
f0633d
 
f0633d
     // Take over NumType.
f0633d
     if( rChged.GetNumType().GetNumberingType() != pDesc->GetNumType().GetNumberingType() )
f0633d
@@ -350,8 +387,9 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
f0633d
               rChged.IsFirstShared() != pDesc->IsFirstShared() );
f0633d
     }
f0633d
     pDesc->GetMaster().SetFmtAttr( rHead );
f0633d
-    CopyMasterHeader(rChged, rHead, pDesc, true); // Copy left header
f0633d
-    CopyMasterHeader(rChged, rHead, pDesc, false); // Copy first header
f0633d
+    CopyMasterHeader(rChged, rHead, pDesc, true, false); // Copy left header
f0633d
+    CopyMasterHeader(rChged, rHead, pDesc, false, true); // Copy first master
f0633d
+    CopyMasterHeader(rChged, rHead, pDesc, true, true);  // Copy first left
f0633d
     pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
f0633d
 
f0633d
     // Synch Footer.
f0633d
@@ -366,8 +404,9 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
f0633d
               rChged.IsFooterShared() != pDesc->IsFooterShared() );
f0633d
     }
f0633d
     pDesc->GetMaster().SetFmtAttr( rFoot );
f0633d
-    CopyMasterFooter(rChged, rFoot, pDesc, true); // Copy left footer
f0633d
-    CopyMasterFooter(rChged, rFoot, pDesc, false); // Copy first footer
f0633d
+    CopyMasterFooter(rChged, rFoot, pDesc, true, false); // Copy left footer
f0633d
+    CopyMasterFooter(rChged, rFoot, pDesc, false, true); // Copy first master
f0633d
+    CopyMasterFooter(rChged, rFoot, pDesc, true, true);  // Copy first left
f0633d
     pDesc->ChgFooterShare( rChged.IsFooterShared() );
f0633d
     // there is just one first shared flag for both header and footer?
f0633d
     pDesc->ChgFirstShare( rChged.IsFirstShared() );
f0633d
@@ -408,7 +447,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
f0633d
     // Take over the page attributes.
f0633d
     ::lcl_DescSetAttr( rChged.GetMaster(), pDesc->GetMaster() );
f0633d
     ::lcl_DescSetAttr( rChged.GetLeft(), pDesc->GetLeft() );
f0633d
-    ::lcl_DescSetAttr( rChged.GetFirst(), pDesc->GetFirst() );
f0633d
+    ::lcl_DescSetAttr( rChged.GetFirstMaster(), pDesc->GetFirstMaster() );
f0633d
+    ::lcl_DescSetAttr( rChged.GetFirstLeft(), pDesc->GetFirstLeft() );
f0633d
 
f0633d
     // If the FootnoteInfo changes, the pages are triggered.
f0633d
     if( !(pDesc->GetFtnInfo() == rChged.GetFtnInfo()) )
f0633d
@@ -422,7 +462,10 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
f0633d
             pDesc->GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
f0633d
         }
f0633d
         {
f0633d
-            pDesc->GetFirst().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
f0633d
+            pDesc->GetFirstMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
f0633d
+        }
f0633d
+        {
f0633d
+            pDesc->GetFirstLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
f0633d
         }
f0633d
     }
f0633d
     SetModified();
f0633d
@@ -444,6 +487,13 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
f0633d
         pBindings->Invalidate( SID_ATTR_PAGE_LRSPACE );
f0633d
     }
f0633d
 
f0633d
+    //h/f of first-left page must not be unique but same as first master or left
f0633d
+    assert((pDesc->IsFirstShared())
f0633d
+        ? pDesc->GetFirstLeft().GetHeader().GetHeaderFmt() == pDesc->GetLeft().GetHeader().GetHeaderFmt()
f0633d
+        : pDesc->GetFirstLeft().GetHeader().GetHeaderFmt() == pDesc->GetFirstMaster().GetHeader().GetHeaderFmt());
f0633d
+    assert((pDesc->IsFirstShared())
f0633d
+        ? pDesc->GetFirstLeft().GetFooter().GetFooterFmt() == pDesc->GetLeft().GetFooter().GetFooterFmt()
f0633d
+        : pDesc->GetFirstLeft().GetFooter().GetFooterFmt() == pDesc->GetFirstMaster().GetFooter().GetFooterFmt());
f0633d
 }
f0633d
 
f0633d
 /// All descriptors whose Follow point to the to-be-deleted have to be adapted.
f0633d
@@ -554,7 +604,7 @@ sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy,
f0633d
     {
f0633d
         pNew = new SwPageDesc( rName, GetDfltFrmFmt(), this );
f0633d
         // Set the default page format.
f0633d
-        lcl_DefaultPageFmt( USHRT_MAX, pNew->GetMaster(), pNew->GetLeft(), pNew->GetFirst() );
f0633d
+        lcl_DefaultPageFmt( USHRT_MAX, pNew->GetMaster(), pNew->GetLeft(), pNew->GetFirstMaster(), pNew->GetFirstLeft() );
f0633d
 
f0633d
         SvxFrameDirection aFrameDirection = bRegardLanguage ?
f0633d
             GetDefaultFrameDirection(GetAppLanguage())
f0633d
@@ -562,7 +612,8 @@ sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy,
f0633d
 
f0633d
         pNew->GetMaster().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
f0633d
         pNew->GetLeft().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
f0633d
-        pNew->GetFirst().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
f0633d
+        pNew->GetFirstMaster().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
f0633d
+        pNew->GetFirstLeft().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
f0633d
     }
f0633d
     maPageDescs.push_back( pNew );
f0633d
 
f0633d
@@ -855,7 +906,7 @@ void SwDoc::CheckDefaultPageFmt()
f0633d
                               LONG_MAX == rLeftSize.GetHeight();
f0633d
 
f0633d
         if ( bSetSize )
f0633d
-            lcl_DefaultPageFmt( rDesc.GetPoolFmtId(), rDesc.GetMaster(), rDesc.GetLeft(), rDesc.GetFirst() );
f0633d
+            lcl_DefaultPageFmt( rDesc.GetPoolFmtId(), rDesc.GetMaster(), rDesc.GetLeft(), rDesc.GetFirstMaster(), rDesc.GetFirstLeft() );
f0633d
     }
f0633d
 }
f0633d
 
f0633d
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
f0633d
index c94b913..78e347b 100644
f0633d
--- a/sw/source/core/doc/docfmt.cxx
f0633d
+++ b/sw/source/core/doc/docfmt.cxx
f0633d
@@ -2156,18 +2156,30 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
f0633d
     else
f0633d
         rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
f0633d
     if( !rDstDesc.IsFirstShared() )
f0633d
-        CopyHeader( rSrcDesc.GetFirst(), rDstDesc.GetFirst() );
f0633d
+    {
f0633d
+        CopyHeader( rSrcDesc.GetFirstMaster(), rDstDesc.GetFirstMaster() );
f0633d
+        rDstDesc.GetFirstLeft().SetFmtAttr(rDstDesc.GetFirstMaster().GetHeader());
f0633d
+    }
f0633d
     else
f0633d
-        rDstDesc.GetFirst().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
f0633d
+    {
f0633d
+        rDstDesc.GetFirstMaster().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
f0633d
+        rDstDesc.GetFirstLeft().SetFmtAttr(rDstDesc.GetLeft().GetHeader());
f0633d
+    }
f0633d
 
f0633d
     if( !rDstDesc.IsFooterShared() )
f0633d
         CopyFooter( rSrcDesc.GetLeft(), rDstDesc.GetLeft() );
f0633d
     else
f0633d
         rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
f0633d
     if( !rDstDesc.IsFirstShared() )
f0633d
-        CopyFooter( rSrcDesc.GetFirst(), rDstDesc.GetFirst() );
f0633d
+    {
f0633d
+        CopyFooter( rSrcDesc.GetFirstMaster(), rDstDesc.GetFirstMaster() );
f0633d
+        rDstDesc.GetFirstLeft().SetFmtAttr(rDstDesc.GetFirstMaster().GetFooter());
f0633d
+    }
f0633d
     else
f0633d
-        rDstDesc.GetFirst().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
f0633d
+    {
f0633d
+        rDstDesc.GetFirstMaster().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
f0633d
+        rDstDesc.GetFirstLeft().SetFmtAttr(rDstDesc.GetLeft().GetFooter());
f0633d
+    }
f0633d
 
f0633d
     if( bNotifyLayout && pTmpRoot )
f0633d
     {
f0633d
diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx
f0633d
index f0ee570..b6494f5 100644
f0633d
--- a/sw/source/core/doc/poolfmt.cxx
f0633d
+++ b/sw/source/core/doc/poolfmt.cxx
f0633d
@@ -1591,9 +1591,12 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
f0633d
     {
f0633d
         {
f0633d
             if( bSetLeft )
f0633d
+            {
f0633d
                 pNewPgDsc->GetLeft().SetFmtAttr( aSet );
f0633d
+                pNewPgDsc->GetFirstLeft().SetFmtAttr( aSet );
f0633d
+            }
f0633d
             pNewPgDsc->GetMaster().SetFmtAttr( aSet );
f0633d
-            pNewPgDsc->GetFirst().SetFmtAttr( aSet );
f0633d
+            pNewPgDsc->GetFirstMaster().SetFmtAttr( aSet );
f0633d
         }
f0633d
     }
f0633d
     return pNewPgDsc;
f0633d
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
f0633d
index 06dc22c..8245f14 100644
f0633d
--- a/sw/source/core/layout/frmtool.cxx
f0633d
+++ b/sw/source/core/layout/frmtool.cxx
f0633d
@@ -2719,18 +2719,19 @@ SwPageFrm * InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
f0633d
         if (rDesc.IsFirstShared())
f0633d
         {
f0633d
             // We need to fallback to left or right page format, decide it now.
f0633d
+            // FIXME: is this still needed?
f0633d
             if (bOdd)
f0633d
             {
f0633d
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetMaster().GetHeader() );
f0633d
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetMaster().GetFooter() );
f0633d
+                rDesc.GetFirstMaster().SetFmtAttr( rDesc.GetMaster().GetHeader() );
f0633d
+                rDesc.GetFirstMaster().SetFmtAttr( rDesc.GetMaster().GetFooter() );
f0633d
                 // fdo#60250 copy margins for mirrored pages
f0633d
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetMaster().GetLRSpace() );
f0633d
+                rDesc.GetFirstMaster().SetFmtAttr( rDesc.GetMaster().GetLRSpace() );
f0633d
             }
f0633d
             else
f0633d
             {
f0633d
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetLeft().GetHeader() );
f0633d
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetLeft().GetFooter() );
f0633d
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetLeft().GetLRSpace() );
f0633d
+                rDesc.GetFirstLeft().SetFmtAttr( rDesc.GetLeft().GetHeader() );
f0633d
+                rDesc.GetFirstLeft().SetFmtAttr( rDesc.GetLeft().GetFooter() );
f0633d
+                rDesc.GetFirstLeft().SetFmtAttr( rDesc.GetLeft().GetLRSpace() );
f0633d
             }
f0633d
         }
f0633d
     }
f0633d
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
f0633d
index 1b248f1..05a24d1 100644
f0633d
--- a/sw/source/core/layout/pagedesc.cxx
f0633d
+++ b/sw/source/core/layout/pagedesc.cxx
f0633d
@@ -49,7 +49,8 @@ SwPageDesc::SwPageDesc( const String& rName, SwFrmFmt *pFmt, SwDoc *pDc ) :
f0633d
     aDescName( rName ),
f0633d
     aMaster( pDc->GetAttrPool(), rName, pFmt ),
f0633d
     aLeft( pDc->GetAttrPool(), rName, pFmt ),
f0633d
-    aFirst( pDc->GetAttrPool(), rName, pFmt ),
f0633d
+    m_FirstMaster( pDc->GetAttrPool(), rName, pFmt ),
f0633d
+    m_FirstLeft( pDc->GetAttrPool(), rName, pFmt ),
f0633d
     aDepend( this, 0 ),
f0633d
     pFollow( this ),
f0633d
     nRegHeight( 0 ),
f0633d
@@ -67,7 +68,8 @@ SwPageDesc::SwPageDesc( const SwPageDesc &rCpy ) :
f0633d
     aNumType( rCpy.GetNumType() ),
f0633d
     aMaster( rCpy.GetMaster() ),
f0633d
     aLeft( rCpy.GetLeft() ),
f0633d
-    aFirst( rCpy.GetFirst() ),
f0633d
+    m_FirstMaster( rCpy.GetFirstMaster() ),
f0633d
+    m_FirstLeft( rCpy.GetFirstLeft() ),
f0633d
     aDepend( this, (SwModify*)rCpy.aDepend.GetRegisteredIn() ),
f0633d
     pFollow( rCpy.pFollow ),
f0633d
     nRegHeight( rCpy.GetRegHeight() ),
f0633d
@@ -85,7 +87,8 @@ SwPageDesc & SwPageDesc::operator = (const SwPageDesc & rSrc)
f0633d
     aNumType = rSrc.aNumType;
f0633d
     aMaster = rSrc.aMaster;
f0633d
     aLeft = rSrc.aLeft;
f0633d
-    aFirst = rSrc.aFirst;
f0633d
+    m_FirstMaster = rSrc.m_FirstMaster;
f0633d
+    m_FirstLeft = rSrc.m_FirstLeft;
f0633d
 
f0633d
     if (rSrc.pFollow == &rSrc)
f0633d
         pFollow = this;
f0633d
@@ -243,7 +246,15 @@ void SwPageDesc::RegisterChange()
f0633d
         }
f0633d
     }
f0633d
     {
f0633d
-        SwIterator<SwFrm,SwFmt> aIter( GetFirst() );
f0633d
+        SwIterator<SwFrm,SwFmt> aIter( GetFirstMaster() );
f0633d
+        for( SwFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
f0633d
+        {
f0633d
+            if( pLast->IsPageFrm() )
f0633d
+                ((SwPageFrm*)pLast)->PrepareRegisterChg();
f0633d
+        }
f0633d
+    }
f0633d
+    {
f0633d
+        SwIterator<SwFrm,SwFmt> aIter( GetFirstLeft() );
f0633d
         for( SwFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
f0633d
         {
f0633d
             if( pLast->IsPageFrm() )
f0633d
@@ -348,14 +359,14 @@ sal_Bool SwPageDesc::IsFollowNextPageOfNode( const SwNode& rNd ) const
f0633d
 SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst)
f0633d
 {
f0633d
     return (nsUseOnPage::PD_LEFT & eUse)
f0633d
-            ? ((bFirst) ? &aFirst : &aLeft)
f0633d
+            ? ((bFirst) ? &m_FirstLeft : &aLeft)
f0633d
             : 0;
f0633d
 }
f0633d
 
f0633d
 SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst)
f0633d
 {
f0633d
     return (nsUseOnPage::PD_RIGHT & eUse)
f0633d
-            ? ((bFirst) ? &aFirst : &aMaster)
f0633d
+            ? ((bFirst) ? &m_FirstMaster : &aMaster)
f0633d
             : 0;
f0633d
 }
f0633d
 
f0633d
diff --git a/sw/source/core/undo/SwUndoPageDesc.cxx b/sw/source/core/undo/SwUndoPageDesc.cxx
f0633d
index 6962684..b60c18b 100644
f0633d
--- a/sw/source/core/undo/SwUndoPageDesc.cxx
f0633d
+++ b/sw/source/core/undo/SwUndoPageDesc.cxx
f0633d
@@ -157,7 +157,7 @@ SwUndoPageDesc::SwUndoPageDesc(const SwPageDesc & _aOld,
f0633d
             }
f0633d
             if( !rNewDesc.IsFirstShared() )
f0633d
             {
f0633d
-                pFormat = new SwFrmFmt( *rNewDesc.GetFirst().GetHeader().GetHeaderFmt() );
f0633d
+                pFormat = new SwFrmFmt( *rNewDesc.GetFirstMaster().GetHeader().GetHeaderFmt() );
f0633d
                 // The Ctor of this object will remove the duplicate!
f0633d
                 SwFmtHeader aFormatHeader( pFormat );
f0633d
             }
f0633d
@@ -176,7 +176,7 @@ SwUndoPageDesc::SwUndoPageDesc(const SwPageDesc & _aOld,
f0633d
             }
f0633d
             if( !rNewDesc.IsFirstShared() )
f0633d
             {
f0633d
-                pFormat = new SwFrmFmt( *rNewDesc.GetFirst().GetFooter().GetFooterFmt() );
f0633d
+                pFormat = new SwFrmFmt( *rNewDesc.GetFirstMaster().GetFooter().GetFooterFmt() );
f0633d
                 // The Ctor of this object will remove the duplicate!
f0633d
                 SwFmtFooter aFormatFooter( pFormat );
f0633d
             }
f0633d
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
f0633d
index a7d3b17..0e090be 100644
f0633d
--- a/sw/source/core/unocore/unostyle.cxx
f0633d
+++ b/sw/source/core/unocore/unostyle.cxx
f0633d
@@ -3411,7 +3411,9 @@ MakeObject:
f0633d
                     }
f0633d
                     else if (bFirst && !bShareFirst)
f0633d
                     {
f0633d
-                        pFrmFmt = &rDesc.GetFirst();
f0633d
+                        pFrmFmt = &rDesc.GetFirstMaster();
f0633d
+                        // no need to make GetFirstLeft() accessible
f0633d
+                        // since it is always shared
f0633d
                     }
f0633d
                     else
f0633d
                     {
f0633d
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
index 097a8a7..bc08a72 100644
f0633d
--- a/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
f0633d
@@ -1614,7 +1614,7 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
f0633d
     // The latter method was previously used by the doc/docx import filter.
f0633d
     // In both of these cases, we emit a single Word section with different
f0633d
     // first page header/footer.
f0633d
-    const SwFrmFmt* pPdFirstPgFmt = &pPd->GetFirst();
f0633d
+    const SwFrmFmt* pPdFirstPgFmt = &pPd->GetFirstMaster();
f0633d
     bool titlePage = !pPd->IsFirstShared();
f0633d
     if ( bOutPgDscSet )
f0633d
     {
f0633d
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
f0633d
index d2dae7c..d211344 100644
f0633d
--- a/sw/source/filter/ww8/ww8atr.cxx
f0633d
+++ b/sw/source/filter/ww8/ww8atr.cxx
f0633d
@@ -371,7 +371,7 @@ bool MSWordExportBase::SetAktPageDescFromNode(const SwNode &rNd)
f0633d
                 bNewPageDesc = true;
f0633d
             else
f0633d
             {
f0633d
-                const SwFrmFmt& rTitleFmt = pAktPageDesc->GetFirst();
f0633d
+                const SwFrmFmt& rTitleFmt = pAktPageDesc->GetFirstMaster();
f0633d
                 const SwFrmFmt& rFollowFmt = pCurrent->GetMaster();
f0633d
 
f0633d
                 bNewPageDesc = !IsPlausableSingleWordSection(rTitleFmt,
f0633d
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
f0633d
index 223de68..b34b966 100644
f0633d
--- a/sw/source/filter/ww8/ww8par.cxx
f0633d
+++ b/sw/source/filter/ww8/ww8par.cxx
f0633d
@@ -2001,7 +2001,7 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
f0633d
                     = (nI & ( WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST )) ? true: false;
f0633d
 
f0633d
                 SwFrmFmt& rFmt = bUseLeft ? pPD->GetLeft()
f0633d
-                    : bUseFirst ? pPD->GetFirst()
f0633d
+                    : bUseFirst ? pPD->GetFirstMaster()
f0633d
                     : pPD->GetMaster();
f0633d
 
f0633d
                 SwFrmFmt* pHdFtFmt;
f0633d
@@ -2016,7 +2016,7 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
f0633d
                     if (bUseLeft)
f0633d
                         pPD->GetLeft().SetFmtAttr(SwFmtFooter(true));
f0633d
                     if (bUseFirst || (rSection.maSep.fTitlePage && bNoFirst))
f0633d
-                        pPD->GetFirst().SetFmtAttr(SwFmtFooter(true));
f0633d
+                        pPD->GetFirstMaster().SetFmtAttr(SwFmtFooter(true));
f0633d
                     pHdFtFmt = const_cast<SwFrmFmt*>(rFmt.GetFooter().GetFooterFmt());
f0633d
                 }
f0633d
                 else
f0633d
@@ -2028,7 +2028,7 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
f0633d
                     if (bUseLeft)
f0633d
                         pPD->GetLeft().SetFmtAttr(SwFmtHeader(true));
f0633d
                     if (bUseFirst || (rSection.maSep.fTitlePage && bNoFirst))
f0633d
-                        pPD->GetFirst().SetFmtAttr(SwFmtHeader(true));
f0633d
+                        pPD->GetFirstMaster().SetFmtAttr(SwFmtHeader(true));
f0633d
                     pHdFtFmt = const_cast<SwFrmFmt*>(rFmt.GetHeader().GetHeaderFmt());
f0633d
                 }
f0633d
 
f0633d
@@ -3853,7 +3853,7 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
f0633d
     if (!(rSection.maSep.pgbApplyTo & 1))
f0633d
         mrReader.SetPageBorder(rFmt, rSection);
f0633d
     if (!(rSection.maSep.pgbApplyTo & 2))
f0633d
-        mrReader.SetPageBorder(rPage.GetFirst(), rSection);
f0633d
+        mrReader.SetPageBorder(rPage.GetFirstMaster(), rSection);
f0633d
 
f0633d
     mrReader.SetDocumentGrid(rFmt, rSection);
f0633d
 }
f0633d
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
f0633d
index 0d9a638..49fd40e 100644
f0633d
--- a/sw/source/filter/ww8/ww8par6.cxx
f0633d
+++ b/sw/source/filter/ww8/ww8par6.cxx
f0633d
@@ -1183,14 +1183,14 @@ void SwWW8ImplReader::CopyPageDescHdFt(const SwPageDesc* pOrgPageDesc,
f0633d
     // copy first page header content section
f0633d
     if( nCode & WW8_HEADER_FIRST )
f0633d
     {
f0633d
-        rDoc.CopyHeader(pOrgPageDesc->GetFirst(),
f0633d
-                        pNewPageDesc->GetFirst());
f0633d
+        rDoc.CopyHeader(pOrgPageDesc->GetFirstMaster(),
f0633d
+                        pNewPageDesc->GetFirstMaster());
f0633d
     }
f0633d
     // copy first page footer content section
f0633d
     if( nCode & WW8_FOOTER_FIRST )
f0633d
     {
f0633d
-        rDoc.CopyFooter(pOrgPageDesc->GetFirst(),
f0633d
-                        pNewPageDesc->GetFirst());
f0633d
+        rDoc.CopyFooter(pOrgPageDesc->GetFirstMaster(),
f0633d
+                        pNewPageDesc->GetFirstMaster());
f0633d
     }
f0633d
 }
f0633d
 
f0633d
-- 
f0633d
1.8.4.2
f0633d