Check explicitily the space at the end of the line
Can be bugous when the last character not a space.
I don't have any real life examples, just some extreme
-Line break is inside a word without hyphenation
-A tabulator follow the last character of the line and so
this tabulator get to the next line.
Change-Id: I3c5d372295b960a5cc22c19ada382d0a995787cc
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index a162a24..42ab844 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -1259,7 +1259,7 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint,
// If necessary, as catch up, do the adjustment
GetAdjusted();
const XubString &rText = GetInfo().GetTxt();
const OUString &rText = GetInfo().GetTxt();
xub_StrLen nOffset = 0;
// x is the horizontal offset within the line.
@@ -1452,7 +1452,7 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint,
( pPor->IsMarginPortion() && !pPor->GetPortion() &&
// 46598: Consider the situation: We might end up behind the last character,
// in the last line of a centered paragraph
nCurrStart < rText.Len() ) )
nCurrStart < rText.getLength() ) )
--nCurrStart;
else if( pPor->InFldGrp() && ((SwFldPortion*)pPor)->IsFollow()
&& nWidth > nX )
@@ -1523,7 +1523,9 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint,
}
}
if( bLastPortion && (pCurr->GetNext() || pFrm->GetFollow() ) )
// Skip space at the end of the line
if( bLastPortion && (pCurr->GetNext() || pFrm->GetFollow() )
&& rText[nCurrStart + nLength - 1] == ' ' )
--nLength;
if( nWidth > nX ||
@@ -1592,8 +1594,7 @@ xub_StrLen SwTxtCursor::GetCrsrOfst( SwPosition *pPos, const Point &rPoint,
else
nOldProp = 0;
{
OUString aText = rText;
SwTxtSizeInfo aSizeInf( GetInfo(), &aText, nCurrStart );
SwTxtSizeInfo aSizeInf( GetInfo(), &rText, nCurrStart );
((SwTxtCursor*)this)->SeekAndChg( aSizeInf );
SwTxtSlot aDiffTxt( &aSizeInf, ((SwTxtPortion*)pPor), false, false );
SwFontSave aSave( aSizeInf, pPor->IsDropPortion() ?