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

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed Jul 23 02:26:27 PDT 2014


 sw/source/core/doc/docbm.cxx |  588 +++++++++++++++----------------------------
 1 file changed, 210 insertions(+), 378 deletions(-)

New commits:
commit b38d520a5f17e96909096ee7bf4d3e9d012fd27e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:58:27 2014 +0200

    _SwSaveTypeCountContent dead and gone (and there was much rejoicing.)
    
    Change-Id: I296b2c58e6d8ad67f30b027b83a442a02d5b2794

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index b695698..a7149a2 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1389,26 +1389,14 @@ namespace
         bool m_isMark;
         sal_Int32 m_nCntnt;
     };
-    class _SwSaveTypeCountContent : public MarkEntry
-    {
-    public:
-        _SwSaveTypeCountContent() { m_bOther=false; m_nIdx=0; m_nCntnt = 0; }
-        _SwSaveTypeCountContent( const std::vector<MarkEntry> &rArr, sal_uInt16& rPos )
-        {
-            m_nIdx = rArr[ rPos ].m_nIdx;
-            m_bOther = rArr[ rPos ].m_bOther;
-            m_nCntnt = rArr[ rPos ].m_nCntnt;
-        }
-    };
     void _SaveCntntIdx(SwDoc* pDoc,
         sal_uLong nNode,
         sal_Int32 nCntnt,
         std::vector<MarkEntry> &rSaveArr,
         sal_uInt8 nSaveFly)
     {
-        // 1. Bookmarks
-        _SwSaveTypeCountContent aSave;
-        // 4. Paragraph anchored objects
+        // Paragraph anchored objects
+        MarkEntry aSave;
         {
             SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
             if( pNode )
@@ -1512,7 +1500,7 @@ namespace
         sal_uInt16 n = 0;
         while( n < rSaveArr.size() )
         {
-            _SwSaveTypeCountContent aSave( rSaveArr, n );
+            MarkEntry aSave = rSaveArr[n++];
             SwPosition* pPos = 0;
             if(!aSave.m_bOther)
             {
@@ -1563,7 +1551,7 @@ namespace
         sal_uInt16 n = 0;
         while( n < rSaveArr.size() )
         {
-            _SwSaveTypeCountContent aSave( rSaveArr, n );
+            MarkEntry aSave = rSaveArr[n];
             if( aSave.m_nCntnt >= nChkLen )
                 rSaveArr[n].m_nCntnt -= nChkLen;
             else
commit 3cb0aaa6dc987f894c0f36e9d8dc6a217b943656
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:50:13 2014 +0200

    remove obsolete Add() function
    
    Change-Id: I5a23fea7d2ef94cd5e313854b5d9b32224fbc7b6

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 1d4b662..b695698 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1399,10 +1399,6 @@ namespace
             m_bOther = rArr[ rPos ].m_bOther;
             m_nCntnt = rArr[ rPos ].m_nCntnt;
         }
-        void Add( std::vector<MarkEntry> &rArr )
-        {
-            rArr.push_back( *this );
-        }
     };
     void _SaveCntntIdx(SwDoc* pDoc,
         sal_uLong nNode,
@@ -1463,7 +1459,7 @@ namespace
                                 OSL_ENSURE( &rFmt == (*pDoc->GetSpzFrmFmts())[
                                                         aSave.m_nIdx ],
                                         "_SaveCntntIdx: Lost FrameFormat" );
-                                aSave.Add( rSaveArr );
+                                rSaveArr.push_back(aSave);
                             }
                         }
                     }
@@ -1497,7 +1493,7 @@ namespace
                                         continue;
                                 }
                             }
-                            aSave.Add( rSaveArr );
+                            rSaveArr.push_back(aSave);
                         }
                     }
                 }
commit 97fc8e191f60f02cd28741d1865612425b5a4290
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:42:47 2014 +0200

    remove obsolete SetContent/GetContent functions
    
    Change-Id: I9a707ffeb220f8f102869030b5266ef02a635628

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 5268b42..1d4b662 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1403,10 +1403,6 @@ namespace
         {
             rArr.push_back( *this );
         }
-
-
-        void SetContent( sal_Int32 n )     { m_nCntnt = n; }
-        sal_Int32 GetContent() const       { return m_nCntnt; }
     };
     void _SaveCntntIdx(SwDoc* pDoc,
         sal_uLong nNode,
@@ -1445,13 +1441,13 @@ namespace
                                    ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) )
                             {
                                 aSave.m_bOther = false;
-                                aSave.SetContent( pAPos->nContent.GetIndex() );
+                                aSave.m_nCntnt = pAPos->nContent.GetIndex();
 
                                 OSL_ENSURE( nNode == pAPos->nNode.GetIndex(),
                                         "_SaveCntntIdx: Wrong Node-Index" );
                                 if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
                                 {
-                                    if( nCntnt <= aSave.GetContent() )
+                                    if( nCntnt <= aSave.m_nCntnt )
                                     {
                                         if( SAVEFLY_SPLIT == nSaveFly )
                                             aSave.m_bOther = true;
@@ -1490,10 +1486,10 @@ namespace
                                FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
                         {
                             aSave.m_bOther = false;
-                            aSave.SetContent( pAPos->nContent.GetIndex() );
+                            aSave.m_nCntnt = pAPos->nContent.GetIndex();
                             if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
                             {
-                                if( nCntnt <= aSave.GetContent() )
+                                if( nCntnt <= aSave.m_nCntnt )
                                 {
                                     if( SAVEFLY_SPLIT == nSaveFly )
                                         aSave.m_bOther = true;
@@ -1534,7 +1530,7 @@ namespace
                     if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
                     {
                         aNewPos.nContent.Assign( pCNd,
-                                                 aSave.GetContent() + nOffset );
+                                                 aSave.m_nCntnt + nOffset );
                     }
                     else
                     {
@@ -1552,9 +1548,9 @@ namespace
             }
             if( pPos )
             {
-                SAL_INFO("sw.core", "setting " << pPos << " for Index " << aSave.m_nIdx << " on Node " << nNode << " from " << pPos->nContent.GetIndex() << " to " << (aSave.GetContent() + nOffset));
+                SAL_INFO("sw.core", "setting " << pPos << " for Index " << aSave.m_nIdx << " on Node " << nNode << " from " << pPos->nContent.GetIndex() << " to " << (aSave.m_nCntnt + nOffset));
                 pPos->nNode = *pCNd;
-                pPos->nContent.Assign( pCNd, aSave.GetContent() + nOffset );
+                pPos->nContent.Assign( pCNd, aSave.m_nCntnt + nOffset );
             }
         }
     }
@@ -1572,7 +1568,7 @@ namespace
         while( n < rSaveArr.size() )
         {
             _SwSaveTypeCountContent aSave( rSaveArr, n );
-            if( aSave.GetContent() >= nChkLen )
+            if( aSave.m_nCntnt >= nChkLen )
                 rSaveArr[n].m_nCntnt -= nChkLen;
             else
             {
@@ -1588,7 +1584,7 @@ namespace
                         if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
                         {
                             aNewPos.nContent.Assign( pCNd, std::min(
-                                                     aSave.GetContent(), nLen ) );
+                                                     aSave.m_nCntnt, nLen ) );
                         }
                         else
                         {
@@ -1602,7 +1598,7 @@ namespace
                 if( pPos )
                 {
                     pPos->nNode = rNd;
-                    pPos->nContent.Assign( pCNd, std::min( aSave.GetContent(), nLen ) );
+                    pPos->nContent.Assign( pCNd, std::min( aSave.m_nCntnt, nLen ) );
                 }
                 n -= 1;
                 rSaveArr.erase( rSaveArr.begin() + n, rSaveArr.begin() + n + 1);
commit eba9ff466200b21ac62754d7104f34274e9d2327
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:39:42 2014 +0200

    remove obsolete SetCount/DecCount/GetCount functions
    
    Change-Id: Ieee429bb96d53d5825ef39b849f757401a1f3e32

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index e1c4521..5268b42 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1404,9 +1404,6 @@ namespace
             rArr.push_back( *this );
         }
 
-        void SetCount( sal_uInt16 n )       { m_nIdx = n; }
-        sal_uInt16 GetCount() const         { return m_nIdx; }
-        sal_uInt16 DecCount()               { return --m_nIdx; }
 
         void SetContent( sal_Int32 n )     { m_nCntnt = n; }
         sal_Int32 GetContent() const       { return m_nCntnt; }
@@ -1462,13 +1459,13 @@ namespace
                                             continue;
                                     }
                                 }
-                                aSave.SetCount( pDoc->GetSpzFrmFmts()->size() );
-                                while( aSave.GetCount() &&
+                                aSave.m_nIdx = pDoc->GetSpzFrmFmts()->size();
+                                while( aSave.m_nIdx &&
                                         &rFmt != (*pDoc->GetSpzFrmFmts())[
-                                        aSave.DecCount() ] )
+                                        --aSave.m_nIdx ] )
                                     ; // nothing
                                 OSL_ENSURE( &rFmt == (*pDoc->GetSpzFrmFmts())[
-                                                        aSave.GetCount() ],
+                                                        aSave.m_nIdx ],
                                         "_SaveCntntIdx: Lost FrameFormat" );
                                 aSave.Add( rSaveArr );
                             }
@@ -1477,11 +1474,11 @@ namespace
                 }
                 else // No layout, so it's a bit more expensive ...
                 {
-                    for( aSave.SetCount( pDoc->GetSpzFrmFmts()->size() );
-                            aSave.GetCount() ; )
+                    for( aSave.m_nIdx = pDoc->GetSpzFrmFmts()->size();
+                            aSave.m_nIdx ; )
                     {
                         SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[
-                                                    aSave.DecCount() ];
+                                                    --aSave.m_nIdx ];
                         if ( RES_FLYFRMFMT != pFrmFmt->Which() &&
                                 RES_DRAWFRMFMT != pFrmFmt->Which() )
                             continue;
@@ -1527,7 +1524,7 @@ namespace
             SwPosition* pPos = 0;
             if(!aSave.m_bOther)
             {
-                SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
+                SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.m_nIdx ];
                 const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
                 if( rFlyAnchor.GetCntntAnchor() )
                 {
@@ -1549,13 +1546,13 @@ namespace
             }
             else if( bAuto )
             {
-                SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
+                SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.m_nIdx ];
                 SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
                 pFrmFmt->NotifyClients( pAnchor, pAnchor );
             }
             if( pPos )
             {
-                SAL_INFO("sw.core", "setting " << pPos << " for Index " << aSave.GetCount() << " on Node " << nNode << " from " << pPos->nContent.GetIndex() << " to " << (aSave.GetContent() + nOffset));
+                SAL_INFO("sw.core", "setting " << pPos << " for Index " << aSave.m_nIdx << " on Node " << nNode << " from " << pPos->nContent.GetIndex() << " to " << (aSave.GetContent() + nOffset));
                 pPos->nNode = *pCNd;
                 pPos->nContent.Assign( pCNd, aSave.GetContent() + nOffset );
             }
@@ -1581,7 +1578,7 @@ namespace
             {
                 SwPosition* pPos = 0;
                 {
-                    SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
+                    SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.m_nIdx ];
                     const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
                     if( rFlyAnchor.GetCntntAnchor() )
                     {
commit 4e579adddf9bbcc6cf3133fb2f412fc267108ec8
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:29:54 2014 +0200

    remove obsolete SetCharBound/IsCharBound functions
    
    Change-Id: I56e7f08178122ed37fcb4c1175770cd202d3c98d

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 3fe9975..e1c4521 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1404,9 +1404,6 @@ namespace
             rArr.push_back( *this );
         }
 
-        void SetCharBound( bool bCB )        { m_bOther = bCB; }
-        bool IsCharBound() const          { return m_bOther; }
-
         void SetCount( sal_uInt16 n )       { m_nIdx = n; }
         sal_uInt16 GetCount() const         { return m_nIdx; }
         sal_uInt16 DecCount()               { return --m_nIdx; }
@@ -1450,7 +1447,7 @@ namespace
                                      FLY_AT_PARA == rAnchor.GetAnchorId() ) ||
                                    ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) )
                             {
-                                aSave.SetCharBound(false);
+                                aSave.m_bOther = false;
                                 aSave.SetContent( pAPos->nContent.GetIndex() );
 
                                 OSL_ENSURE( nNode == pAPos->nNode.GetIndex(),
@@ -1460,7 +1457,7 @@ namespace
                                     if( nCntnt <= aSave.GetContent() )
                                     {
                                         if( SAVEFLY_SPLIT == nSaveFly )
-                                            aSave.SetCharBound(true);
+                                            aSave.m_bOther = true;
                                         else
                                             continue;
                                     }
@@ -1495,14 +1492,14 @@ namespace
                              ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
                                FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
                         {
-                            aSave.SetCharBound(false);
+                            aSave.m_bOther = false;
                             aSave.SetContent( pAPos->nContent.GetIndex() );
                             if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
                             {
                                 if( nCntnt <= aSave.GetContent() )
                                 {
                                     if( SAVEFLY_SPLIT == nSaveFly )
-                                        aSave.SetCharBound(true);
+                                        aSave.m_bOther = true;
                                     else
                                         continue;
                                 }
@@ -1528,7 +1525,7 @@ namespace
         {
             _SwSaveTypeCountContent aSave( rSaveArr, n );
             SwPosition* pPos = 0;
-            if(!aSave.IsCharBound())
+            if(!aSave.m_bOther)
             {
                 SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
                 const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
commit 944d4eae085c098b6754ccd6a3ca88a6f45537c2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:26:31 2014 +0200

    remove obsolete debug functions
    
    Change-Id: I997d20480e5e920f69b3402a4e73ef0fa70f112d

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 84d929b..3fe9975 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1413,13 +1413,6 @@ namespace
 
         void SetContent( sal_Int32 n )     { m_nCntnt = n; }
         sal_Int32 GetContent() const       { return m_nCntnt; }
-#if OSL_DEBUG_LEVEL > 0
-        void Dump()
-        {
-            SAL_INFO("sw.core", "Count: " << GetCount() << "\tType: " << IsCharBound() << "\tContent: " << GetContent());
-        }
-#endif
-
     };
     void _SaveCntntIdx(SwDoc* pDoc,
         sal_uLong nNode,
@@ -1565,9 +1558,6 @@ namespace
             }
             if( pPos )
             {
-    #if OSL_DEBUG_LEVEL > 0
-                aSave.Dump();
-    #endif
                 SAL_INFO("sw.core", "setting " << pPos << " for Index " << aSave.GetCount() << " on Node " << nNode << " from " << pPos->nContent.GetIndex() << " to " << (aSave.GetContent() + nOffset));
                 pPos->nNode = *pCNd;
                 pPos->nContent.Assign( pCNd, aSave.GetContent() + nOffset );
@@ -1762,15 +1752,6 @@ namespace
         BOOST_FOREACH(MarkEntry& aEntry, *pEntries)
             aEntry.Dump();
     }
-    static void DumpSaves(std::vector<sal_uLong> &rSaveArr)
-    {
-        sal_uInt16 n = 0;
-        while( n < rSaveArr.size() )
-        {
-            _SwSaveTypeCountContent aSave( rSaveArr, n );
-            aSave.Dump();
-        }
-    }
 #endif
 }
 
commit 1c13a3d8d7fa8821e78dc5f6674c6846eb683ad5
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:22:26 2014 +0200

    now use MarkEntry vector
    
    Change-Id: I437dab991a5d05f3da0ee9c1e009a69baa74d647

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 082dadb..84d929b 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1393,18 +1393,6 @@ namespace
     {
     public:
         _SwSaveTypeCountContent() { m_bOther=false; m_nIdx=0; m_nCntnt = 0; }
-        _SwSaveTypeCountContent( const std::vector<sal_uLong> &rArr, sal_uInt16& rPos )
-            {
-                m_bOther = static_cast<bool>(rArr[ rPos++ ]);
-                m_nIdx = static_cast<sal_uInt16>(rArr[ rPos++ ]);
-                m_nCntnt = static_cast<sal_Int32>(rArr[ rPos++ ]);
-            }
-        void Add( std::vector<sal_uLong> &rArr )
-        {
-            rArr.push_back( m_bOther );
-            rArr.push_back( m_nIdx );
-            rArr.push_back( m_nCntnt );
-        }
         _SwSaveTypeCountContent( const std::vector<MarkEntry> &rArr, sal_uInt16& rPos )
         {
             m_nIdx = rArr[ rPos ].m_nIdx;
@@ -1436,7 +1424,7 @@ namespace
     void _SaveCntntIdx(SwDoc* pDoc,
         sal_uLong nNode,
         sal_Int32 nCntnt,
-        std::vector<sal_uLong> &rSaveArr,
+        std::vector<MarkEntry> &rSaveArr,
         sal_uInt8 nSaveFly)
     {
         // 1. Bookmarks
@@ -1535,7 +1523,7 @@ namespace
     }
 
     void _RestoreCntntIdx(SwDoc* pDoc,
-        std::vector<sal_uLong> &rSaveArr,
+        std::vector<MarkEntry> &rSaveArr,
         sal_uLong nNode,
         sal_Int32 nOffset,
         bool bAuto)
@@ -1587,7 +1575,7 @@ namespace
         }
     }
 
-    void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
+    void _RestoreCntntIdx(std::vector<MarkEntry> &rSaveArr,
         const SwNode& rNd,
         sal_Int32 nLen,
         sal_Int32 nChkLen)
@@ -1601,7 +1589,7 @@ namespace
         {
             _SwSaveTypeCountContent aSave( rSaveArr, n );
             if( aSave.GetContent() >= nChkLen )
-                rSaveArr[ n-1 ] -= nChkLen;
+                rSaveArr[n].m_nCntnt -= nChkLen;
             else
             {
                 SwPosition* pPos = 0;
@@ -1632,8 +1620,8 @@ namespace
                     pPos->nNode = rNd;
                     pPos->nContent.Assign( pCNd, std::min( aSave.GetContent(), nLen ) );
                 }
-                n -= 2;
-                rSaveArr.erase( rSaveArr.begin() + n, rSaveArr.begin() + n + 2);
+                n -= 1;
+                rSaveArr.erase( rSaveArr.begin() + n, rSaveArr.begin() + n + 1);
             }
         }
     }
@@ -1669,21 +1657,21 @@ namespace
     {
         std::vector<MarkEntry> m_aBkmkEntries;
         std::vector<MarkEntry> m_aRedlineEntries;
+        std::vector<MarkEntry> m_aFlyEntries;
         std::vector<MarkEntry> m_aUnoCrsrEntries;
         std::vector<PaMEntry> m_aShellCrsrEntries;
-        std::vector<sal_uLong> m_aSaveArr;
         typedef boost::function<void (SwPosition& rPos, sal_Int32 nCntnt)> updater_t;
         virtual void Clear() SAL_OVERRIDE
         {
             m_aBkmkEntries.clear();
             m_aRedlineEntries.clear();
+            m_aFlyEntries.clear();
             m_aUnoCrsrEntries.clear();
             m_aShellCrsrEntries.clear();
-            m_aSaveArr.clear();
         }
         virtual bool Empty() SAL_OVERRIDE
         {
-            return m_aBkmkEntries.empty() && m_aRedlineEntries.empty() && m_aUnoCrsrEntries.empty() && m_aShellCrsrEntries.empty() && m_aSaveArr.empty();
+            return m_aBkmkEntries.empty() && m_aRedlineEntries.empty() && m_aFlyEntries.empty() && m_aUnoCrsrEntries.empty() && m_aShellCrsrEntries.empty();
         }
         virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly=0) SAL_OVERRIDE
         {
@@ -1691,7 +1679,7 @@ namespace
             SaveRedlines(pDoc, nNode, nCntnt);
             SaveUnoCrsrs(pDoc, nNode, nCntnt);
             SaveShellCrsrs(pDoc, nNode, nCntnt);
-            return _SaveCntntIdx(pDoc, nNode, nCntnt, m_aSaveArr, nSaveFly);
+            return _SaveCntntIdx(pDoc, nNode, nCntnt, m_aFlyEntries, nSaveFly);
         }
         virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false) SAL_OVERRIDE
         {
@@ -1699,7 +1687,7 @@ namespace
             updater_t aUpdater = OffsetUpdater(pCNd, nOffset);
             RestoreBkmks(pDoc, aUpdater);
             RestoreRedlines(pDoc, aUpdater);
-            _RestoreCntntIdx(pDoc, m_aSaveArr, nNode, nOffset, bAuto);
+            _RestoreCntntIdx(pDoc, m_aFlyEntries, nNode, nOffset, bAuto);
             RestoreUnoCrsrs(pDoc, aUpdater);
             RestoreShellCrsrs(pDoc, aUpdater);
         }
@@ -1710,7 +1698,7 @@ namespace
             updater_t aUpdater = LimitUpdater(pCNd, nLen, nCorrLen);
             RestoreBkmks(pDoc, aUpdater);
             RestoreRedlines(pDoc, aUpdater);
-            _RestoreCntntIdx(m_aSaveArr, rNd, nLen, nCorrLen);
+            _RestoreCntntIdx(m_aFlyEntries, rNd, nLen, nCorrLen);
             RestoreUnoCrsrs(pDoc, aUpdater);
             RestoreShellCrsrs(pDoc, aUpdater);
         }
commit 068e5816fa3b623bcb072bee776dd5d63d5d3370
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:10:20 2014 +0200

    enable saving SwSaveTypeCountContent to a MarkEntry vector
    
    Change-Id: I5aa94b0247db7142ce9ea1687b2d2dcc4e3189e9

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index ce84ceb..082dadb 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1405,6 +1405,16 @@ namespace
             rArr.push_back( m_nIdx );
             rArr.push_back( m_nCntnt );
         }
+        _SwSaveTypeCountContent( const std::vector<MarkEntry> &rArr, sal_uInt16& rPos )
+        {
+            m_nIdx = rArr[ rPos ].m_nIdx;
+            m_bOther = rArr[ rPos ].m_bOther;
+            m_nCntnt = rArr[ rPos ].m_nCntnt;
+        }
+        void Add( std::vector<MarkEntry> &rArr )
+        {
+            rArr.push_back( *this );
+        }
 
         void SetCharBound( bool bCB )        { m_bOther = bCB; }
         bool IsCharBound() const          { return m_bOther; }
commit 05061b257d088d90ee00bb551401f1b2c2c7063e
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 10:03:52 2014 +0200

    reduce SwSaveTypeCountContent to a MarkEntry: step 3
    
    Change-Id: I2379b75dc425faf45ffe7be01a5436cbf9103d79

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 189baf4..ce84ceb 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1391,33 +1391,30 @@ namespace
     };
     class _SwSaveTypeCountContent : public MarkEntry
     {
-        sal_uInt16 nCount;
-        sal_Int32 nContent;
-
     public:
-        _SwSaveTypeCountContent() { m_bOther=false; nCount=0; nContent = 0; }
+        _SwSaveTypeCountContent() { m_bOther=false; m_nIdx=0; m_nCntnt = 0; }
         _SwSaveTypeCountContent( const std::vector<sal_uLong> &rArr, sal_uInt16& rPos )
             {
                 m_bOther = static_cast<bool>(rArr[ rPos++ ]);
-                nCount = static_cast<sal_uInt16>(rArr[ rPos++ ]);
-                nContent = static_cast<sal_Int32>(rArr[ rPos++ ]);
+                m_nIdx = static_cast<sal_uInt16>(rArr[ rPos++ ]);
+                m_nCntnt = static_cast<sal_Int32>(rArr[ rPos++ ]);
             }
         void Add( std::vector<sal_uLong> &rArr )
         {
             rArr.push_back( m_bOther );
-            rArr.push_back( nCount );
-            rArr.push_back( nContent );
+            rArr.push_back( m_nIdx );
+            rArr.push_back( m_nCntnt );
         }
 
         void SetCharBound( bool bCB )        { m_bOther = bCB; }
         bool IsCharBound() const          { return m_bOther; }
 
-        void SetCount( sal_uInt16 n )       { nCount = n; }
-        sal_uInt16 GetCount() const         { return nCount; }
-        sal_uInt16 DecCount()               { return --nCount; }
+        void SetCount( sal_uInt16 n )       { m_nIdx = n; }
+        sal_uInt16 GetCount() const         { return m_nIdx; }
+        sal_uInt16 DecCount()               { return --m_nIdx; }
 
-        void SetContent( sal_Int32 n )     { nContent = n; }
-        sal_Int32 GetContent() const       { return nContent; }
+        void SetContent( sal_Int32 n )     { m_nCntnt = n; }
+        sal_Int32 GetContent() const       { return m_nCntnt; }
 #if OSL_DEBUG_LEVEL > 0
         void Dump()
         {
commit 64f0d275154142ed29010f2a693da21b78ee9c7f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 09:59:54 2014 +0200

    reduce SwSaveTypeCountContent to a MarkEntry: step 2
    
    Change-Id: Ic60280439a55206ee52b4dcf0f802abf78cf5f2b

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 6b18260..189baf4 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1389,29 +1389,28 @@ namespace
         bool m_isMark;
         sal_Int32 m_nCntnt;
     };
-    class _SwSaveTypeCountContent
+    class _SwSaveTypeCountContent : public MarkEntry
     {
-        bool bCharBound;
         sal_uInt16 nCount;
         sal_Int32 nContent;
 
     public:
-        _SwSaveTypeCountContent() { bCharBound=false; nCount=0; nContent = 0; }
+        _SwSaveTypeCountContent() { m_bOther=false; nCount=0; nContent = 0; }
         _SwSaveTypeCountContent( const std::vector<sal_uLong> &rArr, sal_uInt16& rPos )
             {
-                bCharBound = static_cast<bool>(rArr[ rPos++ ]);
+                m_bOther = static_cast<bool>(rArr[ rPos++ ]);
                 nCount = static_cast<sal_uInt16>(rArr[ rPos++ ]);
                 nContent = static_cast<sal_Int32>(rArr[ rPos++ ]);
             }
         void Add( std::vector<sal_uLong> &rArr )
         {
-            rArr.push_back( bCharBound );
+            rArr.push_back( m_bOther );
             rArr.push_back( nCount );
             rArr.push_back( nContent );
         }
 
-        void SetCharBound( bool bCB )        { bCharBound = bCB; }
-        bool IsCharBound() const          { return bCharBound; }
+        void SetCharBound( bool bCB )        { m_bOther = bCB; }
+        bool IsCharBound() const          { return m_bOther; }
 
         void SetCount( sal_uInt16 n )       { nCount = n; }
         sal_uInt16 GetCount() const         { return nCount; }
commit b880be3c5496e8f718943f8892744c45fe08e833
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 09:56:19 2014 +0200

    reformat/reorg docbm.cxx
    
    Change-Id: I73035e39c30056811d6518c5473c5793d0e5c943

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 1080764..6b18260 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1126,45 +1126,6 @@ namespace sw { namespace mark
 
 namespace
 {
-    class _SwSaveTypeCountContent
-    {
-        bool bCharBound;
-        sal_uInt16 nCount;
-        sal_Int32 nContent;
-
-    public:
-        _SwSaveTypeCountContent() { bCharBound=false; nCount=0; nContent = 0; }
-        _SwSaveTypeCountContent( const std::vector<sal_uLong> &rArr, sal_uInt16& rPos )
-            {
-                bCharBound = static_cast<bool>(rArr[ rPos++ ]);
-                nCount = static_cast<sal_uInt16>(rArr[ rPos++ ]);
-                nContent = static_cast<sal_Int32>(rArr[ rPos++ ]);
-            }
-        void Add( std::vector<sal_uLong> &rArr )
-        {
-            rArr.push_back( bCharBound );
-            rArr.push_back( nCount );
-            rArr.push_back( nContent );
-        }
-
-        void SetCharBound( bool bCB )        { bCharBound = bCB; }
-        bool IsCharBound() const          { return bCharBound; }
-
-        void SetCount( sal_uInt16 n )       { nCount = n; }
-        sal_uInt16 GetCount() const         { return nCount; }
-        sal_uInt16 DecCount()               { return --nCount; }
-
-        void SetContent( sal_Int32 n )     { nContent = n; }
-        sal_Int32 GetContent() const       { return nContent; }
-#if OSL_DEBUG_LEVEL > 0
-        void Dump()
-        {
-            SAL_INFO("sw.core", "Count: " << GetCount() << "\tType: " << IsCharBound() << "\tContent: " << GetContent());
-        }
-#endif
-
-    };
-
     // #i59534: If a paragraph will be splitted we have to restore some redline positions
     // This help function checks a position compared with a node and an content index
 
@@ -1197,18 +1158,6 @@ namespace
     {
         return rPos.nNode > rNdIdx || ( pIdx && rPos.nNode == rNdIdx && rPos.nContent > pIdx->GetIndex() );
     }
-
-#if 0
-    static void DumpSaves(std::vector<sal_uLong> &rSaveArr)
-    {
-        sal_uInt16 n = 0;
-        while( n < rSaveArr.size() )
-        {
-            _SwSaveTypeCountContent aSave( rSaveArr, n );
-            aSave.Dump();
-        }
-    }
-#endif
 }
 
 // IDocumentMarkAccess for SwDoc
@@ -1419,47 +1368,148 @@ void _DelBookmarks(
 }
 
 
-void _SaveCntntIdx(SwDoc* pDoc,
-    sal_uLong nNode,
-    sal_Int32 nCntnt,
-    std::vector<sal_uLong> &rSaveArr,
-    sal_uInt8 nSaveFly)
+
+namespace
 {
-    // 1. Bookmarks
-    _SwSaveTypeCountContent aSave;
-    // 4. Paragraph anchored objects
+    struct MarkEntry
+    {
+        long int m_nIdx;
+        bool m_bOther;
+        sal_Int32 m_nCntnt;
+#if 0
+        void Dump()
+        {
+            SAL_INFO("sw.core", "Index: " << m_nIdx << "\tOther: " << m_bOther << "\tContent: " << m_nCntnt);
+        }
+#endif
+    };
+    struct PaMEntry
     {
-        SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
-        if( pNode )
+        SwPaM* m_pPaM;
+        bool m_isMark;
+        sal_Int32 m_nCntnt;
+    };
+    class _SwSaveTypeCountContent
+    {
+        bool bCharBound;
+        sal_uInt16 nCount;
+        sal_Int32 nContent;
+
+    public:
+        _SwSaveTypeCountContent() { bCharBound=false; nCount=0; nContent = 0; }
+        _SwSaveTypeCountContent( const std::vector<sal_uLong> &rArr, sal_uInt16& rPos )
+            {
+                bCharBound = static_cast<bool>(rArr[ rPos++ ]);
+                nCount = static_cast<sal_uInt16>(rArr[ rPos++ ]);
+                nContent = static_cast<sal_Int32>(rArr[ rPos++ ]);
+            }
+        void Add( std::vector<sal_uLong> &rArr )
         {
+            rArr.push_back( bCharBound );
+            rArr.push_back( nCount );
+            rArr.push_back( nContent );
+        }
+
+        void SetCharBound( bool bCB )        { bCharBound = bCB; }
+        bool IsCharBound() const          { return bCharBound; }
 
-            SwFrm* pFrm = pNode->getLayoutFrm( pDoc->GetCurrentLayout() );
-#if OSL_DEBUG_LEVEL > 1
-            static bool bViaDoc = false;
-            if( bViaDoc )
-                pFrm = NULL;
+        void SetCount( sal_uInt16 n )       { nCount = n; }
+        sal_uInt16 GetCount() const         { return nCount; }
+        sal_uInt16 DecCount()               { return --nCount; }
+
+        void SetContent( sal_Int32 n )     { nContent = n; }
+        sal_Int32 GetContent() const       { return nContent; }
+#if OSL_DEBUG_LEVEL > 0
+        void Dump()
+        {
+            SAL_INFO("sw.core", "Count: " << GetCount() << "\tType: " << IsCharBound() << "\tContent: " << GetContent());
+        }
 #endif
-            if( pFrm ) // Do we have a layout? Then it's a bit cheaper ...
+
+    };
+    void _SaveCntntIdx(SwDoc* pDoc,
+        sal_uLong nNode,
+        sal_Int32 nCntnt,
+        std::vector<sal_uLong> &rSaveArr,
+        sal_uInt8 nSaveFly)
+    {
+        // 1. Bookmarks
+        _SwSaveTypeCountContent aSave;
+        // 4. Paragraph anchored objects
+        {
+            SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
+            if( pNode )
             {
-                if( pFrm->GetDrawObjs() )
+
+                SwFrm* pFrm = pNode->getLayoutFrm( pDoc->GetCurrentLayout() );
+    #if OSL_DEBUG_LEVEL > 1
+                static bool bViaDoc = false;
+                if( bViaDoc )
+                    pFrm = NULL;
+    #endif
+                if( pFrm ) // Do we have a layout? Then it's a bit cheaper ...
+                {
+                    if( pFrm->GetDrawObjs() )
+                    {
+                        const SwSortedObjs& rDObj = *pFrm->GetDrawObjs();
+                        for( sal_uInt32 n = rDObj.Count(); n; )
+                        {
+                            SwAnchoredObject* pObj = rDObj[ --n ];
+                            const SwFrmFmt& rFmt = pObj->GetFrmFmt();
+                            const SwFmtAnchor& rAnchor = rFmt.GetAnchor();
+                            SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
+                            if ( pAPos &&
+                                 ( ( nSaveFly &&
+                                     FLY_AT_PARA == rAnchor.GetAnchorId() ) ||
+                                   ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) )
+                            {
+                                aSave.SetCharBound(false);
+                                aSave.SetContent( pAPos->nContent.GetIndex() );
+
+                                OSL_ENSURE( nNode == pAPos->nNode.GetIndex(),
+                                        "_SaveCntntIdx: Wrong Node-Index" );
+                                if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
+                                {
+                                    if( nCntnt <= aSave.GetContent() )
+                                    {
+                                        if( SAVEFLY_SPLIT == nSaveFly )
+                                            aSave.SetCharBound(true);
+                                        else
+                                            continue;
+                                    }
+                                }
+                                aSave.SetCount( pDoc->GetSpzFrmFmts()->size() );
+                                while( aSave.GetCount() &&
+                                        &rFmt != (*pDoc->GetSpzFrmFmts())[
+                                        aSave.DecCount() ] )
+                                    ; // nothing
+                                OSL_ENSURE( &rFmt == (*pDoc->GetSpzFrmFmts())[
+                                                        aSave.GetCount() ],
+                                        "_SaveCntntIdx: Lost FrameFormat" );
+                                aSave.Add( rSaveArr );
+                            }
+                        }
+                    }
+                }
+                else // No layout, so it's a bit more expensive ...
                 {
-                    const SwSortedObjs& rDObj = *pFrm->GetDrawObjs();
-                    for( sal_uInt32 n = rDObj.Count(); n; )
+                    for( aSave.SetCount( pDoc->GetSpzFrmFmts()->size() );
+                            aSave.GetCount() ; )
                     {
-                        SwAnchoredObject* pObj = rDObj[ --n ];
-                        const SwFrmFmt& rFmt = pObj->GetFrmFmt();
-                        const SwFmtAnchor& rAnchor = rFmt.GetAnchor();
+                        SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[
+                                                    aSave.DecCount() ];
+                        if ( RES_FLYFRMFMT != pFrmFmt->Which() &&
+                                RES_DRAWFRMFMT != pFrmFmt->Which() )
+                            continue;
+
+                        const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
                         SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
-                        if ( pAPos &&
-                             ( ( nSaveFly &&
-                                 FLY_AT_PARA == rAnchor.GetAnchorId() ) ||
-                               ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) )
+                        if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) &&
+                             ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
+                               FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
                         {
                             aSave.SetCharBound(false);
                             aSave.SetContent( pAPos->nContent.GetIndex() );
-
-                            OSL_ENSURE( nNode == pAPos->nNode.GetIndex(),
-                                    "_SaveCntntIdx: Wrong Node-Index" );
                             if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
                             {
                                 if( nCntnt <= aSave.GetContent() )
@@ -1470,127 +1520,28 @@ void _SaveCntntIdx(SwDoc* pDoc,
                                         continue;
                                 }
                             }
-                            aSave.SetCount( pDoc->GetSpzFrmFmts()->size() );
-                            while( aSave.GetCount() &&
-                                    &rFmt != (*pDoc->GetSpzFrmFmts())[
-                                    aSave.DecCount() ] )
-                                ; // nothing
-                            OSL_ENSURE( &rFmt == (*pDoc->GetSpzFrmFmts())[
-                                                    aSave.GetCount() ],
-                                    "_SaveCntntIdx: Lost FrameFormat" );
                             aSave.Add( rSaveArr );
                         }
                     }
                 }
             }
-            else // No layout, so it's a bit more expensive ...
-            {
-                for( aSave.SetCount( pDoc->GetSpzFrmFmts()->size() );
-                        aSave.GetCount() ; )
-                {
-                    SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[
-                                                aSave.DecCount() ];
-                    if ( RES_FLYFRMFMT != pFrmFmt->Which() &&
-                            RES_DRAWFRMFMT != pFrmFmt->Which() )
-                        continue;
-
-                    const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
-                    SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
-                    if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) &&
-                         ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
-                           FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
-                    {
-                        aSave.SetCharBound(false);
-                        aSave.SetContent( pAPos->nContent.GetIndex() );
-                        if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
-                        {
-                            if( nCntnt <= aSave.GetContent() )
-                            {
-                                if( SAVEFLY_SPLIT == nSaveFly )
-                                    aSave.SetCharBound(true);
-                                else
-                                    continue;
-                            }
-                        }
-                        aSave.Add( rSaveArr );
-                    }
-                }
-            }
-        }
-    }
-}
-
-void _RestoreCntntIdx(SwDoc* pDoc,
-    std::vector<sal_uLong> &rSaveArr,
-    sal_uLong nNode,
-    sal_Int32 nOffset,
-    bool bAuto)
-{
-    SwCntntNode* pCNd = pDoc->GetNodes()[ nNode ]->GetCntntNode();
-    SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
-    sal_uInt16 n = 0;
-    while( n < rSaveArr.size() )
-    {
-        _SwSaveTypeCountContent aSave( rSaveArr, n );
-        SwPosition* pPos = 0;
-        if(!aSave.IsCharBound())
-        {
-            SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
-            const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
-            if( rFlyAnchor.GetCntntAnchor() )
-            {
-                SwFmtAnchor aNew( rFlyAnchor );
-                SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
-                aNewPos.nNode = *pCNd;
-                if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
-                {
-                    aNewPos.nContent.Assign( pCNd,
-                                             aSave.GetContent() + nOffset );
-                }
-                else
-                {
-                    aNewPos.nContent.Assign( 0, 0 );
-                }
-                aNew.SetAnchor( &aNewPos );
-                pFrmFmt->SetFmtAttr( aNew );
-            }
-        }
-        else if( bAuto )
-        {
-            SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
-            SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
-            pFrmFmt->NotifyClients( pAnchor, pAnchor );
-        }
-        if( pPos )
-        {
-#if OSL_DEBUG_LEVEL > 0
-            aSave.Dump();
-#endif
-            SAL_INFO("sw.core", "setting " << pPos << " for Index " << aSave.GetCount() << " on Node " << nNode << " from " << pPos->nContent.GetIndex() << " to " << (aSave.GetContent() + nOffset));
-            pPos->nNode = *pCNd;
-            pPos->nContent.Assign( pCNd, aSave.GetContent() + nOffset );
         }
     }
-}
 
-void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
-    const SwNode& rNd,
-    sal_Int32 nLen,
-    sal_Int32 nChkLen)
-{
-    const SwDoc* pDoc = rNd.GetDoc();
-    const SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
-    SwCntntNode* pCNd = (SwCntntNode*)rNd.GetCntntNode();
-
-    sal_uInt16 n = 0;
-    while( n < rSaveArr.size() )
+    void _RestoreCntntIdx(SwDoc* pDoc,
+        std::vector<sal_uLong> &rSaveArr,
+        sal_uLong nNode,
+        sal_Int32 nOffset,
+        bool bAuto)
     {
-        _SwSaveTypeCountContent aSave( rSaveArr, n );
-        if( aSave.GetContent() >= nChkLen )
-            rSaveArr[ n-1 ] -= nChkLen;
-        else
+        SwCntntNode* pCNd = pDoc->GetNodes()[ nNode ]->GetCntntNode();
+        SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
+        sal_uInt16 n = 0;
+        while( n < rSaveArr.size() )
         {
+            _SwSaveTypeCountContent aSave( rSaveArr, n );
             SwPosition* pPos = 0;
+            if(!aSave.IsCharBound())
             {
                 SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
                 const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
@@ -1598,11 +1549,11 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
                 {
                     SwFmtAnchor aNew( rFlyAnchor );
                     SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
-                    aNewPos.nNode = rNd;
+                    aNewPos.nNode = *pCNd;
                     if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
                     {
-                        aNewPos.nContent.Assign( pCNd, std::min(
-                                                 aSave.GetContent(), nLen ) );
+                        aNewPos.nContent.Assign( pCNd,
+                                                 aSave.GetContent() + nOffset );
                     }
                     else
                     {
@@ -1612,38 +1563,74 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
                     pFrmFmt->SetFmtAttr( aNew );
                 }
             }
-
+            else if( bAuto )
+            {
+                SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
+                SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
+                pFrmFmt->NotifyClients( pAnchor, pAnchor );
+            }
             if( pPos )
             {
-                pPos->nNode = rNd;
-                pPos->nContent.Assign( pCNd, std::min( aSave.GetContent(), nLen ) );
+    #if OSL_DEBUG_LEVEL > 0
+                aSave.Dump();
+    #endif
+                SAL_INFO("sw.core", "setting " << pPos << " for Index " << aSave.GetCount() << " on Node " << nNode << " from " << pPos->nContent.GetIndex() << " to " << (aSave.GetContent() + nOffset));
+                pPos->nNode = *pCNd;
+                pPos->nContent.Assign( pCNd, aSave.GetContent() + nOffset );
             }
-            n -= 2;
-            rSaveArr.erase( rSaveArr.begin() + n, rSaveArr.begin() + n + 2);
         }
     }
-}
 
-namespace
-{
-    struct MarkEntry
+    void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
+        const SwNode& rNd,
+        sal_Int32 nLen,
+        sal_Int32 nChkLen)
     {
-        long int m_nIdx;
-        bool m_bOther;
-        sal_Int32 m_nCntnt;
-#if 0
-        void Dump()
+        const SwDoc* pDoc = rNd.GetDoc();
+        const SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
+        SwCntntNode* pCNd = (SwCntntNode*)rNd.GetCntntNode();
+
+        sal_uInt16 n = 0;
+        while( n < rSaveArr.size() )
         {
-            SAL_INFO("sw.core", "Index: " << m_nIdx << "\tOther: " << m_bOther << "\tContent: " << m_nCntnt);
+            _SwSaveTypeCountContent aSave( rSaveArr, n );
+            if( aSave.GetContent() >= nChkLen )
+                rSaveArr[ n-1 ] -= nChkLen;
+            else
+            {
+                SwPosition* pPos = 0;
+                {
+                    SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
+                    const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
+                    if( rFlyAnchor.GetCntntAnchor() )
+                    {
+                        SwFmtAnchor aNew( rFlyAnchor );
+                        SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
+                        aNewPos.nNode = rNd;
+                        if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
+                        {
+                            aNewPos.nContent.Assign( pCNd, std::min(
+                                                     aSave.GetContent(), nLen ) );
+                        }
+                        else
+                        {
+                            aNewPos.nContent.Assign( 0, 0 );
+                        }
+                        aNew.SetAnchor( &aNewPos );
+                        pFrmFmt->SetFmtAttr( aNew );
+                    }
+                }
+
+                if( pPos )
+                {
+                    pPos->nNode = rNd;
+                    pPos->nContent.Assign( pCNd, std::min( aSave.GetContent(), nLen ) );
+                }
+                n -= 2;
+                rSaveArr.erase( rSaveArr.begin() + n, rSaveArr.begin() + n + 2);
+            }
         }
-#endif
-    };
-    struct PaMEntry
-    {
-        SwPaM* m_pPaM;
-        bool m_isMark;
-        sal_Int32 m_nCntnt;
-    };
+    }
     struct OffsetUpdater
     {
         const SwCntntNode* m_pNewCntntNode;
@@ -1774,12 +1761,22 @@ namespace
             rPaMEntries.push_back(aEntry);
         }
     }
+
 #if 0
     static void DumpEntries(std::vector<MarkEntry>* pEntries)
     {
         BOOST_FOREACH(MarkEntry& aEntry, *pEntries)
             aEntry.Dump();
     }
+    static void DumpSaves(std::vector<sal_uLong> &rSaveArr)
+    {
+        sal_uInt16 n = 0;
+        while( n < rSaveArr.size() )
+        {
+            _SwSaveTypeCountContent aSave( rSaveArr, n );
+            aSave.Dump();
+        }
+    }
 #endif
 }
 
@@ -1967,6 +1964,7 @@ void CntntIdxStoreImpl::RestoreShellCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater
         rUpdater(aEntry.m_pPaM->GetBound(aEntry.m_isMark), aEntry.m_nCntnt);
     }
 }
+
 namespace sw { namespace mark {
     boost::shared_ptr<CntntIdxStore> CntntIdxStore::Create()
     {
commit 3df855e6ec657106126ba6f13404994641252cf0
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 09:40:33 2014 +0200

    remove some more SwSaveTypeCountContent insanity
    
    Change-Id: I4f2b9b757afd0776c132ccc2eea219723d84cc66

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 923ce85..1080764 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1126,33 +1126,29 @@ namespace sw { namespace mark
 
 namespace
 {
-    //  CntntType --
-    //          0x2000 = Paragraph anchored frame
-    //          0x2001 = frame anchored at character, which should be moved
-
     class _SwSaveTypeCountContent
     {
-        sal_uInt16 nType;
+        bool bCharBound;
         sal_uInt16 nCount;
         sal_Int32 nContent;
 
     public:
-        _SwSaveTypeCountContent() { nType=0; nCount=0; nContent = 0; }
+        _SwSaveTypeCountContent() { bCharBound=false; nCount=0; nContent = 0; }
         _SwSaveTypeCountContent( const std::vector<sal_uLong> &rArr, sal_uInt16& rPos )
             {
-                nType = static_cast<sal_uInt16>(rArr[ rPos++ ]);
+                bCharBound = static_cast<bool>(rArr[ rPos++ ]);
                 nCount = static_cast<sal_uInt16>(rArr[ rPos++ ]);
                 nContent = static_cast<sal_Int32>(rArr[ rPos++ ]);
             }
         void Add( std::vector<sal_uLong> &rArr )
         {
-            rArr.push_back( nType );
+            rArr.push_back( bCharBound );
             rArr.push_back( nCount );
             rArr.push_back( nContent );
         }
 
-        void SetType( sal_uInt16 n )        { nType = n; }
-        sal_uInt16 GetType() const          { return nType; }
+        void SetCharBound( bool bCB )        { bCharBound = bCB; }
+        bool IsCharBound() const          { return bCharBound; }
 
         void SetCount( sal_uInt16 n )       { nCount = n; }
         sal_uInt16 GetCount() const         { return nCount; }
@@ -1163,7 +1159,7 @@ namespace
 #if OSL_DEBUG_LEVEL > 0
         void Dump()
         {
-            SAL_INFO("sw.core", "Count: " << GetCount() << "\tType: " << GetType() << "\tContent: " << GetContent());
+            SAL_INFO("sw.core", "Count: " << GetCount() << "\tType: " << IsCharBound() << "\tContent: " << GetContent());
         }
 #endif
 
@@ -1459,7 +1455,7 @@ void _SaveCntntIdx(SwDoc* pDoc,
                                  FLY_AT_PARA == rAnchor.GetAnchorId() ) ||
                                ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) )
                         {
-                            aSave.SetType( 0x2000 );
+                            aSave.SetCharBound(false);
                             aSave.SetContent( pAPos->nContent.GetIndex() );
 
                             OSL_ENSURE( nNode == pAPos->nNode.GetIndex(),
@@ -1469,7 +1465,7 @@ void _SaveCntntIdx(SwDoc* pDoc,
                                 if( nCntnt <= aSave.GetContent() )
                                 {
                                     if( SAVEFLY_SPLIT == nSaveFly )
-                                        aSave.SetType( 0x2001 );
+                                        aSave.SetCharBound(true);
                                     else
                                         continue;
                                 }
@@ -1504,14 +1500,14 @@ void _SaveCntntIdx(SwDoc* pDoc,
                          ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
                            FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
                     {
-                        aSave.SetType( 0x2000 );
+                        aSave.SetCharBound(false);
                         aSave.SetContent( pAPos->nContent.GetIndex() );
                         if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
                         {
                             if( nCntnt <= aSave.GetContent() )
                             {
                                 if( SAVEFLY_SPLIT == nSaveFly )
-                                    aSave.SetType( 0x2001 );
+                                    aSave.SetCharBound(true);
                                 else
                                     continue;
                             }
@@ -1537,41 +1533,34 @@ void _RestoreCntntIdx(SwDoc* pDoc,
     {
         _SwSaveTypeCountContent aSave( rSaveArr, n );
         SwPosition* pPos = 0;
-        switch( aSave.GetType() )
+        if(!aSave.IsCharBound())
         {
-            case 0x2000:
+            SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
+            const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
+            if( rFlyAnchor.GetCntntAnchor() )
+            {
+                SwFmtAnchor aNew( rFlyAnchor );
+                SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
+                aNewPos.nNode = *pCNd;
+                if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
                 {
-                    SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
-                    const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
-                    if( rFlyAnchor.GetCntntAnchor() )
-                    {
-                        SwFmtAnchor aNew( rFlyAnchor );
-                        SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
-                        aNewPos.nNode = *pCNd;
-                        if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
-                        {
-                            aNewPos.nContent.Assign( pCNd,
-                                                     aSave.GetContent() + nOffset );
-                        }
-                        else
-                        {
-                            aNewPos.nContent.Assign( 0, 0 );
-                        }
-                        aNew.SetAnchor( &aNewPos );
-                        pFrmFmt->SetFmtAttr( aNew );
-                    }
+                    aNewPos.nContent.Assign( pCNd,
+                                             aSave.GetContent() + nOffset );
                 }
-                break;
-            case 0x2001:
-                if( bAuto )
+                else
                 {
-                    SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
-                    SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
-                    pFrmFmt->NotifyClients( pAnchor, pAnchor );
+                    aNewPos.nContent.Assign( 0, 0 );
                 }
-                break;
+                aNew.SetAnchor( &aNewPos );
+                pFrmFmt->SetFmtAttr( aNew );
+            }
+        }
+        else if( bAuto )
+        {
+            SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
+            SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
+            pFrmFmt->NotifyClients( pAnchor, pAnchor );
         }
-
         if( pPos )
         {
 #if OSL_DEBUG_LEVEL > 0
@@ -1602,32 +1591,26 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
         else
         {
             SwPosition* pPos = 0;
-            switch( aSave.GetType() )
             {
-            case 0x2000:
-            case 0x2001:
+                SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
+                const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
+                if( rFlyAnchor.GetCntntAnchor() )
                 {
-                    SwFrmFmt *pFrmFmt = (*pSpz)[ aSave.GetCount() ];
-                    const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
-                    if( rFlyAnchor.GetCntntAnchor() )
+                    SwFmtAnchor aNew( rFlyAnchor );
+                    SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
+                    aNewPos.nNode = rNd;
+                    if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
                     {
-                        SwFmtAnchor aNew( rFlyAnchor );
-                        SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
-                        aNewPos.nNode = rNd;
-                        if ( FLY_AT_CHAR == rFlyAnchor.GetAnchorId() )
-                        {
-                            aNewPos.nContent.Assign( pCNd, std::min(
-                                                     aSave.GetContent(), nLen ) );
-                        }
-                        else
-                        {
-                            aNewPos.nContent.Assign( 0, 0 );
-                        }
-                        aNew.SetAnchor( &aNewPos );
-                        pFrmFmt->SetFmtAttr( aNew );
+                        aNewPos.nContent.Assign( pCNd, std::min(
+                                                 aSave.GetContent(), nLen ) );
                     }
+                    else
+                    {
+                        aNewPos.nContent.Assign( 0, 0 );
+                    }
+                    aNew.SetAnchor( &aNewPos );
+                    pFrmFmt->SetFmtAttr( aNew );
                 }
-                break;
             }
 
             if( pPos )
commit 2d41923b65266e7182fa5e66872c12e37ca34655
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 02:51:27 2014 +0200

    remove some SwSaveTypeCountContent insanity: unused function
    
    Change-Id: Icff9b56245b5850329c8d2582495fd69c7edead5

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 688a7a8..923ce85 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1156,7 +1156,6 @@ namespace
 
         void SetCount( sal_uInt16 n )       { nCount = n; }
         sal_uInt16 GetCount() const         { return nCount; }
-        sal_uInt16 IncCount()               { return ++nCount; }
         sal_uInt16 DecCount()               { return --nCount; }
 
         void SetContent( sal_Int32 n )     { nContent = n; }
commit 068887ed47d9c2e7f96f0474a4c8c7441c0f55f2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 02:49:17 2014 +0200

    remove some SwSaveTypeCountContent insanity: casting via union
    
    Change-Id: I784c41697c56d577881937e8cd524aceb7bc6ad8

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 42fa08e..688a7a8 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1126,42 +1126,38 @@ namespace sw { namespace mark
 
 namespace
 {
-    // Array structure: 2 longs,
-    //  1st long contains the type and position in the DocArray,
-    //  2nd long contains the ContentPosition
-
     //  CntntType --
     //          0x2000 = Paragraph anchored frame
     //          0x2001 = frame anchored at character, which should be moved
 
     class _SwSaveTypeCountContent
     {
-        union {
-            struct { sal_uInt16 nType, nCount; } TC;
-            sal_uLong nTypeCount;
-            } TYPECOUNT;
+        sal_uInt16 nType;
+        sal_uInt16 nCount;
         sal_Int32 nContent;
 
     public:
-        _SwSaveTypeCountContent() { TYPECOUNT.nTypeCount = 0; nContent = 0; }
+        _SwSaveTypeCountContent() { nType=0; nCount=0; nContent = 0; }
         _SwSaveTypeCountContent( const std::vector<sal_uLong> &rArr, sal_uInt16& rPos )
             {
-                TYPECOUNT.nTypeCount = rArr[ rPos++ ];
+                nType = static_cast<sal_uInt16>(rArr[ rPos++ ]);
+                nCount = static_cast<sal_uInt16>(rArr[ rPos++ ]);
                 nContent = static_cast<sal_Int32>(rArr[ rPos++ ]);
             }
         void Add( std::vector<sal_uLong> &rArr )
         {
-            rArr.push_back( TYPECOUNT.nTypeCount );
+            rArr.push_back( nType );
+            rArr.push_back( nCount );
             rArr.push_back( nContent );
         }
 
-        void SetType( sal_uInt16 n )        { TYPECOUNT.TC.nType = n; }
-        sal_uInt16 GetType() const          { return TYPECOUNT.TC.nType; }
+        void SetType( sal_uInt16 n )        { nType = n; }
+        sal_uInt16 GetType() const          { return nType; }
 
-        void SetCount( sal_uInt16 n )       { TYPECOUNT.TC.nCount = n; }
-        sal_uInt16 GetCount() const         { return TYPECOUNT.TC.nCount; }
-        sal_uInt16 IncCount()               { return ++TYPECOUNT.TC.nCount; }
-        sal_uInt16 DecCount()               { return --TYPECOUNT.TC.nCount; }
+        void SetCount( sal_uInt16 n )       { nCount = n; }
+        sal_uInt16 GetCount() const         { return nCount; }
+        sal_uInt16 IncCount()               { return ++nCount; }
+        sal_uInt16 DecCount()               { return --nCount; }
 
         void SetContent( sal_Int32 n )     { nContent = n; }
         sal_Int32 GetContent() const       { return nContent; }
commit 673be4811cbaae1b05d17cf214684bb4dedd79f4
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 02:41:40 2014 +0200

    remove some SwSaveTypeCountContent insanity
    
    Change-Id: I1a270c8b7e08e22f68b9a86c73a76c46d4ce8a5d

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index eef387e..42fa08e 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1157,17 +1157,12 @@ namespace
 
         void SetType( sal_uInt16 n )        { TYPECOUNT.TC.nType = n; }
         sal_uInt16 GetType() const          { return TYPECOUNT.TC.nType; }
-        void IncType()                  { ++TYPECOUNT.TC.nType; }
-        void DecType()                  { --TYPECOUNT.TC.nType; }
 
         void SetCount( sal_uInt16 n )       { TYPECOUNT.TC.nCount = n; }
         sal_uInt16 GetCount() const         { return TYPECOUNT.TC.nCount; }
         sal_uInt16 IncCount()               { return ++TYPECOUNT.TC.nCount; }
         sal_uInt16 DecCount()               { return --TYPECOUNT.TC.nCount; }
 
-        void SetTypeAndCount( sal_uInt16 nT, sal_uInt16 nC )
-            { TYPECOUNT.TC.nCount = nC; TYPECOUNT.TC.nType = nT; }
-
         void SetContent( sal_Int32 n )     { nContent = n; }
         sal_Int32 GetContent() const       { return nContent; }
 #if OSL_DEBUG_LEVEL > 0
@@ -1479,7 +1474,7 @@ void _SaveCntntIdx(SwDoc* pDoc,
                                 if( nCntnt <= aSave.GetContent() )
                                 {
                                     if( SAVEFLY_SPLIT == nSaveFly )
-                                        aSave.IncType(); // = 0x2001;
+                                        aSave.SetType( 0x2001 );
                                     else
                                         continue;
                                 }
@@ -1521,7 +1516,7 @@ void _SaveCntntIdx(SwDoc* pDoc,
                             if( nCntnt <= aSave.GetContent() )
                             {
                                 if( SAVEFLY_SPLIT == nSaveFly )
-                                    aSave.IncType(); // = 0x2001;
+                                    aSave.SetType( 0x2001 );
                                 else
                                     continue;
                             }
commit 3fd5fb7b5944b0b14414750f67927da193ebaca0
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 02:32:31 2014 +0200

    crsr save/restore still works
    
    Change-Id: Ifa1339522460f969f3598179bda4588b31a0179f

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 6a2701f..eef387e 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1133,8 +1133,6 @@ namespace
     //  CntntType --
     //          0x2000 = Paragraph anchored frame
     //          0x2001 = frame anchored at character, which should be moved
-    //          0x0800 = Crsr from the CrsrShell Mark
-    //          0x0801 = Crsr from the CrsrShell Point
 
     class _SwSaveTypeCountContent
     {
@@ -1214,37 +1212,6 @@ namespace
         return rPos.nNode > rNdIdx || ( pIdx && rPos.nNode == rNdIdx && rPos.nContent > pIdx->GetIndex() );
     }
 
-    static void lcl_ChkPaM( std::vector<sal_uLong> &rSaveArr, sal_uLong nNode, sal_Int32 nCntnt,
-                    const SwPaM& rPam, _SwSaveTypeCountContent& rSave,
-                    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 ))
-        {
-            rSave.SetContent( pPos->nContent.GetIndex() );
-            rSave.Add( rSaveArr );
-        }
-
-        pPos = &rPam.GetBound( false );
-        if( pPos->nNode.GetIndex() == nNode &&
-            ( (bBound1IsStart && bChkSelDirection)
-                        ? pPos->nContent.GetIndex() <= nCntnt
-                        : pPos->nContent.GetIndex() < nCntnt ))
-        {
-            rSave.SetContent( pPos->nContent.GetIndex() );
-            rSave.IncType();
-            rSave.Add( rSaveArr );
-            rSave.DecType();
-        }
-    }
 #if 0
     static void DumpSaves(std::vector<sal_uLong> &rSaveArr)
     {
@@ -1565,31 +1532,6 @@ void _SaveCntntIdx(SwDoc* pDoc,
             }
         }
     }
-    // 5. CrsrShell
-//    {
-//        SwCrsrShell* pShell = pDoc->GetEditShell();
-//        if( pShell )
-//        {
-//            aSave.SetTypeAndCount( 0x800, 0 );
-//            FOREACHSHELL_START( pShell )
-//                SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
-//                if( _pStkCrsr )
-//                    do {
-//                        lcl_ChkPaM( rSaveArr, nNode, nCntnt, *_pStkCrsr,
-//                                    aSave, false );
-//                        aSave.IncCount();
-//                    } while ( (_pStkCrsr != 0 ) &&
-//                        ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
-//
-//                FOREACHPAM_START( PCURSH->_GetCrsr() )
-//                    lcl_ChkPaM( rSaveArr, nNode, nCntnt, *PCURCRSR,
-//                                aSave, false );
-//                    aSave.IncCount();
-//                FOREACHPAM_END()
-//
-//            FOREACHSHELL_END( pShell )
-//        }
-//    }
 }
 
 void _RestoreCntntIdx(SwDoc* pDoc,
@@ -1638,47 +1580,6 @@ void _RestoreCntntIdx(SwDoc* pDoc,
                     pFrmFmt->NotifyClients( pAnchor, pAnchor );
                 }
                 break;
-
-            case 0x0800:
-            case 0x0801:
-                {
-                    SwCrsrShell* pShell = pDoc->GetEditShell();
-                    if( pShell )
-                    {
-                        sal_uInt16 nCnt = 0;
-                        FOREACHSHELL_START( pShell )
-                            SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
-                            if( _pStkCrsr )
-                                do {
-                                    if( aSave.GetCount() == nCnt )
-                                    {
-                                        pPos = &_pStkCrsr->GetBound( 0x0800 ==
-                                                            aSave.GetType() );
-                                        break;
-                                    }
-                                    ++nCnt;
-                                } while ( (_pStkCrsr != 0 ) &&
-                                    ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
-
-                            if( pPos )
-                                break;
-
-                            FOREACHPAM_START( PCURSH->_GetCrsr() )
-                                if( aSave.GetCount() == nCnt )
-                                {
-                                    pPos = &PCURCRSR->GetBound( 0x0800 ==
-                                                        aSave.GetType() );
-                                    break;
-                                }
-                                ++nCnt;
-                            FOREACHPAM_END()
-                            if( pPos )
-                                break;
-
-                        FOREACHSHELL_END( pShell )
-                    }
-            }
-            break;
         }
 
         if( pPos )
@@ -1737,47 +1638,6 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
                     }
                 }
                 break;
-
-            case 0x0800:
-            case 0x0801:
-                {
-                    SwCrsrShell* pShell = pDoc->GetEditShell();
-                    if( pShell )
-                    {
-                        sal_uInt16 nCnt = 0;
-                        FOREACHSHELL_START( pShell )
-                            SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
-                            if( _pStkCrsr )
-                                do {
-                                    if( aSave.GetCount() == nCnt )
-                                    {
-                                        pPos = &_pStkCrsr->GetBound( 0x0800 ==
-                                                    aSave.GetType() );
-                                        break;
-                                    }
-                                    ++nCnt;
-                                } while ( (_pStkCrsr != 0 ) &&
-                                    ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
-
-                            if( pPos )
-                                break;
-
-                            FOREACHPAM_START( PCURSH->_GetCrsr() )
-                                if( aSave.GetCount() == nCnt )
-                                {
-                                    pPos = &PCURCRSR->GetBound( 0x0800 ==
-                                                aSave.GetType() );
-                                    break;
-                                }
-                                ++nCnt;
-                            FOREACHPAM_END()
-                            if( pPos )
-                                break;
-
-                        FOREACHSHELL_END( pShell )
-                    }
-                }
-                break;
             }
 
             if( pPos )
@@ -1932,6 +1792,15 @@ namespace
             rMarkEntries.push_back(aEntry);
         }
     }
+    static void lcl_ChkPaM( std::vector<PaMEntry> &rPaMEntries, sal_uLong nNode, sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint)
+    {
+        const SwPosition* pPos = &rPaM.GetBound( bPoint );
+        if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nCntnt )
+        {
+            const PaMEntry aEntry = { &rPaM, bPoint, pPos->nContent.GetIndex() };
+            rPaMEntries.push_back(aEntry);
+        }
+    }
 #if 0
     static void DumpEntries(std::vector<MarkEntry>* pEntries)
     {
@@ -2095,15 +1964,6 @@ void CntntIdxStoreImpl::RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater)
     }
 }
 
-static void lcl_ChkPaM( std::vector<PaMEntry> &rPaMEntries, sal_uLong nNode, sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint)
-{
-    const SwPosition* pPos = &rPaM.GetBound( bPoint );
-    if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nCntnt )
-    {
-        const PaMEntry aEntry = { &rPaM, bPoint, pPos->nContent.GetIndex() };
-        rPaMEntries.push_back(aEntry);
-    }
-}
 void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
 {
     SwCrsrShell* pShell = pDoc->GetEditShell();
commit 5200ec588665ddf6d7b4e9c373b815a6d7932351
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Jul 23 02:19:45 2014 +0200

    crsr save/restore works
    
    Change-Id: Ib32688cabfaa1db3a8ab3bb3bf29aaf42718d918

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 835f696..6a2701f 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1566,30 +1566,30 @@ void _SaveCntntIdx(SwDoc* pDoc,
         }
     }
     // 5. CrsrShell
-    {
-        SwCrsrShell* pShell = pDoc->GetEditShell();
-        if( pShell )
-        {
-            aSave.SetTypeAndCount( 0x800, 0 );
-            FOREACHSHELL_START( pShell )
-                SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
-                if( _pStkCrsr )
-                    do {
-                        lcl_ChkPaM( rSaveArr, nNode, nCntnt, *_pStkCrsr,
-                                    aSave, false );
-                        aSave.IncCount();
-                    } while ( (_pStkCrsr != 0 ) &&
-                        ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
-
-                FOREACHPAM_START( PCURSH->_GetCrsr() )
-                    lcl_ChkPaM( rSaveArr, nNode, nCntnt, *PCURCRSR,
-                                aSave, false );
-                    aSave.IncCount();
-                FOREACHPAM_END()
-
-            FOREACHSHELL_END( pShell )
-        }
-    }
+//    {
+//        SwCrsrShell* pShell = pDoc->GetEditShell();
+//        if( pShell )
+//        {
+//            aSave.SetTypeAndCount( 0x800, 0 );
+//            FOREACHSHELL_START( pShell )
+//                SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
+//                if( _pStkCrsr )
+//                    do {
+//                        lcl_ChkPaM( rSaveArr, nNode, nCntnt, *_pStkCrsr,
+//                                    aSave, false );
+//                        aSave.IncCount();
+//                    } while ( (_pStkCrsr != 0 ) &&
+//                        ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
+//
+//                FOREACHPAM_START( PCURSH->_GetCrsr() )
+//                    lcl_ChkPaM( rSaveArr, nNode, nCntnt, *PCURCRSR,
+//                                aSave, false );
+//                    aSave.IncCount();
+//                FOREACHPAM_END()
+//
+//            FOREACHSHELL_END( pShell )
+//        }
+//    }
 }
 
 void _RestoreCntntIdx(SwDoc* pDoc,
@@ -1805,6 +1805,12 @@ namespace
         }
 #endif
     };
+    struct PaMEntry
+    {
+        SwPaM* m_pPaM;
+        bool m_isMark;
+        sal_Int32 m_nCntnt;
+    };
     struct OffsetUpdater
     {
         const SwCntntNode* m_pNewCntntNode;
@@ -1838,6 +1844,7 @@ namespace
         std::vector<MarkEntry> m_aBkmkEntries;
         std::vector<MarkEntry> m_aRedlineEntries;
         std::vector<MarkEntry> m_aUnoCrsrEntries;
+        std::vector<PaMEntry> m_aShellCrsrEntries;
         std::vector<sal_uLong> m_aSaveArr;
         typedef boost::function<void (SwPosition& rPos, sal_Int32 nCntnt)> updater_t;
         virtual void Clear() SAL_OVERRIDE
@@ -1845,17 +1852,19 @@ namespace
             m_aBkmkEntries.clear();
             m_aRedlineEntries.clear();
             m_aUnoCrsrEntries.clear();
+            m_aShellCrsrEntries.clear();
             m_aSaveArr.clear();
         }
         virtual bool Empty() SAL_OVERRIDE
         {
-            return m_aBkmkEntries.empty() && m_aRedlineEntries.empty() && m_aUnoCrsrEntries.empty() && m_aSaveArr.empty();
+            return m_aBkmkEntries.empty() && m_aRedlineEntries.empty() && m_aUnoCrsrEntries.empty() && m_aShellCrsrEntries.empty() && m_aSaveArr.empty();
         }
         virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly=0) SAL_OVERRIDE
         {
             SaveBkmks(pDoc, nNode, nCntnt);
             SaveRedlines(pDoc, nNode, nCntnt);
             SaveUnoCrsrs(pDoc, nNode, nCntnt);
+            SaveShellCrsrs(pDoc, nNode, nCntnt);
             return _SaveCntntIdx(pDoc, nNode, nCntnt, m_aSaveArr, nSaveFly);
         }
         virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false) SAL_OVERRIDE
@@ -1866,6 +1875,7 @@ namespace
             RestoreRedlines(pDoc, aUpdater);
             _RestoreCntntIdx(pDoc, m_aSaveArr, nNode, nOffset, bAuto);
             RestoreUnoCrsrs(pDoc, aUpdater);
+            RestoreShellCrsrs(pDoc, aUpdater);
         }
         virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen) SAL_OVERRIDE
         {
@@ -1876,6 +1886,7 @@ namespace
             RestoreRedlines(pDoc, aUpdater);
             _RestoreCntntIdx(m_aSaveArr, rNd, nLen, nCorrLen);
             RestoreUnoCrsrs(pDoc, aUpdater);
+            RestoreShellCrsrs(pDoc, aUpdater);
         }
         virtual ~CntntIdxStoreImpl(){};
         private:
@@ -1885,6 +1896,8 @@ namespace
             inline void RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater);
             inline void SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
             inline void RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater);
+            inline void SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
+            inline void RestoreShellCrsrs(SwDoc* pDoc, updater_t& rUpdater);
             inline const SwPosition& GetRightMarkPos(::sw::mark::IMark* pMark, bool bOther)
                 { return bOther ? pMark->GetOtherMarkPos() : pMark->GetMarkPos(); };
             inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
@@ -2082,6 +2095,45 @@ void CntntIdxStoreImpl::RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater)
     }
 }
 
+static void lcl_ChkPaM( std::vector<PaMEntry> &rPaMEntries, sal_uLong nNode, sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint)
+{
+    const SwPosition* pPos = &rPaM.GetBound( bPoint );
+    if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nCntnt )
+    {
+        const PaMEntry aEntry = { &rPaM, bPoint, pPos->nContent.GetIndex() };
+        rPaMEntries.push_back(aEntry);
+    }
+}
+void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
+{
+    SwCrsrShell* pShell = pDoc->GetEditShell();
+    if( pShell )
+    {
+        FOREACHSHELL_START( pShell )
+            SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
+            if( _pStkCrsr )
+                do {
+                    lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, true);
+                    lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, false);
+                } while ( (_pStkCrsr != 0 ) &&
+                    ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
+
+            FOREACHPAM_START( PCURSH->_GetCrsr() )
+                lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, true);
+                lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, false);
+            FOREACHPAM_END()
+
+        FOREACHSHELL_END( pShell )
+    }
+}
+
+void CntntIdxStoreImpl::RestoreShellCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
+{
+    BOOST_FOREACH(const PaMEntry& aEntry, m_aShellCrsrEntries)
+    {
+        rUpdater(aEntry.m_pPaM->GetBound(aEntry.m_isMark), aEntry.m_nCntnt);
+    }
+}
 namespace sw { namespace mark {
     boost::shared_ptr<CntntIdxStore> CntntIdxStore::Create()
     {


More information about the Libreoffice-commits mailing list