[Libreoffice-commits] core.git: sw/inc sw/source

Julien Nabet serval2412 at yahoo.fr
Wed Dec 17 22:40:22 PST 2014


 sw/inc/edimp.hxx                     |    9 ---------
 sw/source/core/doc/CntntIdxStore.cxx |   21 ++++++++++++---------
 sw/source/core/doc/doccorr.cxx       |   35 ++++++++++++++++++++---------------
 sw/source/core/edit/edattr.cxx       |   14 +++++++-------
 4 files changed, 39 insertions(+), 40 deletions(-)

New commits:
commit 2a44e785da22fe08da295208c2819af813e63447
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Mon Dec 15 23:31:51 2014 +0100

    Related fdo#86929: Kill FOREACHPAM_START for good (final part)
    
    Change-Id: I74c6e8633ee5ac477d2f7ac8ee468204076bc886
    Reviewed-on: https://gerrit.libreoffice.org/13488
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx
index a62f0d2..44d53e8 100644
--- a/sw/inc/edimp.hxx
+++ b/sw/inc/edimp.hxx
@@ -27,15 +27,6 @@
 class SwPaM;
 class SwNodeIndex;
 
-// Macros to iterate over all ranges.
-#define PCURCRSR (static_cast<SwPaM *>(&__r))
-
-#define FOREACHPAM_START(pCURSH) \
-    for(SwPaM& __r : (pCURSH)->GetRingContainer()) \
-    {
-
-#define FOREACHPAM_END() }
-
 struct SwPamRange
 {
     sal_uLong nStart, nEnd;
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 353f6f7..3ce5b12 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -382,15 +382,17 @@ void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCn
 {
     BOOST_FOREACH(const SwUnoCrsr* pUnoCrsr, pDoc->GetUnoCrsrTbl())
     {
-        FOREACHPAM_START( const_cast<SwUnoCrsr*>(pUnoCrsr) )
-            lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR );
-        FOREACHPAM_END()
+        for(SwPaM& rPaM : (const_cast<SwUnoCrsr*>(pUnoCrsr))->GetRingContainer())
+        {
+            lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, rPaM);
+        }
         const SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr);
         if( pUnoTblCrsr )
         {
-            FOREACHPAM_START( &(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing() )
-                lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR );
-            FOREACHPAM_END()
+            for(SwPaM& rPaM : (&(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing())->GetRingContainer())
+            {
+                lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, rPaM);
+            }
         }
     }
 }
@@ -419,9 +421,10 @@ void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 n
                 } while ( (_pStkCrsr != 0 ) &&
                     ((_pStkCrsr = _pStkCrsr->GetNext()) != static_cast<SwCrsrShell*>(&rCurShell)->GetStkCrsr()) );
 
-            FOREACHPAM_START( static_cast<SwCrsrShell*>(&rCurShell)->_GetCrsr() )
-                lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR);
-            FOREACHPAM_END()
+            for(SwPaM& rPaM : (static_cast<SwCrsrShell*>(&rCurShell)->_GetCrsr())->GetRingContainer())
+            {
+                lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, rPaM);
+            }
         }
     }
 }
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index b012731..7cf4630 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -111,9 +111,10 @@ void PaMCorrAbs( const SwPaM& rRange,
                 } while ( (_pStkCrsr != 0 ) &&
                     ((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != pCrsrShell->GetStkCrsr()) );
 
-            FOREACHPAM_START( const_cast<SwShellCrsr*>(pCrsrShell->_GetCrsr()) )
-                lcl_PaMCorrAbs( *PCURCRSR, aStart, aEnd, aNewPos );
-            FOREACHPAM_END()
+            for(SwPaM& rPaM : const_cast<SwShellCrsr*>(pCrsrShell->_GetCrsr())->GetRingContainer())
+            {
+                lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
+            }
 
             if( pCrsrShell->IsTableMode() )
                 lcl_PaMCorrAbs( const_cast<SwPaM &>(*pCrsrShell->GetTblCrs()), aStart, aEnd, aNewPos );
@@ -136,18 +137,20 @@ void PaMCorrAbs( const SwPaM& rRange,
                   lcl_FindUnoCrsrSection(
                       pUnoCursor->GetPoint()->nNode.GetNode() ) );
 
-            FOREACHPAM_START( pUnoCursor )
-                bChange |= lcl_PaMCorrAbs( *PCURCRSR, aStart, aEnd, aNewPos );
-            FOREACHPAM_END()
+            for(SwPaM& rPaM : pUnoCursor->GetRingContainer())
+            {
+                bChange |= lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
+            }
 
             SwUnoTableCrsr *const pUnoTblCrsr =
                 dynamic_cast<SwUnoTableCrsr *>(*it);
             if( pUnoTblCrsr )
             {
-                FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
+                for(SwPaM& rPaM : (&pUnoTblCrsr->GetSelRing())->GetRingContainer())
+                {
                     bChange |=
-                        lcl_PaMCorrAbs( *PCURCRSR, aStart, aEnd, aNewPos );
-                FOREACHPAM_END()
+                        lcl_PaMCorrAbs( rPaM, aStart, aEnd, aNewPos );
+                }
             }
 
             // if a UNO cursor leaves its designated section, we must inform
@@ -275,17 +278,19 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
         SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl();
         for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it )
         {
-            FOREACHPAM_START( *it )
-                lcl_PaMCorrRel1( PCURCRSR, pOldNode, aNewPos, nCntIdx );
-            FOREACHPAM_END()
+            for(SwPaM& rPaM : (*it)->GetRingContainer())
+            {
+                lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
+            }
 
             SwUnoTableCrsr* pUnoTblCrsr =
                 dynamic_cast<SwUnoTableCrsr*>(*it);
             if( pUnoTblCrsr )
             {
-                FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() )
-                    lcl_PaMCorrRel1( PCURCRSR, pOldNode, aNewPos, nCntIdx );
-                FOREACHPAM_END()
+                for(SwPaM& rPaM : (&pUnoTblCrsr->GetSelRing())->GetRingContainer())
+                {
+                    lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx );
+                }
             }
         }
     }
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index ffa6d63..248fa1f 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -638,12 +638,12 @@ sal_uInt16 SwEditShell::GetScriptType() const
     sal_uInt16 nRet = 0;
 
     {
-        FOREACHPAM_START(GetCrsr())
-
-            const SwPosition *pStt = PCURCRSR->Start(),
-                             *pEnd = pStt == PCURCRSR->GetMark()
-                                    ? PCURCRSR->GetPoint()
-                                    : PCURCRSR->GetMark();
+        for(SwPaM& rPaM : GetCrsr()->GetRingContainer())
+        {
+            const SwPosition *pStt = rPaM.Start(),
+                             *pEnd = pStt == rPaM.GetMark()
+                                    ? rPaM.GetPoint()
+                                    : rPaM.GetMark();
             if( pStt == pEnd || *pStt == *pEnd )
             {
                 const SwTxtNode* pTNd = pStt->nNode.GetNode().GetTxtNode();
@@ -739,7 +739,7 @@ sal_uInt16 SwEditShell::GetScriptType() const
                                 SCRIPTTYPE_COMPLEX) == nRet )
                 break;
 
-        FOREACHPAM_END()
+        }
     }
     if( !nRet )
         nRet = SvtLanguageOptions::GetScriptTypeOfLanguage( LANGUAGE_SYSTEM );


More information about the Libreoffice-commits mailing list