Kaydet (Commit) 4d585e6f authored tarafından Caolán McNamara's avatar Caolán McNamara

longparas: STRING_NOTFOUND->-1

Change-Id: I596b0bbe32b9f4017e58cedb6802d82b55454d16
üst 09a1a81d
......@@ -238,18 +238,18 @@ void SwHHCWrapper::ChangeText( const OUString &rNewText,
{
// remember cursor start position for later setting of the cursor
const SwPosition *pStart = pCrsr->Start();
const xub_StrLen nStartIndex = pStart->nContent.GetIndex();
const sal_Int32 nStartIndex = pStart->nContent.GetIndex();
const SwNodeIndex aStartNodeIndex = pStart->nNode;
SwTxtNode *pStartTxtNode = aStartNodeIndex.GetNode().GetTxtNode();
const sal_Int32 nIndices = pOffsets->getLength();
const sal_Int32 *pIndices = pOffsets->getConstArray();
sal_Int32 nConvTextLen = rNewText.getLength();
xub_StrLen nPos = 0;
xub_StrLen nChgPos = STRING_NOTFOUND;
xub_StrLen nChgLen = 0;
xub_StrLen nConvChgPos = STRING_NOTFOUND;
xub_StrLen nConvChgLen = 0;
sal_Int32 nPos = 0;
sal_Int32 nChgPos = -1;
sal_Int32 nChgLen = 0;
sal_Int32 nConvChgPos = -1;
sal_Int32 nConvChgLen = 0;
// offset to calculate the position in the text taking into
// account that text may have been replaced with new text of
......@@ -263,20 +263,20 @@ void SwHHCWrapper::ChangeText( const OUString &rNewText,
while (true)
{
// get index in original text that matches nPos in new text
xub_StrLen nIndex;
sal_Int32 nIndex;
if (nPos < nConvTextLen)
nIndex = (sal_Int32) nPos < nIndices ? (xub_StrLen) pIndices[nPos] : nPos;
nIndex = nPos < nIndices ? pIndices[nPos] : nPos;
else
{
nPos = nConvTextLen;
nIndex = static_cast< xub_StrLen >( rOrigText.getLength() );
nIndex = rOrigText.getLength();
}
if (rOrigText[nIndex] == rNewText[nPos] ||
nPos == nConvTextLen /* end of string also terminates non-matching char sequence */)
{
// substring that needs to be replaced found?
if (nChgPos != STRING_NOTFOUND && nConvChgPos != STRING_NOTFOUND)
if (nChgPos != -1 && nConvChgPos != -1)
{
nChgLen = nIndex - nChgPos;
nConvChgLen = nPos - nConvChgPos;
......@@ -286,7 +286,7 @@ void SwHHCWrapper::ChangeText( const OUString &rNewText,
OUString aInNew( rNewText.copy( nConvChgPos, nConvChgLen ) );
// set selection to sub string to be replaced in original text
xub_StrLen nChgInNodeStartIndex = static_cast< xub_StrLen >( nStartIndex + nCorrectionOffset + nChgPos );
sal_Int32 nChgInNodeStartIndex = nStartIndex + nCorrectionOffset + nChgPos;
OSL_ENSURE( m_rWrtShell.GetCrsr()->HasMark(), "cursor misplaced (nothing selected)" );
m_rWrtShell.GetCrsr()->GetMark()->nContent.Assign( pStartTxtNode, nChgInNodeStartIndex );
m_rWrtShell.GetCrsr()->GetPoint()->nContent.Assign( pStartTxtNode, nChgInNodeStartIndex + nChgLen );
......@@ -301,14 +301,14 @@ void SwHHCWrapper::ChangeText( const OUString &rNewText,
nCorrectionOffset += nConvChgLen - nChgLen;
nChgPos = STRING_NOTFOUND;
nConvChgPos = STRING_NOTFOUND;
nChgPos = -1;
nConvChgPos = -1;
}
}
else
{
// begin of non-matching char sequence found ?
if (nChgPos == STRING_NOTFOUND && nConvChgPos == STRING_NOTFOUND)
if (nChgPos == -1 && nConvChgPos == -1)
{
nChgPos = nIndex;
nConvChgPos = nPos;
......@@ -495,7 +495,7 @@ void SwHHCWrapper::ReplaceUnit(
if (bIsChineseConversion)
{
m_rWrtShell.SetMark();
m_rWrtShell.GetCrsr()->GetMark()->nContent -= (xub_StrLen) aNewTxt.getLength();
m_rWrtShell.GetCrsr()->GetMark()->nContent -= aNewTxt.getLength();
OSL_ENSURE( GetTargetLanguage() == LANGUAGE_CHINESE_SIMPLIFIED || GetTargetLanguage() == LANGUAGE_CHINESE_TRADITIONAL,
"SwHHCWrapper::ReplaceUnit : unexpected target language" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment