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

Caolán McNamara caolanm at redhat.com
Thu Jul 21 14:48:07 UTC 2016


 sw/source/core/doc/CntntIdxStore.cxx |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

New commits:
commit a58e46482c2af06ee9be26313db3513f906d6c0b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 21 14:56:00 2016 +0100

    Resolves: tdf#95340 orig lcl_ChkUnoCrsrPaM had reversed 'set' to lcl_ChkPaM
    
    merge lcl_ChkUnoCrsrPaM and lcl_ChkPaM keeping the original logic,
    turns out they differed in how they swapped the mark and point
    
    Change-Id: Id2575c9690442494c3286a26ab099e8c4c62f884

diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 82de6b3..d51b87a 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -187,33 +187,24 @@ namespace
             static inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
                 { bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
     };
-    static void lcl_ChkUnoCrsrPaM(std::vector<PaMEntry>& rPamEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM, bool bPoint)
+    inline void lcl_ChkPaM( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM, const bool bGetPoint, bool bSetMark)
     {
-        const SwPosition* pPos = &rPaM.GetBound(bPoint);
+        const SwPosition* pPos = &rPaM.GetBound(bGetPoint);
         if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nContent )
         {
-            const PaMEntry aEntry = { &rPaM, !bPoint, pPos->nContent.GetIndex() };
-            rPamEntries.push_back(aEntry);
-        }
-    }
-    static void lcl_ChkUnoCrsrPaMBoth(std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM)
-    {
-        lcl_ChkUnoCrsrPaM(rPaMEntries, nNode, nContent, rPaM, true);
-        lcl_ChkUnoCrsrPaM(rPaMEntries, nNode, nContent, rPaM, false);
-    }
-    inline void lcl_ChkPaM( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM, const bool bPoint)
-    {
-        const SwPosition* pPos = &rPaM.GetBound( bPoint );
-        if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nContent )
-        {
-            const PaMEntry aEntry = { &rPaM, bPoint, pPos->nContent.GetIndex() };
+            const PaMEntry aEntry = { &rPaM, bSetMark, pPos->nContent.GetIndex() };
             rPaMEntries.push_back(aEntry);
         }
     }
     inline void lcl_ChkPaMBoth( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM)
     {
-        lcl_ChkPaM(rPaMEntries, nNode, nContent, rPaM, true);
-        lcl_ChkPaM(rPaMEntries, nNode, nContent, rPaM, false);
+        lcl_ChkPaM(rPaMEntries, nNode, nContent, rPaM, true, true);
+        lcl_ChkPaM(rPaMEntries, nNode, nContent, rPaM, false, false);
+    }
+    inline void lcl_ChkUnoCrsrPaMBoth(std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM)
+    {
+        lcl_ChkPaM(rPaMEntries, nNode, nContent, rPaM, true, false);
+        lcl_ChkPaM(rPaMEntries, nNode, nContent, rPaM, false, true);
     }
 
 #if 0
commit a3094a1f898b9efb765fe822fc507d3be4369361
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 21 14:49:23 2016 +0100

    rename lcl_ChkUnoCrsrPaM and split it up to be like lcl_ChkPaM[Both]
    
    Change-Id: I8850031da3901fb3d828c3af20f98ca741fc2a4a

diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index f4d2435..82de6b3 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -187,22 +187,20 @@ namespace
             static inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
                 { bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
     };
-    static void lcl_ChkUnoCrsrPaM(std::vector<PaMEntry>& rMarkEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPam)
+    static void lcl_ChkUnoCrsrPaM(std::vector<PaMEntry>& rPamEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM, bool bPoint)
     {
-        const SwPosition* pPos = &rPam.GetBound( true );
+        const SwPosition* pPos = &rPaM.GetBound(bPoint);
         if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nContent )
         {
-            const PaMEntry aEntry = { &rPam, false, pPos->nContent.GetIndex() };
-            rMarkEntries.push_back(aEntry);
-        }
-
-        pPos = &rPam.GetBound( false );
-        if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nContent )
-        {
-            const PaMEntry aEntry = { &rPam, true, pPos->nContent.GetIndex() };
-            rMarkEntries.push_back(aEntry);
+            const PaMEntry aEntry = { &rPaM, !bPoint, pPos->nContent.GetIndex() };
+            rPamEntries.push_back(aEntry);
         }
     }
+    static void lcl_ChkUnoCrsrPaMBoth(std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM)
+    {
+        lcl_ChkUnoCrsrPaM(rPaMEntries, nNode, nContent, rPaM, true);
+        lcl_ChkUnoCrsrPaM(rPaMEntries, nNode, nContent, rPaM, false);
+    }
     inline void lcl_ChkPaM( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM, const bool bPoint)
     {
         const SwPosition* pPos = &rPaM.GetBound( bPoint );
@@ -402,14 +400,14 @@ void ContentIdxStoreImpl::SaveUnoCursors(SwDoc* pDoc, sal_uLong nNode, sal_Int32
             continue;
         for(SwPaM& rPaM : pUnoCursor.get()->GetRingContainer())
         {
-            lcl_ChkUnoCrsrPaM(m_aUnoCursorEntries, nNode, nContent, rPaM);
+            lcl_ChkUnoCrsrPaMBoth(m_aUnoCursorEntries, nNode, nContent, rPaM);
         }
         const SwUnoTableCursor* pUnoTableCursor = dynamic_cast<const SwUnoTableCursor*>(pUnoCursor.get());
         if( pUnoTableCursor )
         {
             for(SwPaM& rPaM : (&(const_cast<SwUnoTableCursor*>(pUnoTableCursor))->GetSelRing())->GetRingContainer())
             {
-                lcl_ChkUnoCrsrPaM(m_aUnoCursorEntries, nNode, nContent, rPaM);
+                lcl_ChkUnoCrsrPaMBoth(m_aUnoCursorEntries, nNode, nContent, rPaM);
             }
         }
     }
commit 12d9292cd948dbf78bdcab4a46694563b3cce3cf
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 21 14:43:36 2016 +0100

    bChkSelDirection is always false
    
    Change-Id: I1aaf2c17d76ac1d69dfcc268ae1b689c0f1c3fa2

diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 48983d8..f4d2435 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -187,29 +187,17 @@ namespace
             static inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
                 { bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
     };
-    static void lcl_ChkUnoCrsrPaM( std::vector<PaMEntry>& rMarkEntries, const sal_uLong nNode, const sal_Int32 nContent,
-                    SwPaM& rPam, bool bChkSelDirection )
+    static void lcl_ChkUnoCrsrPaM(std::vector<PaMEntry>& rMarkEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPam)
     {
-        // Respect direction of selection
-        bool bBound1IsStart = !bChkSelDirection ||
-                            ( *rPam.GetPoint() < *rPam.GetMark()
-                                ? rPam.GetPoint() == &rPam.GetBound()
-                                : rPam.GetMark() == &rPam.GetBound());
-
         const SwPosition* pPos = &rPam.GetBound( true );
-        if( pPos->nNode.GetIndex() == nNode &&
-            ( bBound1IsStart ? pPos->nContent.GetIndex() < nContent
-                                : pPos->nContent.GetIndex() <= nContent ))
+        if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nContent )
         {
             const PaMEntry aEntry = { &rPam, false, pPos->nContent.GetIndex() };
             rMarkEntries.push_back(aEntry);
         }
 
         pPos = &rPam.GetBound( false );
-        if( pPos->nNode.GetIndex() == nNode &&
-            ( (bBound1IsStart && bChkSelDirection)
-                        ? pPos->nContent.GetIndex() <= nContent
-                        : pPos->nContent.GetIndex() < nContent ))
+        if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nContent )
         {
             const PaMEntry aEntry = { &rPam, true, pPos->nContent.GetIndex() };
             rMarkEntries.push_back(aEntry);
@@ -414,14 +402,14 @@ void ContentIdxStoreImpl::SaveUnoCursors(SwDoc* pDoc, sal_uLong nNode, sal_Int32
             continue;
         for(SwPaM& rPaM : pUnoCursor.get()->GetRingContainer())
         {
-            lcl_ChkUnoCrsrPaM(m_aUnoCursorEntries, nNode, nContent, rPaM, false);
+            lcl_ChkUnoCrsrPaM(m_aUnoCursorEntries, nNode, nContent, rPaM);
         }
         const SwUnoTableCursor* pUnoTableCursor = dynamic_cast<const SwUnoTableCursor*>(pUnoCursor.get());
         if( pUnoTableCursor )
         {
             for(SwPaM& rPaM : (&(const_cast<SwUnoTableCursor*>(pUnoTableCursor))->GetSelRing())->GetRingContainer())
             {
-                lcl_ChkUnoCrsrPaM(m_aUnoCursorEntries, nNode, nContent, rPaM, false);
+                lcl_ChkUnoCrsrPaM(m_aUnoCursorEntries, nNode, nContent, rPaM);
             }
         }
     }
commit dcae0b482ca78fc9cd6f8523f53aad8c8b486b0f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 21 14:38:29 2016 +0100

    update to new naming and casting
    
    Change-Id: I389efc2f45f3110932318882faea82ab8565f89a

diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 187f0f4..48983d8 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -187,9 +187,8 @@ namespace
             static inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
                 { bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
     };
-    static void lcl_ChkUnoCrsrPaM( std::vector<PaMEntry>& rMarkEntries, sal_uLong nNode, sal_Int32 nCntnt,
-                    const SwPaM& rPam,
-                    bool bChkSelDirection )
+    static void lcl_ChkUnoCrsrPaM( std::vector<PaMEntry>& rMarkEntries, const sal_uLong nNode, const sal_Int32 nContent,
+                    SwPaM& rPam, bool bChkSelDirection )
     {
         // Respect direction of selection
         bool bBound1IsStart = !bChkSelDirection ||
@@ -199,20 +198,20 @@ namespace
 
         const SwPosition* pPos = &rPam.GetBound( true );
         if( pPos->nNode.GetIndex() == nNode &&
-            ( bBound1IsStart ? pPos->nContent.GetIndex() < nCntnt
-                                : pPos->nContent.GetIndex() <= nCntnt ))
+            ( bBound1IsStart ? pPos->nContent.GetIndex() < nContent
+                                : pPos->nContent.GetIndex() <= nContent ))
         {
-            const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), false, pPos->nContent.GetIndex() };
+            const PaMEntry aEntry = { &rPam, false, pPos->nContent.GetIndex() };
             rMarkEntries.push_back(aEntry);
         }
 
         pPos = &rPam.GetBound( false );
         if( pPos->nNode.GetIndex() == nNode &&
             ( (bBound1IsStart && bChkSelDirection)
-                        ? pPos->nContent.GetIndex() <= nCntnt
-                        : pPos->nContent.GetIndex() < nCntnt ))
+                        ? pPos->nContent.GetIndex() <= nContent
+                        : pPos->nContent.GetIndex() < nContent ))
         {
-            const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), true, pPos->nContent.GetIndex() };
+            const PaMEntry aEntry = { &rPam, true, pPos->nContent.GetIndex() };
             rMarkEntries.push_back(aEntry);
         }
     }
commit 133ad42956ff38fe94020cd9aab316c9dfceff60
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 21 14:29:25 2016 +0100

    restore lcl_ChkUnoCrsrPaM
    
    Change-Id: Iab155151226f3a7f00ca649bd690c4391ade8a52

diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 5cb63da..187f0f4 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -187,6 +187,35 @@ namespace
             static inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
                 { bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
     };
+    static void lcl_ChkUnoCrsrPaM( std::vector<PaMEntry>& rMarkEntries, sal_uLong nNode, sal_Int32 nCntnt,
+                    const SwPaM& rPam,
+                    bool bChkSelDirection )
+    {
+        // Respect direction of selection
+        bool bBound1IsStart = !bChkSelDirection ||
+                            ( *rPam.GetPoint() < *rPam.GetMark()
+                                ? rPam.GetPoint() == &rPam.GetBound()
+                                : rPam.GetMark() == &rPam.GetBound());
+
+        const SwPosition* pPos = &rPam.GetBound( true );
+        if( pPos->nNode.GetIndex() == nNode &&
+            ( bBound1IsStart ? pPos->nContent.GetIndex() < nCntnt
+                                : pPos->nContent.GetIndex() <= nCntnt ))
+        {
+            const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), false, pPos->nContent.GetIndex() };
+            rMarkEntries.push_back(aEntry);
+        }
+
+        pPos = &rPam.GetBound( false );
+        if( pPos->nNode.GetIndex() == nNode &&
+            ( (bBound1IsStart && bChkSelDirection)
+                        ? pPos->nContent.GetIndex() <= nCntnt
+                        : pPos->nContent.GetIndex() < nCntnt ))
+        {
+            const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), true, pPos->nContent.GetIndex() };
+            rMarkEntries.push_back(aEntry);
+        }
+    }
     inline void lcl_ChkPaM( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nContent, SwPaM& rPaM, const bool bPoint)
     {
         const SwPosition* pPos = &rPaM.GetBound( bPoint );
@@ -386,14 +415,14 @@ void ContentIdxStoreImpl::SaveUnoCursors(SwDoc* pDoc, sal_uLong nNode, sal_Int32
             continue;
         for(SwPaM& rPaM : pUnoCursor.get()->GetRingContainer())
         {
-            lcl_ChkPaMBoth( m_aUnoCursorEntries, nNode, nContent, rPaM);
+            lcl_ChkUnoCrsrPaM(m_aUnoCursorEntries, nNode, nContent, rPaM, false);
         }
         const SwUnoTableCursor* pUnoTableCursor = dynamic_cast<const SwUnoTableCursor*>(pUnoCursor.get());
         if( pUnoTableCursor )
         {
             for(SwPaM& rPaM : (&(const_cast<SwUnoTableCursor*>(pUnoTableCursor))->GetSelRing())->GetRingContainer())
             {
-                lcl_ChkPaMBoth( m_aUnoCursorEntries, nNode, nContent, rPaM);
+                lcl_ChkUnoCrsrPaM(m_aUnoCursorEntries, nNode, nContent, rPaM, false);
             }
         }
     }


More information about the Libreoffice-commits mailing list