[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/inc sw/source

Michael Stahl mstahl at redhat.com
Sat Dec 21 08:02:18 PST 2013


 sw/inc/doc.hxx                         |    4 -
 sw/inc/pagedesc.hxx                    |   10 ++-
 sw/source/core/doc/docdesc.cxx         |   98 +++++++++++++++++++++++++--------
 sw/source/core/doc/docfmt.cxx          |   20 +++++-
 sw/source/core/doc/poolfmt.cxx         |    5 +
 sw/source/core/layout/frmtool.cxx      |   13 ++--
 sw/source/core/layout/pagedesc.cxx     |   23 +++++--
 sw/source/core/undo/SwUndoPageDesc.cxx |    4 -
 sw/source/core/unocore/unostyle.cxx    |    4 +
 sw/source/filter/ww8/wrtw8sty.cxx      |    2 
 sw/source/filter/ww8/ww8atr.cxx        |    2 
 sw/source/filter/ww8/ww8par.cxx        |    8 +-
 sw/source/filter/ww8/ww8par6.cxx       |    8 +-
 13 files changed, 143 insertions(+), 58 deletions(-)

New commits:
commit 0eafb69609d58798a9e00e93dd9ea39e9189db8b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Dec 20 17:58:12 2013 +0100

    fdo#69065: sw: fix mirrored page style with first-page
    
    If a mirrored page style is used with first-page on both a right page
    and a left page the current design cannot work because the margins in
    the SwPageDesc::aFirst cannot be right for both cases.
    
    So split that up so we get a first-master and first-left format and
    copy the headers/footers and margins as appropriate... which is really
    adding epicycles to a flawed design; probably this would be better with
    just a single SwFrmFmt that has different items for master/left/first
    headers.
    
    Change-Id: I0889a4ab5959b5a71172203bb64d185960a07d73
    (cherry picked from commit e936ecc92a7e362f57ce72a955697840920636b8)
    Reviewed-on: https://gerrit.libreoffice.org/7156
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 5898077..987d0ab 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -2077,9 +2077,9 @@ public:
 
 private:
     /// Copies master header to left / first one, if necessary - used by ChgPageDesc().
-    void CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft);
+    void CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft, bool bFirst);
     /// Copies master footer to left / first one, if necessary - used by ChgPageDesc().
-    void CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft);
+    void CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft, bool bFirst);
 
     /** continue computing a chunk of document statistics
       * \param nChars  number of characters to count before exiting
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index 4fa0449..b0bccec 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -135,7 +135,9 @@ class SW_DLLPUBLIC SwPageDesc : public SwModify
     SvxNumberType   aNumType;
     SwFrmFmt    aMaster;
     SwFrmFmt    aLeft;
-    SwFrmFmt    aFirst;
+    // FIXME epicycles growing here - page margins need to be stored differently
+    SwFrmFmt    m_FirstMaster;
+    SwFrmFmt    m_FirstLeft;
     SwDepend    aDepend;    ///< Because of grid alignment (Registerhaltigkeit).
     SwPageDesc *pFollow;
     sal_uInt16  nRegHeight; ///< Sentence spacing and fontascent of style.
@@ -190,10 +192,12 @@ public:
 
           SwFrmFmt &GetMaster() { return aMaster; }
           SwFrmFmt &GetLeft()   { return aLeft; }
-          SwFrmFmt &GetFirst()   { return aFirst; }
+          SwFrmFmt &GetFirstMaster()   { return m_FirstMaster; }
+          SwFrmFmt &GetFirstLeft()   { return m_FirstLeft; }
     const SwFrmFmt &GetMaster() const { return aMaster; }
     const SwFrmFmt &GetLeft()   const { return aLeft; }
-    const SwFrmFmt &GetFirst()   const { return aFirst; }
+    const SwFrmFmt &GetFirstMaster()   const { return m_FirstMaster; }
+    const SwFrmFmt &GetFirstLeft()   const { return m_FirstLeft; }
 
     /** Reset all attrs of the format but keep the ones a pagedesc
        cannot live without. */
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 3f1d636..c84a5d2 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -58,7 +58,8 @@ using namespace com::sun::star;
 static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId,
                                 SwFrmFmt &rFmt1,
                                 SwFrmFmt &rFmt2,
-                                SwFrmFmt &rFmt3 )
+                                SwFrmFmt &rFmt3,
+                                SwFrmFmt &rFmt4)
 {
     // --> #i41075# Printer on demand
     // This function does not require a printer anymore.
@@ -114,6 +115,10 @@ static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId,
     rFmt3.SetFmtAttr( aFrmSize );
     rFmt3.SetFmtAttr( aLR );
     rFmt3.SetFmtAttr( aUL );
+
+    rFmt4.SetFmtAttr( aFrmSize );
+    rFmt4.SetFmtAttr( aLR );
+    rFmt4.SetFmtAttr( aUL );
 }
 
 static void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
@@ -162,10 +167,21 @@ static void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
     rDest.SetPoolHlpFileId( rSource.GetPoolHlpFileId() );
 }
 
-void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft)
+void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft, bool bFirst)
 {
-    SwFrmFmt& rDescFrmFmt = (bLeft ? pDesc->GetLeft() : pDesc->GetFirst());
-    if ( (bLeft ? rChged.IsHeaderShared() : rChged.IsFirstShared() ) || !rHead.IsActive() )
+    assert(bLeft || bFirst);
+    SwFrmFmt& rDescFrmFmt = (bFirst)
+            ? (bLeft) ? pDesc->GetFirstLeft() : pDesc->GetFirstMaster()
+            : pDesc->GetLeft();
+    if (bFirst && bLeft)
+    {
+        // special case: always shared with something
+        rDescFrmFmt.SetFmtAttr( rChged.IsFirstShared()
+                ? pDesc->GetLeft().GetHeader()
+                : pDesc->GetFirstMaster().GetHeader());
+    }
+    else if ((bFirst ? rChged.IsFirstShared() : rChged.IsHeaderShared())
+         || !rHead.IsActive())
     {
         // Left or first shares the header with the Master.
         rDescFrmFmt.SetFmtAttr( pDesc->GetMaster().GetHeader() );
@@ -191,16 +207,19 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
 
             if (!aCnt.GetCntntIdx())
             {
-                const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
+                const SwFrmFmt& rChgedFrmFmt = (bFirst)
+                    ? (bLeft) ? rChged.GetFirstLeft() : rChged.GetFirstMaster()
+                    : rChged.GetLeft();
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetHeader() );
             }
             else if ((*aRCnt.GetCntntIdx() == *aCnt.GetCntntIdx()) ||
                 // The CntntIdx is _always_ different when called from
                 // SwDocStyleSheet::SetItemSet, because it deep-copies the
                 // PageDesc.  So check if it was previously shared.
-                 ((bLeft) ? pDesc->IsHeaderShared() : pDesc->IsFirstShared()))
+                 ((bFirst) ? pDesc->IsFirstShared() : pDesc->IsHeaderShared()))
             {
-                SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left header" : "First header"),
+                SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(),
+                        (bFirst) ? "First header" : "Left header",
                                                 GetDfltFrmFmt() );
                 ::lcl_DescSetAttr( *pRight, *pFmt, false );
                 // The section which the right header attribute is pointing
@@ -225,12 +244,25 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
     }
 }
 
-void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft)
+void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft, bool bFirst)
 {
-    SwFrmFmt& rDescFrmFmt = (bLeft ? pDesc->GetLeft() : pDesc->GetFirst());
-    if ( (bLeft ? rChged.IsFooterShared() : rChged.IsFirstShared() ) || !rFoot.IsActive() )
+    assert(bLeft || bFirst);
+    SwFrmFmt& rDescFrmFmt = (bFirst)
+            ? (bLeft) ? pDesc->GetFirstLeft() : pDesc->GetFirstMaster()
+            : pDesc->GetLeft();
+    if (bFirst && bLeft)
+    {
+        // special case: always shared with something
+        rDescFrmFmt.SetFmtAttr( rChged.IsFirstShared()
+                ? pDesc->GetLeft().GetFooter()
+                : pDesc->GetFirstMaster().GetFooter());
+    }
+    else if ((bFirst ? rChged.IsFirstShared() : rChged.IsFooterShared())
+        || !rFoot.IsActive())
+    {
         // Left or first shares the Header with the Master.
         rDescFrmFmt.SetFmtAttr( pDesc->GetMaster().GetFooter() );
+    }
     else if ( rFoot.IsActive() )
     {   // Left or first gets its own Footer if the Format does not already have one.
         // If the Format already has a Footer and it points to the same section as the Right one,
@@ -251,16 +283,19 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot,
             const SwFmtCntnt &aLCnt = rFmtFoot.GetFooterFmt()->GetCntnt();
             if( !aLCnt.GetCntntIdx() )
             {
-                const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
+                const SwFrmFmt& rChgedFrmFmt = (bFirst)
+                    ? (bLeft) ? rChged.GetFirstLeft() : rChged.GetFirstMaster()
+                    : rChged.GetLeft();
                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetFooter() );
             }
             else if ((*aRCnt.GetCntntIdx() == *aLCnt.GetCntntIdx()) ||
                 // The CntntIdx is _always_ different when called from
                 // SwDocStyleSheet::SetItemSet, because it deep-copies the
                 // PageDesc.  So check if it was previously shared.
-                 ((bLeft) ? pDesc->IsFooterShared() : pDesc->IsFirstShared()))
+                 ((bFirst) ? pDesc->IsFirstShared() : pDesc->IsFooterShared()))
             {
-                SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left footer" : "First footer"),
+                SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(),
+                        (bFirst) ? "First footer" : "Left footer",
                                                 GetDfltFrmFmt() );
                 ::lcl_DescSetAttr( *pRight, *pFmt, false );
                 // The section to which the right footer attribute is pointing
@@ -309,7 +344,9 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
                    const_cast<SwPageDesc&>(rChged).GetLeft());
     }
     ::lcl_DescSetAttr(rChged.GetMaster(),
-                   const_cast<SwPageDesc&>(rChged).GetFirst());
+                   const_cast<SwPageDesc&>(rChged).GetFirstMaster());
+    ::lcl_DescSetAttr(rChged.GetLeft(),
+                   const_cast<SwPageDesc&>(rChged).GetFirstLeft());
 
     // Take over NumType.
     if( rChged.GetNumType().GetNumberingType() != pDesc->GetNumType().GetNumberingType() )
@@ -349,8 +386,9 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
               rChged.IsFirstShared() != pDesc->IsFirstShared() );
     }
     pDesc->GetMaster().SetFmtAttr( rHead );
-    CopyMasterHeader(rChged, rHead, pDesc, true); // Copy left header
-    CopyMasterHeader(rChged, rHead, pDesc, false); // Copy first header
+    CopyMasterHeader(rChged, rHead, pDesc, true, false); // Copy left header
+    CopyMasterHeader(rChged, rHead, pDesc, false, true); // Copy first master
+    CopyMasterHeader(rChged, rHead, pDesc, true, true);  // Copy first left
     pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
 
     // Synch Footer.
@@ -365,8 +403,9 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
               rChged.IsFooterShared() != pDesc->IsFooterShared() );
     }
     pDesc->GetMaster().SetFmtAttr( rFoot );
-    CopyMasterFooter(rChged, rFoot, pDesc, true); // Copy left footer
-    CopyMasterFooter(rChged, rFoot, pDesc, false); // Copy first footer
+    CopyMasterFooter(rChged, rFoot, pDesc, true, false); // Copy left footer
+    CopyMasterFooter(rChged, rFoot, pDesc, false, true); // Copy first master
+    CopyMasterFooter(rChged, rFoot, pDesc, true, true);  // Copy first left
     pDesc->ChgFooterShare( rChged.IsFooterShared() );
     // there is just one first shared flag for both header and footer?
     pDesc->ChgFirstShare( rChged.IsFirstShared() );
@@ -407,7 +446,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
     // Take over the page attributes.
     ::lcl_DescSetAttr( rChged.GetMaster(), pDesc->GetMaster() );
     ::lcl_DescSetAttr( rChged.GetLeft(), pDesc->GetLeft() );
-    ::lcl_DescSetAttr( rChged.GetFirst(), pDesc->GetFirst() );
+    ::lcl_DescSetAttr( rChged.GetFirstMaster(), pDesc->GetFirstMaster() );
+    ::lcl_DescSetAttr( rChged.GetFirstLeft(), pDesc->GetFirstLeft() );
 
     // If the FootnoteInfo changes, the pages are triggered.
     if( !(pDesc->GetFtnInfo() == rChged.GetFtnInfo()) )
@@ -421,7 +461,10 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
             pDesc->GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
         }
         {
-            pDesc->GetFirst().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
+            pDesc->GetFirstMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
+        }
+        {
+            pDesc->GetFirstLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
         }
     }
     SetModified();
@@ -442,6 +485,14 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
         pBindings->Invalidate( SID_ATTR_PAGE_ULSPACE );
         pBindings->Invalidate( SID_ATTR_PAGE_LRSPACE );
     }
+
+    //h/f of first-left page must not be unique but same as first master or left
+    assert((pDesc->IsFirstShared())
+        ? pDesc->GetFirstLeft().GetHeader().GetHeaderFmt() == pDesc->GetLeft().GetHeader().GetHeaderFmt()
+        : pDesc->GetFirstLeft().GetHeader().GetHeaderFmt() == pDesc->GetFirstMaster().GetHeader().GetHeaderFmt());
+    assert((pDesc->IsFirstShared())
+        ? pDesc->GetFirstLeft().GetFooter().GetFooterFmt() == pDesc->GetLeft().GetFooter().GetFooterFmt()
+        : pDesc->GetFirstLeft().GetFooter().GetFooterFmt() == pDesc->GetFirstMaster().GetFooter().GetFooterFmt());
 }
 
 /// All descriptors whose Follow point to the to-be-deleted have to be adapted.
@@ -552,7 +603,7 @@ sal_uInt16 SwDoc::MakePageDesc( const OUString &rName, const SwPageDesc *pCpy,
     {
         pNew = new SwPageDesc( rName, GetDfltFrmFmt(), this );
         // Set the default page format.
-        lcl_DefaultPageFmt( USHRT_MAX, pNew->GetMaster(), pNew->GetLeft(), pNew->GetFirst() );
+        lcl_DefaultPageFmt( USHRT_MAX, pNew->GetMaster(), pNew->GetLeft(), pNew->GetFirstMaster(), pNew->GetFirstLeft() );
 
         SvxFrameDirection aFrameDirection = bRegardLanguage ?
             GetDefaultFrameDirection(GetAppLanguage())
@@ -560,7 +611,8 @@ sal_uInt16 SwDoc::MakePageDesc( const OUString &rName, const SwPageDesc *pCpy,
 
         pNew->GetMaster().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
         pNew->GetLeft().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
-        pNew->GetFirst().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
+        pNew->GetFirstMaster().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
+        pNew->GetFirstLeft().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
     }
     maPageDescs.push_back( pNew );
 
@@ -853,7 +905,7 @@ void SwDoc::CheckDefaultPageFmt()
                               LONG_MAX == rLeftSize.GetHeight();
 
         if ( bSetSize )
-            lcl_DefaultPageFmt( rDesc.GetPoolFmtId(), rDesc.GetMaster(), rDesc.GetLeft(), rDesc.GetFirst() );
+            lcl_DefaultPageFmt( rDesc.GetPoolFmtId(), rDesc.GetMaster(), rDesc.GetLeft(), rDesc.GetFirstMaster(), rDesc.GetFirstLeft() );
     }
 }
 
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index e2e671f..561cb0f 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -2157,18 +2157,30 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
     else
         rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
     if( !rDstDesc.IsFirstShared() )
-        CopyHeader( rSrcDesc.GetFirst(), rDstDesc.GetFirst() );
+    {
+        CopyHeader( rSrcDesc.GetFirstMaster(), rDstDesc.GetFirstMaster() );
+        rDstDesc.GetFirstLeft().SetFmtAttr(rDstDesc.GetFirstMaster().GetHeader());
+    }
     else
-        rDstDesc.GetFirst().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
+    {
+        rDstDesc.GetFirstMaster().SetFmtAttr( rDstDesc.GetMaster().GetHeader() );
+        rDstDesc.GetFirstLeft().SetFmtAttr(rDstDesc.GetLeft().GetHeader());
+    }
 
     if( !rDstDesc.IsFooterShared() )
         CopyFooter( rSrcDesc.GetLeft(), rDstDesc.GetLeft() );
     else
         rDstDesc.GetLeft().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
     if( !rDstDesc.IsFirstShared() )
-        CopyFooter( rSrcDesc.GetFirst(), rDstDesc.GetFirst() );
+    {
+        CopyFooter( rSrcDesc.GetFirstMaster(), rDstDesc.GetFirstMaster() );
+        rDstDesc.GetFirstLeft().SetFmtAttr(rDstDesc.GetFirstMaster().GetFooter());
+    }
     else
-        rDstDesc.GetFirst().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
+    {
+        rDstDesc.GetFirstMaster().SetFmtAttr( rDstDesc.GetMaster().GetFooter() );
+        rDstDesc.GetFirstLeft().SetFmtAttr(rDstDesc.GetLeft().GetFooter());
+    }
 
     if( bNotifyLayout && pTmpRoot )
     {
diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx
index c0836b0..cb754d1 100644
--- a/sw/source/core/doc/poolfmt.cxx
+++ b/sw/source/core/doc/poolfmt.cxx
@@ -1632,9 +1632,12 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
     if( aSet.Count() )
     {
         if( bSetLeft )
+        {
             pNewPgDsc->GetLeft().SetFmtAttr( aSet );
+            pNewPgDsc->GetFirstLeft().SetFmtAttr( aSet );
+        }
         pNewPgDsc->GetMaster().SetFmtAttr( aSet );
-        pNewPgDsc->GetFirst().SetFmtAttr( aSet );
+        pNewPgDsc->GetFirstMaster().SetFmtAttr( aSet );
     }
     return pNewPgDsc;
 }
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index ac95bf8..08b252b 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2719,18 +2719,19 @@ SwPageFrm * InsertNewPage( SwPageDesc &rDesc, SwFrm *pUpper,
         if (rDesc.IsFirstShared())
         {
             // We need to fallback to left or right page format, decide it now.
+            // FIXME: is this still needed?
             if (bOdd)
             {
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetMaster().GetHeader() );
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetMaster().GetFooter() );
+                rDesc.GetFirstMaster().SetFmtAttr( rDesc.GetMaster().GetHeader() );
+                rDesc.GetFirstMaster().SetFmtAttr( rDesc.GetMaster().GetFooter() );
                 // fdo#60250 copy margins for mirrored pages
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetMaster().GetLRSpace() );
+                rDesc.GetFirstMaster().SetFmtAttr( rDesc.GetMaster().GetLRSpace() );
             }
             else
             {
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetLeft().GetHeader() );
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetLeft().GetFooter() );
-                rDesc.GetFirst().SetFmtAttr( rDesc.GetLeft().GetLRSpace() );
+                rDesc.GetFirstLeft().SetFmtAttr( rDesc.GetLeft().GetHeader() );
+                rDesc.GetFirstLeft().SetFmtAttr( rDesc.GetLeft().GetFooter() );
+                rDesc.GetFirstLeft().SetFmtAttr( rDesc.GetLeft().GetLRSpace() );
             }
         }
     }
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index 0cfe870..c450a8c 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -50,7 +50,8 @@ SwPageDesc::SwPageDesc( const OUString& rName, SwFrmFmt *pFmt, SwDoc *pDc ) :
     aDescName( rName ),
     aMaster( pDc->GetAttrPool(), rName, pFmt ),
     aLeft( pDc->GetAttrPool(), rName, pFmt ),
-    aFirst( pDc->GetAttrPool(), rName, pFmt ),
+    m_FirstMaster( pDc->GetAttrPool(), rName, pFmt ),
+    m_FirstLeft( pDc->GetAttrPool(), rName, pFmt ),
     aDepend( this, 0 ),
     pFollow( this ),
     nRegHeight( 0 ),
@@ -68,7 +69,8 @@ SwPageDesc::SwPageDesc( const SwPageDesc &rCpy ) :
     aNumType( rCpy.GetNumType() ),
     aMaster( rCpy.GetMaster() ),
     aLeft( rCpy.GetLeft() ),
-    aFirst( rCpy.GetFirst() ),
+    m_FirstMaster( rCpy.GetFirstMaster() ),
+    m_FirstLeft( rCpy.GetFirstLeft() ),
     aDepend( this, (SwModify*)rCpy.aDepend.GetRegisteredIn() ),
     pFollow( rCpy.pFollow ),
     nRegHeight( rCpy.GetRegHeight() ),
@@ -86,7 +88,8 @@ SwPageDesc & SwPageDesc::operator = (const SwPageDesc & rSrc)
     aNumType = rSrc.aNumType;
     aMaster = rSrc.aMaster;
     aLeft = rSrc.aLeft;
-    aFirst = rSrc.aFirst;
+    m_FirstMaster = rSrc.m_FirstMaster;
+    m_FirstLeft = rSrc.m_FirstLeft;
 
     if (rSrc.pFollow == &rSrc)
         pFollow = this;
@@ -244,7 +247,15 @@ void SwPageDesc::RegisterChange()
         }
     }
     {
-        SwIterator<SwFrm,SwFmt> aIter( GetFirst() );
+        SwIterator<SwFrm,SwFmt> aIter( GetFirstMaster() );
+        for( SwFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
+        {
+            if( pLast->IsPageFrm() )
+                ((SwPageFrm*)pLast)->PrepareRegisterChg();
+        }
+    }
+    {
+        SwIterator<SwFrm,SwFmt> aIter( GetFirstLeft() );
         for( SwFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
         {
             if( pLast->IsPageFrm() )
@@ -349,14 +360,14 @@ sal_Bool SwPageDesc::IsFollowNextPageOfNode( const SwNode& rNd ) const
 SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst)
 {
     return (nsUseOnPage::PD_LEFT & eUse)
-            ? ((bFirst) ? &aFirst : &aLeft)
+            ? ((bFirst) ? &m_FirstLeft : &aLeft)
             : 0;
 }
 
 SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst)
 {
     return (nsUseOnPage::PD_RIGHT & eUse)
-            ? ((bFirst) ? &aFirst : &aMaster)
+            ? ((bFirst) ? &m_FirstMaster : &aMaster)
             : 0;
 }
 
diff --git a/sw/source/core/undo/SwUndoPageDesc.cxx b/sw/source/core/undo/SwUndoPageDesc.cxx
index 6962684..b60c18b 100644
--- a/sw/source/core/undo/SwUndoPageDesc.cxx
+++ b/sw/source/core/undo/SwUndoPageDesc.cxx
@@ -157,7 +157,7 @@ SwUndoPageDesc::SwUndoPageDesc(const SwPageDesc & _aOld,
             }
             if( !rNewDesc.IsFirstShared() )
             {
-                pFormat = new SwFrmFmt( *rNewDesc.GetFirst().GetHeader().GetHeaderFmt() );
+                pFormat = new SwFrmFmt( *rNewDesc.GetFirstMaster().GetHeader().GetHeaderFmt() );
                 // The Ctor of this object will remove the duplicate!
                 SwFmtHeader aFormatHeader( pFormat );
             }
@@ -176,7 +176,7 @@ SwUndoPageDesc::SwUndoPageDesc(const SwPageDesc & _aOld,
             }
             if( !rNewDesc.IsFirstShared() )
             {
-                pFormat = new SwFrmFmt( *rNewDesc.GetFirst().GetFooter().GetFooterFmt() );
+                pFormat = new SwFrmFmt( *rNewDesc.GetFirstMaster().GetFooter().GetFooterFmt() );
                 // The Ctor of this object will remove the duplicate!
                 SwFmtFooter aFormatFooter( pFormat );
             }
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 5560dcc..3df0b18 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -3418,7 +3418,9 @@ MakeObject:
                     }
                     else if (bFirst && !bShareFirst)
                     {
-                        pFrmFmt = &rDesc.GetFirst();
+                        pFrmFmt = &rDesc.GetFirstMaster();
+                        // no need to make GetFirstLeft() accessible
+                        // since it is always shared
                     }
                     else
                     {
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 454bf2e..e131dab 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1730,7 +1730,7 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
     // The latter method was previously used by the doc/docx import filter.
     // In both of these cases, we emit a single Word section with different
     // first page header/footer.
-    const SwFrmFmt* pPdFirstPgFmt = &pPd->GetFirst();
+    const SwFrmFmt* pPdFirstPgFmt = &pPd->GetFirstMaster();
     bool titlePage = !pPd->IsFirstShared();
     if ( bOutPgDscSet )
     {
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 349596c..3a36782 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -372,7 +372,7 @@ bool MSWordExportBase::SetAktPageDescFromNode(const SwNode &rNd)
                 bNewPageDesc = true;
             else
             {
-                const SwFrmFmt& rTitleFmt = pAktPageDesc->GetFirst();
+                const SwFrmFmt& rTitleFmt = pAktPageDesc->GetFirstMaster();
                 const SwFrmFmt& rFollowFmt = pCurrent->GetMaster();
 
                 bNewPageDesc = !IsPlausableSingleWordSection(rTitleFmt,
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 9638ed3..8607c58 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2337,7 +2337,7 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
                     = (nI & ( WW8_FOOTER_EVEN | WW8_FOOTER_ODD | WW8_FOOTER_FIRST )) ? true: false;
 
                 SwFrmFmt& rFmt = bUseLeft ? pPD->GetLeft()
-                    : bUseFirst ? pPD->GetFirst()
+                    : bUseFirst ? pPD->GetFirstMaster()
                     : pPD->GetMaster();
 
                 SwFrmFmt* pHdFtFmt;
@@ -2352,7 +2352,7 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
                     if (bUseLeft)
                         pPD->GetLeft().SetFmtAttr(SwFmtFooter(true));
                     if (bUseFirst || (rSection.maSep.fTitlePage && bNoFirst))
-                        pPD->GetFirst().SetFmtAttr(SwFmtFooter(true));
+                        pPD->GetFirstMaster().SetFmtAttr(SwFmtFooter(true));
                     pHdFtFmt = const_cast<SwFrmFmt*>(rFmt.GetFooter().GetFooterFmt());
                 }
                 else
@@ -2364,7 +2364,7 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
                     if (bUseLeft)
                         pPD->GetLeft().SetFmtAttr(SwFmtHeader(true));
                     if (bUseFirst || (rSection.maSep.fTitlePage && bNoFirst))
-                        pPD->GetFirst().SetFmtAttr(SwFmtHeader(true));
+                        pPD->GetFirstMaster().SetFmtAttr(SwFmtHeader(true));
                     pHdFtFmt = const_cast<SwFrmFmt*>(rFmt.GetHeader().GetHeaderFmt());
                 }
 
@@ -4219,7 +4219,7 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
     if (!(rSection.maSep.pgbApplyTo & 1))
         mrReader.SetPageBorder(rFmt, rSection);
     if (!(rSection.maSep.pgbApplyTo & 2))
-        mrReader.SetPageBorder(rPage.GetFirst(), rSection);
+        mrReader.SetPageBorder(rPage.GetFirstMaster(), rSection);
 
     mrReader.SetDocumentGrid(rFmt, rSection);
 }
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 4c35f4e..7283840 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -1183,14 +1183,14 @@ void SwWW8ImplReader::CopyPageDescHdFt(const SwPageDesc* pOrgPageDesc,
     // copy first page header content section
     if( nCode & WW8_HEADER_FIRST )
     {
-        rDoc.CopyHeader(pOrgPageDesc->GetFirst(),
-                        pNewPageDesc->GetFirst());
+        rDoc.CopyHeader(pOrgPageDesc->GetFirstMaster(),
+                        pNewPageDesc->GetFirstMaster());
     }
     // copy first page footer content section
     if( nCode & WW8_FOOTER_FIRST )
     {
-        rDoc.CopyFooter(pOrgPageDesc->GetFirst(),
-                        pNewPageDesc->GetFirst());
+        rDoc.CopyFooter(pOrgPageDesc->GetFirstMaster(),
+                        pNewPageDesc->GetFirstMaster());
     }
 }
 


More information about the Libreoffice-commits mailing list