summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-09-27 23:49:04 +0200
committerMichael Stahl <mstahl@redhat.com>2016-09-28 11:04:18 +0200
commit2bd8be10e231314e757f29a37177f529e6f1df47 (patch)
tree7c923c9cf858c4b01d74cdd321e1ca0582525961 /sw/source/core
parentbcc3509cdbffef6a3f371434161efbfc4fbd8e5c (diff)
sw: rStart variable isn't a reference
Change-Id: I48c402e3dcd9606d7f40ee2096fa8803d5499d73
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/crsr/bookmrk.cxx21
1 files changed, 12 insertions, 9 deletions
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 26ec9f9996ad..b99edeb71c99 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -72,23 +72,26 @@ namespace
{
io_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_UI_REPLACE, nullptr);
- SwPosition rStart = pField->GetMarkStart();
- SwTextNode const*const pStartTextNode = rStart.nNode.GetNode().GetTextNode();
+ SwPosition start = pField->GetMarkStart();
+ SwTextNode const*const pStartTextNode = start.nNode.GetNode().GetTextNode();
sal_Unicode ch_start = 0;
- if( pStartTextNode && ( rStart.nContent.GetIndex() < pStartTextNode->GetText().getLength() ) )
- ch_start = pStartTextNode->GetText()[rStart.nContent.GetIndex()];
+ if (pStartTextNode && (start.nContent.GetIndex() < pStartTextNode->GetText().getLength()))
+ ch_start = pStartTextNode->GetText()[start.nContent.GetIndex()];
if( ( ch_start != aStartMark ) && ( aEndMark != CH_TXT_ATR_FORMELEMENT ) )
{
- SwPaM aStartPaM(rStart);
+ SwPaM aStartPaM(start);
io_pDoc->getIDocumentContentOperations().InsertString(aStartPaM, OUString(aStartMark));
- --rStart.nContent;
- pField->SetMarkStartPos( rStart );
+ --start.nContent; // restore, it was moved by InsertString
+ // do not manipulate via reference directly but call SetMarkStartPos
+ // which works even if start and end pos were the same
+ pField->SetMarkStartPos( start );
}
SwPosition& rEnd = pField->GetMarkEnd();
SwTextNode const*const pEndTextNode = rEnd.nNode.GetNode().GetTextNode();
- const sal_Int32 nEndPos = ( rEnd == rStart || rEnd.nContent.GetIndex() == 0 ) ?
- rEnd.nContent.GetIndex() : rEnd.nContent.GetIndex() - 1;
+ const sal_Int32 nEndPos = (rEnd == start || rEnd.nContent.GetIndex() == 0)
+ ? rEnd.nContent.GetIndex()
+ : rEnd.nContent.GetIndex() - 1;
sal_Unicode ch_end = 0;
if ( pEndTextNode && ( nEndPos < pEndTextNode->GetText().getLength() ) )
ch_end = pEndTextNode->GetText()[nEndPos];