diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-30 15:24:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-30 18:54:15 +0200 |
commit | 4bef6511332073fbe3899fa2003caf88d9f2ac49 (patch) | |
tree | dca0d58c3fc86d6c88abc2a72fd91f149a917058 /sw/source/uibase | |
parent | c9dcd0a6197160fdc8bf086ae4d8a78558e7d078 (diff) |
loplugin:stringloop in sw
Change-Id: Ie316aee8d1e4f772dc25725b46e130c6717458c2
Reviewed-on: https://gerrit.libreoffice.org/58331
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/app/docstyle.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/config/modcfg.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 22 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mailmergehelper.cxx | 9 | ||||
-rw-r--r-- | sw/source/uibase/dbui/mmconfigitem.cxx | 18 | ||||
-rw-r--r-- | sw/source/uibase/envelp/envimg.cxx | 24 | ||||
-rw-r--r-- | sw/source/uibase/envelp/labelcfg.cxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/shells/annotsh.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/shells/drwtxtsh.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/shells/frmsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtundo.cxx | 6 |
12 files changed, 79 insertions, 85 deletions
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index 260ad592eaa8..71c44a770290 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -828,7 +828,7 @@ OUString SwDocStyleSheet::GetDescription(MapUnit eUnit) GetItemSet(); SfxItemIter aIter( *pSet ); - OUString aDesc; + OUStringBuffer aDesc; for (const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem()) { @@ -850,14 +850,14 @@ OUString SwDocStyleSheet::GetDescription(MapUnit eUnit) *pItem, eUnit, aItemPresentation, aIntlWrapper ) ) { if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() ) - aDesc += sPlus; - aDesc += aItemPresentation; + aDesc.append(sPlus); + aDesc.append(aItemPresentation); } } } } } - return aDesc; + return aDesc.makeStringAndClear(); } if ( SfxStyleFamily::Frame == nFamily || SfxStyleFamily::Para == nFamily || SfxStyleFamily::Char == nFamily ) @@ -866,7 +866,7 @@ OUString SwDocStyleSheet::GetDescription(MapUnit eUnit) GetItemSet(); SfxItemIter aIter( *pSet ); - OUString aDesc; + OUStringBuffer aDesc; OUString sPageNum; OUString sModel; OUString sBreak; @@ -989,8 +989,8 @@ OUString SwDocStyleSheet::GetDescription(MapUnit eUnit) if(bIsDefault) { if ( !aDesc.isEmpty() && !aItemPresentation.isEmpty() ) - aDesc += sPlus; - aDesc += aItemPresentation; + aDesc.append(sPlus); + aDesc.append(aItemPresentation); } } } @@ -1001,20 +1001,20 @@ OUString SwDocStyleSheet::GetDescription(MapUnit eUnit) if (!sModel.isEmpty()) { if (!aDesc.isEmpty()) - aDesc += sPlus; - aDesc += SwResId(STR_PAGEBREAK) + sPlus + sModel; + aDesc.append(sPlus); + aDesc.append(SwResId(STR_PAGEBREAK)).append(sPlus).append(sModel); if (sPageNum != "0") { - aDesc += sPlus + SwResId(STR_PAGEOFFSET) + sPageNum; + aDesc.append(sPlus).append(SwResId(STR_PAGEOFFSET)).append(sPageNum); } } else if (!sBreak.isEmpty()) // Break can be valid only when NO Model { if (!aDesc.isEmpty()) - aDesc += sPlus; - aDesc += sBreak; + aDesc.append(sPlus); + aDesc.append(sBreak); } - return aDesc; + return aDesc.makeStringAndClear(); } if( SfxStyleFamily::Pseudo == nFamily ) diff --git a/sw/source/uibase/config/modcfg.cxx b/sw/source/uibase/config/modcfg.cxx index 3a0b41f3a1b9..5f9e44d15475 100644 --- a/sw/source/uibase/config/modcfg.cxx +++ b/sw/source/uibase/config/modcfg.cxx @@ -135,7 +135,7 @@ SwModuleOptions::SwModuleOptions() : OUString SwModuleOptions::ConvertWordDelimiter(const OUString& rDelim, bool bFromUI) { - OUString sReturn; + OUStringBuffer sReturn; const sal_Int32 nDelimLen = rDelim.getLength(); if(bFromUI) { @@ -147,9 +147,9 @@ OUString SwModuleOptions::ConvertWordDelimiter(const OUString& rDelim, bool bFro { switch (rDelim[i++]) { - case 'n': sReturn += "\n"; break; - case 't': sReturn += "\t"; break; - case '\\': sReturn += "\\"; break; + case 'n': sReturn.append("\n"); break; + case 't': sReturn.append("\t"); break; + case '\\': sReturn.append("\\"); break; case 'x': { @@ -175,18 +175,18 @@ OUString SwModuleOptions::ConvertWordDelimiter(const OUString& rDelim, bool bFro nChar += nVal; } if( bValidData ) - sReturn += OUStringLiteral1(nChar); + sReturn.append(nChar); break; } default: // Unknown, so insert backslash - sReturn += "\\"; + sReturn.append("\\"); i--; break; } } else - sReturn += OUStringLiteral1(c); + sReturn.append(c); } } else @@ -197,23 +197,23 @@ OUString SwModuleOptions::ConvertWordDelimiter(const OUString& rDelim, bool bFro switch (c) { - case '\n': sReturn += "\\n"; break; - case '\t': sReturn += "\\t"; break; - case '\\': sReturn += "\\\\"; break; + case '\n': sReturn.append("\\n"); break; + case '\t': sReturn.append("\\t"); break; + case '\\': sReturn.append("\\\\"); break; default: if( c <= 0x1f || c >= 0x7f ) { - sReturn += "\\x" + OUString::number( c, 16 ); + sReturn.append("\\x").append(OUString::number( c, 16 )); } else { - sReturn += OUStringLiteral1(c); + sReturn.append(c); } } } } - return sReturn; + return sReturn.makeStringAndClear(); } const Sequence<OUString>& SwRevisionConfig::GetPropertyNames() diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 3ce9d2c14156..14ad312e916d 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -609,7 +609,7 @@ void SwDBManager::ImportFromConnection( SwWrtShell* pSh ) static OUString lcl_FindColumn(const OUString& sFormatStr,sal_uInt16 &nUsedPos, sal_uInt8 &nSeparator) { - OUString sReturn; + OUStringBuffer sReturn; sal_uInt16 nLen = sFormatStr.getLength(); nSeparator = 0xff; while(nUsedPos < nLen && nSeparator == 0xff) @@ -630,12 +630,12 @@ static OUString lcl_FindColumn(const OUString& sFormatStr,sal_uInt16 &nUsedPos nSeparator = DB_SEP_NEWLINE; break; default: - sReturn += OUStringLiteral1(cCurrent); + sReturn.append(cCurrent); } nUsedPos++; } - return sReturn; + return sReturn.makeStringAndClear(); } void SwDBManager::ImportDBEntry(SwWrtShell* pSh) @@ -687,7 +687,7 @@ void SwDBManager::ImportDBEntry(SwWrtShell* pSh) } else { - OUString sStr; + OUStringBuffer sStr; uno::Sequence<OUString> aColNames = xCols->getElementNames(); const OUString* pColNames = aColNames.getConstArray(); long nLength = aColNames.getLength(); @@ -697,11 +697,11 @@ void SwDBManager::ImportDBEntry(SwWrtShell* pSh) uno::Reference< beans::XPropertySet > xColumnProp; aCol >>= xColumnProp; SwDBFormatData aDBFormat; - sStr += GetDBField( xColumnProp, aDBFormat); + sStr.append(GetDBField( xColumnProp, aDBFormat)); if (i < nLength - 1) - sStr += "\t"; + sStr.append("\t"); } - pSh->SwEditShell::Insert2(sStr); + pSh->SwEditShell::Insert2(sStr.makeStringAndClear()); pSh->SwFEShell::SplitNode(); // line feed } } @@ -1063,7 +1063,7 @@ static SwMailMessage* lcl_CreateMailFromDoc( pMessage->addRecipient( sMailRecipient ); pMessage->SetSenderAddress( rMergeDescriptor.pMailMergeConfigItem->GetMailAddress() ); - OUString sBody; + OUStringBuffer sBody; if( rMergeDescriptor.bSendAsAttachment ) { sBody = rMergeDescriptor.sMailBody; @@ -1086,13 +1086,13 @@ static SwMailMessage* lcl_CreateMailFromDoc( OString sLine; while ( pInStream->ReadLine( sLine ) ) { - sBody += OStringToOUString( sLine, sMailEncoding ); - sBody += "\n"; + sBody.append(OStringToOUString( sLine, sMailEncoding )); + sBody.append("\n"); } } pMessage->setSubject( rMergeDescriptor.sSubject ); uno::Reference< datatransfer::XTransferable> xBody = - new SwMailTransferable( sBody, sMailBodyMimeType ); + new SwMailTransferable( sBody.makeStringAndClear(), sMailBodyMimeType ); pMessage->setBody( xBody ); for( const OUString& sCcRecipient : rMergeDescriptor.aCopiesTo ) diff --git a/sw/source/uibase/dbui/mailmergehelper.cxx b/sw/source/uibase/dbui/mailmergehelper.cxx index 7345797b1d67..e742e88b8583 100644 --- a/sw/source/uibase/dbui/mailmergehelper.cxx +++ b/sw/source/uibase/dbui/mailmergehelper.cxx @@ -464,7 +464,6 @@ OUString SwAddressPreview::FillData( rConfigItem.GetCurrentDBData() ); const OUString* pAssignment = aAssignment.getConstArray(); const std::vector<std::pair<OUString, int>>& rDefHeaders = rConfigItem.GetDefaultAddressHeaders(); - OUString sAddress(rAddress); OUString sNotAssigned = "<" + SwResId(STR_NOTASSIGNED) + ">"; bool bIncludeCountry = rConfigItem.IsIncludeCountry(); @@ -480,8 +479,8 @@ OUString SwAddressPreview::FillData( sCountryColumn = aSpecialAssignment[MM_PART_COUNTRY]; } - SwAddressIterator aIter(sAddress); - sAddress.clear(); + SwAddressIterator aIter(rAddress); + OUStringBuffer sAddress; while(aIter.HasMore()) { SwMergeAddressItem aItem = aIter.Next(); @@ -540,9 +539,9 @@ OUString SwAddressPreview::FillData( } } - sAddress += aItem.sText; + sAddress.append(aItem.sText); } - return sAddress; + return sAddress.makeStringAndClear(); } SwMergeAddressItem SwAddressIterator::Next() diff --git a/sw/source/uibase/dbui/mmconfigitem.cxx b/sw/source/uibase/dbui/mmconfigitem.cxx index e1a66d04a86e..7c46b9aa45ea 100644 --- a/sw/source/uibase/dbui/mmconfigitem.cxx +++ b/sw/source/uibase/dbui/mmconfigitem.cxx @@ -363,8 +363,7 @@ static OUString lcl_CreateNodeName(Sequence<OUString>& rAssignments ) do { bFound = false; - sNewName = "_"; - sNewName += OUString::number(nStart); + sNewName = "_" + OUString::number(nStart); //search if the name exists for(sal_Int32 nAssign = 0; nAssign < rAssignments.getLength(); ++nAssign) { @@ -400,9 +399,8 @@ static void lcl_ConvertFromNumbers(OUString& rBlock, const std::vector<std::pair { //convert the numbers used for the configuration to strings used for UI to numbers //doesn't use ReplaceAll to prevent expansion of numbers inside of the headers - OUString sBlock(rBlock.replaceAll("\\n", "\n")); - SwAddressIterator aGreetingIter(sBlock); - sBlock.clear(); + SwAddressIterator aGreetingIter(rBlock.replaceAll("\\n", "\n")); + OUStringBuffer sBlock; while(aGreetingIter.HasMore()) { SwMergeAddressItem aNext = aGreetingIter.Next(); @@ -412,11 +410,11 @@ static void lcl_ConvertFromNumbers(OUString& rBlock, const std::vector<std::pair sal_Unicode cChar = aNext.sText[0]; if(cChar >= '0' && cChar <= 'c') { - sBlock += "<"; + sBlock.append("<"); sal_uInt16 nHeader = cChar - '0'; if(nHeader < rHeaders.size()) - sBlock += rHeaders[nHeader].first; - sBlock += ">"; + sBlock.append(rHeaders[nHeader].first); + sBlock.append(">"); } else { @@ -424,9 +422,9 @@ static void lcl_ConvertFromNumbers(OUString& rBlock, const std::vector<std::pair } } else - sBlock += aNext.sText; + sBlock.append(aNext.sText); } - rBlock = sBlock; + rBlock = sBlock.makeStringAndClear(); } const Sequence<OUString>& SwMailMergeConfigItem_Impl::GetPropertyNames() diff --git a/sw/source/uibase/envelp/envimg.cxx b/sw/source/uibase/envelp/envimg.cxx index f3b50063ec75..14bf687ef258 100644 --- a/sw/source/uibase/envelp/envimg.cxx +++ b/sw/source/uibase/envelp/envimg.cxx @@ -53,7 +53,7 @@ OUString MakeSender() if (sSenderToken.isEmpty()) return OUString(); - OUString sRet; + OUStringBuffer sRet; sal_Int32 nSttPos = 0; bool bLastLength = true; do { @@ -61,33 +61,33 @@ OUString MakeSender() if (sToken == "COMPANY") { sal_Int32 nOldLen = sRet.getLength(); - sRet += rUserOpt.GetCompany(); + sRet.append(rUserOpt.GetCompany()); bLastLength = sRet.getLength() != nOldLen; } else if (sToken == "CR") { if(bLastLength) - sRet += NEXTLINE; + sRet.append(NEXTLINE); bLastLength = true; } else if (sToken == "FIRSTNAME") - sRet += rUserOpt.GetFirstName(); + sRet.append(rUserOpt.GetFirstName()); else if (sToken == "LASTNAME") - sRet += rUserOpt.GetLastName(); + sRet.append(rUserOpt.GetLastName()); else if (sToken == "ADDRESS") - sRet += rUserOpt.GetStreet(); + sRet.append(rUserOpt.GetStreet()); else if (sToken == "COUNTRY") - sRet += rUserOpt.GetCountry(); + sRet.append(rUserOpt.GetCountry()); else if (sToken == "POSTALCODE") - sRet += rUserOpt.GetZip(); + sRet.append(rUserOpt.GetZip()); else if (sToken == "CITY") - sRet += rUserOpt.GetCity(); + sRet.append(rUserOpt.GetCity()); else if (sToken == "STATEPROV") - sRet += rUserOpt.GetState(); + sRet.append(rUserOpt.GetState()); else if (!sToken.isEmpty()) //spaces - sRet += sToken; + sRet.append(sToken); } while (nSttPos>=0); - return sRet; + return sRet.makeStringAndClear(); } SwEnvItem::SwEnvItem() : diff --git a/sw/source/uibase/envelp/labelcfg.cxx b/sw/source/uibase/envelp/labelcfg.cxx index 6c6ec6127efc..838789b4b6af 100644 --- a/sw/source/uibase/envelp/labelcfg.cxx +++ b/sw/source/uibase/envelp/labelcfg.cxx @@ -307,8 +307,7 @@ void SwLabelConfig::SaveLabel( const OUString& rManufacturer, sFoundNode += OUString::number( nIndex ); while ( lcl_Exists( sFoundNode, aLabels ) ) { - sFoundNode = sPrefix; - sFoundNode += OUString::number(nIndex++); + sFoundNode = sPrefix + OUString::number(nIndex++); } } else diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 0c8004d58d0c..021d23f62971 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -1631,11 +1631,11 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet) fnGetComment = &SfxUndoManager::GetRedoActionComment; } - OUString sList; + OUStringBuffer sList; if( nCount ) { for( sal_uInt16 n = 0; n < nCount; ++n ) - sList += (pUndoManager->*fnGetComment)( n, SfxUndoManager::TopLevel ) + "\n"; + sList.append( (pUndoManager->*fnGetComment)( n, SfxUndoManager::TopLevel ) ).append("\n"); } SfxStringListItem aItem( nWhich ); @@ -1650,8 +1650,8 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet) rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); } - sList += aItem.GetString(); - aItem.SetString( sList ); + sList.append(aItem.GetString()); + aItem.SetString( sList.makeStringAndClear() ); rSet.Put( aItem ); } else diff --git a/sw/source/uibase/shells/drwtxtsh.cxx b/sw/source/uibase/shells/drwtxtsh.cxx index 017c293cb673..71334558fe68 100644 --- a/sw/source/uibase/shells/drwtxtsh.cxx +++ b/sw/source/uibase/shells/drwtxtsh.cxx @@ -565,12 +565,12 @@ void SwDrawTextShell::StateUndo(SfxItemSet &rSet) } if( nCount ) { - OUString sList; + OUStringBuffer sList; for( sal_uInt16 n = 0; n < nCount; ++n ) - sList += (pUndoManager->*fnGetComment)( n, SfxUndoManager::TopLevel ) + "\n"; + sList.append( (pUndoManager->*fnGetComment)( n, SfxUndoManager::TopLevel ) ).append("\n"); SfxStringListItem aItem( nWhich ); - aItem.SetString( sList ); + aItem.SetString( sList.makeStringAndClear() ); rSet.Put( aItem ); } } diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx index b9c0cdf624fd..c9544baccb5a 100644 --- a/sw/source/uibase/shells/frmsh.cxx +++ b/sw/source/uibase/shells/frmsh.cxx @@ -212,9 +212,7 @@ void SwFrameShell::Execute(SfxRequest &rReq) sal_uInt16 i = 1; while (rSh.FindFlyByName(sName)) { - sName = sOldName; - sName += "_"; - sName += OUString::number(i++); + sName = sOldName + "_" + OUString::number(i++); } rSh.SetFlyName(sName); } diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index e2a33df53430..328f3c209502 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -1071,7 +1071,7 @@ static sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, bool& bException) static OUString lcl_CreateOutlineString( size_t nIndex, const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule) { - OUString sEntry; + OUStringBuffer sEntry; const SwTextNode * pTextNd = rOutlineNodes[ nIndex ]->GetTextNode(); SwNumberTree::tNumberVector aNumVector = pTextNd->GetNumberVector(); if( pOutlRule && pTextNd->GetNumRule()) @@ -1082,12 +1082,12 @@ static OUString lcl_CreateOutlineString( size_t nIndex, long nVal = aNumVector[nLevel]; nVal ++; nVal -= pOutlRule->Get(nLevel).GetStart(); - sEntry += OUString::number( nVal ); - sEntry += "."; + sEntry.append(OUString::number( nVal )); + sEntry.append("."); } - sEntry += rOutlineNodes[ nIndex ]-> - GetTextNode()->GetExpandText(); - return sEntry; + sEntry.append( rOutlineNodes[ nIndex ]-> + GetTextNode()->GetExpandText() ); + return sEntry.makeStringAndClear(); } void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings) diff --git a/sw/source/uibase/wrtsh/wrtundo.cxx b/sw/source/uibase/wrtsh/wrtundo.cxx index 27c7f0e34ed6..2cc9e54ba232 100644 --- a/sw/source/uibase/wrtsh/wrtundo.cxx +++ b/sw/source/uibase/wrtsh/wrtundo.cxx @@ -125,13 +125,13 @@ void SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const default:;//prevent warning } - OUString buf; + OUStringBuffer buf; for (const OUString & comment : comments) { OSL_ENSURE(!comment.isEmpty(), "no Undo/Redo Text set"); - buf += comment + "\n"; + buf.append(comment).append("\n"); } - rStrs.SetString(buf); + rStrs.SetString(buf.makeStringAndClear()); } OUString SwWrtShell::GetRepeatString() const |