diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-01-12 20:29:41 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2014-01-13 22:04:20 +0200 |
commit | 37e948595e95500e3bd1cc5ce7b10767047f61e4 (patch) | |
tree | f6c598bb64eb628aeafc752de9872a0f6e0bf4c9 | |
parent | 04bc25a1e6eeb8b943d34a6e01b555f21e77d131 (diff) |
longparas: drop STRING_MAXLEN limit in TextEngine
Change-Id: Ib0f72e1fc0938ca286d0131b7bb1a00499ada7d4
-rw-r--r-- | vcl/source/edit/texteng.cxx | 153 |
1 files changed, 75 insertions, 78 deletions
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 2a4a9fca390d..c2eac5348c3e 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -676,99 +676,96 @@ TextPaM TextEngine::ImpInsertText( sal_Unicode c, const TextSelection& rCurSel, TextPaM aPaM( rCurSel.GetStart() ); TextNode* pNode = mpDoc->GetNodes().GetObject( aPaM.GetPara() ); - if ( pNode->GetText().getLength() < STRING_MAXLEN ) - { - bool bDoOverwrite = ( bOverwrite && - ( aPaM.GetIndex() < pNode->GetText().getLength() ) ); + bool bDoOverwrite = ( bOverwrite && + ( aPaM.GetIndex() < pNode->GetText().getLength() ) ); - bool bUndoAction = ( rCurSel.HasRange() || bDoOverwrite ); + bool bUndoAction = ( rCurSel.HasRange() || bDoOverwrite ); - if ( bUndoAction ) - UndoActionStart(); + if ( bUndoAction ) + UndoActionStart(); - if ( rCurSel.HasRange() ) - { - aPaM = ImpDeleteText( rCurSel ); - } - else if ( bDoOverwrite ) - { - // if selection, then don't overwrite a character - TextSelection aTmpSel( aPaM ); - aTmpSel.GetEnd().GetIndex()++; - ImpDeleteText( aTmpSel ); - } + if ( rCurSel.HasRange() ) + { + aPaM = ImpDeleteText( rCurSel ); + } + else if ( bDoOverwrite ) + { + // if selection, then don't overwrite a character + TextSelection aTmpSel( aPaM ); + aTmpSel.GetEnd().GetIndex()++; + ImpDeleteText( aTmpSel ); + } - if (bIsUserInput && IsInputSequenceCheckingRequired( c, rCurSel )) + if (bIsUserInput && IsInputSequenceCheckingRequired( c, rCurSel )) + { + uno::Reference < i18n::XExtendedInputSequenceChecker > xISC = GetInputSequenceChecker(); + SvtCTLOptions aCTLOptions; + + if (xISC.is()) { - uno::Reference < i18n::XExtendedInputSequenceChecker > xISC = GetInputSequenceChecker(); - SvtCTLOptions aCTLOptions; + xub_StrLen nTmpPos = aPaM.GetIndex(); + sal_Int16 nCheckMode = aCTLOptions.IsCTLSequenceCheckingRestricted() ? + i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC; - if (xISC.is()) + // the text that needs to be checked is only the one + // before the current cursor position + OUString aOldText( mpDoc->GetText( aPaM.GetPara() ).copy(0, nTmpPos) ); + OUString aNewText( aOldText ); + if (aCTLOptions.IsCTLSequenceCheckingTypeAndReplace()) { - xub_StrLen nTmpPos = aPaM.GetIndex(); - sal_Int16 nCheckMode = aCTLOptions.IsCTLSequenceCheckingRestricted() ? - i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC; - - // the text that needs to be checked is only the one - // before the current cursor position - OUString aOldText( mpDoc->GetText( aPaM.GetPara() ).copy(0, nTmpPos) ); - OUString aNewText( aOldText ); - if (aCTLOptions.IsCTLSequenceCheckingTypeAndReplace()) - { - xISC->correctInputSequence( aNewText, nTmpPos - 1, c, nCheckMode ); - - // find position of first character that has changed - sal_Int32 nOldLen = aOldText.getLength(); - sal_Int32 nNewLen = aNewText.getLength(); - const sal_Unicode *pOldTxt = aOldText.getStr(); - const sal_Unicode *pNewTxt = aNewText.getStr(); - sal_Int32 nChgPos = 0; - while ( nChgPos < nOldLen && nChgPos < nNewLen && - pOldTxt[nChgPos] == pNewTxt[nChgPos] ) - ++nChgPos; - - 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 ); - - if (!aChgText.isEmpty()) - // ImpInsertText implicitly handles undo... - return ImpInsertText( aSel, aChgText ); - else - return aPaM; - } + xISC->correctInputSequence( aNewText, nTmpPos - 1, c, nCheckMode ); + + // find position of first character that has changed + sal_Int32 nOldLen = aOldText.getLength(); + sal_Int32 nNewLen = aNewText.getLength(); + const sal_Unicode *pOldTxt = aOldText.getStr(); + const sal_Unicode *pNewTxt = aNewText.getStr(); + sal_Int32 nChgPos = 0; + while ( nChgPos < nOldLen && nChgPos < nNewLen && + pOldTxt[nChgPos] == pNewTxt[nChgPos] ) + ++nChgPos; + + 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 ); + + if (!aChgText.isEmpty()) + // ImpInsertText implicitly handles undo... + return ImpInsertText( aSel, aChgText ); else - { - // should the character be ignored (i.e. not get inserted) ? - if (!xISC->checkInputSequence( aOldText, nTmpPos - 1, c, nCheckMode )) - return aPaM; // nothing to be done -> no need for undo - } + return aPaM; + } + else + { + // should the character be ignored (i.e. not get inserted) ? + if (!xISC->checkInputSequence( aOldText, nTmpPos - 1, c, nCheckMode )) + return aPaM; // nothing to be done -> no need for undo } - - // at this point now we will insert the character 'normally' some lines below... } + // at this point now we will insert the character 'normally' some lines below... + } - if ( IsUndoEnabled() && !IsInUndo() ) - { - TextUndoInsertChars* pNewUndo = new TextUndoInsertChars( this, aPaM, OUString(c) ); - sal_Bool bTryMerge = ( !bDoOverwrite && ( c != ' ' ) ) ? sal_True : sal_False; - InsertUndo( pNewUndo, bTryMerge ); - } - TEParaPortion* pPortion = mpTEParaPortions->GetObject( aPaM.GetPara() ); - pPortion->MarkInvalid( aPaM.GetIndex(), 1 ); - if ( c == '\t' ) - pPortion->SetNotSimpleInvalid(); - aPaM = mpDoc->InsertText( aPaM, c ); - ImpCharsInserted( aPaM.GetPara(), aPaM.GetIndex()-1, 1 ); + if ( IsUndoEnabled() && !IsInUndo() ) + { + TextUndoInsertChars* pNewUndo = new TextUndoInsertChars( this, aPaM, OUString(c) ); + sal_Bool bTryMerge = ( !bDoOverwrite && ( c != ' ' ) ) ? sal_True : sal_False; + InsertUndo( pNewUndo, bTryMerge ); + } - TextModified(); + TEParaPortion* pPortion = mpTEParaPortions->GetObject( aPaM.GetPara() ); + pPortion->MarkInvalid( aPaM.GetIndex(), 1 ); + if ( c == '\t' ) + pPortion->SetNotSimpleInvalid(); + aPaM = mpDoc->InsertText( aPaM, c ); + ImpCharsInserted( aPaM.GetPara(), aPaM.GetIndex()-1, 1 ); - if ( bUndoAction ) - UndoActionEnd(); - } + TextModified(); + + if ( bUndoAction ) + UndoActionEnd(); return aPaM; } |