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 | |
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>
126 files changed, 1027 insertions, 861 deletions
diff --git a/basic/qa/cppunit/test_append.cxx b/basic/qa/cppunit/test_append.cxx index 1bda71d37287..242d16fa0b46 100644 --- a/basic/qa/cppunit/test_append.cxx +++ b/basic/qa/cppunit/test_append.cxx @@ -67,15 +67,12 @@ void EnableTest::testDimEnable() void EnableTest::testWin64() { - OUStringBuffer aSource1(" #If Win64\n"); - aSource1.append("Declare PtrSafe Function aht_apiGetOpenFileName Lib "); - aSource1.append('"'); - aSource1.append("comdlg32.dll"); - aSource1.append('"'); - aSource1.append("\n"); - aSource1.append("#End if\n"); + OUString aSource1 = " #If Win64\n" + "Declare PtrSafe Function aht_apiGetOpenFileName Lib \"comdlg32.dll\"" + "\n" + "#End if\n"; - MacroSnippet myMacro(aSource1.toString()); + MacroSnippet myMacro(aSource1); myMacro.Compile(); CPPUNIT_ASSERT_MESSAGE("#if Win64 Declare PtrSafe causes compile error", !myMacro.HasError() ); } diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 0346b9be91f8..03f261a860db 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -567,13 +567,10 @@ OUString ObjectIdentifier::createParticleForAxis( sal_Int32 nDimensionIndex , sal_Int32 nAxisIndex ) { - OUStringBuffer aRet("Axis="); - - aRet.append( OUString::number( nDimensionIndex ) ); - aRet.append(","); - aRet.append( OUString::number( nAxisIndex ) ); - - return aRet.makeStringAndClear(); + return "Axis=" + + OUString::number( nDimensionIndex ) + + "," + + OUString::number( nAxisIndex ); } OUString ObjectIdentifier::createParticleForGrid( diff --git a/compilerplugins/clang/bufferadd.cxx b/compilerplugins/clang/bufferadd.cxx new file mode 100644 index 000000000000..deb97bb35c11 --- /dev/null +++ b/compilerplugins/clang/bufferadd.cxx @@ -0,0 +1,416 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef LO_CLANG_SHARED_PLUGINS + +#include <cassert> +#include <string> +#include <iostream> +#include <unordered_set> + +#include "plugin.hxx" +#include "check.hxx" +#include "clang/AST/CXXInheritance.h" +#include "clang/AST/StmtVisitor.h" + +/** + Look for *StringBuffer append sequences which can be converted to *String + sequences. +*/ + +namespace +{ +class BufferAdd : public loplugin::FilteringPlugin<BufferAdd> +{ +public: + explicit BufferAdd(loplugin::InstantiationData const& data) + : FilteringPlugin(data) + { + } + + bool preRun() override + { + std::string fn(handler.getMainFileName()); + loplugin::normalizeDotDotInFilePath(fn); + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/rtl/oustring/")) + return false; + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/rtl/oustringbuffer/")) + return false; + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/rtl/strings/")) + return false; + if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/OStringBuffer/")) + return false; + // some false + + if (loplugin::isSamePathname(fn, SRCDIR "/unoidl/source/sourcetreeprovider.cxx")) + return false; + if (loplugin::isSamePathname(fn, SRCDIR "/writerfilter/source/dmapper/StyleSheetTable.cxx")) + return false; + if (loplugin::isSamePathname(fn, SRCDIR "/writerfilter/source/dmapper/GraphicImport.cxx")) + return false; + return true; + } + + virtual void run() override + { + if (!preRun()) + return; + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + for (auto const& pair : goodMap) + if (!isa<ParmVarDecl>(pair.first) && + // reference types have slightly weird behaviour + !pair.first->getType()->isReferenceType() + && badMap.find(pair.first) == badMap.end()) + report(DiagnosticsEngine::Warning, + "convert this append sequence into a *String + sequence", + compat::getBeginLoc(pair.first)) + << pair.first->getSourceRange(); + } + + bool VisitStmt(Stmt const*); + bool VisitCallExpr(CallExpr const*); + bool VisitCXXConstructExpr(CXXConstructExpr const*); + bool VisitUnaryOperator(UnaryOperator const*); + +private: + void findBufferAssignOrAdd(const Stmt* parentStmt, Stmt const*); + Expr const* ignore(Expr const*); + bool isSideEffectFree(Expr const*); + bool isMethodOkToMerge(CXXMemberCallExpr const*); + void addToGoodMap(const VarDecl* varDecl, const Stmt* parentStmt); + + std::unordered_map<const VarDecl*, const Stmt*> goodMap; + std::unordered_set<const VarDecl*> badMap; +}; + +bool BufferAdd::VisitStmt(Stmt const* stmt) +{ + if (ignoreLocation(stmt)) + return true; + + if (!isa<CompoundStmt>(stmt) && !isa<CXXCatchStmt>(stmt) && !isa<CXXForRangeStmt>(stmt) + && !isa<CXXTryStmt>(stmt) && !isa<DoStmt>(stmt) && !isa<ForStmt>(stmt) && !isa<IfStmt>(stmt) + && !isa<SwitchStmt>(stmt) && !isa<WhileStmt>(stmt)) + return true; + + for (auto it = stmt->child_begin(); it != stmt->child_end(); ++it) + if (*it) + findBufferAssignOrAdd(stmt, *it); + + return true; +} + +bool BufferAdd::VisitCallExpr(CallExpr const* callExpr) +{ + if (ignoreLocation(callExpr)) + return true; + + for (unsigned i = 0; i != callExpr->getNumArgs(); ++i) + { + auto a = ignore(callExpr->getArg(i)); + if (auto declRefExpr = dyn_cast<DeclRefExpr>(a)) + if (auto varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl())) + badMap.insert(varDecl); + } + return true; +} + +bool BufferAdd::VisitCXXConstructExpr(CXXConstructExpr const* callExpr) +{ + if (ignoreLocation(callExpr)) + return true; + + for (unsigned i = 0; i != callExpr->getNumArgs(); ++i) + { + auto a = ignore(callExpr->getArg(i)); + if (auto declRefExpr = dyn_cast<DeclRefExpr>(a)) + if (auto varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl())) + badMap.insert(varDecl); + } + return true; +} + +bool BufferAdd::VisitUnaryOperator(const UnaryOperator* unaryOp) +{ + if (ignoreLocation(unaryOp)) + return true; + if (unaryOp->getOpcode() != UO_AddrOf) + return true; + auto a = ignore(unaryOp->getSubExpr()); + if (auto declRefExpr = dyn_cast<DeclRefExpr>(a)) + if (auto varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl())) + badMap.insert(varDecl); + return true; +} + +void BufferAdd::findBufferAssignOrAdd(const Stmt* parentStmt, Stmt const* stmt) +{ + if (auto exprCleanup = dyn_cast<ExprWithCleanups>(stmt)) + stmt = exprCleanup->getSubExpr(); + if (auto switchCase = dyn_cast<SwitchCase>(stmt)) + stmt = switchCase->getSubStmt(); + if (auto declStmt = dyn_cast<DeclStmt>(stmt)) + { + if (declStmt->isSingleDecl()) + if (auto varDeclLHS = dyn_cast_or_null<VarDecl>(declStmt->getSingleDecl())) + { + auto tc = loplugin::TypeCheck(varDeclLHS->getType()); + if (!tc.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace() + && !tc.Class("OStringBuffer").Namespace("rtl").GlobalNamespace()) + return; + if (varDeclLHS->getStorageDuration() == SD_Static) + return; + if (!varDeclLHS->hasInit()) + return; + auto cxxConstructExpr = dyn_cast<CXXConstructExpr>(ignore(varDeclLHS->getInit())); + if (cxxConstructExpr) + { + if (cxxConstructExpr->getNumArgs() == 0) + { + addToGoodMap(varDeclLHS, parentStmt); + return; + } + auto tc2 = loplugin::TypeCheck(cxxConstructExpr->getArg(0)->getType()); + if (cxxConstructExpr->getArg(0)->getType()->isBuiltinType() + || tc2.LvalueReference().Class("OUStringBuffer") + || tc2.LvalueReference().Class("OStringBuffer") + || tc2.Class("OUStringBuffer") || tc2.Class("OStringBuffer")) + { + badMap.insert(varDeclLHS); + return; + } + } + if (!isSideEffectFree(varDeclLHS->getInit())) + badMap.insert(varDeclLHS); + else + addToGoodMap(varDeclLHS, parentStmt); + } + return; + } + + // check for single calls to buffer method + + if (auto memberCallExpr = dyn_cast<CXXMemberCallExpr>(stmt)) + { + if (auto declRefExprLHS + = dyn_cast<DeclRefExpr>(ignore(memberCallExpr->getImplicitObjectArgument()))) + { + auto methodDecl = memberCallExpr->getMethodDecl(); + if (methodDecl && methodDecl->getIdentifier()) + if (auto varDeclLHS = dyn_cast<VarDecl>(declRefExprLHS->getDecl())) + { + auto tc = loplugin::TypeCheck(varDeclLHS->getType()); + if (tc.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace() + || tc.Class("OStringBuffer").Namespace("rtl").GlobalNamespace()) + { + if (isMethodOkToMerge(memberCallExpr)) + addToGoodMap(varDeclLHS, parentStmt); + else + badMap.insert(varDeclLHS); + } + } + return; + } + } + + // now check for chained append calls + + auto expr = dyn_cast<Expr>(stmt); + if (!expr) + return; + auto tc = loplugin::TypeCheck(expr->getType()); + if (!tc.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace() + && !tc.Class("OStringBuffer").Namespace("rtl").GlobalNamespace()) + return; + + // unwrap the chain (which runs from right to left) + const VarDecl* varDeclLHS = nullptr; + bool good = true; + while (true) + { + auto memberCallExpr = dyn_cast<CXXMemberCallExpr>(expr); + if (!memberCallExpr) + break; + good &= isMethodOkToMerge(memberCallExpr); + + if (auto declRefExprLHS + = dyn_cast<DeclRefExpr>(ignore(memberCallExpr->getImplicitObjectArgument()))) + { + varDeclLHS = dyn_cast<VarDecl>(declRefExprLHS->getDecl()); + break; + } + expr = memberCallExpr->getImplicitObjectArgument(); + } + + if (varDeclLHS) + { + if (good) + addToGoodMap(varDeclLHS, parentStmt); + else + badMap.insert(varDeclLHS); + } +} + +void BufferAdd::addToGoodMap(const VarDecl* varDecl, const Stmt* parentStmt) +{ + // check that vars are all inside the same compoundstmt, if they are not, we cannot combine them + auto it = goodMap.find(varDecl); + if (it != goodMap.end()) + { + if (it->second == parentStmt) + return; + // don't treat these as parents, otherwise we eliminate .append.append sequences + if (isa<MemberExpr>(parentStmt)) + return; + if (isa<CXXMemberCallExpr>(parentStmt)) + return; + badMap.insert(varDecl); + } + else + goodMap.emplace(varDecl, parentStmt); +} + +bool BufferAdd::isMethodOkToMerge(CXXMemberCallExpr const* memberCall) +{ + auto methodDecl = memberCall->getMethodDecl(); + if (methodDecl->getNumParams() == 0) + return true; + auto tc2 = loplugin::TypeCheck(methodDecl->getParamDecl(0)->getType()); + if (tc2.LvalueReference().Class("OUStringBuffer") + || tc2.LvalueReference().Class("OStringBuffer")) + return false; + + auto name = methodDecl->getName(); + if (name == "appendUninitialized" || name == "setLength" || name == "remove" || name == "insert" + || name == "appendAscii" || name == "appendUtf32") + return false; + + auto rhs = memberCall->getArg(0); + + if (loplugin::TypeCheck(memberCall->getType()) + .Class("OStringBuffer") + .Namespace("rtl") + .GlobalNamespace()) + { + // because we have no OStringLiteral1 + if (tc2.Char()) + return false; + // Can't see how to make the call to append(sal_Unicode*pStart, sal_Unicode*pEnd) work + if (memberCall->getNumArgs() == 2 && loplugin::TypeCheck(rhs->getType()).Pointer()) + return false; + } + if (loplugin::TypeCheck(memberCall->getType()) + .Class("OUStringBuffer") + .Namespace("rtl") + .GlobalNamespace()) + { + // character literals we do with OUStringBuffer, not variables of type sal_Unicode/char + if (tc2.Typedef("sal_Unicode").GlobalNamespace() && !isa<CharacterLiteral>(rhs)) + return false; + // Can't see how to make the call to append(sal_Unicode*pStart, sal_Unicode*pEnd) work + if (memberCall->getNumArgs() == 2 + && loplugin::TypeCheck(memberCall->getArg(0)->getType()).Pointer()) + return false; + } + if (!isSideEffectFree(rhs)) + return false; + return true; +} + +Expr const* BufferAdd::ignore(Expr const* expr) +{ + return compat::IgnoreImplicit(compat::IgnoreImplicit(expr)->IgnoreParens()); +} + +bool BufferAdd::isSideEffectFree(Expr const* expr) +{ + expr = ignore(expr); + // I don't think the OUStringAppend functionality can handle this efficiently + if (isa<ConditionalOperator>(expr)) + return false; + // Multiple statements have a well defined evaluation order (sequence points between them) + // but a single expression may be evaluated in arbitrary order; + // if there are side effects in one of the sub-expressions that have an effect on another subexpression, + // the result may be incorrect, and you don't necessarily notice in tests because the order is compiler-dependent. + // for example see commit afd743141f7a7dd05914d0872c9afe079f16fe0c where such a refactoring introduced such a bug. + // So only consider simple RHS expressions. + if (!expr->HasSideEffects(compiler.getASTContext())) + return true; + + // check for chained adds which are side-effect free + if (auto operatorCall = dyn_cast<CXXOperatorCallExpr>(expr)) + { + auto op = operatorCall->getOperator(); + if (op == OO_PlusEqual || op == OO_Plus) + if (isSideEffectFree(operatorCall->getArg(0)) + && isSideEffectFree(operatorCall->getArg(1))) + return true; + } + + if (auto callExpr = dyn_cast<CallExpr>(expr)) + { + // check for calls through OUString::number/OUString::unacquired + if (auto calleeMethodDecl = dyn_cast_or_null<CXXMethodDecl>(callExpr->getCalleeDecl())) + if (calleeMethodDecl && calleeMethodDecl->getIdentifier()) + { + auto name = calleeMethodDecl->getName(); + if (name == "number" || name == "unacquired") + { + auto tc = loplugin::TypeCheck(calleeMethodDecl->getParent()); + if (tc.Class("OUString") || tc.Class("OString")) + { + if (isSideEffectFree(callExpr->getArg(0))) + return true; + } + } + } + if (auto calleeFunctionDecl = dyn_cast_or_null<FunctionDecl>(callExpr->getCalleeDecl())) + if (calleeFunctionDecl && calleeFunctionDecl->getIdentifier()) + { + auto name = calleeFunctionDecl->getName(); + // check for calls through OUStringToOString + if (name == "OUStringToOString" || name == "OStringToOUString") + if (isSideEffectFree(callExpr->getArg(0))) + return true; + // whitelist some known-safe methods + if (name.endswith("ResId") || name == "GetXMLToken") + if (isSideEffectFree(callExpr->getArg(0))) + return true; + } + } + + // sometimes we have a constructor call on the RHS + if (auto constructExpr = dyn_cast<CXXConstructExpr>(expr)) + { + auto dc = loplugin::DeclCheck(constructExpr->getConstructor()); + if (dc.MemberFunction().Class("OUString") || dc.MemberFunction().Class("OString") + || dc.MemberFunction().Class("OUStringBuffer") + || dc.MemberFunction().Class("OStringBuffer")) + if (constructExpr->getNumArgs() == 0 || isSideEffectFree(constructExpr->getArg(0))) + return true; + // Expr::HasSideEffects does not like stuff that passes through OUStringLiteral + auto dc2 = loplugin::DeclCheck(constructExpr->getConstructor()->getParent()); + if (dc2.Struct("OUStringLiteral").Namespace("rtl").GlobalNamespace()) + return true; + } + + // when adding literals, we sometimes get this + if (auto functionalCastExpr = dyn_cast<CXXFunctionalCastExpr>(expr)) + { + auto tc = loplugin::TypeCheck(functionalCastExpr->getType()); + if (tc.Struct("OUStringLiteral").Namespace("rtl").GlobalNamespace()) + return isSideEffectFree(functionalCastExpr->getSubExpr()); + } + + return false; +} + +loplugin::Plugin::Registration<BufferAdd> bufferadd("bufferadd"); +} + +#endif // LO_CLANG_SHARED_PLUGINS + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/compilerplugins/clang/test/bufferadd.cxx b/compilerplugins/clang/test/bufferadd.cxx new file mode 100644 index 000000000000..18c6055111a4 --- /dev/null +++ b/compilerplugins/clang/test/bufferadd.cxx @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <rtl/strbuf.hxx> +#include <rtl/string.hxx> +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.hxx> + +// --------------------------------------------------------------- +// replaceing OUStringBuffer.append sequences to OUString+ +namespace test1 +{ +void f1() +{ + // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}} + OUStringBuffer v; + v.append("xxx"); + v.append("xxx"); +} +void f2() +{ + // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}} + OUStringBuffer v; + v.append("xxx").append("aaaa"); +} +} + +namespace test2 +{ +void f2() +{ + // no warning expected + OUStringBuffer v; + v.append("xxx"); + if (true) + v.append("yyyy"); +} +void appendTo(OUStringBuffer&); +void f3() +{ + // no warning expected + OUStringBuffer v; + appendTo(v); + v.append("xxx"); +} +void f4() +{ + // no warning expected + OUStringBuffer v; + v.append("xxx"); + v.setLength(0); +} +void f5() +{ + // no warning expected + OUStringBuffer v; + v.append("xxx"); + v[1] = 'x'; +} +void f6() +{ + // no warning expected + OUStringBuffer noel1("xxx"); + while (true) + noel1.append("ffff").append("aaa"); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx index cf6b500cc567..7ff344650ebc 100644 --- a/configmgr/source/data.cxx +++ b/configmgr/source/data.cxx @@ -154,10 +154,7 @@ OUString Data::fullTemplateName( "bad component/name pair containing colon " + component + "/" + name); } - OUStringBuffer buf(component); - buf.append(':'); - buf.append(name); - return buf.makeStringAndClear(); + return component + ":" + name; } bool Data::equalTemplateNames( diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx index 22fcdaa466e2..af6f49afee17 100644 --- a/connectivity/source/drivers/hsqldb/HConnection.cxx +++ b/connectivity/source/drivers/hsqldb/HConnection.cxx @@ -316,13 +316,11 @@ namespace connectivity { namespace hsqldb xProvider.set( GraphicProvider::create(m_xContext) ); // assemble the image URL - OUStringBuffer aImageURL; + OUString sImageURL = // load the graphic from the global graphic repository - aImageURL.append( "private:graphicrepository/" ); + "private:graphicrepository/" // the relative path within the images.zip - aImageURL.append( LINKED_TEXT_TABLE_IMAGE_RESOURCE ); - // the name of the graphic to use - OUString sImageURL( aImageURL.makeStringAndClear() ); + LINKED_TEXT_TABLE_IMAGE_RESOURCE; // ask the provider to obtain a graphic Sequence< PropertyValue > aMediaProperties( 1 ); diff --git a/connectivity/source/drivers/hsqldb/HView.cxx b/connectivity/source/drivers/hsqldb/HView.cxx index 810acdf08561..0eb3fd9439e4 100644 --- a/connectivity/source/drivers/hsqldb/HView.cxx +++ b/connectivity/source/drivers/hsqldb/HView.cxx @@ -102,18 +102,13 @@ namespace connectivity { namespace hsqldb try { // drop the existing view - OUStringBuffer aCommand; - aCommand.append( "DROP VIEW " ); - aCommand.append ( sQualifiedName ); - xStatement->execute( aCommand.makeStringAndClear() ); + OUString aCommand ="DROP VIEW " + sQualifiedName; + xStatement->execute( aCommand ); bDropSucceeded = true; // create a new one with the same name - aCommand.append( "CREATE VIEW " ); - aCommand.append ( sQualifiedName ); - aCommand.append( " AS " ); - aCommand.append ( _rNewCommand ); - xStatement->execute( aCommand.makeStringAndClear() ); + aCommand = "CREATE VIEW " + sQualifiedName + " AS " + _rNewCommand; + xStatement->execute( aCommand ); } catch( const SQLException& ) { diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx index b5fcd1d0261a..95332e360522 100644 --- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx @@ -280,12 +280,11 @@ void Columns::refresh() { if (isLog(m_pSettings, LogLevel::Info)) { - OStringBuffer buf; - buf.append( "sdbcx.Columns get refreshed for table " ); - buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) ); - buf.append( "." ); - buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) ); - log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() ); + OString buf = "sdbcx.Columns get refreshed for table " + + OUStringToOString( m_schemaName, ConnectionSettings::encoding ) + + "." + + OUStringToOString( m_tableName, ConnectionSettings::encoding ); + log( m_pSettings, LogLevel::Info, buf.getStr() ); } osl::MutexGuard guard( m_xMutex->GetMutex() ); diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx index 5717c03dcd17..a80c3952b255 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx @@ -104,10 +104,9 @@ void IndexColumns::refresh() { if (isLog(m_pSettings, LogLevel::Info)) { - OStringBuffer buf; - buf.append( "sdbcx.IndexColumns get refreshed for index " ); - buf.append( OUStringToOString( m_indexName, ConnectionSettings::encoding ) ); - log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() ); + OString buf = "sdbcx.IndexColumns get refreshed for index " + + OUStringToOString( m_indexName, ConnectionSettings::encoding ); + log( m_pSettings, LogLevel::Info, buf.getStr() ); } osl::MutexGuard guard( m_xMutex->GetMutex() ); diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx index 705ffefa818e..aa8d3036b9a9 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx @@ -96,12 +96,11 @@ void Indexes::refresh() { if (isLog(m_pSettings, LogLevel::Info)) { - OStringBuffer buf; - buf.append( "sdbcx.Indexes get refreshed for table " ); - buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) ); - buf.append( "." ); - buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) ); - log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() ); + OString buf = "sdbcx.Indexes get refreshed for table " + + OUStringToOString( m_schemaName, ConnectionSettings::encoding ) + + "." + + OUStringToOString( m_tableName, ConnectionSettings::encoding ); + log( m_pSettings, LogLevel::Info, buf.getStr() ); } osl::MutexGuard guard( m_xMutex->GetMutex() ); diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx index fdc74afd6e45..39a2c292da33 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx @@ -92,12 +92,11 @@ void KeyColumns::refresh() { if (isLog(m_pSettings, LogLevel::Info)) { - OStringBuffer buf; - buf.append( "sdbcx.KeyColumns get refreshed for table " ); - buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) ); - buf.append( "." ); - buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) ); - log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() ); + OString buf = "sdbcx.KeyColumns get refreshed for table " + + OUStringToOString( m_schemaName, ConnectionSettings::encoding ) + + "." + + OUStringToOString( m_tableName, ConnectionSettings::encoding ); + log( m_pSettings, LogLevel::Info, buf.getStr() ); } osl::MutexGuard guard( m_xMutex->GetMutex() ); diff --git a/cppu/source/cppu/cppu_opt.cxx b/cppu/source/cppu/cppu_opt.cxx index b41ecf821cb7..9ad9fbd98f0f 100644 --- a/cppu/source/cppu/cppu_opt.cxx +++ b/cppu/source/cppu/cppu_opt.cxx @@ -60,13 +60,11 @@ extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg( uno_Any const * pAny, typelib_TypeDescriptionReference * pType ) SAL_THROW_EXTERN_C() { - OUStringBuffer buf; - buf.append( "Cannot extract an Any(" ); - buf.append( OUString::unacquired(&pAny->pType->pTypeName) ); - buf.append( ") to " ); - buf.append( OUString::unacquired(&pType->pTypeName) ); - buf.append( '!' ); - const OUString ret( buf.makeStringAndClear() ); + OUString ret = "Cannot extract an Any(" + + OUString::unacquired(&pAny->pType->pTypeName) + + ") to " + + OUString::unacquired(&pType->pTypeName) + + "!"; rtl_uString_acquire( ret.pData ); return ret.pData; } diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx index d9fe276a6c3b..1604cf7b7997 100644 --- a/cppu/source/typelib/typelib.cxx +++ b/cppu/source/typelib/typelib.cxx @@ -1006,14 +1006,13 @@ extern "C" void SAL_CALL typelib_typedescription_newMIInterface( for (sal_Int32 j = 0; j < pBase->nMembers; ++j) { typelib_TypeDescriptionReference const * pDirectBaseMember = pDirectBase->ppAllMembers[rEntry.directBaseMemberOffset + j]; - OUStringBuffer aBuf(pDirectBaseMember->pTypeName); - aBuf.append(":@"); - aBuf.append(rEntry.directBaseIndex); - aBuf.append(','); - aBuf.append(rEntry.memberOffset + j); - aBuf.append(':'); - aBuf.append(pITD->aBase.pTypeName); - OUString aName(aBuf.makeStringAndClear()); + OUString aName = OUString::unacquired(&pDirectBaseMember->pTypeName) + + ":@" + + OUString::number(rEntry.directBaseIndex) + + "," + + OUString::number(rEntry.memberOffset + j) + + ":" + + OUString::unacquired(&pITD->aBase.pTypeName); typelib_TypeDescriptionReference * pDerivedMember = nullptr; typelib_typedescriptionreference_new( &pDerivedMember, pDirectBaseMember->eTypeClass, diff --git a/cppu/source/uno/loadmodule.cxx b/cppu/source/uno/loadmodule.cxx index b56c03965518..9e970b754536 100644 --- a/cppu/source/uno/loadmodule.cxx +++ b/cppu/source/uno/loadmodule.cxx @@ -32,15 +32,15 @@ namespace cppu { namespace detail { #ifndef DISABLE_DYNLOADING bool loadModule(osl::Module& rModule, OUString const & name) { - OUStringBuffer b; + OUString b = #if defined SAL_DLLPREFIX - b.append(SAL_DLLPREFIX); + SAL_DLLPREFIX + #endif - b.append(name); - b.append(SAL_DLLEXTENSION); + name + + SAL_DLLEXTENSION; return rModule.loadRelative( reinterpret_cast< oslGenericFunction >(&loadModule), - b.makeStringAndClear(), + b, SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY); } diff --git a/cui/source/customize/CustomNotebookbarGenerator.cxx b/cui/source/customize/CustomNotebookbarGenerator.cxx index 9bff37e428d7..a839667e7449 100644 --- a/cui/source/customize/CustomNotebookbarGenerator.cxx +++ b/cui/source/customize/CustomNotebookbarGenerator.cxx @@ -91,9 +91,7 @@ static OUString getAppNameRegistryPath() eApp = vcl::EnumContext::GetApplicationEnum(xModuleManager->identify(xFrame)); OUString sAppName(lcl_getAppName(eApp)); - OUStringBuffer sPath("org.openoffice.Office.UI.ToolbarMode/Applications/"); - sPath.append(sAppName); - return sPath.makeStringAndClear(); + return "org.openoffice.Office.UI.ToolbarMode/Applications/" + sAppName; } static OUString customizedUIPathBuffer() diff --git a/dbaccess/source/core/api/viewcontainer.cxx b/dbaccess/source/core/api/viewcontainer.cxx index ea3b8bef81d6..32fd35a7b704 100644 --- a/dbaccess/source/core/api/viewcontainer.cxx +++ b/dbaccess/source/core/api/viewcontainer.cxx @@ -136,11 +136,7 @@ ObjectType OViewContainer::appendObject( const OUString& _rForName, const Refere OUString sCommand; descriptor->getPropertyValue(PROPERTY_COMMAND) >>= sCommand; - OUStringBuffer aSQL; - aSQL.append( "CREATE VIEW " ); - aSQL.append ( sComposedName ); - aSQL.append( " AS " ); - aSQL.append ( sCommand ); + OUString aSQL = "CREATE VIEW " + sComposedName + " AS " + sCommand; Reference<XConnection> xCon = m_xConnection; OSL_ENSURE(xCon.is(),"Connection is null!"); @@ -148,7 +144,7 @@ ObjectType OViewContainer::appendObject( const OUString& _rForName, const Refere { ::utl::SharedUNOComponent< XStatement > xStmt( xCon->createStatement() ); if ( xStmt.is() ) - xStmt->execute( aSQL.makeStringAndClear() ); + xStmt->execute( aSQL ); } } diff --git a/dbaccess/source/filter/hsqldb/parseschema.cxx b/dbaccess/source/filter/hsqldb/parseschema.cxx index 60e7103cdfa2..d2215e96eb31 100644 --- a/dbaccess/source/filter/hsqldb/parseschema.cxx +++ b/dbaccess/source/filter/hsqldb/parseschema.cxx @@ -91,11 +91,7 @@ public: OUString lcl_createAlterForeign(const OUString& sForeignPart, const OUString& sTableName) { - OUStringBuffer sBuff("ALTER TABLE "); - sBuff.append(sTableName); - sBuff.append(" ADD "); - sBuff.append(sForeignPart); - return sBuff.makeStringAndClear(); + return "ALTER TABLE " + sTableName + " ADD " + sForeignPart; } } // anonymous namespace diff --git a/desktop/source/deployment/misc/dp_identifier.cxx b/desktop/source/deployment/misc/dp_identifier.cxx index 2c429890d0e9..bb90b8bb0d2f 100644 --- a/desktop/source/deployment/misc/dp_identifier.cxx +++ b/desktop/source/deployment/misc/dp_identifier.cxx @@ -50,10 +50,7 @@ OUString getIdentifier( } OUString generateLegacyIdentifier(OUString const & fileName) { - OUStringBuffer b; - b.append("org.openoffice.legacy."); - b.append(fileName); - return b.makeStringAndClear(); + return "org.openoffice.legacy." + fileName; } } diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index d991f9b48071..40d0ee9c8b3c 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -229,9 +229,9 @@ BackendImpl::BackendImpl( } catch (const Exception &e) { - OUStringBuffer aStr( "Exception loading legacy package database: '" ); - aStr.append( e.Message ); - aStr.append( "' - ignoring file, please remove it.\n" ); + OUString aStr = "Exception loading legacy package database: '" + + e.Message + + "' - ignoring file, please remove it.\n"; dp_misc::writeConsole( aStr.getStr() ); } } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 048b358175c4..cd604f939d8b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -5127,10 +5127,10 @@ static void force_c_locale() static void aBasicErrorFunc(const OUString& rError, const OUString& rAction) { - OStringBuffer aBuffer("Unexpected dialog: "); - aBuffer.append(OUStringToOString(rAction, RTL_TEXTENCODING_ASCII_US)); - aBuffer.append(" Error: "); - aBuffer.append(OUStringToOString(rError, RTL_TEXTENCODING_ASCII_US)); + OString aBuffer = "Unexpected dialog: " + + OUStringToOString(rAction, RTL_TEXTENCODING_ASCII_US) + + " Error: " + + OUStringToOString(rError, RTL_TEXTENCODING_ASCII_US); fprintf(stderr, "Unexpected basic error dialog '%s'\n", aBuffer.getStr()); } diff --git a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx index aebf71fc26d1..ff1b9dc6e0bf 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_misc.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_misc.cxx @@ -356,12 +356,9 @@ Reference<XComponentContext> connectToOffice( bool verbose ) { OUString pipeId( ::dp_misc::generateRandomPipeId() ); - OUStringBuffer buf; - buf.append( "--accept=pipe,name=" ); - buf.append( pipeId ); - buf.append( ";urp;" ); + OUString acceptArg = "--accept=pipe,name=" + pipeId + ";urp;"; - Sequence<OUString> args { "--nologo", "--nodefault", buf.makeStringAndClear() }; + Sequence<OUString> args { "--nologo", "--nodefault", acceptArg }; OUString appURL( getExecutableDir() + "/soffice" ); if (verbose) @@ -377,13 +374,10 @@ Reference<XComponentContext> connectToOffice( if (verbose) dp_misc::writeConsole("OK. Connecting..."); - OSL_ASSERT( buf.isEmpty() ); - buf.append( "uno:pipe,name=" ); - buf.append( pipeId ); - buf.append( ";urp;StarOffice.ComponentContext" ); + OUString sUnoUrl = "uno:pipe,name=" + pipeId + ";urp;StarOffice.ComponentContext"; Reference<XComponentContext> xRet( ::dp_misc::resolveUnoURL( - buf.makeStringAndClear(), xLocalComponentContext ), + sUnoUrl, xLocalComponentContext ), UNO_QUERY_THROW ); if (verbose) dp_misc::writeConsole("OK.\n"); diff --git a/extensions/source/logging/loggerconfig.cxx b/extensions/source/logging/loggerconfig.cxx index 9d04e98715bb..f43a3c080858 100644 --- a/extensions/source/logging/loggerconfig.cxx +++ b/extensions/source/logging/loggerconfig.cxx @@ -108,11 +108,7 @@ namespace logging ::sal::static_int_cast< sal_Int16 >( aDateTime.NanoSeconds / 10000000 ) ); OUString sTime = OUString::createFromAscii( buffer ); - OUStringBuffer aBuff; - aBuff.append( sDate ); - aBuff.append( '.' ); - aBuff.append( sTime ); - OUString sDateTime = aBuff.makeStringAndClear(); + OUString sDateTime = sDate + "." + sTime; oslProcessIdentifier aProcessId = 0; oslProcessInfo info; diff --git a/extensions/source/logging/plaintextformatter.cxx b/extensions/source/logging/plaintextformatter.cxx index a4ac9c35000c..58884a36512c 100644 --- a/extensions/source/logging/plaintextformatter.cxx +++ b/extensions/source/logging/plaintextformatter.cxx @@ -61,18 +61,17 @@ namespace logging OUString SAL_CALL PlainTextFormatter::getHead( ) { - OUStringBuffer aHeader; - aHeader.append( " event no" ); // column 1: the event number - aHeader.append( " " ); - aHeader.append( "thread " ); // column 2: the thread ID - aHeader.append( " " ); - aHeader.append( "date " ); // column 3: date - aHeader.append( " " ); - aHeader.append( "time " ); // column 4: time - aHeader.append( " " ); - aHeader.append( "(class/method:) message" ); // column 5: class/method/message - aHeader.append( "\n" ); - return aHeader.makeStringAndClear(); + return + " event no" // column 1: the event number + " " + "thread " // column 2: the thread ID + " " + "date " // column 3: date + " " + "time " // column 4: time + " " + "(class/method:) message" // column 5: class/method/message + "\n"; } diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index 3a9a6d147cc5..cd25a2b3b656 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -250,13 +250,11 @@ namespace pcr OUString sLocation = aScriptEvent.ScriptCode.copy( 0, nPrefixLen ); OUString sMacroPath = aScriptEvent.ScriptCode.copy( nPrefixLen + 1 ); - OUStringBuffer aNewStyleSpec; - aNewStyleSpec.append( "vnd.sun.star.script:" ); - aNewStyleSpec.append ( sMacroPath ); - aNewStyleSpec.append( "?language=Basic&location=" ); - aNewStyleSpec.append ( sLocation ); - - aScriptEvent.ScriptCode = aNewStyleSpec.makeStringAndClear(); + aScriptEvent.ScriptCode = + "vnd.sun.star.script:" + + sMacroPath + + "?language=Basic&location=" + + sLocation; // also, this new-style spec requires the script code to be "Script" instead of "StarBasic" aScriptEvent.ScriptType = "Script"; @@ -1080,11 +1078,10 @@ namespace pcr Reference< XScriptEventsSupplier > xEventsSupplier( m_xComponent, UNO_QUERY_THROW ); Reference< XNameContainer > xEvents( xEventsSupplier->getEvents(), UNO_SET_THROW ); - OUStringBuffer aCompleteName; - aCompleteName.append( _rScriptEvent.ListenerType ); - aCompleteName.append( "::" ); - aCompleteName.append( _rScriptEvent.EventMethod ); - OUString sCompleteName( aCompleteName.makeStringAndClear() ); + OUString sCompleteName = + _rScriptEvent.ListenerType + + "::" + + _rScriptEvent.EventMethod; bool bExists = xEvents->hasByName( sCompleteName ); diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx index b4eada0786fb..166e6989cd0b 100644 --- a/extensions/source/propctrlr/formcomponenthandler.cxx +++ b/extensions/source/propctrlr/formcomponenthandler.cxx @@ -668,14 +668,10 @@ namespace pcr xPSI = xSet->getPropertySetInfo(); if ( xPSI.is() && xPSI->hasPropertyByName( PROPERTY_LABEL ) ) { - OUStringBuffer aValue; - aValue.append( '<' ); OUString sLabel; if( ! (xSet->getPropertyValue( PROPERTY_LABEL) >>= sLabel) ) SAL_WARN("extensions.propctrlr", "convertToPropertyValue: unable to get property " PROPERTY_LABEL); - aValue.append( sLabel ); - aValue.append( '>' ); - sControlValue = aValue.makeStringAndClear(); + sControlValue = "<" + sLabel + ">"; } aControlValue <<= sControlValue; diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx index 9ddbaa519c1d..06dfbb6fdb2a 100644 --- a/extensions/source/scanner/sanedlg.cxx +++ b/extensions/source/scanner/sanedlg.cxx @@ -1367,9 +1367,8 @@ void SaneDlg::SaveState() bool bValue; if( mrSane.GetOptionValue( nOption, bValue ) ) { - OStringBuffer aString("BOOL="); - aString.append(static_cast<sal_Int32>(bValue)); - aConfig.WriteKey(aOption, aString.makeStringAndClear()); + OString aString = "BOOL=" + OString::number(static_cast<sal_Int32>(bValue)); + aConfig.WriteKey(aOption, aString); } } break; @@ -1378,9 +1377,8 @@ void SaneDlg::SaveState() OString aValue; if( mrSane.GetOptionValue( nOption, aValue ) ) { - OStringBuffer aString("STRING="); - aString.append(aValue); - aConfig.WriteKey( aOption, aString.makeStringAndClear() ); + OString aString = "STRING=" + aValue; + aConfig.WriteKey( aOption, aString ); } } break; diff --git a/extensions/source/update/check/updateprotocol.cxx b/extensions/source/update/check/updateprotocol.cxx index 43d55c87b31f..0b083657b5bc 100644 --- a/extensions/source/update/check/updateprotocol.cxx +++ b/extensions/source/update/check/updateprotocol.cxx @@ -132,16 +132,15 @@ checkForUpdates( if ( !aUpdateInfoEnumeration.is() ) return false; // something went wrong .. - OUStringBuffer aBuffer; - aBuffer.append("/child::inst:description[inst:os=\'"); - aBuffer.append( rOS ); - aBuffer.append("\' and inst:arch=\'"); - aBuffer.append( rArch ); - aBuffer.append("\' and inst:gitid!=\'"); - aBuffer.append( rGitID ); - aBuffer.append("\']"); - - OUString aXPathExpression = aBuffer.makeStringAndClear(); + OUString aXPathExpression = + "/child::inst:description[inst:os=\'"+ + rOS + + "\' and inst:arch=\'"+ + rArch + + "\' and inst:gitid!=\'"+ + rGitID + + "\']"; + while( aUpdateInfoEnumeration->hasMoreElements() ) { diff --git a/filter/qa/cppunit/priority-test.cxx b/filter/qa/cppunit/priority-test.cxx index 88b232684ecf..223d0c58c937 100644 --- a/filter/qa/cppunit/priority-test.cxx +++ b/filter/qa/cppunit/priority-test.cxx @@ -63,24 +63,20 @@ void PriorityFilterTest::testPriority() OUString aTypeName = xDetection->queryTypeByURL(aURL); OUString aFormatCorrect = OUString::createFromAscii(aToCheck[i].pFormat); - OUStringBuffer aMsg("Mis-matching formats "); - aMsg.append("'"); - aMsg.append(aTypeName); - aMsg.append("' should be '"); - aMsg.append(aFormatCorrect); - aMsg.append("'"); - CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aMsg.makeStringAndClear(), + OUString aMsg = "Mis-matching formats " + "'" + + aTypeName + + "' should be '" + + aFormatCorrect + + "'"; + CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aMsg, RTL_TEXTENCODING_UTF8).getStr(), aFormatCorrect, aTypeName); } catch (const uno::Exception &e) { - OUStringBuffer aMsg("Exception querying for type: "); - aMsg.append("'"); - aMsg.append(e.Message); - aMsg.append("'"); - CPPUNIT_FAIL(OUStringToOString(aMsg.makeStringAndClear(), - RTL_TEXTENCODING_UTF8).getStr()); + OUString aMsg = "Exception querying for type: '" + e.Message + "'"; + CPPUNIT_FAIL(OUStringToOString(aMsg, RTL_TEXTENCODING_UTF8).getStr()); } } } diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 673fdff8a743..f2b307c702ad 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -925,11 +925,8 @@ void ODatabaseForm::InsertTextPart( INetMIMEMessage& rParent, const OUString& rN // Header //TODO: Encode rName into a properly formatted Content-Disposition header // field as per RFC 2231: - OUStringBuffer aContentDisp; - aContentDisp.append("form-data; name=\""); - aContentDisp.append(rName); - aContentDisp.append('\"'); - pChild->SetContentDisposition(aContentDisp.makeStringAndClear()); + OUString aContentDisp = "form-data; name=\"" + rName + "\""; + pChild->SetContentDisposition(aContentDisp); rtl_TextEncoding eSystemEncoding = osl_getThreadTextEncoding(); const sal_Char* pBestMatchingEncoding = rtl_getBestMimeCharsetFromTextEncoding( eSystemEncoding ); @@ -989,14 +986,14 @@ void ODatabaseForm::InsertFilePart( INetMIMEMessage& rParent, const OUString& rN // Header //TODO: Encode rName and aFileName into a properly formatted // Content-Disposition header field as per RFC 2231: - OUStringBuffer aContentDisp; - aContentDisp.append("form-data; name=\""); - aContentDisp.append(rName); - aContentDisp.append('\"'); - aContentDisp.append("; filename=\""); - aContentDisp.append(aFileName); - aContentDisp.append('\"'); - pChild->SetContentDisposition(aContentDisp.makeStringAndClear()); + OUString aContentDisp = + "form-data; name=\"" + + rName + + "\"" + "; filename=\"" + + aFileName + + "\""; + pChild->SetContentDisposition(aContentDisp); pChild->SetContentType( aContentType ); pChild->SetContentTransferEncoding("8bit"); diff --git a/fpicker/source/office/iodlgimp.cxx b/fpicker/source/office/iodlgimp.cxx index b78603711847..4876e8db76df 100644 --- a/fpicker/source/office/iodlgimp.cxx +++ b/fpicker/source/office/iodlgimp.cxx @@ -226,11 +226,7 @@ void SvtExpFileDlg_Impl::SetStandardDir( const OUString& _rDir ) namespace { OUString lcl_DecoratedFilter( const OUString& _rOriginalFilter ) { - OUStringBuffer aDecoratedFilter; - aDecoratedFilter.append('<'); - aDecoratedFilter.append(_rOriginalFilter); - aDecoratedFilter.append('>'); - return aDecoratedFilter.makeStringAndClear(); + return "<" + _rOriginalFilter + ">"; } } diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx index 4f33a0c8b76b..6a5ef90cbe19 100644 --- a/framework/source/fwe/classes/addonsoptions.cxx +++ b/framework/source/fwe/classes/addonsoptions.cxx @@ -885,10 +885,9 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager ) OUString aImagesItemNode( aAddonImagesNode + aAddonImagesNodeSeq[n] ); // Create sequence for data access - OUStringBuffer aBuffer( aImagesItemNode ); - aBuffer.append( m_aPathDelimiter ); - aBuffer.append( m_aPropNames[ OFFSET_MENUITEM_URL ] ); - aAddonImageItemNodePropNames[0] = aBuffer.makeStringAndClear(); + aAddonImageItemNodePropNames[0] = aImagesItemNode + + m_aPathDelimiter + + m_aPropNames[ OFFSET_MENUITEM_URL ]; Sequence< Any > aAddonImageItemNodeValues = GetProperties( aAddonImageItemNodePropNames ); @@ -898,11 +897,10 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager ) !aURL.isEmpty() && !HasAssociatedImages( aURL )) { - OUStringBuffer aBuf( aImagesItemNode ); - aBuf.append( m_aPathDelimiter ); - aBuf.append( IMAGES_NODENAME ); - aBuf.append( m_aPathDelimiter ); - OUString aImagesUserDefinedItemNode = aBuf.makeStringAndClear(); + OUString aImagesUserDefinedItemNode = aImagesItemNode + + m_aPathDelimiter + + IMAGES_NODENAME + + m_aPathDelimiter; // Read a user-defined images data std::unique_ptr<ImageEntry> pImageEntry = ReadImageData( aImagesUserDefinedItemNode ); @@ -1074,10 +1072,8 @@ void AddonsOptions_Impl::ReadToolbarMergeInstructions( ToolbarMergingInstruction bool AddonsOptions_Impl::ReadMergeToolbarData( const OUString& aMergeAddonInstructionBase, Sequence< Sequence< PropertyValue > >& rMergeToolbarItems ) { - OUStringBuffer aBuffer( aMergeAddonInstructionBase ); - aBuffer.append( m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ] ); - - OUString aMergeToolbarBaseNode = aBuffer.makeStringAndClear(); + OUString aMergeToolbarBaseNode = aMergeAddonInstructionBase + + m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ]; return ReadToolBarItemSet( aMergeToolbarBaseNode, rMergeToolbarItems ); } @@ -1158,10 +1154,8 @@ bool AddonsOptions_Impl::ReadMergeNotebookBarData( const OUString& aMergeAddonInstructionBase, Sequence<Sequence<PropertyValue>>& rMergeNotebookBarItems) { - OUStringBuffer aBuffer(aMergeAddonInstructionBase); - aBuffer.append(m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_NOTEBOOKBARITEMS]); - - OUString aMergeNotebookBarBaseNode = aBuffer.makeStringAndClear(); + OUString aMergeNotebookBarBaseNode = aMergeAddonInstructionBase + + m_aPropMergeNotebookBarNames[OFFSET_MERGENOTEBOOKBAR_NOTEBOOKBARITEMS]; return ReadNotebookBarItemSet(aMergeNotebookBarBaseNode, rMergeNotebookBarItems); } @@ -1233,9 +1227,8 @@ bool AddonsOptions_Impl::ReadMergeStatusbarData( { sal_uInt32 nStatusbarItemCount = rMergeStatusbarItems.getLength(); - OUStringBuffer aBuffer( aMergeAddonInstructionBase ); - aBuffer.append( m_aPropMergeStatusbarNames[ OFFSET_MERGESTATUSBAR_STATUSBARITEMS ] ); - OUString aMergeStatusbarBaseNode = aBuffer.makeStringAndClear(); + OUString aMergeStatusbarBaseNode = aMergeAddonInstructionBase + + m_aPropMergeStatusbarNames[ OFFSET_MERGESTATUSBAR_STATUSBARITEMS ]; OUString aAddonStatusbarItemSetNode( aMergeStatusbarBaseNode + m_aPathDelimiter ); Sequence< OUString > aAddonStatusbarItemSetNodeSeq = GetNodeNames( aMergeStatusbarBaseNode ); diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 625739ec4cfe..8da37225f2e0 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -2001,10 +2001,7 @@ void AutoRecovery::implts_flushConfigItem(const AutoRecovery::TDocumentInfo& rIn css::uno::Reference< css::container::XNameContainer > xModify(xCheck, css::uno::UNO_QUERY_THROW); css::uno::Reference< css::lang::XSingleServiceFactory > xCreate(xCheck, css::uno::UNO_QUERY_THROW); - OUStringBuffer sIDBuf; - sIDBuf.append(RECOVERY_ITEM_BASE_IDENTIFIER); - sIDBuf.append(rInfo.ID); - OUString sID = sIDBuf.makeStringAndClear(); + OUString sID = RECOVERY_ITEM_BASE_IDENTIFIER + OUString::number(rInfo.ID); // remove if (bRemoveIt) @@ -4176,11 +4173,7 @@ void AutoRecovery::st_impl_removeLockFile() OUString sUserURL; ::utl::Bootstrap::locateUserInstallation( sUserURL ); - OUStringBuffer sLockURLBuf; - sLockURLBuf.append (sUserURL); - sLockURLBuf.append("/.lock"); - OUString sLockURL = sLockURLBuf.makeStringAndClear(); - + OUString sLockURL = sUserURL + "/.lock"; AutoRecovery::st_impl_removeFile(sLockURL); } catch(const css::uno::Exception&) diff --git a/framework/source/services/urltransformer.cxx b/framework/source/services/urltransformer.cxx index a769790d22c8..ce9ae752ec60 100644 --- a/framework/source/services/urltransformer.cxx +++ b/framework/source/services/urltransformer.cxx @@ -261,9 +261,7 @@ sal_Bool SAL_CALL URLTransformer::assemble( css::util::URL& aURL ) else if ( !aURL.Protocol.isEmpty() ) { // Minimal support for unknown protocols - OUStringBuffer aBuffer( aURL.Protocol ); - aBuffer.append( aURL.Path ); - aURL.Complete = aBuffer.makeStringAndClear(); + aURL.Complete = aURL.Protocol + aURL.Path; aURL.Main = aURL.Complete; return true; } diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx index 9852adf70eee..df76e7d0ced7 100644 --- a/framework/source/uielement/toolbarmodemenucontroller.cxx +++ b/framework/source/uielement/toolbarmodemenucontroller.cxx @@ -240,12 +240,10 @@ void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent OUString aCmd( pVCLPopupMenu->GetItemCommand( rEvent.MenuId )); { - OUStringBuffer aBuf(".uno:Notebookbar?File:string="); - aBuf.append( aCmd ); URL aTargetURL; Sequence<PropertyValue> aArgs; - aTargetURL.Complete = aBuf.makeStringAndClear(); + aTargetURL.Complete = ".uno:Notebookbar?File:string=" + aCmd; xURLTransformer->parseStrict( aTargetURL ); Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( xDispatchProvider.is() ) @@ -261,12 +259,10 @@ void SAL_CALL ToolbarModeMenuController::itemSelected( const css::awt::MenuEvent } } - OUStringBuffer aBuf(".uno:ToolbarMode?Mode:string="); - aBuf.append( aCmd ); URL aTargetURL; Sequence<PropertyValue> aArgs; - aTargetURL.Complete = aBuf.makeStringAndClear(); + aTargetURL.Complete = ".uno:ToolbarMode?Mode:string=" + aCmd; xURLTransformer->parseStrict( aTargetURL ); Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( xDispatchProvider.is() ) diff --git a/framework/source/uifactory/factoryconfiguration.cxx b/framework/source/uifactory/factoryconfiguration.cxx index c3a2f964b2e2..97440dd16306 100644 --- a/framework/source/uifactory/factoryconfiguration.cxx +++ b/framework/source/uifactory/factoryconfiguration.cxx @@ -47,10 +47,7 @@ namespace framework { static OUString getHashKeyFromStrings( const OUString& aCommandURL, const OUString& aModuleName ) { - OUStringBuffer aKey( aCommandURL ); - aKey.append( "-" ); - aKey.append( aModuleName ); - return aKey.makeStringAndClear(); + return aCommandURL + "-" + aModuleName; } // XInterface, XTypeProvider diff --git a/idl/source/prj/parser.cxx b/idl/source/prj/parser.cxx index c6fa85431f0e..8bb45b10b273 100644 --- a/idl/source/prj/parser.cxx +++ b/idl/source/prj/parser.cxx @@ -134,18 +134,18 @@ void SvIdlParser::ReadInclude( SvMetaModule& rModule ) osl::FileBase::RC searchError = osl::File::searchFileURL(aFullName, rBase.GetPath(), aFullName); if( osl::FileBase::E_None != searchError ) { - OStringBuffer aStr("cannot find file:"); - aStr.append(OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8)); - throw SvParseException(aStr.makeStringAndClear(), rInStm.GetToken()); + OString aStr = "cannot find file:" + + OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8); + throw SvParseException(aStr, rInStm.GetToken()); } osl::FileBase::getSystemPathFromFileURL( aFullName, aFullName ); rBase.AddDepFile( aFullName ); SvTokenStream aTokStm( aFullName ); if( ERRCODE_NONE != aTokStm.GetStream().GetError() ) { - OStringBuffer aStr("cannot open file: "); - aStr.append(OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8)); - throw SvParseException(aStr.makeStringAndClear(), rInStm.GetToken()); + OString aStr = "cannot open file: " + + OUStringToOString(aFullName, RTL_TEXTENCODING_UTF8); + throw SvParseException(aStr, rInStm.GetToken()); } // rescue error from old file SvIdlError aOldErr = rBase.GetError(); diff --git a/idl/source/prj/svidl.cxx b/idl/source/prj/svidl.cxx index fcfebed79816..91ad73d19336 100644 --- a/idl/source/prj/svidl.cxx +++ b/idl/source/prj/svidl.cxx @@ -95,8 +95,8 @@ static OUString tempFileHelper(OUString const & fname) } else { - OStringBuffer aStr("invalid filename: "); - aStr.append(OUStringToOString(fname, RTL_TEXTENCODING_UTF8)); + OString aStr = "invalid filename: " + + OUStringToOString(fname, RTL_TEXTENCODING_UTF8); fprintf(stderr, "%s\n", aStr.getStr()); } return aTmpFile; @@ -134,8 +134,8 @@ int main ( int argc, char ** argv) if( !pDataBase->WriteSfx( aOutStm ) ) { nExit = -1; - OStringBuffer aStr("cannot write slotmap file: "); - aStr.append(OUStringToOString(aCommand.aSlotMapFile, RTL_TEXTENCODING_UTF8)); + OString aStr = "cannot write slotmap file: " + + OUStringToOString(aCommand.aSlotMapFile, RTL_TEXTENCODING_UTF8); fprintf(stderr, "%s\n", aStr.getStr()); } } @@ -181,12 +181,10 @@ int main ( int argc, char ** argv) if( bErr ) { nExit = -1; - OStringBuffer aStr("cannot move file from: "); - aStr.append(OUStringToOString(aErrFile2, - RTL_TEXTENCODING_UTF8)); - aStr.append("\n to file: "); - aStr.append(OUStringToOString(aErrFile, - RTL_TEXTENCODING_UTF8)); + OString aStr = "cannot move file from: " + + OUStringToOString(aErrFile2, RTL_TEXTENCODING_UTF8) + + "\n to file: " + + OUStringToOString(aErrFile, RTL_TEXTENCODING_UTF8); fprintf( stderr, "%s\n", aStr.getStr() ); } else diff --git a/oox/source/drawingml/chart/titlecontext.cxx b/oox/source/drawingml/chart/titlecontext.cxx index 0a9cc5ccbea6..042b12553483 100644 --- a/oox/source/drawingml/chart/titlecontext.cxx +++ b/oox/source/drawingml/chart/titlecontext.cxx @@ -72,9 +72,7 @@ void TextContext::onCharacters( const OUString& rChars ) if( isCurrentElement( C_TOKEN( v ) ) ) { // Static text is stored as a single string formula token for Excel document. - OUStringBuffer aBuf; - aBuf.append('"').append(rChars).append('"'); - mrModel.mxDataSeq.create().maFormula = aBuf.makeStringAndClear(); + mrModel.mxDataSeq.create().maFormula = "\"" + rChars + "\""; // Also store it as a single element type for non-Excel document. mrModel.mxDataSeq->maData[0] <<= rChars; diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 0bc408f3ef1c..c4b0fe42249e 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -1181,15 +1181,15 @@ sal_Int32 VMLExport::StartShape() nShapeElement = XML_shape; if ( !m_aShapeTypeWritten[ m_nShapeType ] ) { - OStringBuffer sShapeType; - sShapeType.append("<v:shapetype id=\"shapetype_").append(OString::number(m_nShapeType)). - append("\" coordsize=\"21600,21600\" o:spt=\"").append(OString::number(m_nShapeType)). - append("\" path=\"m,l,21600l21600,21600l21600,xe\">\n"). - append("<v:stroke joinstyle=\"miter\"/>\n" + OString sShapeType = + "<v:shapetype id=\"shapetype_" + OString::number(m_nShapeType) + + "\" coordsize=\"21600,21600\" o:spt=\"" + OString::number(m_nShapeType) + + "\" path=\"m,l,21600l21600,21600l21600,xe\">\n" + "<v:stroke joinstyle=\"miter\"/>\n" "<v:path shadowok=\"f\" o:extrusionok=\"f\" strokeok=\"f\" fillok=\"f\" o:connecttype=\"rect\"/>\n" "<o:lock v:ext=\"edit\" shapetype=\"t\"/>\n" - "</v:shapetype>"); - m_pSerializer->write(sShapeType.makeStringAndClear()); + "</v:shapetype>"; + m_pSerializer->write(sShapeType); m_aShapeTypeWritten[ m_nShapeType ] = true; } break; @@ -1202,11 +1202,11 @@ sal_Int32 VMLExport::StartShape() nShapeElement = XML_shape; if ( !m_aShapeTypeWritten[ m_nShapeType ] ) { - OStringBuffer sShapeType; - sShapeType.append("<v:shapetype id=\"shapetype_").append(OString::number(m_nShapeType)). - append("\" coordsize=\"21600,21600\" o:spt=\"").append(OString::number(m_nShapeType)). - append("\" o:preferrelative=\"t\" path=\"m@4@5l@4@11@9@11@9@5xe\" filled=\"f\" stroked=\"f\">\n"). - append("<v:stroke joinstyle=\"miter\"/>\n" + OString sShapeType = + "<v:shapetype id=\"shapetype_" + OString::number(m_nShapeType) + + "\" coordsize=\"21600,21600\" o:spt=\"" + OString::number(m_nShapeType) + + "\" o:preferrelative=\"t\" path=\"m@4@5l@4@11@9@11@9@5xe\" filled=\"f\" stroked=\"f\">\n" + "<v:stroke joinstyle=\"miter\"/>\n" "<v:formulas>\n" "<v:f eqn=\"if lineDrawn pixelLineWidth 0\"/>\n" "<v:f eqn=\"sum @0 1 0\"/>\n" @@ -1223,8 +1223,8 @@ sal_Int32 VMLExport::StartShape() "</v:formulas>\n" "<v:path o:extrusionok=\"f\" gradientshapeok=\"t\" o:connecttype=\"rect\"/>\n" "<o:lock v:ext=\"edit\" aspectratio=\"t\"/>\n" - "</v:shapetype>"); - m_pSerializer->write(sShapeType.makeStringAndClear()); + "</v:shapetype>"; + m_pSerializer->write(sShapeType); m_aShapeTypeWritten[ m_nShapeType ] = true; } break; diff --git a/package/source/manifest/ManifestExport.cxx b/package/source/manifest/ManifestExport.cxx index 4b4d57ce9294..f30b1604f20e 100644 --- a/package/source/manifest/ManifestExport.cxx +++ b/package/source/manifest/ManifestExport.cxx @@ -346,9 +346,7 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con { sal_Int64 nSize = 0; rValue.Value >>= nSize; - OUStringBuffer aBuffer; - aBuffer.append ( nSize ); - pAttrList->AddAttribute ( sSizeAttribute, sCdataAttribute, aBuffer.makeStringAndClear() ); + pAttrList->AddAttribute ( sSizeAttribute, sCdataAttribute, OUString::number( nSize ) ); } else if (rValue.Name == sInitialisationVectorProperty ) pVector = &rValue.Value; diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx index d9c9dacbb3fd..d554f5ca769c 100644 --- a/pyuno/source/module/pyuno.cxx +++ b/pyuno/source/module/pyuno.cxx @@ -93,16 +93,14 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef return "void"; OUStringBuffer buf( 64 ); - buf.append( '(' ); - buf.append( pTypeRef->pTypeName ); - buf.append( ')' ); + buf.append( "(" + OUString::unacquired(&pTypeRef->pTypeName) + ")" ); switch (pTypeRef->eTypeClass) { case typelib_TypeClass_INTERFACE: { - buf.append( "0x" ); - buf.append( reinterpret_cast< sal_IntPtr >(*static_cast<void * const *>(pVal)), 16 ); + buf.append( "0x" + + OUString::number( reinterpret_cast< sal_IntPtr >(*static_cast<void * const *>(pVal)), 16 )); if( VAL2STR_MODE_DEEP == mode ) { buf.append( "{" ); Reference< XInterface > r = *static_cast<Reference< XInterface > const *>(pVal); @@ -164,8 +162,7 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos ) { - buf.append( ppMemberNames[nPos] ); - buf.append( " = " ); + buf.append( OUString::unacquired(&ppMemberNames[nPos]) + " = " ); typelib_TypeDescription * pMemberType = nullptr; TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] ); buf.append( val2str( static_cast<char const *>(pVal) + pMemberOffsets[nPos], pMemberType->pWeakRef, mode ) ); @@ -222,9 +219,9 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef buf.append( (*static_cast<typelib_TypeDescriptionReference * const *>(pVal))->pTypeName ); break; case typelib_TypeClass_STRING: - buf.append( '\"' ); - buf.append( *static_cast<rtl_uString * const *>(pVal) ); - buf.append( '\"' ); + buf.append( "\"" + + OUString::unacquired(&*static_cast<rtl_uString * const *>(pVal)) + + "\"" ); break; case typelib_TypeClass_ENUM: { @@ -264,24 +261,24 @@ OUString val2str( const void * pVal, typelib_TypeDescriptionReference * pTypeRef buf.append( *static_cast<double const *>(pVal) ); break; case typelib_TypeClass_BYTE: - buf.append( "0x" ); - buf.append( static_cast<sal_Int32>(*static_cast<sal_Int8 const *>(pVal)), 16 ); + buf.append( "0x" + + OUString::number( static_cast<sal_Int32>(*static_cast<sal_Int8 const *>(pVal)), 16 )); break; case typelib_TypeClass_SHORT: - buf.append( "0x" ); - buf.append( static_cast<sal_Int32>(*static_cast<sal_Int16 const *>(pVal)), 16 ); + buf.append( "0x" + + OUString::number( static_cast<sal_Int32>(*static_cast<sal_Int16 const *>(pVal)), 16 )); break; case typelib_TypeClass_UNSIGNED_SHORT: - buf.append( "0x" ); - buf.append( static_cast<sal_Int32>(*static_cast<sal_uInt16 const *>(pVal)), 16 ); + buf.append( "0x" + + OUString::number( static_cast<sal_Int32>(*static_cast<sal_uInt16 const *>(pVal)), 16 )); break; case typelib_TypeClass_LONG: - buf.append( "0x" ); - buf.append( *static_cast<sal_Int32 const *>(pVal), 16 ); + buf.append( "0x" + + OUString::number( *static_cast<sal_Int32 const *>(pVal), 16 )); break; case typelib_TypeClass_UNSIGNED_LONG: - buf.append( "0x" ); - buf.append( static_cast<sal_Int64>(*static_cast<sal_uInt32 const *>(pVal)), 16 ); + buf.append( "0x" + + OUString::number( static_cast<sal_Int64>(*static_cast<sal_uInt32 const *>(pVal)), 16 )); break; case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: @@ -464,15 +461,14 @@ PyObject *PyUNO_str( PyObject * self ) { PyUNO *me = reinterpret_cast<PyUNO *>(self); - OStringBuffer buf; + OString buf; { PyThreadDetach antiguard; - buf.append( "pyuno object " ); OUString s = val2str( me->members->wrappedObject.getValue(), me->members->wrappedObject.getValueType().getTypeLibType() ); - buf.append( OUStringToOString(s,RTL_TEXTENCODING_ASCII_US) ); + buf = "pyuno object " + OUStringToOString(s,RTL_TEXTENCODING_ASCII_US); } return PyStr_FromString( buf.getStr() ); diff --git a/pyuno/source/module/pyuno_except.cxx b/pyuno/source/module/pyuno_except.cxx index 8b712400adf3..7cd879f0e81e 100644 --- a/pyuno/source/module/pyuno_except.cxx +++ b/pyuno/source/module/pyuno_except.cxx @@ -47,15 +47,11 @@ void raisePyExceptionWithAny( const css::uno::Any &anyExc ) css::uno::Exception e; anyExc >>= e; - OUStringBuffer buf; - buf.append( "Couldn't convert uno exception to a python exception (" ); - buf.append(anyExc.getValueType().getTypeName()); - buf.append( ": " ); - buf.append(e.Message ); - buf.append( ")" ); + OUString buf = "Couldn't convert uno exception to a python exception (" + + anyExc.getValueType().getTypeName() + ": " + e.Message + ")"; PyErr_SetString( PyExc_SystemError, - OUStringToOString(buf.makeStringAndClear(),RTL_TEXTENCODING_ASCII_US).getStr() ); + OUStringToOString(buf,RTL_TEXTENCODING_ASCII_US).getStr() ); } } catch(const css::lang::IllegalArgumentException & e) diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx index 715d5c6dbb27..184e7e4b6f9d 100644 --- a/pyuno/source/module/pyuno_module.cxx +++ b/pyuno/source/module/pyuno_module.cxx @@ -113,13 +113,10 @@ public: if (initialised[key]) { OUStringBuffer buf; - buf.append( "pyuno._createUnoStructHelper: member '"); - buf.append(key); - buf.append( "'"); + buf.append( "pyuno._createUnoStructHelper: member '" + key + "'"); if ( pos >= 0 ) { - buf.append( " at position "); - buf.append(pos); + buf.append( " at position " + OUString::number(pos)); } buf.append( " initialised multiple times."); throw RuntimeException(buf.makeStringAndClear()); @@ -191,13 +188,12 @@ void fillStruct( const OUString memberName (pCompType->ppMemberNames[i]); if ( ! state.isInitialised( memberName ) ) { - OUStringBuffer buf; - buf.append( "pyuno._createUnoStructHelper: member '"); - buf.append(memberName); - buf.append( "' of struct type '"); - buf.append(pCompType->aBase.pTypeName); - buf.append( "' not given a value."); - throw RuntimeException(buf.makeStringAndClear()); + OUString buf = "pyuno._createUnoStructHelper: member '" + + memberName + + "' of struct type '" + + OUString::unacquired(&pCompType->aBase.pTypeName) + + "' not given a value."; + throw RuntimeException(buf); } } } @@ -223,12 +219,11 @@ OUString getLibDir() void raisePySystemException( const char * exceptionType, const OUString & message ) { - OStringBuffer buf; - buf.append( "Error during bootstrapping uno ("); - buf.append( exceptionType ); - buf.append( "):" ); - buf.append( OUStringToOString( message, osl_getThreadTextEncoding() ) ); - PyErr_SetString( PyExc_SystemError, buf.makeStringAndClear().getStr() ); + OString buf = OStringLiteral("Error during bootstrapping uno (") + + exceptionType + + "):" + + OUStringToOString( message, osl_getThreadTextEncoding() ); + PyErr_SetString( PyExc_SystemError, buf.getStr() ); } extern "C" { @@ -250,7 +245,6 @@ static PyObject* getComponentContext( } else { - OUString iniFile; if( path.isEmpty() ) { PyErr_SetString( @@ -259,14 +253,11 @@ static PyObject* getComponentContext( return nullptr; } - OUStringBuffer iniFileName; - iniFileName.append( path ); + OUString iniFile = path + #ifdef MACOSX - iniFileName.append( "/../" LIBO_ETC_FOLDER ); + "/../" LIBO_ETC_FOLDER #endif - iniFileName.append( "/" ); - iniFileName.append( SAL_CONFIGFILE( "pyuno" ) ); - iniFile = iniFileName.makeStringAndClear(); + "/" SAL_CONFIGFILE( "pyuno" ); osl::DirectoryItem item; if( osl::DirectoryItem::get( iniFile, item ) == osl::FileBase::E_None ) { @@ -395,16 +386,14 @@ PyObject * extractOneStringArg( PyObject *args, char const *funcName ) { if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 ) { - OStringBuffer buf; - buf.append( funcName ).append( ": expecting one string argument" ); + OString buf = funcName + OStringLiteral(": expecting one string argument"); PyErr_SetString( PyExc_RuntimeError, buf.getStr() ); return nullptr; } PyObject *obj = PyTuple_GetItem( args, 0 ); if (!PyStr_Check(obj) && !PyUnicode_Check(obj)) { - OStringBuffer buf; - buf.append( funcName ).append( ": expecting one string argument" ); + OString buf = funcName + OStringLiteral(": expecting one string argument"); PyErr_SetString( PyExc_TypeError, buf.getStr()); return nullptr; } @@ -515,8 +504,7 @@ static PyObject *getTypeByName( } else { - OStringBuffer buf; - buf.append( "Type " ).append(name).append( " is unknown" ); + OString buf = OStringLiteral("Type ") + name + " is unknown"; PyErr_SetString( PyExc_RuntimeError, buf.getStr() ); } } @@ -577,8 +565,7 @@ static PyObject *checkType( SAL_UNUSED_PARAMETER PyObject *, PyObject *args ) { if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 ) { - OStringBuffer buf; - buf.append( "pyuno.checkType : expecting one uno.Type argument" ); + OString buf = "pyuno.checkType : expecting one uno.Type argument"; PyErr_SetString( PyExc_RuntimeError, buf.getStr() ); return nullptr; } @@ -601,8 +588,7 @@ static PyObject *checkEnum( SAL_UNUSED_PARAMETER PyObject *, PyObject *args ) { if( !PyTuple_Check( args ) || PyTuple_Size( args) != 1 ) { - OStringBuffer buf; - buf.append( "pyuno.checkType : expecting one uno.Type argument" ); + OString buf = "pyuno.checkType : expecting one uno.Type argument"; PyErr_SetString( PyExc_RuntimeError, buf.getStr() ); return nullptr; } @@ -684,14 +670,13 @@ static PyObject *systemPathToFileUrl( if( e != osl::FileBase::E_None ) { - OUStringBuffer buf; - buf.append( "Couldn't convert " ); - buf.append( sysPath ); - buf.append( " to a file url for reason (" ); - buf.append( static_cast<sal_Int32>(e) ); - buf.append( ")" ); + OUString buf = "Couldn't convert " + + sysPath + + " to a file url for reason (" + + OUString::number( static_cast<sal_Int32>(e) ) + + ")"; raisePyExceptionWithAny( - makeAny( RuntimeException( buf.makeStringAndClear() ))); + makeAny( RuntimeException( buf ))); return nullptr; } return ustring2PyUnicode( url ).getAcquired(); @@ -710,14 +695,13 @@ static PyObject * fileUrlToSystemPath( if( e != osl::FileBase::E_None ) { - OUStringBuffer buf; - buf.append( "Couldn't convert file url " ); - buf.append( sysPath ); - buf.append( " to a system path for reason (" ); - buf.append( static_cast<sal_Int32>(e) ); - buf.append( ")" ); + OUString buf = "Couldn't convert file url " + + sysPath + + " to a system path for reason (" + + OUString::number( static_cast<sal_Int32>(e) ) + + ")"; raisePyExceptionWithAny( - makeAny( RuntimeException( buf.makeStringAndClear() ))); + makeAny( RuntimeException( buf ))); return nullptr; } return ustring2PyUnicode( sysPath ).getAcquired(); @@ -733,18 +717,18 @@ static PyObject * absolutize( SAL_UNUSED_PARAMETER PyObject *, PyObject * args ) oslFileError e = osl_getAbsoluteFileURL( ouPath.pData, ouRel.pData, &(ret.pData) ); if( e != osl_File_E_None ) { - OUStringBuffer buf; - buf.append( "Couldn't absolutize " ); - buf.append( ouRel ); - buf.append( " using root " ); - buf.append( ouPath ); - buf.append( " for reason (" ); - buf.append( static_cast<sal_Int32>(e) ); - buf.append( ")" ); + OUString buf = + "Couldn't absolutize " + + ouRel + + " using root " + + ouPath + + " for reason (" + + OUString::number(static_cast<sal_Int32>(e) ) + + ")"; PyErr_SetString( PyExc_OSError, - OUStringToOString(buf.makeStringAndClear(),osl_getThreadTextEncoding()).getStr()); + OUStringToOString(buf,osl_getThreadTextEncoding()).getStr()); return nullptr; } return ustring2PyUnicode( ret ).getAcquired(); @@ -787,9 +771,8 @@ static PyObject * invoke(SAL_UNUSED_PARAMETER PyObject *, PyObject *args) } else { - OStringBuffer buf; - buf.append("uno.invoke expects object, name, (arg1, arg2, ... )\n"); - PyErr_SetString(PyExc_RuntimeError, buf.makeStringAndClear().getStr()); + OString buf = "uno.invoke expects object, name, (arg1, arg2, ... )\n"; + PyErr_SetString(PyExc_RuntimeError, buf.getStr()); } return ret; } @@ -841,10 +824,9 @@ static PyObject *setCurrentContext( } else { - OStringBuffer buf; - buf.append( "uno.setCurrentContext expects exactly one argument (the current Context)\n" ); + OString buf = "uno.setCurrentContext expects exactly one argument (the current Context)\n"; PyErr_SetString( - PyExc_RuntimeError, buf.makeStringAndClear().getStr() ); + PyExc_RuntimeError, buf.getStr() ); } } catch( const css::uno::Exception & e ) diff --git a/pyuno/source/module/pyuno_struct.cxx b/pyuno/source/module/pyuno_struct.cxx index 64dc11499f6b..50b74126bee9 100644 --- a/pyuno/source/module/pyuno_struct.cxx +++ b/pyuno/source/module/pyuno_struct.cxx @@ -57,7 +57,7 @@ static void PyUNOStruct_del( PyObject* self ) static PyObject *PyUNOStruct_str( PyObject *self ) { PyUNO *me = reinterpret_cast<PyUNO*>( self ); - OStringBuffer buf; + OString buf; Reference<XMaterialHolder> rHolder( me->members->xInvocation,UNO_QUERY ); if( rHolder.is() ) @@ -65,7 +65,7 @@ static PyObject *PyUNOStruct_str( PyObject *self ) PyThreadDetach antiguard; Any a = rHolder->getMaterial(); OUString s = val2str( a.getValue(), a.getValueType().getTypeLibType() ); - buf.append( OUStringToOString( s, RTL_TEXTENCODING_ASCII_US ) ); + buf = OUStringToOString( s, RTL_TEXTENCODING_ASCII_US ); } return PyStr_FromString( buf.getStr()); diff --git a/pyuno/source/module/pyuno_type.cxx b/pyuno/source/module/pyuno_type.cxx index 8cc41e8c0de1..de4a212e22bb 100644 --- a/pyuno/source/module/pyuno_type.cxx +++ b/pyuno/source/module/pyuno_type.cxx @@ -232,9 +232,7 @@ static PyObject* callCtor( const Runtime &r , const char * clazz, const PyRef & PyRef code( PyDict_GetItemString( r.getImpl()->cargo->getUnoModule().get(), clazz ) ); if( ! code.is() ) { - OStringBuffer buf; - buf.append( "couldn't access uno." ); - buf.append( clazz ); + OString buf = OStringLiteral("couldn't access uno.") + clazz; PyErr_SetString( PyExc_RuntimeError, buf.getStr() ); return nullptr; } diff --git a/pyuno/source/module/pyuno_util.cxx b/pyuno/source/module/pyuno_util.cxx index 3765dc7df356..f75533d47fdb 100644 --- a/pyuno/source/module/pyuno_util.cxx +++ b/pyuno/source/module/pyuno_util.cxx @@ -161,9 +161,7 @@ void logException( RuntimeCargo *cargo, const char *intro, OUStringBuffer buf( 128 ); buf.appendAscii( intro ); appendPointer(buf, ptr); - buf.append( "]." ); - buf.append( aFunctionName ); - buf.append( " = " ); + buf.append( "]." + aFunctionName + " = " ); buf.append( val2str( data, type.getTypeLibType(), VAL2STR_MODE_SHALLOW ) ); log( cargo,LogLevel::CALL, buf.makeStringAndClear() ); @@ -182,9 +180,7 @@ void logReply( OUStringBuffer buf( 128 ); buf.appendAscii( intro ); appendPointer(buf, ptr); - buf.append( "]." ); - buf.append( aFunctionName ); - buf.append( "()=" ); + buf.append( "]." + aFunctionName + "()=" ); if( isLog( cargo, LogLevel::ARGS ) ) { buf.append( @@ -207,9 +203,7 @@ void logCall( RuntimeCargo *cargo, const char *intro, OUStringBuffer buf( 128 ); buf.appendAscii( intro ); appendPointer(buf, ptr); - buf.append( "]." ); - buf.append( aFunctionName ); - buf.append( "(" ); + buf.append( "]." + aFunctionName + "(" ); if( isLog( cargo, LogLevel::ARGS ) ) { for( int i = 0; i < aParams.getLength() ; i ++ ) diff --git a/reportdesign/source/core/misc/reportformula.cxx b/reportdesign/source/core/misc/reportformula.cxx index c5026a545e94..1f743afd765f 100644 --- a/reportdesign/source/core/misc/reportformula.cxx +++ b/reportdesign/source/core/misc/reportformula.cxx @@ -58,12 +58,7 @@ namespace rptui case Field: { - OUStringBuffer aBuffer; - aBuffer.append( sFieldPrefix ); - aBuffer.append( "[" ); - aBuffer.append( _rFieldOrExpression ); - aBuffer.append( "]" ); - m_sCompleteFormula = aBuffer.makeStringAndClear(); + m_sCompleteFormula = sFieldPrefix + OUStringLiteral("[") + _rFieldOrExpression + "]"; } break; default: diff --git a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx index 2116ca0c0893..4d8f8356f6be 100644 --- a/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx +++ b/reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx @@ -49,12 +49,11 @@ static void lcl_exportPrettyPrinting(const uno::Reference< xml::sax::XDocumentHa OUString lcl_createAttribute(const xmloff::token::XMLTokenEnum& _eNamespace,const xmloff::token::XMLTokenEnum& _eAttribute) { - OUStringBuffer sQName; + return // ...if it's in our map, make the prefix - sQName.append ( xmloff::token::GetXMLToken(_eNamespace) ); - sQName.append ( ':' ); - sQName.append ( xmloff::token::GetXMLToken(_eAttribute) ); - return sQName.makeStringAndClear(); + xmloff::token::GetXMLToken(_eNamespace) + + ":" + + xmloff::token::GetXMLToken(_eAttribute); } static void lcl_correctCellAddress(const OUString & _sName, const uno::Reference< xml::sax::XAttributeList > & xAttribs) diff --git a/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx b/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx index 7021ed43f1ae..329b57014b53 100644 --- a/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx +++ b/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx @@ -90,10 +90,7 @@ namespace rptui OUString sLabel = m_rReportController.getColumnLabel_throw(sColumnName); if ( !sLabel.isEmpty() ) { - OUStringBuffer aBuffer; - aBuffer.append( "=" ); - aBuffer.append( sLabel ); - sDataField = aBuffer.makeStringAndClear(); + sDataField = "=" + sLabel; bSet = false; } } diff --git a/sal/qa/osl/security/osl_Security.cxx b/sal/qa/osl/security/osl_Security.cxx index 40eef7a6b940..3bce893731cc 100644 --- a/sal/qa/osl/security/osl_Security.cxx +++ b/sal/qa/osl/security/osl_Security.cxx @@ -129,13 +129,12 @@ namespace osl_Security OUString strID; bRes = aSec.getUserIdent( strID ); - OStringBuffer aMessage; - aMessage.append("strUserID: "); - aMessage.append(OUStringToOString(strUserID, osl_getThreadTextEncoding())); - aMessage.append(", strID: "); - aMessage.append(OUStringToOString(strID, osl_getThreadTextEncoding())); - aMessage.append(", bRes: "); - aMessage.append(bRes); + OString aMessage = "strUserID: " + + OUStringToOString(strUserID, osl_getThreadTextEncoding()) + + ", strID: " + + OUStringToOString(strID, osl_getThreadTextEncoding()) + + ", bRes: " + + OString::boolean(bRes); CPPUNIT_ASSERT_EQUAL_MESSAGE( aMessage.getStr(), strUserID, strID ); CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), bRes ); diff --git a/sal/qa/rtl/uri/rtl_testuri.cxx b/sal/qa/rtl/uri/rtl_testuri.cxx index 3310ec25bba6..aea0d50c6c54 100644 --- a/sal/qa/rtl/uri/rtl_testuri.cxx +++ b/sal/qa/rtl/uri/rtl_testuri.cxx @@ -44,7 +44,6 @@ void Test::test_Uri() { rtl_UriCharClass const eFirstCharClass = rtl_UriCharClassNone; rtl_UriCharClass const eLastCharClass = rtl_UriCharClassUnoParamValue; - OUStringBuffer aBuffer; OUString aText1; OUString aText2; @@ -182,12 +181,11 @@ void Test::test_Uri() { // Check surrogate handling: - aBuffer.append(u'\xD800'); // %ED%A0%80 - aBuffer.append(u'\xD800'); // %F0%90%8F%BF - aBuffer.append(u'\xDFFF'); - aBuffer.append(u'\xDFFF'); // %ED%BF%BF - aBuffer.append('A'); // A - aText1 = aBuffer.makeStringAndClear(); + aText1 = OUStringLiteral1(u'\xD800') + // %ED%A0%80 + OUStringLiteral1(u'\xD800') + // %F0%90%8F%BF + OUStringLiteral1(u'\xDFFF') + + OUStringLiteral1(u'\xDFFF') + // %ED%BF%BF + "A"; // A aText2 = "%ED%A0%80" "%F0%90%8F%BF" "%ED%BF%BF" "A"; CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 11", @@ -209,12 +207,11 @@ void Test::test_Uri() { RTL_TEXTENCODING_UTF8)); aText1 = "%ed%a0%80" "%f0%90%8f%bf" "%ed%bf%bf" "A"; - aBuffer.append("%ED%A0%80"); - aBuffer.append(u'\xD800'); - aBuffer.append(u'\xDFFF'); - aBuffer.append("%ED%BF%BF"); - aBuffer.append('A'); - aText2 = aBuffer.makeStringAndClear(); + aText2 = "%ED%A0%80" + + OUStringLiteral1(u'\xD800') + + OUStringLiteral1(u'\xDFFF') + + "%ED%BF%BF" + "A"; CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 14", aText2, @@ -250,9 +247,8 @@ void Test::test_Uri() { // Check IURI handling: aText1 = "%30%C3%BF"; - aBuffer.append("%30"); - aBuffer.append(u'\x00FF'); - aText2 = aBuffer.makeStringAndClear(); + aText2 = "%30" + + OUStringLiteral1(u'\x00FF'); CPPUNIT_ASSERT_EQUAL_MESSAGE( "failure 18", aText2, diff --git a/sc/qa/unit/helper/csv_handler.hxx b/sc/qa/unit/helper/csv_handler.hxx index f9d0f31b18d5..71dfc9cae1e2 100644 --- a/sc/qa/unit/helper/csv_handler.hxx +++ b/sc/qa/unit/helper/csv_handler.hxx @@ -39,13 +39,12 @@ inline OUString getConditionalFormatString(ScDocument* pDoc, SCCOL nCol, SCROW n inline OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab) { - OStringBuffer aString("Error in Table: "); - aString.append(static_cast<sal_Int32>(nTab)); - aString.append(" Column: "); - aString.append(static_cast<sal_Int32>(nCol)); - aString.append(" Row: "); - aString.append(nRow); - return aString.makeStringAndClear(); + return "Error in Table: " + + OString::number(static_cast<sal_Int32>(nTab)) + + " Column: " + + OString::number(static_cast<sal_Int32>(nCol)) + + " Row: " + + OString::number(nRow); } inline OString createErrorMessage(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString& rExpectedString, const OUString& rString) diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index 219d47635feb..4ee21b98512b 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -117,8 +117,7 @@ void loadFile(const OUString& aFileName, std::string& aContent) std::ifstream aFile(aOFileName.getStr()); - OStringBuffer aErrorMsg("Could not open csv file: "); - aErrorMsg.append(aOFileName); + OString aErrorMsg = "Could not open csv file: " + aOFileName; CPPUNIT_ASSERT_MESSAGE(aErrorMsg.getStr(), aFile); std::ostringstream aOStream; aOStream << aFile.rdbuf(); diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index cde984532dca..9f2f8854286a 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -708,17 +708,16 @@ void ScFiltersTest::testCachedFormulaResultsODS() { for(SCROW nRow = 0; nRow < 2; ++nRow) { - OUStringBuffer aIsErrorFormula("=ISERROR("); - aIsErrorFormula.append(static_cast<char>('A'+nCol)).append(OUString::number(nRow)); - aIsErrorFormula.append(")"); - OUString aFormula = aIsErrorFormula.makeStringAndClear(); + OUString aFormula = "=ISERROR(" + + OUStringLiteral1(static_cast<char>('A'+nCol)) + OUString::number(nRow) + + ")"; rDoc.SetString(nCol, nRow + 2, 2, aFormula); CPPUNIT_ASSERT_EQUAL_MESSAGE(OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8).getStr(), OUString("TRUE"), rDoc.GetString(nCol, nRow +2, 2)); - OUStringBuffer aIsTextFormula("=ISTEXT("); - aIsTextFormula.append(static_cast<char>('A'+nCol)).append(OUString::number(nRow)); - aIsTextFormula.append(")"); - rDoc.SetString(nCol, nRow + 4, 2, aIsTextFormula.makeStringAndClear()); + OUString aIsTextFormula = "=ISTEXT(" + + OUString::number(static_cast<char>('A'+nCol))+ OUString::number(nRow) + + ")"; + rDoc.SetString(nCol, nRow + 4, 2, aIsTextFormula); CPPUNIT_ASSERT_EQUAL(OUString("FALSE"), rDoc.GetString(nCol, nRow +4, 2)); } } @@ -1285,9 +1284,8 @@ void checkValiditationEntries( const ValDataTestParams& rVDTParams ) sal_Int32 nCol( static_cast<sal_Int32>(rVDTParams.aPosition.Col()) ); sal_Int32 nRow( static_cast<sal_Int32>(rVDTParams.aPosition.Row()) ); sal_Int32 nTab( static_cast<sal_Int32>(rVDTParams.aPosition.Tab()) ); - OStringBuffer sMsg("Data Validation Entry with base-cell-address: ("); - sMsg.append(nCol).append(",").append(nRow).append(",").append(nTab).append(") "); - OString aMsgPrefix = sMsg.makeStringAndClear(); + OString aMsgPrefix = "Data Validation Entry with base-cell-address: (" + + OString::number(nCol) + "," + OString::number(nRow) + "," + OString::number(nTab) + ") "; OString aMsg = aMsgPrefix + "did not get imported at all."; CPPUNIT_ASSERT_MESSAGE(aMsg.getStr(), pValDataTest); @@ -1323,11 +1321,13 @@ void checkCellValidity( const ScAddress& rValBaseAddr, const ScRange& rRange, co sal_Int32 nCol = static_cast<sal_Int32>(i); sal_Int32 nRow = static_cast<sal_Int32>(j); sal_Int32 nTab32 = static_cast<sal_Int32>(nTab); - OStringBuffer sMsg("\nData validation entry base-cell-address: ("); - sMsg.append( static_cast<sal_Int32>(nBCol) ).append(","); - sMsg.append( static_cast<sal_Int32>(nBRow) ).append(","); - sMsg.append( nTab32 ).append(")\n"); - sMsg.append("Cell: (").append(nCol).append(",").append(nRow).append(",").append(nTab32).append(")"); + OString sMsg = "\nData validation entry base-cell-address: (" + + OString::number( static_cast<sal_Int32>(nBCol) ) + "," + + OString::number( static_cast<sal_Int32>(nBRow) ) + "," + + OString::number( nTab32 ) + ")\n" + "Cell: (" + OString::number(nCol) + "," + + OString::number(nRow) + "," + + OString::number(nTab32) + ")"; sal_uInt32 expectedKey(pValData->GetKey()); sal_uInt32 actualKey(0); if(pValDataTest) diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index d7fff9711e0e..5068656aab39 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -843,13 +843,12 @@ void ScDocument::UpdateExternalRefLinks(weld::Window* pWin) INetURLObject aUrl(aFile,INetURLObject::EncodeMechanism::WasEncoded); aFile = aUrl.GetMainURL(INetURLObject::DecodeMechanism::Unambiguous); - OUStringBuffer aBuf; - aBuf.append(ScResId(SCSTR_EXTDOC_NOT_LOADED)); - aBuf.append("\n\n"); - aBuf.append(aFile); + OUString sMessage = ScResId(SCSTR_EXTDOC_NOT_LOADED) + + "\n\n" + + aFile; std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin, VclMessageType::Warning, VclButtonsType::Ok, - aBuf.makeStringAndClear())); + sMessage)); xBox->run(); } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index e94d0b4f0db5..cc961b20b1a4 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -408,10 +408,7 @@ void ScDocument::CreateValidTabName(OUString& rName) const for ( SCTAB i = static_cast<SCTAB>(maTabs.size())+1; !bOk ; i++ ) { - OUStringBuffer aBuf; - aBuf.append(aStrTable); - aBuf.append(static_cast<sal_Int32>(i)); - rName = aBuf.makeStringAndClear(); + rName = aStrTable + OUString::number(static_cast<sal_Int32>(i)); if (bPrefix) bOk = ValidNewTabName( rName ); else diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 558d4bde8d4b..60b423aec6c6 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1507,10 +1507,7 @@ OUString lcl_GetDataFieldName( const OUString& rSourceName, sal_Int16 eFunc ) if (!pStrId) return OUString(); - OUStringBuffer aRet(ScResId(pStrId)); - aRet.append(" - "); - aRet.append(rSourceName); - return aRet.makeStringAndClear(); + return ScResId(pStrId) + " - " + rSourceName; } } diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx index bdd30ad3dfe2..5a3d21c69c33 100644 --- a/sc/source/core/tool/chartarr.cxx +++ b/sc/source/core/tool/chartarr.cxx @@ -374,14 +374,11 @@ std::unique_ptr<ScMemChart> ScChartArray::CreateMemChartMulti() if (aString.isEmpty()) { - OUStringBuffer aBuf(ScResId(STR_ROW)); - aBuf.append(' '); if ( pPos ) nPosRow = pPos->Row() + 1; else nPosRow++; - aBuf.append(static_cast<sal_Int32>(nPosRow)); - aString = aBuf.makeStringAndClear(); + aString = ScResId(STR_ROW) + " " + OUString::number(static_cast<sal_Int32>(nPosRow)); } pMemChart->SetRowText( nRow, aString); } diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx index 5717f297c38d..79f164f87a5e 100644 --- a/sc/source/core/tool/chartlis.cxx +++ b/sc/source/core/tool/chartlis.cxx @@ -420,9 +420,7 @@ OUString ScChartListenerCollection::getUniqueName(const OUString& rPrefix) const { for (sal_Int32 nNum = 1; nNum < 10000; ++nNum) // arbitrary limit to prevent infinite loop. { - OUStringBuffer aBuf(rPrefix); - aBuf.append(nNum); - OUString aTestName = aBuf.makeStringAndClear(); + OUString aTestName = rPrefix + OUString::number(nNum); if (m_Listeners.find(aTestName) == m_Listeners.end()) return aTestName; } diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx index d7f92341a634..991c25615def 100644 --- a/sc/source/core/tool/chgtrack.cxx +++ b/sc/source/core/tool/chgtrack.cxx @@ -1197,9 +1197,7 @@ void ScChangeActionMove::GetDescription( aRsc = aRsc.replaceAt(nPos, 2, aTmpStr); } - OUStringBuffer aBuf(rStr); // append to the original string. - aBuf.append(aRsc); - rStr = aBuf.makeStringAndClear(); + rStr += aRsc; // append to the original string. } void ScChangeActionMove::GetRefString( @@ -1470,9 +1468,7 @@ void ScChangeActionContent::GetDescription( aRsc = aRsc.replaceAt(nPos, 2, aTmpStr); } - OUStringBuffer aBuf(rStr); // append to the original string. - aBuf.append(aRsc); - rStr = aBuf.makeStringAndClear(); + rStr += aRsc; // append to the original string. } void ScChangeActionContent::GetRefString( @@ -1502,11 +1498,7 @@ void ScChangeActionContent::GetRefString( if ( IsDeletedIn() ) { // Insert the parentheses. - OUStringBuffer aBuf; - aBuf.append('('); - aBuf.append(rStr); - aBuf.append(')'); - rStr = aBuf.makeStringAndClear(); + rStr = "(" + rStr + ")"; } } else diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 2f17b222aaa1..df8821b84531 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2323,16 +2323,14 @@ void ScInterpreter::ScCell() else if( aInfoType == "COORD" ) { // address, lotus 1-2-3 formatted: $TABLE:$COL$ROW // Yes, passing tab as col is intentional! - OUStringBuffer aFuncResult; - OUString aCellStr = - ScAddress( static_cast<SCCOL>(aCellPos.Tab()), 0, 0 ).Format( - (ScRefFlags::COL_ABS|ScRefFlags::COL_VALID), nullptr, pDok->GetAddressConvention() ); - aFuncResult.append(aCellStr); - aFuncResult.append(':'); - aCellStr = aCellPos.Format((ScRefFlags::COL_ABS|ScRefFlags::COL_VALID|ScRefFlags::ROW_ABS|ScRefFlags::ROW_VALID), + OUString aCellStr1 = + ScAddress( static_cast<SCCOL>(aCellPos.Tab()), 0, 0 ).Format( + (ScRefFlags::COL_ABS|ScRefFlags::COL_VALID), nullptr, pDok->GetAddressConvention() ); + OUString aCellStr2 = + aCellPos.Format((ScRefFlags::COL_ABS|ScRefFlags::COL_VALID|ScRefFlags::ROW_ABS|ScRefFlags::ROW_VALID), nullptr, pDok->GetAddressConvention()); - aFuncResult.append(aCellStr); - PushString( aFuncResult.makeStringAndClear() ); + OUString aFuncResult = aCellStr1 + ":" + aCellStr2; + PushString( aFuncResult ); } // *** CELL PROPERTIES *** @@ -2493,12 +2491,8 @@ void ScInterpreter::ScCellExternal() return; } - OUStringBuffer aBuf; - aBuf.append('\''); - aBuf.append(*p); - aBuf.append("'#$"); - aBuf.append(aTabName); - PushString(aBuf.makeStringAndClear()); + OUString aBuf = "'" + *p + "'#$" + aTabName; + PushString(aBuf); } else if ( aInfoType == "CONTENTS" ) { diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index d2dedf012c46..f39bab0e63bf 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -1168,14 +1168,14 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP XML_showRowStripes, "0", XML_showColStripes, "0", XML_showLastColumn, "1"); - OUStringBuffer aBuf("../pivotCache/pivotCacheDefinition"); - aBuf.append(nCacheId); - aBuf.append(".xml"); + OUString aBuf = "../pivotCache/pivotCacheDefinition" + + OUString::number(nCacheId) + + ".xml"; rStrm.addRelation( pPivotStrm->getOutputStream(), CREATE_OFFICEDOC_RELATION_TYPE("pivotCacheDefinition"), - aBuf.makeStringAndClear()); + aBuf); pPivotStrm->endElement(XML_pivotTableDefinition); } diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index 93c6d0ec31b6..2a531a70da61 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -635,13 +635,12 @@ static const char maCFStyleNamePrefix2[] = "ConditionalStyle_"; /// Prefix for c OUString XclTools::GetCondFormatStyleName( SCTAB nScTab, sal_Int32 nFormat, sal_uInt16 nCondition ) { - OUStringBuffer aBuf(maCFStyleNamePrefix1); - aBuf.append(static_cast<sal_Int32>(nScTab+1)); - aBuf.append('_'); - aBuf.append(static_cast<sal_Int32>(nFormat+1)); - aBuf.append('_'); - aBuf.append(static_cast<sal_Int32>(nCondition+1)); - return aBuf.makeStringAndClear(); + return maCFStyleNamePrefix1 + + OUString::number(static_cast<sal_Int32>(nScTab+1)) + + "_" + + OUString::number(static_cast<sal_Int32>(nFormat+1)) + + "_" + + OUString::number(static_cast<sal_Int32>(nCondition+1)); } bool XclTools::IsCondFormatStyleName( const OUString& rStyleName ) diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx index a02b9533247a..89904a27d49c 100644 --- a/sc/source/filter/qpro/qproform.cxx +++ b/sc/source/filter/qpro/qproform.cxx @@ -81,9 +81,8 @@ void QProToSc::DoFunc( DefTokenId eOc, sal_uInt16 nArgs, const sal_Char* pExtStr bAddIn = true; if( pExtString ) { - OStringBuffer s("QPRO_"); - s.append(pExtString); - nPush = aPool.Store(eOc, OStringToOUString(s.makeStringAndClear(), maIn.GetStreamCharSet())); + OString s = OStringLiteral("QPRO_") + pExtString; + nPush = aPool.Store(eOc, OStringToOUString(s, maIn.GetStreamCharSet())); aPool << nPush; } else diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx index e494b2486c6f..937ac271db26 100644 --- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx +++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx @@ -103,10 +103,8 @@ void writeSort(ScXMLExport& mrExport, const ScSortParam& aParam, const ScRange& if (aParam.bUserDef) { - OUStringBuffer aBuf; - aBuf.append(SC_USERLIST); - aBuf.append(static_cast<sal_Int32>(aParam.nUserIndex)); - mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf.makeStringAndClear()); + OUString aBuf = SC_USERLIST + OUString::number(static_cast<sal_Int32>(aParam.nUserIndex)); + mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf); } else { @@ -198,11 +196,10 @@ public: return; // name - OUStringBuffer aBuf; - aBuf.append(STR_DB_LOCAL_NONAME); - aBuf.append(static_cast<sal_Int32>(r.first)); // appended number equals sheet index on import. + OUString aBuf = STR_DB_LOCAL_NONAME + + OUString::number(static_cast<sal_Int32>(r.first)); // appended number equals sheet index on import. - write(aBuf.makeStringAndClear(), *r.second); + write(aBuf, *r.second); } void operator() (const ScDBData& rData) @@ -639,10 +636,8 @@ private: if (aParam.bUserDef) { - OUStringBuffer aBuf; - aBuf.append(SC_USERLIST); - aBuf.append(static_cast<sal_Int32>(aParam.nUserIndex)); - mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf.makeStringAndClear()); + OUString aBuf = SC_USERLIST + OUString::number(static_cast<sal_Int32>(aParam.nUserIndex)); + mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DATA_TYPE, aBuf); } SvXMLElementExport aElemSGs(mrExport, XML_NAMESPACE_TABLE, XML_SORT_GROUPS, true, true); } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 9b504788465c..6d91fae22f76 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -4884,14 +4884,12 @@ void ScXMLExport::WriteExternalRefCaches() { if (nRow > 1) { - OUStringBuffer aVal; - aVal.append(nRow); - AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal.makeStringAndClear()); + OUString aVal = OUString::number(nRow); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal); } SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true); - OUStringBuffer aVal; - aVal.append(static_cast<sal_Int32>(nMaxColsUsed)); - AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear()); + OUString aVal = OUString::number(static_cast<sal_Int32>(nMaxColsUsed)); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal); SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true); } } @@ -4902,14 +4900,12 @@ void ScXMLExport::WriteExternalRefCaches() { if (nRowGap > 2) { - OUStringBuffer aVal; - aVal.append(static_cast<sal_Int32>(nRowGap-1)); - AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal.makeStringAndClear()); + OUString aVal = OUString::number(static_cast<sal_Int32>(nRowGap-1)); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_ROWS_REPEATED, aVal); } SvXMLElementExport aElemRow(*this, XML_NAMESPACE_TABLE, XML_TABLE_ROW, true, true); - OUStringBuffer aVal; - aVal.append(static_cast<sal_Int32>(nMaxColsUsed)); - AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear()); + OUString aVal = OUString::number(static_cast<sal_Int32>(nMaxColsUsed)); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal); SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true); } } @@ -4927,9 +4923,8 @@ void ScXMLExport::WriteExternalRefCaches() { if (nCol > 1) { - OUStringBuffer aVal; - aVal.append(static_cast<sal_Int32>(nCol)); - AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear()); + OUString aVal = OUString::number(static_cast<sal_Int32>(nCol)); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal); } SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true); } @@ -4941,9 +4936,8 @@ void ScXMLExport::WriteExternalRefCaches() { if (nColGap > 2) { - OUStringBuffer aVal; - aVal.append(static_cast<sal_Int32>(nColGap-1)); - AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal.makeStringAndClear()); + OUString aVal = OUString::number(static_cast<sal_Int32>(nColGap-1)); + AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aVal); } SvXMLElementExport aElemCell(*this, XML_NAMESPACE_TABLE, XML_TABLE_CELL, true, true); } diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 111c57d9f105..6d897489bfcc 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -1551,11 +1551,8 @@ static OUString lcl_Calculate( const OUString& rFormula, ScDocument* pDoc, const if ( pCalc->GetCode()->GetCodeLen() <= 1 ) { // ==1: Single one is as a Parameter always a Range // ==0: It might be one, if ... - OUStringBuffer aBraced; - aBraced.append('('); - aBraced.append(rFormula); - aBraced.append(')'); - pCalc.reset( new ScSimpleFormulaCalculator( pDoc, rPos, aBraced.makeStringAndClear(), false ) ); + OUString aBraced = "(" + rFormula + ")"; + pCalc.reset( new ScSimpleFormulaCalculator( pDoc, rPos, aBraced, false ) ); } else bColRowName = false; diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index ebfe92e781f8..4ff8735e0950 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -2028,11 +2028,7 @@ namespace { OUString createLocalRangeName(const OUString& rName, const OUString& rTableName) { - OUStringBuffer aString (rName); - aString.append(" ("); - aString.append(rTableName); - aString.append(")"); - return aString.makeStringAndClear(); + return rName + " (" + rTableName + ")"; } } diff --git a/sc/source/ui/attrdlg/scabstdlg.cxx b/sc/source/ui/attrdlg/scabstdlg.cxx index 1b5e0ddde237..3d74406e0f4a 100644 --- a/sc/source/ui/attrdlg/scabstdlg.cxx +++ b/sc/source/ui/attrdlg/scabstdlg.cxx @@ -41,10 +41,9 @@ ScAbstractDialogFactory* ScAbstractDialogFactory::Create() #ifndef DISABLE_DYNLOADING static ::osl::Module aDialogLibrary; - OUStringBuffer aStrBuf; - aStrBuf.append( SVLIBRARY("scui") ); + OUString aStrBuf = SVLIBRARY("scui"); - if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, aStrBuf.makeStringAndClear(), + if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, aStrBuf, SAL_LOADMODULE_GLOBAL | SAL_LOADMODULE_LAZY ) ) fp = reinterpret_cast<ScAbstractDialogFactory* (SAL_CALL*)()>( aDialogLibrary.getFunctionSymbol( "ScCreateDialogFactory" )); diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx index e53f0cfc43a7..8ab7a954f440 100644 --- a/sc/source/ui/dbgui/pfiltdlg.cxx +++ b/sc/source/ui/dbgui/pfiltdlg.cxx @@ -126,11 +126,8 @@ void ScPivotFilterDlg::Init( const SfxItemSet& rArgSet ) theDbName = pDBData->GetName(); } - OUStringBuffer aBuf; - aBuf.append(" ("); - aBuf.append(theDbName); - aBuf.append(')'); - m_xFtDbArea->set_label(aBuf.makeStringAndClear()); + OUString sLabel = " (" + theDbName + ")"; + m_xFtDbArea->set_label(sLabel); } else { diff --git a/sc/source/ui/docshell/documentlinkmgr.cxx b/sc/source/ui/docshell/documentlinkmgr.cxx index 479d1b0e56b2..cb3467c8bb69 100644 --- a/sc/source/ui/docshell/documentlinkmgr.cxx +++ b/sc/source/ui/docshell/documentlinkmgr.cxx @@ -193,18 +193,18 @@ bool DocumentLinkManager::updateDdeOrOleOrWebServiceLinks(weld::Window* pWin) const OUString& aElem = pDdeLink->GetItem(); const OUString& aType = pDdeLink->GetAppl(); - OUStringBuffer aBuf; - aBuf.append(ScResId(SCSTR_DDEDOC_NOT_LOADED)); - aBuf.append("\n\n"); - aBuf.append("Source : "); - aBuf.append(aFile); - aBuf.append("\nElement : "); - aBuf.append(aElem); - aBuf.append("\nType : "); - aBuf.append(aType); + OUString sMessage = + ScResId(SCSTR_DDEDOC_NOT_LOADED) + + "\n\n" + "Source : " + + aFile + + "\nElement : " + + aElem + + "\nType : " + + aType; std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pWin, VclMessageType::Warning, VclButtonsType::Ok, - aBuf.makeStringAndClear())); + sMessage)); xBox->run(); } } diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx index b87662fb98d1..d71351840b85 100644 --- a/sc/source/ui/formdlg/formula.cxx +++ b/sc/source/ui/formdlg/formula.cxx @@ -309,12 +309,9 @@ bool ScFormulaDlg::calculateValue( const OUString& rStrExp, OUString& rStrResult if ( pFCell->GetCode()->GetCodeLen() <= 1 ) { // ==1: area // ==0: would be an area if... - OUStringBuffer aBraced; - aBraced.append('('); - aBraced.append(rStrExp); - aBraced.append(')'); + OUString aBraced = "(" + rStrExp + ")"; pFCell.reset( new ScSimpleFormulaCalculator( - m_pDoc, m_CursorPos, aBraced.makeStringAndClear(), bMatrixFormula)); + m_pDoc, m_CursorPos, aBraced, bMatrixFormula)); pFCell->SetLimitString(true); } else diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx index 1e0fed27c45f..44f0ef4d7e00 100644 --- a/sc/source/ui/miscdlgs/datafdlg.cxx +++ b/sc/source/ui/miscdlgs/datafdlg.cxx @@ -213,11 +213,11 @@ void ScDataFormDlg::FillCtrls() if (nCurrentRow <= nEndRow) { - OUStringBuffer aBuf; - aBuf.append(static_cast<sal_Int32>(nCurrentRow - nStartRow)); - aBuf.append(" / "); - aBuf.append(static_cast<sal_Int32>(nEndRow - nStartRow)); - m_xFixedText->set_label(aBuf.makeStringAndClear()); + OUString sLabel = + OUString::number(static_cast<sal_Int32>(nCurrentRow - nStartRow)) + + " / " + + OUString::number(static_cast<sal_Int32>(nEndRow - nStartRow)); + m_xFixedText->set_label(sLabel); } else m_xFixedText->set_label(sNewRecord); diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index c26808a26ece..8d120a9194f5 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -863,11 +863,7 @@ namespace { OUString createLocalRangeName(const OUString& rName, const OUString& rTableName) { - OUStringBuffer aString (rName); - aString.append(" ("); - aString.append(rTableName); - aString.append(")"); - return aString.makeStringAndClear(); + return rName + " (" + rTableName + ")"; } } diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx index 0374f4f14ff0..0e3cfde39e24 100644 --- a/sc/source/ui/view/viewfun6.cxx +++ b/sc/source/ui/view/viewfun6.cxx @@ -180,16 +180,15 @@ void ScViewFunc::DetectiveMarkPred() if (pPath && ScRefTokenHelper::getRangeFromToken(aRange, p, aCurPos, true)) { OUString aTabName = p->GetString().getString(); - OUStringBuffer aBuf; - aBuf.append(*pPath); - aBuf.append('#'); - aBuf.append(aTabName); - aBuf.append('.'); - OUString aRangeStr(aRange.Format(ScRefFlags::VALID)); - aBuf.append(aRangeStr); - - ScGlobal::OpenURL(aBuf.makeStringAndClear(), OUString()); + OUString sUrl = + *pPath + + "#" + + aTabName + + "." + + aRangeStr; + + ScGlobal::OpenURL(sUrl, OUString()); } return; } diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 15f1e1732254..28b41219325a 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -327,11 +327,8 @@ protected: uno::Reference< drawing::XShapes > xShapes(xDrawPage, uno::UNO_QUERY_THROW); OUString aString = XShapeDumper::dump(xShapes); - OStringBuffer aFileNameBuf( OUStringToOString( rShapesDumpFileNameBase, RTL_TEXTENCODING_UTF8 ) ); - aFileNameBuf.append(i); - aFileNameBuf.append(".xml"); - - OString aFileName = aFileNameBuf.makeStringAndClear(); + OString aFileName = OUStringToOString( rShapesDumpFileNameBase, RTL_TEXTENCODING_UTF8 ) + + OString::number(i) + ".xml"; if ( bCreate ) { diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 12691c5175a8..077023df9dc7 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -79,9 +79,7 @@ void SdPage::SetPresentationLayout(const OUString& rLayoutName, |* Name of the layout of the page \********************************************************************/ OUString aOldLayoutName(maLayoutName); // memorize - OUStringBuffer aBuf(rLayoutName); - aBuf.append(SD_LT_SEPARATOR).append(STR_LAYOUT_OUTLINE); - maLayoutName = aBuf.makeStringAndClear(); + maLayoutName = rLayoutName + SD_LT_SEPARATOR STR_LAYOUT_OUTLINE; /********************************************************************* |* search and replace master page if necessary diff --git a/sd/source/ui/remotecontrol/Communicator.cxx b/sd/source/ui/remotecontrol/Communicator.cxx index 81a5cf04c6ef..b93112d9542c 100644 --- a/sd/source/ui/remotecontrol/Communicator.cxx +++ b/sd/source/ui/remotecontrol/Communicator.cxx @@ -58,10 +58,9 @@ void Communicator::execute() pTransmitter->addMessage( "LO_SERVER_SERVER_PAIRED\n\n", Transmitter::PRIORITY_HIGH ); - OStringBuffer aServerInformationBuffer; - aServerInformationBuffer.append( "LO_SERVER_INFO\n" LIBO_VERSION_DOTTED "\n\n" ); + OString aServerInformation = "LO_SERVER_INFO\n" LIBO_VERSION_DOTTED "\n\n"; - pTransmitter->addMessage( aServerInformationBuffer.makeStringAndClear(), Transmitter::PRIORITY_HIGH ); + pTransmitter->addMessage( aServerInformation, Transmitter::PRIORITY_HIGH ); Receiver aReceiver( pTransmitter.get() ); try { diff --git a/sd/source/ui/remotecontrol/ImagePreparer.cxx b/sd/source/ui/remotecontrol/ImagePreparer.cxx index a3cdc74d4ffa..786effb8b8eb 100644 --- a/sd/source/ui/remotecontrol/ImagePreparer.cxx +++ b/sd/source/ui/remotecontrol/ImagePreparer.cxx @@ -177,18 +177,15 @@ void ImagePreparer::sendNotes( sal_uInt32 aSlideNumber ) return; // Start the writing - OStringBuffer aBuffer; - - aBuffer.append( "slide_notes\n" ); - - aBuffer.append( static_cast<sal_Int32>(aSlideNumber) ); - aBuffer.append( "\n" ); - - aBuffer.append( "<html><body>" ); - aBuffer.append( aNotes ); - aBuffer.append( "</body></html>" ); - aBuffer.append( "\n\n" ); - pTransmitter->addMessage( aBuffer.makeStringAndClear(), + OString aBuffer = + "slide_notes\n" + + OString::number( static_cast<sal_Int32>(aSlideNumber) ) + + "\n" + "<html><body>" + + aNotes + + "</body></html>" + "\n\n"; + pTransmitter->addMessage( aBuffer, Transmitter::PRIORITY_LOW ); } diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx index 290d35cb897f..3c9527b175f4 100644 --- a/sd/source/ui/remotecontrol/Listener.cxx +++ b/sd/source/ui/remotecontrol/Listener.cxx @@ -43,12 +43,11 @@ void Listener::init( const css::uno::Reference< css::presentation::XSlideShowCon sal_Int32 aSlides = aController->getSlideCount(); sal_Int32 aCurrentSlide = aController->getCurrentSlideIndex(); - OStringBuffer aBuffer; - aBuffer.append( "slideshow_started\n" ) - .append( OString::number( aSlides ) ).append("\n") - .append( OString::number( aCurrentSlide ) ).append( "\n\n" ); + OString aBuffer = "slideshow_started\n" + + OString::number( aSlides ) + "\n" + + OString::number( aCurrentSlide ) + "\n\n"; - pTransmitter->addMessage( aBuffer.makeStringAndClear(), + pTransmitter->addMessage( aBuffer, Transmitter::PRIORITY_HIGH ); { @@ -98,13 +97,13 @@ void SAL_CALL Listener::slideTransitionStarted() { sal_Int32 aSlide = mController->getCurrentSlideIndex(); - OStringBuffer aBuilder( "slide_updated\n" ); - aBuilder.append( OString::number( aSlide ) ); - aBuilder.append( "\n\n" ); + OString aBuilder = "slide_updated\n" + + OString::number( aSlide ) + + "\n\n"; if ( pTransmitter ) { - pTransmitter->addMessage( aBuilder.makeStringAndClear(), + pTransmitter->addMessage( aBuilder, Transmitter::PRIORITY_HIGH ); } } diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index 872c3a71458e..6c728052b2cb 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -1465,14 +1465,13 @@ uno::Any SAL_CALL SdUnoEventsAccess::getByName( const OUString& aName ) const OUString aModulName = aMacro.getToken(0, '.', nIdx); const OUString aLibName = aMacro.getToken(0, '.', nIdx); - OUStringBuffer sBuffer; - sBuffer.append( aLibName ); - sBuffer.append( '.' ); - sBuffer.append( aModulName ); - sBuffer.append( '.' ); - sBuffer.append( aMacroName ); - - aAny <<= sBuffer.makeStringAndClear(); + OUString sBuffer = aLibName + + "." + + aModulName + + "." + + aMacroName; + + aAny <<= sBuffer; pProperties->Name = gaStrMacroName; pProperties->Handle = -1; pProperties->Value = aAny; diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx index 0d6bc61f2dab..ca082fe01c11 100644 --- a/sd/source/ui/unoidl/unopage.cxx +++ b/sd/source/ui/unoidl/unopage.cxx @@ -2103,11 +2103,8 @@ OUString getPageApiName( SdPage const * pPage ) if( aPageName.isEmpty() ) { - OUStringBuffer sBuffer; - sBuffer.append( sEmptyPageName ); const sal_Int32 nPageNum = ( ( pPage->GetPageNum() - 1 ) >> 1 ) + 1; - sBuffer.append( nPageNum ); - aPageName = sBuffer.makeStringAndClear(); + aPageName = sEmptyPageName + OUString::number( nPageNum ); } } @@ -2165,11 +2162,7 @@ OUString getUiNameFromPageApiNameImpl( const OUString& rApiName ) if( nPageNumber != -1) { - OUStringBuffer sBuffer; - sBuffer.append( SdResId(STR_PAGE) ); - sBuffer.append( ' ' ); - sBuffer.append( aNumber ); - return sBuffer.makeStringAndClear(); + return SdResId(STR_PAGE) + " " + aNumber; } } diff --git a/sdext/source/minimizer/pppoptimizerdialog.cxx b/sdext/source/minimizer/pppoptimizerdialog.cxx index 66efb3e29824..1bd04455a258 100644 --- a/sdext/source/minimizer/pppoptimizerdialog.cxx +++ b/sdext/source/minimizer/pppoptimizerdialog.cxx @@ -112,12 +112,11 @@ void SAL_CALL PPPOptimizerDialog::dispatch( const URL& rURL, if ( nFileSizeSource && nFileSizeDest ) { - OUStringBuffer sBuf( "Your Presentation has been minimized from:" ); - sBuf.append( OUString::number( nFileSizeSource >> 10 ) ); - sBuf.append( "KB to " ); - sBuf.append( OUString::number( nFileSizeDest >> 10 ) ); - sBuf.append( "KB." ); - OUString sResult( sBuf.makeStringAndClear() ); + OUString sResult = "Your Presentation has been minimized from:" + + OUString::number( nFileSizeSource >> 10 ) + + "KB to " + + OUString::number( nFileSizeDest >> 10 ) + + "KB."; SAL_INFO("sdext.minimizer", sResult ); } } diff --git a/sdext/source/pdfimport/odf/odfemitter.cxx b/sdext/source/pdfimport/odf/odfemitter.cxx index 78a38e42502f..a46d73ac9346 100644 --- a/sdext/source/pdfimport/odf/odfemitter.cxx +++ b/sdext/source/pdfimport/odf/odfemitter.cxx @@ -56,9 +56,8 @@ OdfEmitter::OdfEmitter( const uno::Reference<io::XOutputStream>& xOutput ) : OSL_PRECOND(m_xOutput.is(), "OdfEmitter(): invalid output stream"); m_aLineFeed[0] = '\n'; - OUStringBuffer aElement; - aElement.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); - write(aElement.makeStringAndClear()); + OUString aElement = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; + write(aElement); } void OdfEmitter::beginTag( const char* pTag, const PropertyMap& rProperties ) @@ -73,12 +72,12 @@ void OdfEmitter::beginTag( const char* pTag, const PropertyMap& rProperties ) std::vector<OUString> aAttributes; for( const auto& rCurr : rProperties ) { - OUStringBuffer aAttribute; - aAttribute.append(rCurr.first); - aAttribute.append("=\""); - aAttribute.append(rCurr.second); - aAttribute.append("\" "); - aAttributes.push_back(aAttribute.makeStringAndClear()); + OUString aAttribute = + rCurr.first + + "=\"" + + rCurr.second + + "\" "; + aAttributes.push_back(aAttribute); } // since the hash map's sorting is undefined (and varies across diff --git a/sdext/source/pdfimport/test/pdfunzip.cxx b/sdext/source/pdfimport/test/pdfunzip.cxx index a014fa4ccae0..e2a6602ad74a 100644 --- a/sdext/source/pdfimport/test/pdfunzip.cxx +++ b/sdext/source/pdfimport/test/pdfunzip.cxx @@ -263,11 +263,11 @@ static int write_addStreamArray( const char* pOutFile, PDFArray* pStreams, PDFFi PDFObject* pObject = pPDFFile->findObject( pStreamRef->m_nNumber, pStreamRef->m_nGeneration ); if( pObject ) { - OStringBuffer aOutStream( pOutFile ); - aOutStream.append( "_stream_" ); - aOutStream.append( sal_Int32(pStreamRef->m_nNumber) ); - aOutStream.append( "_" ); - aOutStream.append( sal_Int32(pStreamRef->m_nGeneration) ); + OString aOutStream = pOutFile + + OStringLiteral("_stream_") + + OString::number( sal_Int32(pStreamRef->m_nNumber) ) + + "_" + + OString::number( sal_Int32(pStreamRef->m_nGeneration) ); FileEmitContext aContext( aOutStream.getStr(), pInFile, pPDFFile ); aContext.m_bDecrypt = pPDFFile->isEncrypted(); pObject->writeStream( aContext, pPDFFile ); @@ -406,11 +406,11 @@ static int write_objects( const char* i_pInFile, const char* i_pOutFile, PDFFile continue; } - OStringBuffer aOutStream( i_pOutFile ); - aOutStream.append( "_stream_" ); - aOutStream.append( nObject ); - aOutStream.append( "_" ); - aOutStream.append( nGeneration ); + OString aOutStream = i_pOutFile + + OStringLiteral("_stream_") + + OString::number( nObject ) + + "_" + + OString::number( nGeneration ); FileEmitContext aContext( aOutStream.getStr(), i_pInFile, i_pPDFFile ); aContext.m_bDecrypt = i_pPDFFile->isEncrypted(); pStream->writeStream( aContext, i_pPDFFile ); diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 64977135ba3a..30495736f821 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -1377,17 +1377,14 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) if ( xSystemShell.is() && !sTemplRepoURL.isEmpty() ) { - OUStringBuffer aURLBuf( sTemplRepoURL ); - aURLBuf.append("?lang="); - // read locale from configuration OUString sLocale(officecfg::Setup::L10N::ooLocale::get()); if (sLocale.isEmpty()) sLocale = "en-US"; - aURLBuf.append( sLocale ); + OUString aURLBuf = sTemplRepoURL + "?lang=" + sLocale; xSystemShell->execute( - aURLBuf.makeStringAndClear(), + aURLBuf, OUString(), css::system::SystemShellExecuteFlags::URIS_ONLY ); } diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 6c70975db7a1..069d1b1fe47c 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -1230,8 +1230,7 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, uno::Sequence<b continue; } - OStringBuffer aDbg("Unknown item detected: "); - aDbg.append(static_cast<sal_Int32>(nId)); + OString aDbg = "Unknown item detected: " + OString::number(static_cast<sal_Int32>(nId)); DBG_ASSERT(nArg<nFormalArgs, aDbg.getStr()); } } diff --git a/sfx2/source/control/thumbnailviewacc.cxx b/sfx2/source/control/thumbnailviewacc.cxx index bc1b3b711592..ccebccacbf81 100644 --- a/sfx2/source/control/thumbnailviewacc.cxx +++ b/sfx2/source/control/thumbnailviewacc.cxx @@ -1134,9 +1134,7 @@ OUString SAL_CALL ThumbnailViewItemAcc::getAccessibleName() if( aRet.isEmpty() ) { - OUStringBuffer aBuffer("Item "); - aBuffer.append(static_cast<sal_Int32>(mpParent->mnId)); - aRet = aBuffer.makeStringAndClear(); + aRet = "Item " + OUString::number(static_cast<sal_Int32>(mpParent->mnId)); } } diff --git a/sfx2/source/doc/Metadatable.cxx b/sfx2/source/doc/Metadatable.cxx index ea221535863c..13d3021bc95f 100644 --- a/sfx2/source/doc/Metadatable.cxx +++ b/sfx2/source/doc/Metadatable.cxx @@ -1527,11 +1527,7 @@ OUString SAL_CALL MetadatableMixin::getLocalName() ensureMetadataReference(); // N.B.: side effect! mdref = getMetadataReference(); } - OUStringBuffer buf; - buf.append(mdref.First); - buf.append('#'); - buf.append(mdref.Second); - return buf.makeStringAndClear(); + return mdref.First + "#" + mdref.Second; } OUString SAL_CALL MetadatableMixin::getNamespace() diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index 0b47a818ef11..5b9dd2018ae7 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -279,12 +279,11 @@ bool SfxNotebookBar::IsActive() return false; - OUStringBuffer aPath("org.openoffice.Office.UI.ToolbarMode/Applications/"); - aPath.append( appName ); + OUString aPath = "org.openoffice.Office.UI.ToolbarMode/Applications/" + appName; const utl::OConfigurationTreeRoot aAppNode( ::comphelper::getProcessComponentContext(), - aPath.makeStringAndClear(), + aPath, false); if ( !aAppNode.isValid() ) return false; @@ -378,8 +377,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, { RemoveListeners(pSysWindow); - OUStringBuffer aBuf(rUIFile); - aBuf.append( sFile ); + OUString aBuf = rUIFile + sFile; //Addons For Notebookbar std::vector<Image> aImageValues; @@ -390,7 +388,7 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow, aNotebookBarAddonsItem.aImageValues = aImageValues; // setup if necessary - pSysWindow->SetNotebookBar(aBuf.makeStringAndClear(), xFrame, aNotebookBarAddonsItem , bReloadNotebookbar); + pSysWindow->SetNotebookBar(aBuf, xFrame, aNotebookBarAddonsItem , bReloadNotebookbar); pNotebookBar = pSysWindow->GetNotebookBar(); pNotebookBar->Show(); pNotebookBar->GetParent()->Resize(); diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index eb169ee43c0f..e1e011422da7 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -714,12 +714,10 @@ utl::OConfigurationTreeRoot ResourceManager::GetLegacyAddonRootNode (const OUStr "ooSetupFactoryWindowStateConfigRef", OUString())); - OUStringBuffer aPathComposer; - aPathComposer.append("org.openoffice.Office.UI."); - aPathComposer.append(sWindowStateRef); - aPathComposer.append("/UIElements/States"); + OUString aPathComposer = "org.openoffice.Office.UI." + sWindowStateRef + + "/UIElements/States"; - return utl::OConfigurationTreeRoot(xContext, aPathComposer.makeStringAndClear(), false); + return utl::OConfigurationTreeRoot(xContext, aPathComposer, false); } catch (const Exception&) { diff --git a/slideshow/source/engine/animationnodes/nodetools.cxx b/slideshow/source/engine/animationnodes/nodetools.cxx index 9925513b2254..f2f98ad15035 100644 --- a/slideshow/source/engine/animationnodes/nodetools.cxx +++ b/slideshow/source/engine/animationnodes/nodetools.cxx @@ -35,11 +35,9 @@ namespace slideshow OUString debugGetNodeName( const BaseNode *pNode ) { - OUStringBuffer aBuf; - aBuf.append(lcl_nOffset); - aBuf.append(" - 0x"); - aBuf.append(reinterpret_cast<sal_Int64>(pNode), 16); - return aBuf.makeStringAndClear(); + return OUString::number(lcl_nOffset) + + " - 0x" + + OUString::number(reinterpret_cast<sal_Int64>(pNode), 16); } void debugNodesShowTree( const BaseNode* pNode ) diff --git a/solenv/CompilerTest_compilerplugins_clang.mk b/solenv/CompilerTest_compilerplugins_clang.mk index d83542bfbfc4..27144e953407 100644 --- a/solenv/CompilerTest_compilerplugins_clang.mk +++ b/solenv/CompilerTest_compilerplugins_clang.mk @@ -12,6 +12,7 @@ $(eval $(call gb_CompilerTest_CompilerTest,compilerplugins_clang)) $(eval $(call gb_CompilerTest_add_exception_objects,compilerplugins_clang, \ compilerplugins/clang/test/badstatics \ compilerplugins/clang/test/blockblock \ + compilerplugins/clang/test/bufferadd \ compilerplugins/clang/test/buriedassign \ compilerplugins/clang/test/casttovoid \ compilerplugins/clang/test/classmemaccess \ diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index 264285d75174..d1930096ffe8 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -1290,10 +1290,8 @@ Reference<XInterface > ORegistryServiceManager::loadWithImplementationName( Sequence<OUString> ORegistryServiceManager::getFromServiceName( const OUString& serviceName ) const { - OUStringBuffer buf; - buf.append( "/SERVICES/" ); - buf.append( serviceName ); - return retrieveAsciiValueList( m_xRegistry, buf.makeStringAndClear() ); + OUString buf = "/SERVICES/" + serviceName; + return retrieveAsciiValueList( m_xRegistry, buf ); } /** diff --git a/svl/qa/unit/test_lngmisc.cxx b/svl/qa/unit/test_lngmisc.cxx index b4ba30c6c63b..748b61e2b57e 100644 --- a/svl/qa/unit/test_lngmisc.cxx +++ b/svl/qa/unit/test_lngmisc.cxx @@ -42,11 +42,7 @@ namespace OUString str1(""); OUString str2("a-b--c---"); - OUStringBuffer str3Buf; - str3Buf.append(SVT_SOFT_HYPHEN); - str3Buf.append(SVT_HARD_HYPHEN); - str3Buf.append(SVT_HARD_HYPHEN); - OUString str3(str3Buf.makeStringAndClear()); + OUString str3 = OUStringLiteral1(SVT_SOFT_HYPHEN) + OUStringLiteral1(SVT_HARD_HYPHEN) + OUStringLiteral1(SVT_HARD_HYPHEN); OUString str4("asdf"); diff --git a/svx/source/accessibility/lookupcolorname.cxx b/svx/source/accessibility/lookupcolorname.cxx index feffea69fe18..29f517a5edf4 100644 --- a/svx/source/accessibility/lookupcolorname.cxx +++ b/svx/source/accessibility/lookupcolorname.cxx @@ -102,10 +102,7 @@ OUString ColorNameMap::lookUp(long color) const { return i->second; } // Did not find the given color; return its RGB tuple representation: - OUStringBuffer buf; - buf.append('#'); - buf.append(color, 16); - return buf.makeStringAndClear(); + return "#" + OUString::number(color, 16); } struct theColorNameMap: public rtl::Static< ColorNameMap, theColorNameMap > {}; diff --git a/svx/source/form/fmscriptingenv.cxx b/svx/source/form/fmscriptingenv.cxx index bddfc8827b6f..5edf19daa490 100644 --- a/svx/source/form/fmscriptingenv.cxx +++ b/svx/source/form/fmscriptingenv.cxx @@ -1035,14 +1035,11 @@ namespace svxform sMacroLocation = "document"; } - OUStringBuffer aScriptURI; - aScriptURI.append( "vnd.sun.star.script:" ); - aScriptURI.append( sScriptCode ); - aScriptURI.append( "?language=Basic" ); - aScriptURI.append( "&location=" ); - aScriptURI.append( sMacroLocation ); - - const OUString sScriptURI( aScriptURI.makeStringAndClear() ); + OUString sScriptURI = "vnd.sun.star.script:" + + sScriptCode + + "?language=Basic&location=" + + sMacroLocation; + pScript.reset( new NewStyleUNOScript( *xObjectShell, sScriptURI ) ); } 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); } diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx index 6279ec8d8633..545dfe5516f6 100644 --- a/test/source/bootstrapfixture.cxx +++ b/test/source/bootstrapfixture.cxx @@ -43,10 +43,10 @@ using namespace ::com::sun::star; static void aBasicErrorFunc( const OUString &rErr, const OUString &rAction ) { - OStringBuffer aErr( "Unexpected dialog: " ); - aErr.append( OUStringToOString( rAction, RTL_TEXTENCODING_ASCII_US ) ); - aErr.append( " Error: " ); - aErr.append( OUStringToOString( rErr, RTL_TEXTENCODING_ASCII_US ) ); + OString aErr = "Unexpected dialog: " + + OUStringToOString( rAction, RTL_TEXTENCODING_ASCII_US ) + + " Error: " + + OUStringToOString( rErr, RTL_TEXTENCODING_ASCII_US ); CPPUNIT_ASSERT_MESSAGE( aErr.getStr(), false); } diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index d880b62a3df8..9d6a28fa6625 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -267,10 +267,8 @@ private: { ::rtl::Reference< GridColumn > const pGridColumn = new GridColumn(); Reference< XGridColumn > const xColumn( pGridColumn.get() ); - OUStringBuffer colTitle; - colTitle.append( "Column " ); - colTitle.append( i + 1 ); - pGridColumn->setTitle( colTitle.makeStringAndClear() ); + OUString colTitle = "Column " + OUString::number( i + 1 ); + pGridColumn->setTitle( colTitle ); pGridColumn->setColumnWidth( 80 /* APPFONT */ ); pGridColumn->setFlexibility( 1 ); pGridColumn->setResizeable( true ); diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index cc2490120173..991ea410149d 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -178,14 +178,12 @@ bool createContentProviderData( ContentProviderData & rInfo) { // Obtain service name. - OUStringBuffer aKeyBuffer (rProvider); - aKeyBuffer.append( "/ServiceName" ); OUString aValue; try { if ( !( rxHierNameAccess->getByHierarchicalName( - aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) + rProvider + "/ServiceName" ) >>= aValue ) ) { OSL_FAIL( "UniversalContentBroker::getContentProviderData - " "Error getting item value!" ); @@ -199,11 +197,9 @@ bool createContentProviderData( rInfo.ServiceName = aValue; // Obtain URL Template. - aKeyBuffer.append(rProvider); - aKeyBuffer.append( "/URLTemplate" ); if ( !( rxHierNameAccess->getByHierarchicalName( - aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) + rProvider + "/URLTemplate" ) >>= aValue ) ) { OSL_FAIL( "UniversalContentBroker::getContentProviderData - " "Error getting item value!" ); @@ -212,11 +208,9 @@ bool createContentProviderData( rInfo.URLTemplate = aValue; // Obtain Arguments. - aKeyBuffer.append(rProvider); - aKeyBuffer.append( "/Arguments" ); if ( !( rxHierNameAccess->getByHierarchicalName( - aKeyBuffer.makeStringAndClear() ) >>= aValue ) ) + rProvider + "/Arguments" ) >>= aValue ) ) { OSL_FAIL( "UniversalContentBroker::getContentProviderData - " "Error getting item value!" ); diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 823bdea776ab..757a0b49cec4 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -357,11 +357,7 @@ namespace ucb { namespace ucp { namespace ext const sal_Int32 nLastSep = sRelativeURL.lastIndexOf( '/' ); sRelativeURL = sRelativeURL.copy( 0, nLastSep != -1 ? nLastSep : 0 ); - OUStringBuffer aComposer; - aComposer.append( sRootURL ); - aComposer.append( sSeparatedExtensionId ); - aComposer.append( sRelativeURL ); - return aComposer.makeStringAndClear(); + return sRootURL + sSeparatedExtensionId + sRelativeURL; } default: diff --git a/ucb/source/ucp/tdoc/tdoc_provider.cxx b/ucb/source/ucp/tdoc/tdoc_provider.cxx index 801dbc40daeb..d738d59bb935 100644 --- a/ucb/source/ucp/tdoc/tdoc_provider.cxx +++ b/ucb/source/ucp/tdoc/tdoc_provider.cxx @@ -189,12 +189,10 @@ ContentProvider::createDocumentContentIdentifier( 1 ); } - OUStringBuffer aBuffer; - aBuffer.append( TDOC_URL_SCHEME ":/" ); - aBuffer.append( aDocId ); + OUString aBuffer = TDOC_URL_SCHEME ":/" + aDocId; uno::Reference< ucb::XContentIdentifier > xId - = new ::ucbhelper::ContentIdentifier( aBuffer.makeStringAndClear() ); + = new ::ucbhelper::ContentIdentifier( aBuffer ); return xId; } diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index ec306acfa07a..cfccb4d91b33 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -311,9 +311,9 @@ std::vector< LanguageType > LocaleDataWrapper::getInstalledLanguageTypes() LanguageType eLang = aLanguageTag.getLanguageType( false); if (areChecksEnabled() && eLang == LANGUAGE_DONTKNOW) { - OUStringBuffer aMsg("ConvertIsoNamesToLanguage: unknown MS-LCID for locale\n"); - aMsg.append(aDebugLocale); - outputCheckMessage(aMsg.makeStringAndClear()); + OUString aMsg = "ConvertIsoNamesToLanguage: unknown MS-LCID for locale\n" + + aDebugLocale; + outputCheckMessage(aMsg); } if ( eLang == LANGUAGE_NORWEGIAN) // no_NO, not Bokmal (nb_NO), not Nynorsk (nn_NO) diff --git a/unoxml/source/rdf/CLiteral.cxx b/unoxml/source/rdf/CLiteral.cxx index e0aa7f1481a8..f7f8c726e626 100644 --- a/unoxml/source/rdf/CLiteral.cxx +++ b/unoxml/source/rdf/CLiteral.cxx @@ -134,15 +134,9 @@ void SAL_CALL CLiteral::initialize(const css::uno::Sequence< css::uno::Any > & a OUString SAL_CALL CLiteral::getStringValue() { if (!m_Language.isEmpty()) { - OUStringBuffer buf(m_Value); - buf.append("@"); - buf.append(m_Language); - return buf.makeStringAndClear(); + return m_Value + "@" + m_Language; } else if (m_xDatatype.is()) { - OUStringBuffer buf(m_Value); - buf.append("^^"); - buf.append(m_xDatatype->getStringValue()); - return buf.makeStringAndClear(); + return m_Value + "^^" + m_xDatatype->getStringValue(); } else { return m_Value; } diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index cd26da12de5d..5b026a4082d9 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -865,13 +865,11 @@ UUIInteractionHelper::getInteractionHandlerList( uno::Reference< lang::XMultiServiceFactory > xConfigProv = configuration::theDefaultProvider::get( m_xContext ); - OUStringBuffer aFullPath; - aFullPath.append( - "/org.openoffice.ucb.InteractionHandler/InteractionHandlers" ); + OUString aFullPath = "/org.openoffice.ucb.InteractionHandler/InteractionHandlers"; uno::Sequence<uno::Any> aArguments(comphelper::InitAnyPropertySequence( { - {"nodepath", uno::Any(aFullPath.makeStringAndClear())} + {"nodepath", uno::Any(aFullPath)} })); uno::Reference< uno::XInterface > xInterface( diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index 1aec86c9ee2f..02bde3fcaedb 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -836,10 +836,8 @@ bool PDFDocument::Sign(const uno::Reference<security::XCertificate>& xCertificat = nFileEnd - (nSignatureContentOffset + MAX_SIGNATURE_CONTENT_LENGTH + 1); // Write the length to the buffer. m_aEditBuffer.Seek(nSignatureLastByteRangeOffset); - OStringBuffer aByteRangeBuffer; - aByteRangeBuffer.append(nLastByteRangeLength); - aByteRangeBuffer.append(" ]"); - m_aEditBuffer.WriteOString(aByteRangeBuffer.toString()); + OString aByteRangeBuffer = OString::number(nLastByteRangeLength) + " ]"; + m_aEditBuffer.WriteOString(aByteRangeBuffer); // Create the PKCS#7 object. css::uno::Sequence<sal_Int8> aDerEncoded = xCertificate->getEncoded(); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 0048cc548d54..47d90025172a 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -794,11 +794,11 @@ void PDFWriterImpl::PDFPage::endStream() // emit stream length object if( ! m_pWriter->updateObject( m_nStreamLengthObject ) ) return; - OStringBuffer aLine; - aLine.append( m_nStreamLengthObject ); - aLine.append( " 0 obj\n" ); - aLine.append( static_cast<sal_Int64>(nEndStreamPos-m_nBeginStreamPos) ); - aLine.append( "\nendobj\n\n" ); + OString aLine = + OString::number( m_nStreamLengthObject ) + + " 0 obj\n" + + OString::number( static_cast<sal_Int64>(nEndStreamPos-m_nBeginStreamPos) ) + + "\nendobj\n\n"; m_pWriter->writeBuffer( aLine.getStr(), aLine.getLength() ); } @@ -2044,9 +2044,9 @@ OString PDFWriterImpl::emitStructureAttributes( PDFStructureElement& i_rEle ) SAL_INFO("vcl.pdfwriter", "unresolved link id " << nLink << " for Link structure"); if (g_bDebugDisableCompression) { - OStringBuffer aLine( "unresolved link id " ); - aLine.append( nLink ); - aLine.append( " for Link structure" ); + OString aLine = "unresolved link id " + + OString::number( nLink ) + + " for Link structure"; emitComment( aLine.getStr() ); } } diff --git a/vcl/unx/generic/print/printerjob.cxx b/vcl/unx/generic/print/printerjob.cxx index 5bf85101869d..73dedc5a2415 100644 --- a/vcl/unx/generic/print/printerjob.cxx +++ b/vcl/unx/generic/print/printerjob.cxx @@ -951,9 +951,9 @@ bool PrinterJob::writeSetup( osl::File* pFile, const JobData& rJob ) if( ! bExternalDialog && rJob.m_nCopies > 1 ) { // setup code - OStringBuffer aLine("/#copies "); - aLine.append(static_cast<sal_Int32>(rJob.m_nCopies)); - aLine.append(" def\n"); + OString aLine = "/#copies " + + OString::number(static_cast<sal_Int32>(rJob.m_nCopies)) + + " def\n"; sal_uInt64 nWritten = 0; bSuccess = !(pFile->write(aLine.getStr(), aLine.getLength(), nWritten) || nWritten != static_cast<sal_uInt64>(aLine.getLength())); diff --git a/xmloff/source/core/nmspmap.cxx b/xmloff/source/core/nmspmap.cxx index 669d0cc9f727..44e619c0f348 100644 --- a/xmloff/source/core/nmspmap.cxx +++ b/xmloff/source/core/nmspmap.cxx @@ -219,11 +219,7 @@ OUString SvXMLNamespaceMap::GetQNameByKey( sal_uInt16 nKey, case XML_NAMESPACE_XML: { // this namespace is reserved, and needs not to be declared - OUStringBuffer sQName; - sQName.append ( GetXMLToken(XML_XML) ); - sQName.append ( ':' ); - sQName.append ( rLocalName ); - return sQName.makeStringAndClear(); + return GetXMLToken(XML_XML) + ":" + rLocalName; } default: { diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index 706b5b10a1b9..d5569f633eec 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -220,11 +220,9 @@ bool XMLStyleExport::exportStyle( aAny >>= nOutlineLevel; if( nOutlineLevel > 0 ) { - OUStringBuffer sTmp; - sTmp.append(nOutlineLevel); GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DEFAULT_OUTLINE_LEVEL, - sTmp.makeStringAndClear() ); + OUString::number(nOutlineLevel) ); } else { diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index cd34a861b3f3..2ae5b7520bde 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -1811,10 +1811,8 @@ void XMLSectionExport::ExportMasterDocHeadingDummies() GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( sStyle ) ); - OUStringBuffer sTmp; - sTmp.append( nLevel + 1 ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_LEVEL, - sTmp.makeStringAndClear() ); + OUString::number( nLevel + 1 ) ); SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_H, true, false ); } diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx index b4005a976b9a..a1c04371666f 100644 --- a/xmloff/source/text/txtflde.cxx +++ b/xmloff/source/text/txtflde.cxx @@ -3446,10 +3446,7 @@ OUString XMLTextFieldExport::MakeFootnoteRefName( sal_Int16 nSeqNo) { // generate foot-/endnote ID - OUStringBuffer aBuf; - aBuf.append("ftn"); - aBuf.append(static_cast<sal_Int32>(nSeqNo)); - return aBuf.makeStringAndClear(); + return "ftn" + OUString::number(static_cast<sal_Int32>(nSeqNo)); } OUString XMLTextFieldExport::MakeSequenceRefName( @@ -3457,11 +3454,7 @@ OUString XMLTextFieldExport::MakeSequenceRefName( const OUString& rSeqName) { // generate foot-/endnote ID - OUStringBuffer aBuf; - aBuf.append("ref"); - aBuf.append(rSeqName); - aBuf.append(static_cast<sal_Int32>(nSeqNo)); - return aBuf.makeStringAndClear(); + return "ref" +rSeqName + OUString::number(static_cast<sal_Int32>(nSeqNo)); } diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx index 124ebb010d52..cde1edd6daa3 100644 --- a/xmloff/source/text/txtfldi.cxx +++ b/xmloff/source/text/txtfldi.cxx @@ -2784,11 +2784,6 @@ void XMLDdeFieldDeclImportContext::StartElement( // valid data? if (bNameOK && bCommandApplicationOK && bCommandTopicOK && bCommandItemOK) { - // make service name - OUStringBuffer sBuf; - sBuf.append(sAPI_fieldmaster_prefix); - sBuf.append(sAPI_dde); - // create DDE TextFieldMaster Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(), UNO_QUERY); @@ -2803,7 +2798,7 @@ void XMLDdeFieldDeclImportContext::StartElement( try { Reference<XInterface> xIfc = - xFactory->createInstance(sBuf.makeStringAndClear()); + xFactory->createInstance(OUStringLiteral(sAPI_fieldmaster_prefix) + sAPI_dde); if( xIfc.is() ) { Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY ); diff --git a/xmloff/source/text/txtftne.cxx b/xmloff/source/text/txtftne.cxx index 3ab12bb6d601..c41fad2fe63b 100644 --- a/xmloff/source/text/txtftne.cxx +++ b/xmloff/source/text/txtftne.cxx @@ -166,11 +166,8 @@ void XMLTextParagraphExport::exportTextFootnoteHelper( Any aAny = xPropSet->getPropertyValue(gsReferenceId); sal_Int32 nNumber = 0; aAny >>= nNumber; - OUStringBuffer aBuf; - aBuf.append("ftn"); - aBuf.append(nNumber); GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_ID, - aBuf.makeStringAndClear()); + "ftn" + OUString::number(nNumber)); GetExport().AddAttribute(XML_NAMESPACE_TEXT, XML_NOTE_CLASS, GetXMLToken( bIsEndnote ? XML_ENDNOTE : XML_FOOTNOTE ) ); diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index af8e721bce65..0238e918535d 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -1086,11 +1086,9 @@ void XMLTextParagraphExport::exportListChange( } else if (bRestartNumberingAtContinuedList) { - OUStringBuffer aBuffer; - aBuffer.append( nRestartValueForContinuedList ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_START_VALUE, - aBuffer.makeStringAndClear() ); + OUString::number(nRestartValueForContinuedList) ); bRestartNumberingAtContinuedList = false; } } @@ -1972,11 +1970,9 @@ void XMLTextParagraphExport::exportParagraph( if( 0 < nOutlineLevel ) { - OUStringBuffer sTmp; - sTmp.append( sal_Int32( nOutlineLevel) ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_OUTLINE_LEVEL, - sTmp.makeStringAndClear() ); + OUString::number( sal_Int32( nOutlineLevel) ) ); if( rPropSetHelper.hasProperty( NUMBERING_IS_NUMBER ) ) { @@ -2051,15 +2047,10 @@ void XMLTextParagraphExport::exportParagraph( xPropSet->getPropertyValue("NumberingStartValue") >>= nStartValue; - OUStringBuffer sTmpStartValue; - - sTmpStartValue.append(nStartValue); - GetExport(). AddAttribute(XML_NAMESPACE_TEXT, XML_START_VALUE, - sTmpStartValue. - makeStringAndClear()); + OUString::number(nStartValue)); } } } @@ -3543,10 +3534,8 @@ void XMLTextParagraphExport::exportCharacterData(const OUString& rText, if( nSpaceChars > 1 ) { - OUStringBuffer sTmp; - sTmp.append( nSpaceChars ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C, - sTmp.makeStringAndClear() ); + OUString::number(nSpaceChars) ); } SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, @@ -3606,10 +3595,8 @@ void XMLTextParagraphExport::exportCharacterData(const OUString& rText, { if( nSpaceChars > 1 ) { - OUStringBuffer sTmp; - sTmp.append( nSpaceChars ); GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_C, - sTmp.makeStringAndClear() ); + OUString::number(nSpaceChars) ); } SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_TEXT, XML_S, diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx index 24ab366f71e7..5a1f2255035e 100644 --- a/xmloff/source/text/txtvfldi.cxx +++ b/xmloff/source/text/txtvfldi.cxx @@ -827,18 +827,17 @@ bool XMLVariableDeclImportContext::FindFieldMaster( Reference<container::XNameAccess> xFieldMasterNameAccess = xTextFieldsSupp->getTextFieldMasters(); - OUStringBuffer sBuffer; - sBuffer.append(sAPI_fieldmaster_prefix); - sBuffer.append(sAPI_set_expression); - sBuffer.append("."); - sBuffer.append(sName); - OUString sVarServiceName = sBuffer.makeStringAndClear(); - - sBuffer.append(sAPI_fieldmaster_prefix); - sBuffer.append(sAPI_user); - sBuffer.append("."); - sBuffer.append(sName); - OUString sUserServiceName = sBuffer.makeStringAndClear(); + OUString sVarServiceName = + OUStringLiteral(sAPI_fieldmaster_prefix) + + sAPI_set_expression + + "." + + sName; + + OUString sUserServiceName = + OUStringLiteral(sAPI_fieldmaster_prefix) + + sAPI_user + + "." + + sName; if (xFieldMasterNameAccess->hasByName(sVarServiceName)) { // variable field master already in document diff --git a/xmloff/source/xforms/xformsexport.cxx b/xmloff/source/xforms/xformsexport.cxx index 84adcb6f59c8..35b10383f6d4 100644 --- a/xmloff/source/xforms/xformsexport.cxx +++ b/xmloff/source/xforms/xformsexport.cxx @@ -269,11 +269,8 @@ void exportXFormsBinding( SvXMLExport& rExport, if( sName.isEmpty() ) { // if we don't have a name yet, generate one on the fly - OUStringBuffer aBuffer; - aBuffer.append( "bind_" ); sal_Int64 nId = reinterpret_cast<sal_uInt64>( xBinding.get() ); - aBuffer.append( nId , 16 ); - sName = aBuffer.makeStringAndClear(); + sName = "bind_" + OUString::number( nId , 16 ); xBinding->setPropertyValue( "BindingID", makeAny(sName)); } } |