diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-14 14:27:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-15 14:33:57 +0200 |
commit | f13c6ad5f020a196a0e3aa6f28bda3dc185d465b (patch) | |
tree | f9aaab122974d36c134fb1723ec3c1c8df51eeef /sw | |
parent | 9270f74466d0eb841babaa24997f608631c70341 (diff) |
new loplugin:bufferadd
look for OUStringBuffer append sequences that can be turned
into creating an OUString with + operations
Change-Id: Ica840dc096000307b4a105fb4d9ec7588a15ade6
Reviewed-on: https://gerrit.libreoffice.org/80809
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/core/macros-test.cxx | 5 | ||||
-rw-r--r-- | sw/qa/core/uwriter.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/crsr/bookmrk.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 13 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 5 |
9 files changed, 24 insertions, 33 deletions
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index ec7f76af8a5b..01b317cb12c2 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -113,9 +113,8 @@ void SwMacrosTest::testVba() OUString aFileName; createFileURL(testInfo[i].sFileBaseName, "doc", aFileName); uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.text.TextDocument"); - OUStringBuffer sMsg( "Failed to load " ); - sMsg.append ( aFileName ); - CPPUNIT_ASSERT_MESSAGE( OUStringToOString( sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() ); + OUString sMsg = "Failed to load " + aFileName; + CPPUNIT_ASSERT_MESSAGE( OUStringToOString( sMsg, RTL_TEXTENCODING_UTF8 ).getStr(), xComponent.is() ); OUString sUrl = testInfo[i].sMacroUrl; Any aRet; diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index d8d351089a9c..64ad23f53001 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -522,11 +522,10 @@ void SwDocTest::testModelToViewHelperHideInvisibleHideRedlined() ModelToViewHelper aModelToViewHelper(*pTextNode, nullptr, ExpandMode::HideInvisible | ExpandMode::HideDeletions); OUString sViewText = aModelToViewHelper.getViewText(); - OUStringBuffer aBuffer; - aBuffer.append("AAAACCCCC "); - aBuffer.append(CH_TXTATR_BREAKWORD); - aBuffer.append(" DDDDD"); - CPPUNIT_ASSERT_EQUAL(aBuffer.makeStringAndClear(), sViewText); + OUString aBuffer = "AAAACCCCC " + + OUStringLiteral1(CH_TXTATR_BREAKWORD) + + " DDDDD"; + CPPUNIT_ASSERT_EQUAL(aBuffer, sViewText); } void SwDocTest::testModelToViewHelperExpandFieldsHideInvisibleHideRedlinedExpandFootnote() diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index ae735607f631..118942ce87f1 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -215,7 +215,6 @@ namespace sw { namespace mark { static OUString sUniquePostfix; static sal_Int32 nCount = SAL_MAX_INT32; - OUStringBuffer aResult(rPrefix); if(nCount == SAL_MAX_INT32) { unsigned int const n(comphelper::rng::uniform_uint_distribution(0, @@ -224,7 +223,7 @@ namespace sw { namespace mark nCount = 0; } // putting the counter in front of the random parts will speed up string comparisons - return aResult.append(nCount++).append(sUniquePostfix).makeStringAndClear(); + return rPrefix + OUString::number(nCount++) + sUniquePostfix; } } diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 880943fd6560..e385f5445abd 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1482,7 +1482,6 @@ namespace sw { namespace mark { return rName; } - OUStringBuffer sBuf; OUString sTmp; // try the name "<rName>XXX" (where XXX is a number starting from 1) unless there is @@ -1494,7 +1493,7 @@ namespace sw { namespace mark if(aIter != m_aMarkBasenameMapUniqueOffset.end()) nCnt = aIter->second; while(nCnt < SAL_MAX_INT32) { - sTmp = sBuf.append(rName).append(nCnt).makeStringAndClear(); + sTmp = rName + OUString::number(nCnt); nCnt++; if (lcl_FindMarkByName(sTmp, m_vAllMarks.begin(), m_vAllMarks.end()) == m_vAllMarks.end()) { diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index c2dbad75a1d9..d638abac1052 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2013,9 +2013,8 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken ) } else { - OUStringBuffer aComment; - aComment.append('<').append(aToken).append('>'); - InsertComment( aComment.makeStringAndClear() ); + OUString aComment = "<" + aToken + ">"; + InsertComment( aComment ); } } break; diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 196970c2b4da..e7468c1c8d6d 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -5422,11 +5422,10 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S m_pSerializer->startElementNS(XML_w, XML_object); } - OStringBuffer sShapeStyle, sShapeId; - sShapeStyle.append( "width:" ).append( double( rSize.Width() ) / 20 ) - .append( "pt;height:" ).append( double( rSize.Height() ) / 20 ) - .append( "pt" ); //from VMLExport::AddRectangleDimensions(), it does: value/20 - sShapeId.append( "ole_" ).append( sId ); + OString sShapeStyle = "width:" + OString::number( double( rSize.Width() ) / 20 ) + + "pt;height:" + OString::number( double( rSize.Height() ) / 20 ) + + "pt"; //from VMLExport::AddRectangleDimensions(), it does: value/20 + OString sShapeId = "ole_" + sId; // shape definition m_pSerializer->startElementNS( XML_v, XML_shape, diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 6651124711dc..1ff5f4bb25e6 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -992,13 +992,12 @@ void DocxExport::WriteSettings() SwDBData aData = m_pDoc->GetDBData(); if ( !aData.sDataSource.isEmpty() && aData.nCommandType == css::sdb::CommandType::TABLE && !aData.sCommand.isEmpty() ) { - OUStringBuffer aDataSource; - aDataSource.append("SELECT * FROM "); - aDataSource.append(aData.sDataSource); // current database - aDataSource.append(".dbo."); // default database owner - aDataSource.append(aData.sCommand); // sheet name - aDataSource.append("$"); // sheet identifier - const OUString sDataSource = aDataSource.makeStringAndClear(); + OUString sDataSource = + "SELECT * FROM " + + aData.sDataSource + // current database + ".dbo." + // default database owner + aData.sCommand + // sheet name + "$"; // sheet identifier pFS->startElementNS( XML_w, XML_mailMerge ); pFS->singleElementNS(XML_w, XML_mainDocumentType, FSNS( XML_w, XML_val ), "formLetters" ); diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 7932a848cc4a..f3d1fb00997e 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -3049,10 +3049,9 @@ void SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrUnoObj& rFo tools::SvRef<SotStorage> xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage(SL::aObjectPool); //Create a destination storage for the microsoft control - OUStringBuffer sStorageName; sal_uInt32 nObjId = ++mnObjectId; - sStorageName.append('_').append( static_cast<sal_Int64>( nObjId )); - tools::SvRef<SotStorage> xOleStg = xObjPool->OpenSotStorage(sStorageName.makeStringAndClear()); + OUString sStorageName = "_" + OUString::number( static_cast<sal_Int64>( nObjId )); + tools::SvRef<SotStorage> xOleStg = xObjPool->OpenSotStorage(sStorageName); if (!xOleStg.is()) return; diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 5c4bb4411092..58bba479a432 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -678,9 +678,8 @@ void SwDBManager::ImportDBEntry(SwWrtShell* pSh) else { // column not found -> show error - OUStringBuffer sInsert; - sInsert.append('?').append(sColumn).append('?'); - pSh->Insert(sInsert.makeStringAndClear()); + OUString sInsert = "?" + sColumn + "?"; + pSh->Insert(sInsert); } sColumn = lcl_FindColumn(sFormatStr, nUsedPos, nSeparator); } |