[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - 2 commits - sw/inc sw/source xmloff/source

Oliver-Rainer Wittmann orw at apache.org
Tue May 20 05:10:21 PDT 2014


 sw/inc/IDocumentMarkAccess.hxx         |    2 
 sw/inc/doc.hxx                         |   27 +++-
 sw/source/core/crsr/annotationmark.cxx |    1 
 sw/source/core/doc/docbm.cxx           |  189 ++++++++++++++++++++-------------
 sw/source/core/doc/doccorr.cxx         |   20 +--
 sw/source/core/undo/undobj.cxx         |   13 +-
 sw/source/core/unocore/unoobj.cxx      |   72 +++++++-----
 sw/source/ui/docvw/SidebarWin.cxx      |   25 +++-
 sw/source/ui/shells/textfld.cxx        |    3 
 sw/source/ui/wrtsh/wrtsh2.cxx          |   21 ++-
 xmloff/source/text/txtfldi.cxx         |    4 
 11 files changed, 246 insertions(+), 131 deletions(-)

New commits:
commit afbf61890a4d5e846c4aa09380d8b641d99ceefd
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Thu Jan 16 11:47:18 2014 +0000

    Resolves: cp#1000079 i#124030 do not delete UNO mark which are not expanded...
    
    and only touch the start of the given range.
    
    (cherry picked from commit ae295f7d009842cdceb50c4daffe948ede2b4b88)
    
    Conflicts:
    	sw/source/core/doc/docbm.cxx
    
    (cherry picked from commit 4b6b51182a9a600805729313278eb707c6ebfb14)
    
    Change-Id: Id7317eeb8e9c063c9d8b30bca97ed0afee3ec8c5

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 856bbc6..3deaccc 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -50,7 +50,6 @@
 #include <edimp.hxx>
 #include <stdio.h>
 
-using namespace ::std;
 using namespace ::boost;
 using namespace ::sw::mark;
 
@@ -58,12 +57,19 @@ namespace
 {
     static bool lcl_GreaterThan( const SwPosition& rPos, const SwNodeIndex& rNdIdx, const SwIndex* pIdx )
     {
-        return pIdx ? ( rPos.nNode > rNdIdx || ( rPos.nNode == rNdIdx && rPos.nContent >= pIdx->GetIndex() )) : rPos.nNode >= rNdIdx;
+        return pIdx != NULL
+               ? ( rPos.nNode > rNdIdx
+                   || ( rPos.nNode == rNdIdx
+                        && rPos.nContent >= pIdx->GetIndex() ) )
+               : rPos.nNode >= rNdIdx;
     }
 
     static bool lcl_Lower( const SwPosition& rPos, const SwNodeIndex& rNdIdx, const SwIndex* pIdx )
     {
-        return rPos.nNode < rNdIdx || ( pIdx && rPos.nNode == rNdIdx && rPos.nContent < pIdx->GetIndex() );
+        return rPos.nNode < rNdIdx
+               || ( pIdx != NULL
+                    && rPos.nNode == rNdIdx
+                    && rPos.nContent < pIdx->GetIndex() );
     }
 
     static bool lcl_MarkOrderingByStart(const IDocumentMarkAccess::pMark_t& rpFirst,
@@ -91,9 +97,9 @@ namespace
     }
 
     SAL_WNODEPRECATED_DECLARATIONS_PUSH
-    static inline auto_ptr<SwPosition> lcl_PositionFromCntntNode(SwCntntNode * const pCntntNode, const bool bAtEnd=false)
+    static inline ::std::auto_ptr<SwPosition> lcl_PositionFromCntntNode(SwCntntNode * const pCntntNode, const bool bAtEnd=false)
     {
-        auto_ptr<SwPosition> pResult(new SwPosition(*pCntntNode));
+        ::std::auto_ptr<SwPosition> pResult(new SwPosition(*pCntntNode));
         pResult->nContent.Assign(pCntntNode, bAtEnd ? pCntntNode->Len() : 0);
         return pResult;
     }
@@ -104,7 +110,7 @@ namespace
     // else set it to the end of the node before rStt
     // else set it to the CntntNode of the Pos outside the Range
     SAL_WNODEPRECATED_DECLARATIONS_PUSH
-    static inline auto_ptr<SwPosition> lcl_FindExpelPosition(const SwNodeIndex& rStt,
+    static inline ::std::auto_ptr<SwPosition> lcl_FindExpelPosition(const SwNodeIndex& rStt,
         const SwNodeIndex& rEnd,
         const SwPosition& rOtherPosition)
     {
@@ -118,7 +124,7 @@ namespace
             pNode = rStt.GetNodes().GoPrevious(&aStt), bAtEnd = true;
         if(pNode)
             return lcl_PositionFromCntntNode(pNode, bAtEnd);
-        return auto_ptr<SwPosition>(new SwPosition(rOtherPosition));
+        return ::std::auto_ptr<SwPosition>(new SwPosition(rOtherPosition));
     }
     SAL_WNODEPRECATED_DECLARATIONS_POP
 
@@ -149,7 +155,7 @@ namespace
             rMarks.begin(),
             pCandidatesEnd,
             back_inserter(vCandidates),
-            boost::bind(logical_not<bool>(), boost::bind(&IMark::EndsBefore, _1, rPos)));
+            boost::bind( ::std::logical_not<bool>(), boost::bind( &IMark::EndsBefore, _1, rPos ) ) );
         // no candidate left => we are in front of the first mark or there are none
         if(!vCandidates.size()) return NULL;
         // return the highest (last) candidate using mark end ordering
@@ -630,8 +636,8 @@ namespace sw { namespace mark
             const SwIndex* pSttIdx,
             const SwIndex* pEndIdx )
     {
-        vector<const_iterator_t> vMarksToDelete;
-        bool isSortingNeeded = false;
+        ::std::vector<const_iterator_t> vMarksToDelete;
+        bool bIsSortingNeeded = false;
 
         // copy all bookmarks in the move area to a vector storing all position data as offset
         // reassignment is performed after the move
@@ -646,61 +652,77 @@ namespace sw { namespace mark
 
             ::sw::mark::MarkBase* pMark = dynamic_cast< ::sw::mark::MarkBase* >(ppMark->get());
             // on position ??
-            bool isPosInRange = (lcl_GreaterThan(pMark->GetMarkPos(), rStt, pSttIdx) &&
-                lcl_Lower(pMark->GetMarkPos(), rEnd, pEndIdx));
-            bool isOtherPosInRange = (pMark->IsExpanded() &&
-                lcl_GreaterThan(pMark->GetOtherMarkPos(), rStt, pSttIdx) &&
-                lcl_Lower(pMark->GetOtherMarkPos(), rEnd, pEndIdx));
+            bool bIsPosInRange = lcl_GreaterThan(pMark->GetMarkPos(), rStt, pSttIdx)
+                                 && lcl_Lower(pMark->GetMarkPos(), rEnd, pEndIdx);
+            bool bIsOtherPosInRange = pMark->IsExpanded()
+                                      && lcl_GreaterThan(pMark->GetOtherMarkPos(), rStt, pSttIdx)
+                                      && lcl_Lower(pMark->GetOtherMarkPos(), rEnd, pEndIdx);
             // special case: completely in range, touching the end?
             if ( pEndIdx != NULL
-                 && ( ( isOtherPosInRange
+                 && ( ( bIsOtherPosInRange
                         && pMark->GetMarkPos().nNode == rEnd
                         && pMark->GetMarkPos().nContent == *pEndIdx )
-                      || ( isPosInRange
+                      || ( bIsPosInRange
                            && pMark->IsExpanded()
                            && pMark->GetOtherMarkPos().nNode == rEnd
                            && pMark->GetOtherMarkPos().nContent == *pEndIdx ) ) )
             {
-                isPosInRange = true, isOtherPosInRange = true;
+                bIsPosInRange = true, bIsOtherPosInRange = true;
             }
 
-            if(isPosInRange && (isOtherPosInRange || !pMark->IsExpanded()))
+            if ( bIsPosInRange
+                 && ( bIsOtherPosInRange
+                      || !pMark->IsExpanded() ) )
             {
                 // completely in range
 
-                // #i92125#
-                bool bKeepCrossRefBkmk( false );
+                bool bDeleteMark = true;
                 {
-                    if ( rStt == rEnd &&
-                         ( IDocumentMarkAccess::GetType(*pMark) ==
-                            IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK ||
-                           IDocumentMarkAccess::GetType(*pMark) ==
-                            IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK ) )
+                    switch ( IDocumentMarkAccess::GetType( *pMark ) )
                     {
-                        bKeepCrossRefBkmk = true;
+                    case IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK:
+                    case IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK:
+                        // no delete of cross-reference bookmarks, if range is inside one paragraph
+                        bDeleteMark = rStt != rEnd;
+                        break;
+                    case IDocumentMarkAccess::UNO_BOOKMARK:
+                        // no delete of UNO mark, if it is not expanded and only touches the start of the range
+                        bDeleteMark = bIsOtherPosInRange
+                                      || pMark->IsExpanded()
+                                      || pSttIdx == NULL
+                                      || !( pMark->GetMarkPos().nNode == rStt
+                                            && pMark->GetMarkPos().nContent == *pSttIdx );
+                        break;
+                    default:
+                        bDeleteMark = true;
+                        break;
                     }
                 }
-                if ( !bKeepCrossRefBkmk )
+
+                if ( bDeleteMark )
                 {
-                    if(pSaveBkmk)
-                        pSaveBkmk->push_back(SaveBookmark(true, true, *pMark, rStt, pSttIdx));
+                    if ( pSaveBkmk )
+                    {
+                        pSaveBkmk->push_back( SaveBookmark( true, true, *pMark, rStt, pSttIdx ) );
+                    }
                     vMarksToDelete.push_back(ppMark);
                 }
             }
-            else if ( isPosInRange ^ isOtherPosInRange )
+            else if ( bIsPosInRange ^ bIsOtherPosInRange )
             {
                 // the bookmark is partitially in the range
                 // move position of that is in the range out of it
+
                 SAL_WNODEPRECATED_DECLARATIONS_PUSH
-                auto_ptr< SwPosition > pNewPos;
+                ::std::auto_ptr< SwPosition > pNewPos;
                 {
                     if ( pEndIdx != NULL )
                     {
-                        pNewPos = auto_ptr< SwPosition >( new SwPosition( rEnd, *pEndIdx ) );
+                        pNewPos = ::std::auto_ptr< SwPosition >( new SwPosition( rEnd, *pEndIdx ) );
                     }
                     else
                     {
-                        pNewPos = lcl_FindExpelPosition( rStt, rEnd, isPosInRange ? pMark->GetOtherMarkPos() : pMark->GetMarkPos() );
+                        pNewPos = lcl_FindExpelPosition( rStt, rEnd, bIsPosInRange ? pMark->GetOtherMarkPos() : pMark->GetMarkPos() );
                     }
                 }
 
@@ -725,13 +747,13 @@ namespace sw { namespace mark
                 SAL_WNODEPRECATED_DECLARATIONS_POP
                 if ( bMoveMark )
                 {
-                    if ( isPosInRange )
+                    if ( bIsPosInRange )
                         pMark->SetMarkPos(*pNewPos);
                     else
                         pMark->SetOtherMarkPos(*pNewPos);
 
                     // illegal selection? collapse the mark and restore sorting later
-                    isSortingNeeded |= lcl_FixCorrectedMark( isPosInRange, isOtherPosInRange, pMark );
+                    bIsSortingNeeded |= lcl_FixCorrectedMark( bIsPosInRange, bIsOtherPosInRange, pMark );
                 }
             }
         }
@@ -740,13 +762,13 @@ namespace sw { namespace mark
             // fdo#61016 delay the deletion of the fieldmark characters
             // to prevent that from deleting the marks on that position
             // which would invalidate the iterators in vMarksToDelete
-            vector< ::boost::shared_ptr<ILazyDeleter> > vDelay;
+            std::vector< ::boost::shared_ptr<ILazyDeleter> > vDelay;
             vDelay.reserve(vMarksToDelete.size());
             // we just remembered the iterators to delete, so we do not need to
             // search for the boost::shared_ptr<> (the entry in m_vAllMarks) again.
             // reverse iteration, since erasing an entry invalidates iterators
             // behind it (the iterators in vMarksToDelete are sorted)
-            for (vector<const_iterator_t>::reverse_iterator pppMark
+            for (std::vector<const_iterator_t>::reverse_iterator pppMark
                     = vMarksToDelete.rbegin();
                 pppMark != vMarksToDelete.rend();
                 ++pppMark)
@@ -754,7 +776,7 @@ namespace sw { namespace mark
                 vDelay.push_back(deleteMark(*pppMark));
             }
         } // scope to kill vDelay
-        if(isSortingNeeded)
+        if(bIsSortingNeeded)
             sortMarks();
 #if 0
         OSL_TRACE("deleteMarks");
@@ -875,7 +897,7 @@ namespace sw { namespace mark
             find_if(
                 pMarkLow,
                 pMarkHigh,
-                boost::bind(equal_to<const IMark*>(), boost::bind(&boost::shared_ptr<IMark>::get, _1), pMark));
+                boost::bind( ::std::equal_to<const IMark*>(), boost::bind(&boost::shared_ptr<IMark>::get, _1), pMark ) );
         if(pMarkFound != pMarkHigh)
             deleteMark(pMarkFound);
     }
@@ -1305,6 +1327,7 @@ void SaveBookmark::SetInDoc(
     }
 }
 
+
 // _DelBookmarks, _{Save,Restore}CntntIdx
 
 void _DelBookmarks(
commit 9caa7237deaf3aa6aa6dafdeee810f659c8548da
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date:   Wed Jan 8 14:20:43 2014 +0000

    Related: cp#1000079, i#123792 correction for comments/annotations on ...
    
    ... table cell ranges
    
    (cherry picked from commit c25523dd3a302d1bd36297a817a869afb3605d1f)
    
    Conflicts:
    	sw/inc/IDocumentMarkAccess.hxx
    	sw/inc/doc.hxx
    	sw/source/core/doc/docbm.cxx
    	sw/source/core/undo/undobj.cxx
    	sw/source/ui/shells/textfld.cxx
    	xmloff/source/text/txtfldi.cxx
    
    (cherry picked from commit 6af2caab7271e11d9501fd6a597e05194d33fd10)
    
    Change-Id: Ic2e12f47e7775ee16f31bedf89d5644b18734d7a

diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx
index 917a57f..271266f 100644
--- a/sw/inc/IDocumentMarkAccess.hxx
+++ b/sw/inc/IDocumentMarkAccess.hxx
@@ -262,7 +262,7 @@ class IDocumentMarkAccess
 
         /** Returns the MarkType used to create the mark
         */
-        static MarkType SAL_DLLPUBLIC_EXPORT GetType(const ::sw::mark::IMark& rMark);
+        static SAL_DLLPUBLIC_EXPORT MarkType GetType(const ::sw::mark::IMark& rMark);
 
         static SAL_DLLPUBLIC_EXPORT OUString GetCrossRefHeadingBookmarkNamePrefix();
         static SAL_DLLPUBLIC_EXPORT bool IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& rPaM );
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 73efd7d..7de655f 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1451,20 +1451,31 @@ public:
     // If bMoveCrsr is set move Crsr too.
 
     /// Set everything in rOldNode on rNewPos + Offset.
-    void CorrAbs( const SwNodeIndex& rOldNode, const SwPosition& rNewPos,
-                    const xub_StrLen nOffset = 0, sal_Bool bMoveCrsr = sal_False );
+    void CorrAbs(
+        const SwNodeIndex& rOldNode,
+        const SwPosition& rNewPos,
+        const xub_StrLen nOffset = 0,
+        sal_Bool bMoveCrsr = sal_False );
 
     /// Set everything in the range of [rStartNode, rEndNode] to rNewPos.
-    void CorrAbs( const SwNodeIndex& rStartNode, const SwNodeIndex& rEndNode,
-                    const SwPosition& rNewPos, sal_Bool bMoveCrsr = sal_False );
+    void CorrAbs(
+        const SwNodeIndex& rStartNode,
+        const SwNodeIndex& rEndNode,
+        const SwPosition& rNewPos,
+        sal_Bool bMoveCrsr = sal_False );
 
     /// Set everything in this range from rRange to rNewPos.
-    void CorrAbs( const SwPaM& rRange, const SwPosition& rNewPos,
-                    sal_Bool bMoveCrsr = sal_False );
+    void CorrAbs(
+        const SwPaM& rRange,
+        const SwPosition& rNewPos,
+        sal_Bool bMoveCrsr = sal_False );
 
     /// Set everything in rOldNode to relative Pos.
-    void CorrRel( const SwNodeIndex& rOldNode, const SwPosition& rNewPos,
-                    const xub_StrLen nOffset = 0, sal_Bool bMoveCrsr = sal_False );
+    void CorrRel(
+        const SwNodeIndex& rOldNode,
+        const SwPosition& rNewPos,
+        const xub_StrLen nOffset = 0,
+        sal_Bool bMoveCrsr = sal_False );
 
     /// Query / set rules for Outline.
     inline SwNumRule* GetOutlineNumRule() const
diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx
index 964e736..80751a4 100644
--- a/sw/source/core/crsr/annotationmark.cxx
+++ b/sw/source/core/crsr/annotationmark.cxx
@@ -54,6 +54,7 @@ namespace sw { namespace mark
         SwTxtFld* pTxtFld =
             GetMarkEnd().nNode.GetNode().GetTxtNode()->GetFldTxtAttrAt(
             GetMarkEnd().nContent.GetIndex()-1, true );
+        OSL_ENSURE( pTxtFld != NULL, "<AnnotationMark::InitDoc(..)> - missing text attribute for annotation field!" );
         if ( pTxtFld != NULL )
         {
             const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pTxtFld->GetFmtFld().GetField());
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 7ac32fa..856bbc6 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -156,18 +156,34 @@ namespace
         return max_element(vCandidates.begin(), vCandidates.end(), &lcl_MarkOrderingByEnd)->get();
     }
 
-    static bool lcl_FixCorrectedMark(bool bChangedPos, bool bChangedOPos, MarkBase* io_pMark)
+    static bool lcl_FixCorrectedMark(
+        const bool bChangedPos,
+        const bool bChangedOPos,
+        MarkBase* io_pMark )
     {
-        if( (bChangedPos || bChangedOPos) && io_pMark->IsExpanded() &&
-            io_pMark->GetOtherMarkPos().nNode.GetNode().FindTableBoxStartNode() !=
-            io_pMark->GetMarkPos().nNode.GetNode().FindTableBoxStartNode() )
+        if ( IDocumentMarkAccess::GetType(*io_pMark) == IDocumentMarkAccess::ANNOTATIONMARK )
         {
-            if(!bChangedOPos)
-                io_pMark->SetMarkPos(io_pMark->GetOtherMarkPos());
+            // annotation marks are allowed to span a table cell range.
+            // but trigger sorting to be save
+            return true;
+        }
+
+        if ( ( bChangedPos || bChangedOPos )
+             && io_pMark->IsExpanded()
+             && io_pMark->GetOtherMarkPos().nNode.GetNode().FindTableBoxStartNode() !=
+                    io_pMark->GetMarkPos().nNode.GetNode().FindTableBoxStartNode() )
+        {
+            if ( !bChangedOPos )
+            {
+                io_pMark->SetMarkPos( io_pMark->GetOtherMarkPos() );
+            }
             io_pMark->ClearOtherMarkPos();
             DdeBookmark * const pDdeBkmk = dynamic_cast< DdeBookmark*>(io_pMark);
-            if(pDdeBkmk && pDdeBkmk->IsServer())
+            if ( pDdeBkmk != NULL
+                 && pDdeBkmk->IsServer() )
+            {
                 pDdeBkmk->SetRefObject(NULL);
+            }
             return true;
         }
         return false;
@@ -636,14 +652,14 @@ namespace sw { namespace mark
                 lcl_GreaterThan(pMark->GetOtherMarkPos(), rStt, pSttIdx) &&
                 lcl_Lower(pMark->GetOtherMarkPos(), rEnd, pEndIdx));
             // special case: completely in range, touching the end?
-            if(pEndIdx &&
-                    ((isOtherPosInRange
-                    && pMark->GetMarkPos().nNode == rEnd
-                    && pMark->GetMarkPos().nContent == *pEndIdx)
-                || (isPosInRange
-                    && pMark->IsExpanded()
-                    && pMark->GetOtherMarkPos().nNode == rEnd
-                    && pMark->GetOtherMarkPos().nContent == *pEndIdx)))
+            if ( pEndIdx != NULL
+                 && ( ( isOtherPosInRange
+                        && pMark->GetMarkPos().nNode == rEnd
+                        && pMark->GetMarkPos().nContent == *pEndIdx )
+                      || ( isPosInRange
+                           && pMark->IsExpanded()
+                           && pMark->GetOtherMarkPos().nNode == rEnd
+                           && pMark->GetOtherMarkPos().nContent == *pEndIdx ) ) )
             {
                 isPosInRange = true, isOtherPosInRange = true;
             }
@@ -671,39 +687,51 @@ namespace sw { namespace mark
                     vMarksToDelete.push_back(ppMark);
                 }
             }
-            else if(isPosInRange ^ isOtherPosInRange)
+            else if ( isPosInRange ^ isOtherPosInRange )
             {
                 // the bookmark is partitially in the range
                 // move position of that is in the range out of it
                 SAL_WNODEPRECATED_DECLARATIONS_PUSH
-                auto_ptr<SwPosition> pNewPos;
-                if(pEndIdx)
-                    pNewPos = auto_ptr<SwPosition>(new SwPosition(
-                        rEnd,
-                        *pEndIdx));
-                else
-                    pNewPos = lcl_FindExpelPosition(
-                        rStt,
-                        rEnd,
-                        isPosInRange ? pMark->GetOtherMarkPos() : pMark->GetMarkPos());
-                SAL_WNODEPRECATED_DECLARATIONS_POP
+                auto_ptr< SwPosition > pNewPos;
+                {
+                    if ( pEndIdx != NULL )
+                    {
+                        pNewPos = auto_ptr< SwPosition >( new SwPosition( rEnd, *pEndIdx ) );
+                    }
+                    else
+                    {
+                        pNewPos = lcl_FindExpelPosition( rStt, rEnd, isPosInRange ? pMark->GetOtherMarkPos() : pMark->GetMarkPos() );
+                    }
+                }
 
-                // #i92125#
-                // no move of position for cross-reference bookmarks,
-                // if move occurs inside a certain node
-                if ( ( IDocumentMarkAccess::GetType(*pMark) !=
-                                IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK &&
-                       IDocumentMarkAccess::GetType(*pMark) !=
-                                IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK ) ||
-                     pMark->GetMarkPos().nNode != pNewPos->nNode )
+                bool bMoveMark = true;
+                {
+                    switch ( IDocumentMarkAccess::GetType( *pMark ) )
+                    {
+                    case IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK:
+                    case IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK:
+                        // no move of cross-reference bookmarks, if move occurs inside a certain node
+                        bMoveMark = pMark->GetMarkPos().nNode != pNewPos->nNode;
+                        break;
+                    case IDocumentMarkAccess::ANNOTATIONMARK:
+                        // no move of annotation marks, if method is called to collect deleted marks
+                        bMoveMark = pSaveBkmk == NULL;
+                        break;
+                    default:
+                        bMoveMark = true;
+                        break;
+                    }
+                }
+                SAL_WNODEPRECATED_DECLARATIONS_POP
+                if ( bMoveMark )
                 {
-                    if(isPosInRange)
+                    if ( isPosInRange )
                         pMark->SetMarkPos(*pNewPos);
                     else
                         pMark->SetOtherMarkPos(*pNewPos);
 
                     // illegal selection? collapse the mark and restore sorting later
-                    isSortingNeeded |= lcl_FixCorrectedMark(isPosInRange, isOtherPosInRange, pMark);
+                    isSortingNeeded |= lcl_FixCorrectedMark( isPosInRange, isOtherPosInRange, pMark );
                 }
             }
         }
@@ -847,7 +875,7 @@ namespace sw { namespace mark
             find_if(
                 pMarkLow,
                 pMarkHigh,
-                boost::bind(equal_to<const IMark*>(), boost::bind(&boost::shared_ptr<IMark>::get, _1), pMark) );
+                boost::bind(equal_to<const IMark*>(), boost::bind(&boost::shared_ptr<IMark>::get, _1), pMark));
         if(pMarkFound != pMarkHigh)
             deleteMark(pMarkFound);
     }
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index cd6065f..6d4b0d7 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -214,26 +214,28 @@ void SwDoc::CorrAbs(const SwNodeIndex& rOldNode,
     }
 }
 
-void SwDoc::CorrAbs(const SwPaM& rRange,
+void SwDoc::CorrAbs(
+    const SwPaM& rRange,
     const SwPosition& rNewPos,
-    sal_Bool bMoveCrsr)
+    sal_Bool bMoveCrsr )
 {
     SwPosition aStart(*rRange.Start());
     SwPosition aEnd(*rRange.End());
     SwPosition aNewPos(rNewPos);
 
-    _DelBookmarks(aStart.nNode, aEnd.nNode, NULL,
-        &aStart.nContent, &aEnd.nContent);
+    _DelBookmarks( aStart.nNode, aEnd.nNode, NULL, &aStart.nContent, &aEnd.nContent );
+
     if(bMoveCrsr)
         ::PaMCorrAbs(rRange, rNewPos);
 }
 
-void SwDoc::CorrAbs(const SwNodeIndex& rStartNode,
-     const SwNodeIndex& rEndNode,
-     const SwPosition& rNewPos,
-     sal_Bool bMoveCrsr)
+void SwDoc::CorrAbs(
+    const SwNodeIndex& rStartNode,
+    const SwNodeIndex& rEndNode,
+    const SwPosition& rNewPos,
+    sal_Bool bMoveCrsr )
 {
-    _DelBookmarks(rStartNode, rEndNode);
+    _DelBookmarks( rStartNode, rEndNode );
 
     if(bMoveCrsr)
     {
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index e108f3c..f552dc9 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -826,12 +826,21 @@ void SwUndoSaveSection::SaveSection( SwDoc* pDoc, const SwNodeIndex& rSttIdx )
     SaveSection( pDoc, aRg );
 }
 
-void SwUndoSaveSection::SaveSection( SwDoc* , const SwNodeRange& rRange )
+void SwUndoSaveSection::SaveSection(
+    SwDoc* pDoc,
+    const SwNodeRange& rRange )
 {
     SwPaM aPam( rRange.aStart, rRange.aEnd );
 
-    // delete all Footnotes / FlyFrames / Bookmarks / Directories
+    // delete all footnotes, fly frames, bookmarks and indexes
     DelCntntIndex( *aPam.GetMark(), *aPam.GetPoint() );
+    {
+        // move certain indexes out of deleted range
+        SwNodeIndex aSttIdx( aPam.Start()->nNode.GetNode() );
+        SwNodeIndex aEndIdx( aPam.End()->nNode.GetNode() );
+        SwNodeIndex aMvStt( aEndIdx, 1 );
+        pDoc->CorrAbs( aSttIdx, aEndIdx, SwPosition( aMvStt ), sal_True );
+    }
 
     pRedlSaveData = new SwRedlineSaveDatas;
     if( !SwUndo::FillSaveData( aPam, *pRedlSaveData, sal_True, sal_True ))
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 844f374..68aa3f3 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -1143,22 +1143,6 @@ throw (uno::RuntimeException)
         throw uno::RuntimeException();
     }
 
-    SwStartNodeType eSearchNodeType = SwNormalStartNode;
-    switch (m_pImpl->m_eType)
-    {
-        case CURSOR_FRAME:      eSearchNodeType = SwFlyStartNode;       break;
-        case CURSOR_TBLTEXT:    eSearchNodeType = SwTableBoxStartNode;  break;
-        case CURSOR_FOOTNOTE:   eSearchNodeType = SwFootnoteStartNode;  break;
-        case CURSOR_HEADER:     eSearchNodeType = SwHeaderStartNode;    break;
-        case CURSOR_FOOTER:     eSearchNodeType = SwFooterStartNode;    break;
-        //case CURSOR_INVALID:
-        //case CURSOR_BODY:
-        default:
-            ;
-    }
-    const SwStartNode* pOwnStartNode =
-        rOwnCursor.GetNode()->FindSttNodeByType(eSearchNodeType);
-
     SwPaM aPam(GetDoc()->GetNodes());
     const SwPaM * pPam(0);
     if (pCursor)
@@ -1177,21 +1161,51 @@ throw (uno::RuntimeException)
     {
         throw uno::RuntimeException();
     }
-    const SwStartNode* pTmp =
-        pPam->GetNode()->FindSttNodeByType(eSearchNodeType);
 
-    //SectionNodes ueberspringen
-    while(pTmp && pTmp->IsSectionNode())
     {
-        pTmp = pTmp->StartOfSectionNode();
-    }
-    while(pOwnStartNode && pOwnStartNode->IsSectionNode())
-    {
-        pOwnStartNode = pOwnStartNode->StartOfSectionNode();
-    }
-    if(pOwnStartNode != pTmp)
-    {
-        throw uno::RuntimeException();
+        SwStartNodeType eSearchNodeType = SwNormalStartNode;
+        switch (m_pImpl->m_eType)
+        {
+        case CURSOR_FRAME:      eSearchNodeType = SwFlyStartNode;       break;
+        case CURSOR_TBLTEXT:    eSearchNodeType = SwTableBoxStartNode;  break;
+        case CURSOR_FOOTNOTE:   eSearchNodeType = SwFootnoteStartNode;  break;
+        case CURSOR_HEADER:     eSearchNodeType = SwHeaderStartNode;    break;
+        case CURSOR_FOOTER:     eSearchNodeType = SwFooterStartNode;    break;
+            //case CURSOR_INVALID:
+            //case CURSOR_BODY:
+        default:
+            ;
+        }
+
+        const SwStartNode* pOwnStartNode = rOwnCursor.GetNode()->FindSttNodeByType(eSearchNodeType);
+        while ( pOwnStartNode != NULL
+                && pOwnStartNode->IsSectionNode())
+        {
+            pOwnStartNode = pOwnStartNode->StartOfSectionNode();
+        }
+
+        const SwStartNode* pTmp =
+            pPam->GetNode()->FindSttNodeByType(eSearchNodeType);
+        while ( pTmp != NULL
+                && pTmp->IsSectionNode() )
+        {
+            pTmp = pTmp->StartOfSectionNode();
+        }
+
+        if ( eSearchNodeType == SwTableBoxStartNode )
+        {
+            if ( pOwnStartNode->FindTableNode() != pTmp->FindTableNode() )
+            {
+                throw uno::RuntimeException();
+            }
+        }
+        else
+        {
+            if ( pOwnStartNode != pTmp )
+            {
+                throw uno::RuntimeException();
+            }
+        }
     }
 
     if (CURSOR_META == m_pImpl->m_eType)
diff --git a/sw/source/ui/docvw/SidebarWin.cxx b/sw/source/ui/docvw/SidebarWin.cxx
index ff696df..527cc29 100644
--- a/sw/source/ui/docvw/SidebarWin.cxx
+++ b/sw/source/ui/docvw/SidebarWin.cxx
@@ -641,11 +641,26 @@ void SwSidebarWin::SetPosAndSize()
                 SwNodes& rNds = pTxtNode->GetDoc()->GetNodes();
                 SwCntntNode* const pCntntNd = rNds[mrSidebarItem.maLayoutInfo.mnStartNodeIdx]->GetCntntNode();
                 SwPosition aStartPos( *pCntntNd, mrSidebarItem.maLayoutInfo.mnStartContent );
-                ::boost::scoped_ptr<SwShellCrsr> pTmpCrsrForAnnotationTextRange(
-                    new SwShellCrsr( DocView().GetWrtShell(), aStartPos ) );
-                pTmpCrsrForAnnotationTextRange->SetMark();
-                pTmpCrsrForAnnotationTextRange->GetMark()->nNode = *pTxtNode;
-                pTmpCrsrForAnnotationTextRange->GetMark()->nContent.Assign( pTxtNode, *(pTxtAnnotationFld->GetStart())+1 );
+                SwShellCrsr* pTmpCrsr = NULL;
+                const bool bTableCrsrNeeded = pTxtNode->FindTableBoxStartNode() != pCntntNd->FindTableBoxStartNode();
+                if ( bTableCrsrNeeded )
+                {
+                    SwShellTableCrsr* pTableCrsr = new SwShellTableCrsr( DocView().GetWrtShell(), aStartPos );
+                    pTableCrsr->SetMark();
+                    pTableCrsr->GetMark()->nNode = *pTxtNode;
+                    pTableCrsr->GetMark()->nContent.Assign( pTxtNode, *(pTxtAnnotationFld->GetStart())+1 );
+                    pTableCrsr->NewTableSelection();
+                    pTmpCrsr = pTableCrsr;
+                }
+                else
+                {
+                    SwShellCrsr* pCrsr = new SwShellCrsr( DocView().GetWrtShell(), aStartPos );
+                    pCrsr->SetMark();
+                    pCrsr->GetMark()->nNode = *pTxtNode;
+                    pCrsr->GetMark()->nContent.Assign( pTxtNode, *(pTxtAnnotationFld->GetStart())+1 );
+                    pTmpCrsr = pCrsr;
+                }
+                ::boost::scoped_ptr<SwShellCrsr> pTmpCrsrForAnnotationTextRange( pTmpCrsr );
 
                 pTmpCrsrForAnnotationTextRange->FillRects();
 
diff --git a/sw/source/ui/shells/textfld.cxx b/sw/source/ui/shells/textfld.cxx
index 63b7323..9afcce6 100644
--- a/sw/source/ui/shells/textfld.cxx
+++ b/sw/source/ui/shells/textfld.cxx
@@ -358,9 +358,8 @@ void SwTextShell::ExecField(SfxRequest &rReq)
                         if( (sAuthor = aUserOpt.GetID()).isEmpty() )
                             sAuthor = SW_RES( STR_REDLINE_UNKNOWN_AUTHOR );
 
-                    if( rSh.HasSelection() )
+                    if ( rSh.HasSelection() && !rSh.IsTableMode() )
                     {
-                        rSh.NormalizePam(false);
                         rSh.KillPams();
                     }
 
diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx
index 38d8ee6..6a277ed 100644
--- a/sw/source/ui/wrtsh/wrtsh2.cxx
+++ b/sw/source/ui/wrtsh/wrtsh2.cxx
@@ -85,10 +85,23 @@ void SwWrtShell::Insert(SwField &rFld)
         {
             // for annotation fields:
             // - keep the current selection in order to create a corresponding annotation mark
-            // - collapse cursur to its point
-            const SwPaM& rCurrPaM = GetCurrentShellCursor();
-            pAnnotationTextRange = new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() );
-            ClearMark();
+            // - collapse cursor to its end
+            if ( IsTableMode() )
+            {
+                GetTblCrs()->Normalize( sal_False );
+                const SwPosition rStartPos( *(GetTblCrs()->GetMark()->nNode.GetNode().GetCntntNode()), 0 );
+                KillPams();
+                EndPara();
+                const SwPosition rEndPos( *GetCurrentShellCursor().GetPoint() );
+                pAnnotationTextRange = new SwPaM( rStartPos, rEndPos );
+            }
+            else
+            {
+                NormalizePam( sal_False );
+                const SwPaM& rCurrPaM = GetCurrentShellCursor();
+                pAnnotationTextRange = new SwPaM( *rCurrPaM.GetPoint(), *rCurrPaM.GetMark() );
+                ClearMark();
+            }
         }
         else
         {
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index 349cd37..349f5ca 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -3755,8 +3755,8 @@ void XMLAnnotationImportContext::EndElement()
                 // let's create a text range covering the old and the current position.
                 uno::Reference<text::XText> xText = GetImportHelper().GetText();
                 uno::Reference<text::XTextCursor> xCursor =
-                    xText->createTextCursorByRange(xPrevField->getAnchor());
-                xCursor->gotoRange(GetImportHelper().GetCursorAsRange(), true);
+                    xText->createTextCursorByRange(GetImportHelper().GetCursorAsRange());
+                xCursor->gotoRange(xPrevField->getAnchor(), true);
                 uno::Reference<text::XTextRange> xTextRange(xCursor, uno::UNO_QUERY);
 
                 xText->insertTextContent(xTextRange, xPrevField, !xCursor->isCollapsed());


More information about the Libreoffice-commits mailing list