diff options
-rw-r--r-- | sw/source/core/crsr/bookmrk.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index d4947963a2a1..39d1a480a581 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -73,8 +73,9 @@ namespace SwPosition rStart = pField->GetMarkStart(); SwTextNode const*const pStartTextNode = rStart.nNode.GetNode().GetTextNode(); - const sal_Unicode ch_start = ( rStart.nContent.GetIndex() >= pStartTextNode->GetText().getLength() ) ? 0 : - pStartTextNode->GetText()[rStart.nContent.GetIndex()]; + sal_Unicode ch_start = 0; + if( pStartTextNode && ( rStart.nContent.GetIndex() < pStartTextNode->GetText().getLength() ) ) + ch_start = pStartTextNode->GetText()[rStart.nContent.GetIndex()]; if( ( ch_start != aStartMark ) && ( aEndMark != CH_TXT_ATR_FORMELEMENT ) ) { SwPaM aStartPaM(rStart); @@ -87,7 +88,9 @@ namespace 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_Unicode ch_end = nEndPos >= pEndTextNode->GetText().getLength() ? 0 : pEndTextNode->GetText()[nEndPos]; + sal_Unicode ch_end = 0; + if ( pEndTextNode && ( nEndPos < pEndTextNode->GetText().getLength() ) ) + ch_end = pEndTextNode->GetText()[nEndPos]; if ( aEndMark && ( ch_end != aEndMark ) ) { SwPaM aEndPaM(rEnd); @@ -107,8 +110,9 @@ namespace const SwPosition& rStart = pField->GetMarkStart(); SwTextNode const*const pStartTextNode = rStart.nNode.GetNode().GetTextNode(); - const sal_Unicode ch_start = - pStartTextNode->GetText()[rStart.nContent.GetIndex()]; + sal_Unicode ch_start = 0; + if( pStartTextNode ) + ch_start = pStartTextNode->GetText()[rStart.nContent.GetIndex()]; if( ch_start == aStartMark ) { @@ -122,7 +126,9 @@ namespace const sal_Int32 nEndPos = ( rEnd == rStart || rEnd.nContent.GetIndex() == 0 ) ? rEnd.nContent.GetIndex() : rEnd.nContent.GetIndex() - 1; - const sal_Unicode ch_end = pEndTextNode->GetText()[nEndPos]; + sal_Unicode ch_end = 0; + if ( pEndTextNode ) + ch_end = pEndTextNode->GetText()[nEndPos]; if ( ch_end == aEndMark ) { SwPaM aEnd(rEnd, rEnd); |