summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-12-20 13:20:47 +0100
committerMichael Stahl <mstahl@redhat.com>2012-12-20 14:11:23 +0100
commit91a90acc033cfadb0cc7bf271fa9ea92c4c52e88 (patch)
tree7d235b4b62ae5ccf0993fd20e50c8fcd1eecc9ce /sw
parent5f75082ef17c713a9e41a05d222fe9dda9c3136e (diff)
SwUndoSaveCntnt: simplify Move{From,To}UndoNds
If we always create a new text node in MoveToUndoNds, there is no need for this silly and fragile adding of a "space" at the end, and clients can rely on having a unique start node for their content. Change-Id: I60937f33bac8ae2f9732eebfe6e8083b6bb2f210
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/undo/undobj.cxx43
1 files changed, 1 insertions, 42 deletions
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 73e1d833c484..ab3035cd3d27 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -332,22 +332,9 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx,
SwNodes & rNds = rDoc.GetUndoManager().GetUndoNodes();
SwPosition aPos( pEndNdIdx ? rNds.GetEndOfPostIts()
: rNds.GetEndOfExtras() );
- aPos.nNode--;
const SwPosition* pStt = rPaM.Start(), *pEnd = rPaM.End();
- if( pCpyNd || pEndNdIdx || !aPos.nNode.GetNode().GetCntntNode() ||
- (!pStt->nContent.GetIndex() && (pStt->nNode != pEnd->nNode ||
- (!pStt->nNode.GetNode().GetCntntNode() ||
- pStt->nNode.GetNode().GetCntntNode()->Len() ==
- pEnd->nContent.GetIndex() ) ) ) )
- {
- aPos.nNode++;
- aPos.nContent = 0;
- }
- else
- aPos.nNode.GetNode().GetCntntNode()->MakeEndIndex( &aPos.nContent );
-
// keep as sal_uInt16; the indices shift!
sal_uLong nTmpMvNode = aPos.nNode.GetIndex();
xub_StrLen nTmpMvCntnt = aPos.nContent.GetIndex();
@@ -362,29 +349,6 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx,
else
{
rDoc.GetNodes().MoveRange( rPaM, aPos, rNds );
-
- SwTxtNode* pTxtNd = aPos.nNode.GetNode().GetTxtNode();
- if( pTxtNd ) // add a seperator for the attributes
- {
- // But since all attributes will be touched at an insert (meaning
- // deleted from the array and re-added again), attributes might
- // disappear (e.g. "no bold" for 10-20, "bold" for 12-15 -> when
- // inserting/deleting, the "bold" will be deleted, which is not
- // wanted here!)! Thus do not touch the hints but manipulate the
- // string directly.
- String& rStr = (String&)pTxtNd->GetTxt();
- // For safety reasons better only if positioned at the end
- if( rStr.Len() == aPos.nContent.GetIndex() )
- {
- rStr.Insert( ' ' );
- ++aPos.nContent;
- }
- else
- {
- pTxtNd->InsertText( rtl::OUString(' '), aPos.nContent,
- IDocumentContentOperations::INS_NOHINTEXPAND );
- }
- }
}
if( pEndNdIdx )
*pEndNdIdx = aPos.nNode.GetIndex();
@@ -427,15 +391,10 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, sal_uLong nNodeIdx,
}
SwTxtNode* pTxtNd = aPaM.GetNode()->GetTxtNode();
- if( !pEndNdIdx && pTxtNd ) // delete the seperator again
+ if (!pEndNdIdx && pTxtNd)
{
if( pEndCntIdx )
aPaM.GetPoint()->nContent.Assign( pTxtNd, *pEndCntIdx );
- if( pTxtNd->GetTxt().Len() )
- {
- GoInCntnt( aPaM, fnMoveBackward );
- pTxtNd->EraseText( aPaM.GetPoint()->nContent, 1 );
- }
aPaM.SetMark();
aPaM.GetPoint()->nNode = nNodeIdx;