diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-28 11:30:23 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-28 17:23:19 +0200 |
commit | 8d344ea12cfe50dd0c3ccc24252acee3290903e7 (patch) | |
tree | c88ff9995f05d7cd66feea4b3ee003a5cb6386f0 /editeng | |
parent | 4d20ec5ad75e8268cbc753f5bf86e3ef7c0be557 (diff) |
loplugin:stringloop in editeng
Change-Id: Ie0bff59cbb3ef4e79b1923ddebec979a135dd000
Reviewed-on: https://gerrit.libreoffice.org/58213
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/accessibility/AccessibleStaticTextBase.cxx | 22 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 12 | ||||
-rw-r--r-- | editeng/source/editeng/impedit2.cxx | 8 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 6 | ||||
-rw-r--r-- | editeng/source/items/numitem.cxx | 31 | ||||
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 12 | ||||
-rw-r--r-- | editeng/source/outliner/outliner.cxx | 8 |
7 files changed, 49 insertions, 50 deletions
diff --git a/editeng/source/accessibility/AccessibleStaticTextBase.cxx b/editeng/source/accessibility/AccessibleStaticTextBase.cxx index f44d1482bb6d..6dac619d4e49 100644 --- a/editeng/source/accessibility/AccessibleStaticTextBase.cxx +++ b/editeng/source/accessibility/AccessibleStaticTextBase.cxx @@ -655,11 +655,11 @@ namespace accessibility SolarMutexGuard aGuard; sal_Int32 i, nParas; - OUString aRes; + OUStringBuffer aRes; for( i=0, nParas=mpImpl->GetParagraphCount(); i<nParas; ++i ) - aRes += mpImpl->GetParagraph(i).getText(); + aRes.append(mpImpl->GetParagraph(i).getText()); - return aRes; + return aRes.makeStringAndClear(); } OUString SAL_CALL AccessibleStaticTextBase::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) @@ -697,7 +697,7 @@ namespace accessibility { nEndIndex++; } - OUString aRes; + OUStringBuffer aRes; EPosition aStartIndex( mpImpl->Range2Internal(nStartIndex) ); EPosition aEndIndex( mpImpl->Range2Internal(nEndIndex) ); @@ -717,8 +717,8 @@ namespace accessibility // paragraphs inbetween are fully included for( ; i<aEndIndex.nPara; ++i ) { - aRes += OUStringLiteral1(cNewLine); - aRes += mpImpl->GetParagraph(i).getText(); + aRes.append(cNewLine); + aRes.append(mpImpl->GetParagraph(i).getText()); } if( i<=aEndIndex.nPara ) @@ -727,22 +727,22 @@ namespace accessibility //we need to add a "\n" before we add the last part of the string. if ( !bEnd && aEndIndex.nIndex ) { - aRes += OUStringLiteral1(cNewLine); + aRes.append(cNewLine); } - aRes += mpImpl->GetParagraph(i).getTextRange( 0, aEndIndex.nIndex ); + aRes.append(mpImpl->GetParagraph(i).getTextRange( 0, aEndIndex.nIndex )); } } //According to the flag we marked before, we have to add "\n" at the beginning //or at the end of the result string. if ( bStart ) { - aRes = OUStringLiteral1(cNewLine) + aRes; + aRes.insert(0, OUStringLiteral1(cNewLine)); } if ( bEnd ) { - aRes += OUStringLiteral1(cNewLine); + aRes.append(OUStringLiteral1(cNewLine)); } - return aRes; + return aRes.makeStringAndClear(); } css::accessibility::TextSegment SAL_CALL AccessibleStaticTextBase::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 40f4a8619cfd..9c70eff997ec 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -1633,7 +1633,7 @@ OUString ContentNode::GetExpandedText(sal_Int32 nStartPos, sal_Int32 nEndPos) co DBG_ASSERT( nStartPos <= nEndPos, "Start and End reversed?" ); sal_Int32 nIndex = nStartPos; - OUString aStr; + OUStringBuffer aStr; const EditCharAttrib* pNextFeature = GetCharAttribs().FindFeature( nIndex ); while ( nIndex < nEndPos ) { @@ -1646,18 +1646,18 @@ OUString ContentNode::GetExpandedText(sal_Int32 nStartPos, sal_Int32 nEndPos) co DBG_ASSERT( nEnd >= nIndex, "End in front of the index?" ); //!! beware of sub string length of -1 if (nEnd > nIndex) - aStr += GetString().copy(nIndex, nEnd - nIndex); + aStr.append( GetString().copy(nIndex, nEnd - nIndex) ); if ( pNextFeature ) { switch ( pNextFeature->GetItem()->Which() ) { - case EE_FEATURE_TAB: aStr += "\t"; + case EE_FEATURE_TAB: aStr.append( "\t" ); break; - case EE_FEATURE_LINEBR: aStr += "\x0A"; + case EE_FEATURE_LINEBR: aStr.append( "\x0A" ); break; case EE_FEATURE_FIELD: - aStr += static_cast<const EditCharAttribField*>(pNextFeature)->GetFieldValue(); + aStr.append( static_cast<const EditCharAttribField*>(pNextFeature)->GetFieldValue() ); break; default: OSL_FAIL( "What feature?" ); } @@ -1665,7 +1665,7 @@ OUString ContentNode::GetExpandedText(sal_Int32 nStartPos, sal_Int32 nEndPos) co } nIndex = nEnd; } - return aStr; + return aStr.makeStringAndClear(); } void ContentNode::UnExpandPosition( sal_Int32 &rPos, bool bBiasStart ) diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index bd641ce70b7b..af0565f76df5 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -286,7 +286,7 @@ OUString ImpEditEngine::GetSelected( const EditSelection& rSel ) const OSL_ENSURE( nStartNode <= nEndNode, "Selection not sorted ?" ); - OUString aText; + OUStringBuffer aText; const OUString aSep = EditDoc::GetSepStr( LINEEND_LF ); // iterate over the paragraphs ... @@ -298,11 +298,11 @@ OUString ImpEditEngine::GetSelected( const EditSelection& rSel ) const const sal_Int32 nStartPos = nNode==nStartNode ? aSel.Min().GetIndex() : 0; const sal_Int32 nEndPos = nNode==nEndNode ? aSel.Max().GetIndex() : pNode->Len(); // can also be == nStart! - aText += EditDoc::GetParaAsString( pNode, nStartPos, nEndPos ); + aText.append(EditDoc::GetParaAsString( pNode, nStartPos, nEndPos )); if ( nNode < nEndNode ) - aText += aSep; + aText.append(aSep); } - return aText; + return aText.makeStringAndClear(); } bool ImpEditEngine::MouseButtonDown( const MouseEvent& rMEvt, EditView* pView ) diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index a19876928bb4..e619351963f9 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -1810,7 +1810,6 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView ) EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() ); aCurSel.Min() = aCurSel.Max(); - OUString aWord; Reference< XSpellAlternatives > xSpellAlt; Sequence< PropertyValue > aEmptySeq; while (!xSpellAlt.is()) @@ -1834,7 +1833,7 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpSpell( EditView* pEditView ) } aCurSel = SelectWord( aCurSel, css::i18n::WordType::DICTIONARY_WORD ); - aWord = GetSelected( aCurSel ); + OUString aWord = GetSelected( aCurSel ); // If afterwards a dot, this must be handed over! // If an abbreviation ... @@ -1872,7 +1871,6 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpFindNextError(EditSelection& r { EditSelection aCurSel( rSelection.Min() ); - OUString aWord; Reference< XSpellAlternatives > xSpellAlt; Sequence< PropertyValue > aEmptySeq; while (!xSpellAlt.is()) @@ -1885,7 +1883,7 @@ Reference< XSpellAlternatives > ImpEditEngine::ImpFindNextError(EditSelection& r } aCurSel = SelectWord( aCurSel, css::i18n::WordType::DICTIONARY_WORD ); - aWord = GetSelected( aCurSel ); + OUString aWord = GetSelected( aCurSel ); // If afterwards a dot, this must be handed over! // If an abbreviation ... diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index 1efd88c84026..8e483d66ca51 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -501,7 +501,7 @@ OUString SvxNumberFormat::CreateRomanString( sal_uLong nNo, bool bUpper ) ? "MDCLXVI--" // +2 Dummy entries! : "mdclxvi--"; // +2 Dummy entries! - OUString sRet; + OUStringBuffer sRet; sal_uInt16 nMask = 1000; while( nMask ) { @@ -512,30 +512,30 @@ OUString SvxNumberFormat::CreateRomanString( sal_uLong nNo, bool bUpper ) if( 5 < nNumber ) { if( nNumber < 9 ) - sRet += OUString(*(cRomanArr-1)); + sRet.append(*(cRomanArr-1)); ++nDiff; nNumber -= 5; } switch( nNumber ) { - case 3: { sRet += OUString(*cRomanArr); SAL_FALLTHROUGH; } - case 2: { sRet += OUString(*cRomanArr); SAL_FALLTHROUGH; } - case 1: { sRet += OUString(*cRomanArr); } + case 3: { sRet.append(*cRomanArr); SAL_FALLTHROUGH; } + case 2: { sRet.append(*cRomanArr); SAL_FALLTHROUGH; } + case 1: { sRet.append(*cRomanArr); } break; case 4: { - sRet += OUString(*cRomanArr); - sRet += OUString(*(cRomanArr-nDiff)); + sRet.append(*cRomanArr); + sRet.append(*(cRomanArr-nDiff)); } break; - case 5: { sRet += OUString(*(cRomanArr-nDiff)); } + case 5: { sRet.append(*(cRomanArr-nDiff)); } break; } nMask /= 10; // for the next decade cRomanArr += 2; } - return sRet; + return sRet.makeStringAndClear(); } OUString SvxNumberFormat::GetCharFormatName()const @@ -812,10 +812,11 @@ void SvxNumRule::SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt) OUString SvxNumRule::MakeNumString( const SvxNodeNum& rNum ) const { - OUString aStr; + OUStringBuffer aStr; if( SVX_NO_NUM > rNum.GetLevel() && !( SVX_NO_NUMLEVEL & rNum.GetLevel() ) ) { const SvxNumberFormat& rMyNFmt = GetLevel( rNum.GetLevel() ); + aStr.append(rMyNFmt.GetPrefix()); if( SVX_NUM_NUMBER_NONE != rMyNFmt.GetNumberingType() ) { sal_uInt8 i = rNum.GetLevel(); @@ -847,21 +848,21 @@ OUString SvxNumRule::MakeNumString( const SvxNodeNum& rNum ) const if(SVX_NUM_BITMAP != rNFmt.GetNumberingType()) { const LanguageTag& rLang = Application::GetSettings().GetLanguageTag(); - aStr += rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], rLang.getLocale() ); + aStr.append(rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], rLang.getLocale() )); } else bDot = false; } else - aStr += "0"; // all 0-levels are a 0 + aStr.append("0"); // all 0-levels are a 0 if( i != rNum.GetLevel() && bDot) - aStr += "."; + aStr.append("."); } } - aStr = rMyNFmt.GetPrefix() + aStr + rMyNFmt.GetSuffix(); + aStr.append(rMyNFmt.GetSuffix()); } - return aStr; + return aStr.makeStringAndClear(); } // changes linked to embedded bitmaps diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index b890b5cd0984..cf56f2a4552f 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1110,9 +1110,9 @@ bool SvxAutoCorrect::FnCorrectCapsLock( SvxAutoCorrDoc& rDoc, const OUString& rT if ( !IsUpperLetter(rCC.getCharacterType(rTxt, nSttPos+1)) ) return false; - OUString aConverted; - aConverted += rCC.uppercase(OUString(rTxt[nSttPos])); - aConverted += rCC.lowercase(OUString(rTxt[nSttPos+1])); + OUStringBuffer aConverted; + aConverted.append( rCC.uppercase(OUString(rTxt[nSttPos])) ); + aConverted.append( rCC.lowercase(OUString(rTxt[nSttPos+1])) ); for( sal_Int32 i = nSttPos+2; i < nEndPos; ++i ) { @@ -1122,15 +1122,15 @@ bool SvxAutoCorrect::FnCorrectCapsLock( SvxAutoCorrDoc& rDoc, const OUString& rT if ( IsUpperLetter(rCC.getCharacterType(rTxt, i)) ) // Another uppercase letter. Convert it. - aConverted += rCC.lowercase(OUString(rTxt[i])); + aConverted.append( rCC.lowercase(OUString(rTxt[i])) ); else // This is not an alphabetic letter. Leave it as-is. - aConverted += OUStringLiteral1( rTxt[i] ); + aConverted.append( rTxt[i] ); } // Replace the word. rDoc.Delete(nSttPos, nEndPos); - rDoc.Insert(nSttPos, aConverted); + rDoc.Insert(nSttPos, aConverted.makeStringAndClear()); return true; } diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 294f000d3796..374fa86025f9 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -1638,15 +1638,15 @@ EBulletInfo Outliner::GetBulletInfo( sal_Int32 nPara ) OUString Outliner::GetText( Paragraph const * pParagraph, sal_Int32 nCount ) const { - OUString aText; + OUStringBuffer aText; sal_Int32 nStartPara = pParaList->GetAbsPos( pParagraph ); for ( sal_Int32 n = 0; n < nCount; n++ ) { - aText += pEditEngine->GetText( nStartPara + n ); + aText.append(pEditEngine->GetText( nStartPara + n )); if ( (n+1) < nCount ) - aText += "\n"; + aText.append("\n"); } - return aText; + return aText.makeStringAndClear(); } void Outliner::Remove( Paragraph const * pPara, sal_Int32 nParaCount ) |