diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-08-01 19:31:34 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-08-01 19:33:22 +0200 |
commit | 44cd9ef88bfc14b4520de8a73a692f0d59c40946 (patch) | |
tree | f7a358c1a6dc342519b45b9e248ee40eab5edc4f /vcl | |
parent | 9b49846fad132f121b2848c69477e42a0051884e (diff) |
sal_uInt16 to sal_Int32, constify, minor optimizations
Change-Id: Icc41bbe09e495454ca27e9281eca6f4731a135c8
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/edit/texteng.cxx | 44 | ||||
-rw-r--r-- | vcl/source/edit/textundo.cxx | 8 | ||||
-rw-r--r-- | vcl/source/edit/textview.cxx | 67 | ||||
-rw-r--r-- | vcl/source/edit/xtextedt.cxx | 16 |
4 files changed, 61 insertions, 74 deletions
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 83929a0def85..69af62728932 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -53,6 +53,7 @@ #include <unicode/ubidi.h> +#include <algorithm> #include <cstdlib> #include <memory> #include <set> @@ -410,7 +411,7 @@ OUString TextEngine::GetText( const TextSelection& rSel, LineEnd aSeparator ) co { TextNode* pNode = mpDoc->GetNodes()[ nNode ]; - sal_uInt16 nStartPos = 0; + sal_Int32 nStartPos = 0; sal_Int32 nEndPos = pNode->GetText().getLength(); if ( nNode == nStartPara ) nStartPos = aSel.GetStart().GetIndex(); @@ -637,10 +638,7 @@ bool TextEngine::IsInputSequenceCheckingRequired( sal_Unicode c, const TextSelec SvtCTLOptions aCTLOptions; // get the index that really is first - sal_uInt16 nFirstPos = rCurSel.GetStart().GetIndex(); - sal_uInt16 nMaxPos = rCurSel.GetEnd().GetIndex(); - if (nMaxPos < nFirstPos) - nFirstPos = nMaxPos; + const sal_Int32 nFirstPos = std::min(rCurSel.GetStart().GetIndex(), rCurSel.GetEnd().GetIndex()); bool bIsSequenceChecking = aCTLOptions.IsCTLFontEnabled() && @@ -685,7 +683,7 @@ TextPaM TextEngine::ImpInsertText( sal_Unicode c, const TextSelection& rCurSel, { // if selection, then don't overwrite a character TextSelection aTmpSel( aPaM ); - aTmpSel.GetEnd().GetIndex()++; + ++aTmpSel.GetEnd().GetIndex(); ImpDeleteText( aTmpSel ); } @@ -721,7 +719,7 @@ TextPaM TextEngine::ImpInsertText( sal_Unicode c, const TextSelection& rCurSel, OUString aChgText( aNewText.copy( nChgPos ) ); // select text from first pos to be changed to current pos - TextSelection aSel( TextPaM( aPaM.GetPara(), (sal_uInt16) nChgPos ), aPaM ); + TextSelection aSel( TextPaM( aPaM.GetPara(), nChgPos ), aPaM ); if (!aChgText.isEmpty()) // ImpInsertText implicitly handles undo... @@ -895,7 +893,7 @@ Rectangle TextEngine::GetEditCursor( const TextPaM& rPaM, bool bSpecial, bool bP */ long nY = 0; - sal_uInt16 nCurIndex = 0; + sal_Int32 nCurIndex = 0; TextLine* pLine = 0; for ( size_t nLine = 0; nLine < pPortion->GetLines().size(); nLine++ ) { @@ -1678,7 +1676,7 @@ void TextEngine::ImpBreakLine( sal_uLong nPara, TextLine* pLine, TETextPortion*, static const com::sun::star::lang::Locale aDefLocale; i18n::LineBreakResults aLBR = xBI->getLineBreak( pNode->GetText(), nMaxBreakPos, aDefLocale, pLine->GetStart(), aHyphOptions, aUserOptions ); - sal_uInt16 nBreakPos = (sal_uInt16)aLBR.breakIndex; + sal_Int32 nBreakPos = aLBR.breakIndex; if ( nBreakPos <= pLine->GetStart() ) { nBreakPos = nMaxBreakPos; @@ -1960,7 +1958,7 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan { // for all lines of the paragraph sal_uInt16 nLines = pPortion->GetLines().size(); - sal_uInt16 nIndex = 0; + sal_Int32 nIndex = 0; for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ ) { TextLine& pLine = pPortion->GetLines()[nLine]; @@ -2004,8 +2002,8 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan aFont.SetTransparent( false ); pOutDev->SetFont( aFont ); - sal_uInt16 nTmpIndex = nIndex; - sal_uInt16 nEnd = nTmpIndex + pTextPortion->GetLen(); + sal_Int32 nTmpIndex = nIndex; + sal_Int32 nEnd = nTmpIndex + pTextPortion->GetLen(); Point aPos = aTmpPos; if ( pPaintRange ) { @@ -2030,12 +2028,10 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan TextPaM aTextEnd( nPara, nEnd ); if ( ( aTextStart < *pSelEnd ) && ( aTextEnd > *pSelStart ) ) { - sal_uInt16 nL; - // 1) vcl::Region before Selection if ( aTextStart < *pSelStart ) { - nL = pSelStart->GetIndex() - nTmpIndex; + const sal_Int32 nL = pSelStart->GetIndex() - nTmpIndex; pOutDev->SetFont( aFont); aPos.X() = rStartPos.X() + ImpGetOutputOffset( nPara, &pLine, nTmpIndex, nTmpIndex+nL ); pOutDev->DrawText( aPos, pPortion->GetNode()->GetText(), nTmpIndex, nL ); @@ -2043,7 +2039,7 @@ void TextEngine::ImpPaint( OutputDevice* pOutDev, const Point& rStartPos, Rectan } // 2) vcl::Region with Selection - nL = nEnd-nTmpIndex; + sal_Int32 nL = nEnd - nTmpIndex; if ( aTextEnd > *pSelEnd ) nL = pSelEnd->GetIndex() - nTmpIndex; if ( nL ) @@ -2464,8 +2460,8 @@ OUString TextEngine::GetWord( const TextPaM& rCursorPos, TextPaM* pStartOfWord ) TextNode* pNode = mpDoc->GetNodes()[ rCursorPos.GetPara() ]; uno::Reference < i18n::XBreakIterator > xBI = GetBreakIterator(); i18n::Boundary aBoundary = xBI->getWordBoundary( pNode->GetText(), rCursorPos.GetIndex(), GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true ); - aSel.GetStart().GetIndex() = (sal_uInt16)aBoundary.startPos; - aSel.GetEnd().GetIndex() = (sal_uInt16)aBoundary.endPos; + aSel.GetStart().GetIndex() = aBoundary.startPos; + aSel.GetEnd().GetIndex() = aBoundary.endPos; aWord = pNode->GetText().copy( aSel.GetStart().GetIndex(), aSel.GetEnd().GetIndex() - aSel.GetStart().GetIndex() ); if ( pStartOfWord ) *pStartOfWord = aSel.GetStart(); @@ -2541,12 +2537,10 @@ bool TextEngine::Write( SvStream& rOutput, const TextSelection* pSel, bool bHTML { TextNode* pNode = mpDoc->GetNodes()[ nPara ]; - sal_Int32 nStartPos = 0; - sal_Int32 nEndPos = pNode->GetText().getLength(); - if ( nPara == aSel.GetStart().GetPara() ) - nStartPos = aSel.GetStart().GetIndex(); - if ( nPara == aSel.GetEnd().GetPara() ) - nEndPos = aSel.GetEnd().GetIndex(); + const sal_Int32 nStartPos = nPara == aSel.GetStart().GetPara() + ? aSel.GetStart().GetIndex() : 0; + const sal_Int32 nEndPos = nPara == aSel.GetEnd().GetPara() + ? aSel.GetEnd().GetIndex() : pNode->GetText().getLength(); OUStringBuffer aText; if ( !bHTML ) @@ -2831,7 +2825,7 @@ void TextEngine::ImpCharsInserted( sal_uLong nPara, sal_Int32 nPos, sal_Int32 nC if ( rPaM.GetPara() == nPara ) { if ( rPaM.GetIndex() >= nPos ) - rPaM.GetIndex() = rPaM.GetIndex() + nChars; + rPaM.GetIndex() += nChars; } } } diff --git a/vcl/source/edit/textundo.cxx b/vcl/source/edit/textundo.cxx index 1ba423a45e50..328c3ca21194 100644 --- a/vcl/source/edit/textundo.cxx +++ b/vcl/source/edit/textundo.cxx @@ -259,7 +259,7 @@ TextUndoInsertChars::TextUndoInsertChars( TextEngine* pTextEngine, const TextPaM void TextUndoInsertChars::Undo() { TextSelection aSel( maTextPaM, maTextPaM ); - aSel.GetEnd().GetIndex() = aSel.GetEnd().GetIndex() + maText.getLength(); + aSel.GetEnd().GetIndex() += maText.getLength(); TextPaM aPaM = GetTextEngine()->ImpDeleteText( aSel ); SetSelection( aPaM ); } @@ -269,7 +269,7 @@ void TextUndoInsertChars::Redo() TextSelection aSel( maTextPaM, maTextPaM ); GetTextEngine()->ImpInsertText( aSel, maText ); TextPaM aNewPaM( maTextPaM ); - aNewPaM.GetIndex() = aNewPaM.GetIndex() + maText.getLength(); + aNewPaM.GetIndex() += maText.getLength(); SetSelection( TextSelection( aSel.GetStart(), aNewPaM ) ); } @@ -309,14 +309,14 @@ void TextUndoRemoveChars::Undo() { TextSelection aSel( maTextPaM, maTextPaM ); GetTextEngine()->ImpInsertText( aSel, maText ); - aSel.GetEnd().GetIndex() = aSel.GetEnd().GetIndex() + maText.getLength(); + aSel.GetEnd().GetIndex() += maText.getLength(); SetSelection( aSel ); } void TextUndoRemoveChars::Redo() { TextSelection aSel( maTextPaM, maTextPaM ); - aSel.GetEnd().GetIndex() = aSel.GetEnd().GetIndex() + maText.getLength(); + aSel.GetEnd().GetIndex() += maText.getLength(); TextPaM aPaM = GetTextEngine()->ImpDeleteText( aSel ); SetSelection( aPaM ); } diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index affa0c88e4c2..f680f23a5e9d 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -56,6 +56,8 @@ #include <osl/mutex.hxx> +#include <algorithm> + using namespace ::com::sun::star; class TETextDataObject : public ::com::sun::star::datatransfer::XTransferable, @@ -418,8 +420,8 @@ void TextView::ImpHighlight( const TextSelection& rSel ) for ( sal_uInt16 nLine = nStartLine; nLine <= nEndLine; nLine++ ) { TextLine& pLine = pTEParaPortion->GetLines()[ nLine ]; - sal_uInt16 nStartIndex = pLine.GetStart(); - sal_uInt16 nEndIndex = pLine.GetEnd(); + sal_Int32 nStartIndex = pLine.GetStart(); + sal_Int32 nEndIndex = pLine.GetEnd(); if ( ( nPara == nStartPara ) && ( nLine == nStartLine ) ) nStartIndex = aSel.GetStart().GetIndex(); if ( ( nPara == nEndPara ) && ( nLine == nEndLine ) ) @@ -732,7 +734,7 @@ bool TextView::KeyInput( const KeyEvent& rKeyEvent ) if ( mpImpl->mbAutoIndent ) { TextNode* pPrev = mpImpl->mpTextEngine->mpDoc->GetNodes()[ aCurSel.GetEnd().GetPara() - 1 ]; - sal_uInt16 n = 0; + sal_Int32 n = 0; while ( ( n < pPrev->GetText().getLength() ) && ( ( pPrev->GetText()[ n ] == ' ' ) || ( pPrev->GetText()[ n ] == '\t' ) ) ) @@ -856,18 +858,16 @@ void TextView::MouseButtonDown( const MouseEvent& rMouseEvent ) uno::Reference < i18n::XBreakIterator > xBI = mpImpl->mpTextEngine->GetBreakIterator(); i18n::Boundary aBoundary = xBI->getWordBoundary( pNode->GetText(), mpImpl->maSelection.GetEnd().GetIndex(), mpImpl->mpTextEngine->GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true ); TextSelection aNewSel( mpImpl->maSelection ); - aNewSel.GetStart().GetIndex() = (sal_uInt16)aBoundary.startPos; - aNewSel.GetEnd().GetIndex() = (sal_uInt16)aBoundary.endPos; + aNewSel.GetStart().GetIndex() = aBoundary.startPos; + aNewSel.GetEnd().GetIndex() = aBoundary.endPos; if(mpImpl->mbSupportProtectAttribute) { //expand selection to include all protected content - if there is any const TextCharAttrib* pStartAttr = mpImpl->mpTextEngine->FindCharAttrib( - TextPaM(aNewSel.GetStart().GetPara(), - (sal_uInt16)aBoundary.startPos), + TextPaM(aNewSel.GetStart().GetPara(), aBoundary.startPos), TEXTATTR_PROTECTED ); const TextCharAttrib* pEndAttr = mpImpl->mpTextEngine->FindCharAttrib( - TextPaM(aNewSel.GetEnd().GetPara(), - (sal_uInt16)aBoundary.endPos), + TextPaM(aNewSel.GetEnd().GetPara(), aBoundary.endPos), TEXTATTR_PROTECTED ); if(pStartAttr && pStartAttr->GetStart() < aNewSel.GetStart().GetIndex()) { @@ -950,14 +950,14 @@ void TextView::Command( const CommandEvent& rCEvt ) if ( !pData->IsOnlyCursorChanged() ) { TextSelection aSelect( mpImpl->mpTextEngine->mpIMEInfos->aPos ); - aSelect.GetEnd().GetIndex() = aSelect.GetEnd().GetIndex() + mpImpl->mpTextEngine->mpIMEInfos->nLen; + aSelect.GetEnd().GetIndex() += mpImpl->mpTextEngine->mpIMEInfos->nLen; aSelect = mpImpl->mpTextEngine->ImpDeleteText( aSelect ); aSelect = mpImpl->mpTextEngine->ImpInsertText( aSelect, pData->GetText() ); if ( mpImpl->mpTextEngine->mpIMEInfos->bWasCursorOverwrite ) { - sal_Int32 nOldIMETextLen = mpImpl->mpTextEngine->mpIMEInfos->nLen; - sal_Int32 nNewIMETextLen = pData->GetText().getLength(); + const sal_Int32 nOldIMETextLen = mpImpl->mpTextEngine->mpIMEInfos->nLen; + const sal_Int32 nNewIMETextLen = pData->GetText().getLength(); if ( ( nOldIMETextLen > nNewIMETextLen ) && ( nNewIMETextLen < mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.getLength() ) ) @@ -965,22 +965,19 @@ void TextView::Command( const CommandEvent& rCEvt ) // restore old characters sal_Int32 nRestore = nOldIMETextLen - nNewIMETextLen; TextPaM aPaM( mpImpl->mpTextEngine->mpIMEInfos->aPos ); - aPaM.GetIndex() = aPaM.GetIndex() + nNewIMETextLen; + aPaM.GetIndex() += nNewIMETextLen; mpImpl->mpTextEngine->ImpInsertText( aPaM, mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.copy( nNewIMETextLen, nRestore ) ); } else if ( ( nOldIMETextLen < nNewIMETextLen ) && ( nOldIMETextLen < mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.getLength() ) ) { // overwrite - sal_uInt16 nOverwrite = nNewIMETextLen - nOldIMETextLen; - if ( ( nOldIMETextLen + nOverwrite ) > mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.getLength() ) - nOverwrite = mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.getLength() - nOldIMETextLen; + const sal_Int32 nOverwrite = std::min( nNewIMETextLen, mpImpl->mpTextEngine->mpIMEInfos->aOldTextAfterStartPos.getLength() ) - nOldIMETextLen; DBG_ASSERT( nOverwrite && (nOverwrite < 0xFF00), "IME Overwrite?!" ); TextPaM aPaM( mpImpl->mpTextEngine->mpIMEInfos->aPos ); - aPaM.GetIndex() = aPaM.GetIndex() + nNewIMETextLen; + aPaM.GetIndex() += nNewIMETextLen; TextSelection aSel( aPaM ); - aSel.GetEnd().GetIndex() = - aSel.GetEnd().GetIndex() + nOverwrite; + aSel.GetEnd().GetIndex() += nOverwrite; mpImpl->mpTextEngine->ImpDeleteText( aSel ); } } @@ -1367,7 +1364,7 @@ TextPaM TextView::CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIterator TextNode* pNode = mpImpl->mpTextEngine->mpDoc->GetNodes()[ aPaM.GetPara() ]; uno::Reference < i18n::XBreakIterator > xBI = mpImpl->mpTextEngine->GetBreakIterator(); sal_Int32 nCount = 1; - aPaM.GetIndex() = (sal_uInt16)xBI->previousCharacters( pNode->GetText(), aPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), nCharacterIteratorMode, nCount, nCount ); + aPaM.GetIndex() = xBI->previousCharacters( pNode->GetText(), aPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), nCharacterIteratorMode, nCount, nCount ); } else if ( aPaM.GetPara() ) { @@ -1387,7 +1384,7 @@ TextPaM TextView::CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIterato { uno::Reference < i18n::XBreakIterator > xBI = mpImpl->mpTextEngine->GetBreakIterator(); sal_Int32 nCount = 1; - aPaM.GetIndex() = (sal_uInt16)xBI->nextCharacters( pNode->GetText(), aPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), nCharacterIteratorMode, nCount, nCount ); + aPaM.GetIndex() = xBI->nextCharacters( pNode->GetText(), aPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), nCharacterIteratorMode, nCount, nCount ); } else if ( aPaM.GetPara() < ( mpImpl->mpTextEngine->mpDoc->GetNodes().size()-1) ) { @@ -1409,7 +1406,7 @@ TextPaM TextView::CursorWordLeft( const TextPaM& rPaM ) i18n::Boundary aBoundary = xBI->getWordBoundary( pNode->GetText(), rPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES, true ); if ( aBoundary.startPos >= rPaM.GetIndex() ) aBoundary = xBI->previousWord( pNode->GetText(), rPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES ); - aPaM.GetIndex() = ( aBoundary.startPos != -1 ) ? (sal_uInt16)aBoundary.startPos : 0; + aPaM.GetIndex() = ( aBoundary.startPos != -1 ) ? aBoundary.startPos : 0; } else if ( aPaM.GetPara() ) { @@ -1429,7 +1426,7 @@ TextPaM TextView::CursorWordRight( const TextPaM& rPaM ) { uno::Reference < i18n::XBreakIterator > xBI = mpImpl->mpTextEngine->GetBreakIterator(); i18n::Boundary aBoundary = xBI->nextWord( pNode->GetText(), aPaM.GetIndex(), mpImpl->mpTextEngine->GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES ); - aPaM.GetIndex() = (sal_uInt16)aBoundary.startPos; + aPaM.GetIndex() = aBoundary.startPos; } else if ( aPaM.GetPara() < ( mpImpl->mpTextEngine->mpDoc->GetNodes().size()-1) ) { @@ -1461,7 +1458,7 @@ TextPaM TextView::ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode ) if ( aBoundary.startPos == mpImpl->maSelection.GetEnd().GetIndex() ) aBoundary = xBI->previousWord( pNode->GetText(), mpImpl->maSelection.GetEnd().GetIndex(), mpImpl->mpTextEngine->GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES ); // #i63506# startPos is -1 when the paragraph starts with a tab - aEndPaM.GetIndex() = (aBoundary.startPos >= 0) ? (sal_uInt16)aBoundary.startPos : 0; + aEndPaM.GetIndex() = std::max<sal_Int32>(aBoundary.startPos, 0); } else // DELMODE_RESTOFCONTENT { @@ -1486,7 +1483,7 @@ TextPaM TextView::ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode ) TextNode* pNode = mpImpl->mpTextEngine->mpDoc->GetNodes()[ aEndPaM.GetPara() ]; uno::Reference < i18n::XBreakIterator > xBI = mpImpl->mpTextEngine->GetBreakIterator(); i18n::Boundary aBoundary = xBI->nextWord( pNode->GetText(), mpImpl->maSelection.GetEnd().GetIndex(), mpImpl->mpTextEngine->GetLocale(), i18n::WordType::ANYWORD_IGNOREWHITESPACES ); - aEndPaM.GetIndex() = (sal_uInt16)aBoundary.startPos; + aEndPaM.GetIndex() = aBoundary.startPos; } else // DELMODE_RESTOFCONTENT { @@ -1530,7 +1527,7 @@ TextPaM TextView::CursorUp( const TextPaM& rPaM ) // Problem: Last character of an automatically wrapped line = Cursor TextLine& pLine = pPPortion->GetLines()[ nLine - 1 ]; if ( aPaM.GetIndex() && ( aPaM.GetIndex() == pLine.GetEnd() ) ) - aPaM.GetIndex()--; + --aPaM.GetIndex(); } else if ( rPaM.GetPara() ) // previous paragraph { @@ -1567,7 +1564,7 @@ TextPaM TextView::CursorDown( const TextPaM& rPaM ) // special case CursorUp TextLine& pLine = pPPortion->GetLines()[ nLine + 1 ]; if ( ( aPaM.GetIndex() == pLine.GetEnd() ) && ( aPaM.GetIndex() > pLine.GetStart() ) && aPaM.GetIndex() < pPPortion->GetNode()->GetText().getLength() ) - aPaM.GetIndex()--; + --aPaM.GetIndex(); } else if ( rPaM.GetPara() < ( mpImpl->mpTextEngine->mpDoc->GetNodes().size() - 1 ) ) // next paragraph { @@ -1577,7 +1574,7 @@ TextPaM TextView::CursorDown( const TextPaM& rPaM ) aPaM.GetIndex() = nCharPos; TextLine& pLine = pPPortion->GetLines().front(); if ( ( aPaM.GetIndex() == pLine.GetEnd() ) && ( aPaM.GetIndex() > pLine.GetStart() ) && ( pPPortion->GetLines().size() > 1 ) ) - aPaM.GetIndex()--; + --aPaM.GetIndex(); } return aPaM; @@ -1612,7 +1609,7 @@ TextPaM TextView::CursorEndOfLine( const TextPaM& rPaM ) // for a blank in an automatically-wrapped line it is better to stand before it, // as the user will intend to stand behind the prior word. // If there is a change, special case for Pos1 after End! - aPaM.GetIndex()--; + --aPaM.GetIndex(); } } return aPaM; @@ -2094,11 +2091,9 @@ void TextView::drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEv const sal_Int32 nNewChars = mpImpl->mpTextEngine->GetTextLen( aPrevSel.GetStart().GetPara() ) - nPrevStartParaLen; - aPrevSel.GetStart().GetIndex() = - aPrevSel.GetStart().GetIndex() + nNewChars; + aPrevSel.GetStart().GetIndex() += nNewChars; if ( aPrevSel.GetStart().GetPara() == aPrevSel.GetEnd().GetPara() ) - aPrevSel.GetEnd().GetIndex() = - aPrevSel.GetEnd().GetIndex() + nNewChars; + aPrevSel.GetEnd().GetIndex() += nNewChars; } } else @@ -2108,11 +2103,9 @@ void TextView::drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEv aPaM.GetPara() -= ( aPrevSel.GetEnd().GetPara() - aPrevSel.GetStart().GetPara() ); if ( aPrevSel.GetEnd().GetPara() == mpImpl->mpDDInfo->maDropPos.GetPara() ) { - aPaM.GetIndex() = - aPaM.GetIndex() - aPrevSel.GetEnd().GetIndex(); + aPaM.GetIndex() -= aPrevSel.GetEnd().GetIndex(); if ( aPrevSel.GetStart().GetPara() == mpImpl->mpDDInfo->maDropPos.GetPara() ) - aPaM.GetIndex() = - aPaM.GetIndex() + aPrevSel.GetStart().GetIndex(); + aPaM.GetIndex() += aPrevSel.GetStart().GetIndex(); } ImpSetSelection( aPaM ); diff --git a/vcl/source/edit/xtextedt.cxx b/vcl/source/edit/xtextedt.cxx index 072e1f9dab91..de773e27e1ed 100644 --- a/vcl/source/edit/xtextedt.cxx +++ b/vcl/source/edit/xtextedt.cxx @@ -37,7 +37,7 @@ ExtTextEngine::~ExtTextEngine() TextSelection ExtTextEngine::MatchGroup( const TextPaM& rCursor ) const { TextSelection aSel( rCursor ); - sal_uInt16 nPos = rCursor.GetIndex(); + const sal_Int32 nPos = rCursor.GetIndex(); sal_uLong nPara = rCursor.GetPara(); sal_uLong nParas = GetParagraphCount(); if ( ( nPara < nParas ) && ( nPos < GetTextLen( nPara ) ) ) @@ -51,7 +51,7 @@ TextSelection ExtTextEngine::MatchGroup( const TextPaM& rCursor ) const sal_Unicode nSC = maGroupChars[ nMatchIndex ]; sal_Unicode nEC = maGroupChars[ nMatchIndex+1 ]; - sal_uInt16 nCur = nPos+1; + sal_Int32 nCur = nPos+1; sal_uInt16 nLevel = 1; while ( nLevel && ( nPara < nParas ) ) { @@ -87,7 +87,7 @@ TextSelection ExtTextEngine::MatchGroup( const TextPaM& rCursor ) const sal_Unicode nEC = maGroupChars[ nMatchIndex ]; sal_Unicode nSC = maGroupChars[ nMatchIndex-1 ]; - sal_uInt16 nCur = rCursor.GetIndex()-1; + sal_Int32 nCur = rCursor.GetIndex()-1; sal_uInt16 nLevel = 1; while ( nLevel ) { @@ -124,7 +124,7 @@ TextSelection ExtTextEngine::MatchGroup( const TextPaM& rCursor ) const if ( nLevel == 0 ) // found { aSel.GetStart() = rCursor; - aSel.GetStart().GetIndex()++; // behind the char + ++aSel.GetStart().GetIndex(); // behind the char aSel.GetEnd() = TextPaM( nPara, nCur ); } } @@ -373,16 +373,16 @@ bool ExtTextView::ImpIndentBlock( bool bRight ) bool bRange = aSel.HasRange(); if ( bRight ) { - aSel.GetStart().GetIndex()++; + ++aSel.GetStart().GetIndex(); if ( bRange && ( aSel.GetEnd().GetPara() == nEndPara ) ) - aSel.GetEnd().GetIndex()++; + ++aSel.GetEnd().GetIndex(); } else { if ( aSel.GetStart().GetIndex() ) - aSel.GetStart().GetIndex()--; + --aSel.GetStart().GetIndex(); if ( bRange && aSel.GetEnd().GetIndex() ) - aSel.GetEnd().GetIndex()--; + --aSel.GetEnd().GetIndex(); } ImpSetSelection( aSel ); |