From 4bb1b555c533493799d780f18c1ab602677ef88a Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 9 Jun 2013 13:17:42 +0200 Subject: Rework code after OUString'ification Change-Id: Ic93472b0621a13a777d37cfacc4230630f88a6ac Reviewed-on: https://gerrit.libreoffice.org/4214 Reviewed-by: Noel Power Tested-by: Noel Power --- sw/source/ui/docvw/edtwin.cxx | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 60b7c8b27fcc..d72b270603d6 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -861,26 +861,25 @@ void SwEditWin::FlushInBuffer() if (!rSh.GetCrsr()->HasMark()) rSh.GetCrsr()->SetMark(); rSh.GetCrsr()->GetMark()->nContent = 0; - OUString aLeftText( rSh.GetCrsr()->GetTxt() ); + + const OUString aOldText( rSh.GetCrsr()->GetTxt() ); + const sal_Int32 nOldLen = aOldText.getLength(); SvtCTLOptions& rCTLOptions = SW_MOD()->GetCTLOptions(); xub_StrLen nExpandSelection = 0; - if (aLeftText.getLength() > 0) + if (nOldLen > 0) { - sal_Unicode cChar = '\0'; - - sal_Int32 nTmpPos = aLeftText.getLength(); + sal_Int32 nTmpPos = nOldLen; sal_Int16 nCheckMode = rCTLOptions.IsCTLSequenceCheckingRestricted() ? i18n::InputSequenceCheckMode::STRICT : i18n::InputSequenceCheckMode::BASIC; - OUString aOldText( aLeftText ); OUString aNewText( aOldText ); if (rCTLOptions.IsCTLSequenceCheckingTypeAndReplace()) { for (xub_StrLen k = 0; k < m_aInBuffer.Len(); ++k) { - cChar = m_aInBuffer.GetChar(k); + const sal_Unicode cChar = m_aInBuffer.GetChar(k); const sal_Int32 nPrevPos =xISC->correctInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode ); // valid sequence or sequence could be corrected: @@ -889,7 +888,6 @@ void SwEditWin::FlushInBuffer() } // 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(); @@ -898,13 +896,11 @@ void SwEditWin::FlushInBuffer() pOldTxt[nChgPos] == pNewTxt[nChgPos] ) ++nChgPos; - xub_StrLen nChgLen = static_cast< xub_StrLen >(nNewLen - nChgPos); - String aChgText( aNewText.copy( static_cast< xub_StrLen >(nChgPos), nChgLen ) ); - - if (aChgText.Len()) + const sal_Int32 nChgLen = nNewLen - nChgPos; + if (nChgLen) { - m_aInBuffer = aChgText; - nExpandSelection = static_cast< xub_StrLen >(aLeftText.getLength() - nChgPos); + m_aInBuffer = aNewText.copy( nChgPos, nChgLen ); + nExpandSelection = static_cast< xub_StrLen >(nOldLen - nChgPos); } else m_aInBuffer.Erase(); @@ -913,7 +909,7 @@ void SwEditWin::FlushInBuffer() { for (xub_StrLen k = 0; k < m_aInBuffer.Len(); ++k) { - cChar = m_aInBuffer.GetChar(k); + const sal_Unicode cChar = m_aInBuffer.GetChar(k); if (xISC->checkInputSequence( aNewText, nTmpPos - 1, cChar, nCheckMode )) { // character can be inserted: -- cgit