summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2014-01-16 11:47:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-01-16 15:18:33 +0000
commit4b6b51182a9a600805729313278eb707c6ebfb14 (patch)
tree61bd6512a770c877a4a70f694f4a7bec06736e6a /sw
parentc2b002ba96a9cd1ffc45281f7ba195063c94a54a (diff)
Resolves: #i124030# 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 Change-Id: Id7317eeb8e9c063c9d8b30bca97ed0afee3ec8c5
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/docbm.cxx103
1 files changed, 63 insertions, 40 deletions
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index dac5379af9bb..97b3298cc683 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
@@ -626,8 +632,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
@@ -642,61 +648,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() );
}
}
@@ -721,13 +743,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 );
}
}
}
@@ -736,13 +758,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)
@@ -750,7 +772,7 @@ namespace sw { namespace mark
vDelay.push_back(deleteMark(*pppMark));
}
} // scope to kill vDelay
- if(isSortingNeeded)
+ if(bIsSortingNeeded)
sortMarks();
#if 0
OSL_TRACE("deleteMarks");
@@ -871,7 +893,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);
}
@@ -1301,6 +1323,7 @@ void SaveBookmark::SetInDoc(
}
}
+
// _DelBookmarks, _{Save,Restore}CntntIdx
void _DelBookmarks(