diff options
-rw-r--r-- | accessibility/source/extended/textwindowaccessibility.cxx | 20 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 12 | ||||
-rw-r--r-- | cui/source/dialogs/SpellDialog.cxx | 6 | ||||
-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 |
7 files changed, 77 insertions, 96 deletions
diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx index be6a97629eca..2224fecb99bd 100644 --- a/accessibility/source/extended/textwindowaccessibility.cxx +++ b/accessibility/source/extended/textwindowaccessibility.cxx @@ -882,13 +882,11 @@ void Document::retrieveParagraphSelection(Paragraph const * pParagraph, if ( nNumber >= aMinPaM.GetPara() && nNumber <= aMaxPaM.GetPara() ) { - *pBegin = nNumber > aMinPaM.GetPara() - ? 0 - : static_cast< ::sal_Int32 >( aMinPaM.GetIndex() ); + *pBegin = nNumber > aMinPaM.GetPara() ? 0 : aMinPaM.GetIndex(); // XXX numeric overflow *pEnd = nNumber < aMaxPaM.GetPara() - ? static_cast< ::sal_Int32 >( m_rEngine.GetText(static_cast< ::sal_uLong >(nNumber)).getLength() ) - : static_cast< ::sal_Int32 >( aMaxPaM.GetIndex() ); + ? m_rEngine.GetText(static_cast< ::sal_uLong >(nNumber)).getLength() + : aMaxPaM.GetIndex(); // XXX numeric overflow (3x) if ( aStartPaM > aEndPaM ) @@ -909,8 +907,7 @@ void Document::retrieveParagraphSelection(Paragraph const * pParagraph, Paragraphs::size_type nNumber = pParagraph->getNumber(); TextPaM aEndPaM( rSelection.GetEnd() ); - return aEndPaM.GetPara() == nNumber - ? static_cast< ::sal_Int32 >(aEndPaM.GetIndex()) : -1; + return aEndPaM.GetPara() == nNumber ? aEndPaM.GetIndex() : -1; } css::awt::Rectangle @@ -974,8 +971,7 @@ Document::retrieveCharacterBounds(Paragraph const * pParagraph, ::TextPaM aPaM(m_rEngine.GetPaM(::Point(static_cast< long >(rPoint.X), static_cast< long >(rPoint.Y)))); // XXX numeric overflow (2x) - return aPaM.GetPara() == nNumber - ? static_cast< ::sal_Int32 >(aPaM.GetIndex()) : -1; + return aPaM.GetPara() == nNumber ? aPaM.GetIndex() : -1; // XXX numeric overflow } @@ -2248,13 +2244,11 @@ void Document::handleSelectionChangeNotification() "bad TEXT_HINT_VIEWSELECTIONCHANGED event"); ::sal_Int32 nNewFirstPara = static_cast< ::sal_Int32 >(rSelection.GetStart().GetPara()); - ::sal_Int32 nNewFirstPos - = static_cast< ::sal_Int32 >(rSelection.GetStart().GetIndex()); + ::sal_Int32 nNewFirstPos = rSelection.GetStart().GetIndex(); // XXX numeric overflow ::sal_Int32 nNewLastPara = static_cast< ::sal_Int32 >(rSelection.GetEnd().GetPara()); - ::sal_Int32 nNewLastPos - = static_cast< ::sal_Int32 >(rSelection.GetEnd().GetIndex()); + ::sal_Int32 nNewLastPos = rSelection.GetEnd().GetIndex(); // XXX numeric overflow // Lose focus: diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 9512e4052aef..0a4277ff128a 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -598,7 +598,7 @@ void EditorWindow::HandleAutoCorrect() { TextSelection aSel = GetEditView()->GetSelection(); sal_uLong nLine = aSel.GetStart().GetPara(); - sal_uInt16 nIndex = aSel.GetStart().GetIndex(); + const sal_Int32 nIndex = aSel.GetStart().GetIndex(); OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified const OUString& sActSubName = GetActualSubName( nLine ); // the actual procedure @@ -609,7 +609,7 @@ void EditorWindow::HandleAutoCorrect() return; HighlightPortion& r = aPortions.back(); - if( nIndex != aPortions.size()-1 ) + if( static_cast<size_t>(nIndex) != aPortions.size()-1 ) {//cursor is not standing at the end of the line for (std::vector<HighlightPortion>::iterator i(aPortions.begin()); i != aPortions.end(); ++i) @@ -675,14 +675,14 @@ void EditorWindow::HandleAutoCorrect() TextSelection EditorWindow::GetLastHighlightPortionTextSelection() {//creates a text selection from the highlight portion on the cursor sal_uLong nLine = GetEditView()->GetSelection().GetStart().GetPara(); - sal_uInt16 nIndex = GetEditView()->GetSelection().GetStart().GetIndex(); + const sal_Int32 nIndex = GetEditView()->GetSelection().GetStart().GetIndex(); OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified std::vector<HighlightPortion> aPortions; aHighlighter.getHighlightPortions( aLine, aPortions ); assert(!aPortions.empty()); HighlightPortion& r = aPortions.back(); - if( nIndex != aPortions.size()-1 ) + if( static_cast<size_t>(nIndex) != aPortions.size()-1 ) {//cursor is not standing at the end of the line for (std::vector<HighlightPortion>::iterator i(aPortions.begin()); i != aPortions.end(); ++i) @@ -906,8 +906,8 @@ void EditorWindow::SetupAndShowCodeCompleteWnd( const std::vector< OUString >& a pCodeCompleteWnd->ResizeAndPositionListBox(); pCodeCompleteWnd->SelectFirstEntry(); // correct text selection, and set it - aSel.GetStart().GetIndex() += 1; - aSel.GetEnd().GetIndex() += 1; + ++aSel.GetStart().GetIndex(); + ++aSel.GetEnd().GetIndex(); pCodeCompleteWnd->SetTextSelection( aSel ); //give the focus to the EditView pEditView->GetWindow()->GrabFocus(); diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index 631ab8c473dc..754cb7bbf42f 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -1601,10 +1601,10 @@ bool SentenceEditWindow_Impl::MarkNextError( bool bIgnoreCurrentError, css::uno: ChangeMarkedWord(sReplacement, LanguageTag::convertToLanguageType( pSpellErrorDescription->aLocale )); - aCursor.GetIndex() = aCursor.GetIndex() + (sal_uInt16)(xEntry->getReplacementText().getLength()); + aCursor.GetIndex() += xEntry->getReplacementText().getLength(); // maybe the error found here is already added to the dictionary and has to be ignored } else if(pSpellErrorDescription && !bGrammarError && xSpell->isValid( GetErrorText(), LanguageTag::convertToLanguageType( pSpellErrorDescription->aLocale ), Sequence< PropertyValue >() )) { - aCursor.GetIndex() = aCursor.GetIndex() + 1; + ++aCursor.GetIndex(); } else break; @@ -1853,7 +1853,7 @@ svx::SpellPortions SentenceEditWindow_Impl::CreateSpellPortions( bool bSetIgnore pLastError = pError; } - aCursor.GetIndex()++; + ++aCursor.GetIndex(); } if(nTextLen && aBreakPositions.empty()) 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 ); |