[Libreoffice-commits] core.git: basic/qa chart2/source compilerplugins/clang configmgr/source connectivity/source cppu/source cui/source dbaccess/source desktop/source extensions/source filter/qa forms/source fpicker/source framework/source idl/source oox/source package/source pyuno/source reportdesign/source sal/qa sc/qa sc/source sdext/source sd/qa sd/source sfx2/source slideshow/source solenv/CompilerTest_compilerplugins_clang.mk stoc/source svl/qa svx/source sw/qa sw/source test/source toolkit/source ucb/source unotools/source unoxml/source uui/source vcl/source vcl/unx xmloff/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 15 12:35:28 UTC 2019


 basic/qa/cppunit/test_append.cxx                                      |   13 
 chart2/source/tools/ObjectIdentifier.cxx                              |   11 
 compilerplugins/clang/bufferadd.cxx                                   |  416 ++++++++++
 compilerplugins/clang/test/bufferadd.cxx                              |   75 +
 configmgr/source/data.cxx                                             |    5 
 connectivity/source/drivers/hsqldb/HConnection.cxx                    |    8 
 connectivity/source/drivers/hsqldb/HView.cxx                          |   13 
 connectivity/source/drivers/postgresql/pq_xcolumns.cxx                |   11 
 connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx           |    7 
 connectivity/source/drivers/postgresql/pq_xindexes.cxx                |   11 
 connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx             |   11 
 cppu/source/cppu/cppu_opt.cxx                                         |   12 
 cppu/source/typelib/typelib.cxx                                       |   15 
 cppu/source/uno/loadmodule.cxx                                        |   10 
 cui/source/customize/CustomNotebookbarGenerator.cxx                   |    4 
 dbaccess/source/core/api/viewcontainer.cxx                            |    8 
 dbaccess/source/filter/hsqldb/parseschema.cxx                         |    6 
 desktop/source/deployment/misc/dp_identifier.cxx                      |    5 
 desktop/source/deployment/registry/configuration/dp_configuration.cxx |    6 
 desktop/source/lib/init.cxx                                           |    8 
 desktop/source/pkgchk/unopkg/unopkg_misc.cxx                          |   14 
 extensions/source/logging/loggerconfig.cxx                            |    6 
 extensions/source/logging/plaintextformatter.cxx                      |   23 
 extensions/source/propctrlr/eventhandler.cxx                          |   21 
 extensions/source/propctrlr/formcomponenthandler.cxx                  |    6 
 extensions/source/scanner/sanedlg.cxx                                 |   10 
 extensions/source/update/check/updateprotocol.cxx                     |   19 
 filter/qa/cppunit/priority-test.cxx                                   |   22 
 forms/source/component/DatabaseForm.cxx                               |   23 
 fpicker/source/office/iodlgimp.cxx                                    |    6 
 framework/source/fwe/classes/addonsoptions.cxx                        |   33 
 framework/source/services/autorecovery.cxx                            |   11 
 framework/source/services/urltransformer.cxx                          |    4 
 framework/source/uielement/toolbarmodemenucontroller.cxx              |    8 
 framework/source/uifactory/factoryconfiguration.cxx                   |    5 
 idl/source/prj/parser.cxx                                             |   12 
 idl/source/prj/svidl.cxx                                              |   18 
 oox/source/drawingml/chart/titlecontext.cxx                           |    4 
 oox/source/export/vmlexport.cxx                                       |   28 
 package/source/manifest/ManifestExport.cxx                            |    4 
 pyuno/source/module/pyuno.cxx                                         |   42 -
 pyuno/source/module/pyuno_except.cxx                                  |   10 
 pyuno/source/module/pyuno_module.cxx                                  |  110 +-
 pyuno/source/module/pyuno_struct.cxx                                  |    4 
 pyuno/source/module/pyuno_type.cxx                                    |    4 
 pyuno/source/module/pyuno_util.cxx                                    |   12 
 reportdesign/source/core/misc/reportformula.cxx                       |    7 
 reportdesign/source/filter/xml/xmlExportDocumentHandler.cxx           |    9 
 reportdesign/source/ui/report/FormattedFieldBeautifier.cxx            |    5 
 sal/qa/osl/security/osl_Security.cxx                                  |   13 
 sal/qa/rtl/uri/rtl_testuri.cxx                                        |   28 
 sc/qa/unit/helper/csv_handler.hxx                                     |   13 
 sc/qa/unit/helper/qahelper.cxx                                        |    3 
 sc/qa/unit/subsequent_filters-test.cxx                                |   32 
 sc/source/core/data/documen8.cxx                                      |    9 
 sc/source/core/data/document.cxx                                      |    5 
 sc/source/core/data/dpoutput.cxx                                      |    5 
 sc/source/core/tool/chartarr.cxx                                      |    5 
 sc/source/core/tool/chartlis.cxx                                      |    4 
 sc/source/core/tool/chgtrack.cxx                                      |   14 
 sc/source/core/tool/interpr1.cxx                                      |   24 
 sc/source/filter/excel/xepivotxml.cxx                                 |    8 
 sc/source/filter/excel/xltools.cxx                                    |   13 
 sc/source/filter/qpro/qproform.cxx                                    |    5 
 sc/source/filter/xml/XMLExportDatabaseRanges.cxx                      |   19 
 sc/source/filter/xml/xmlexprt.cxx                                     |   30 
 sc/source/ui/app/inputhdl.cxx                                         |    7 
 sc/source/ui/app/inputwin.cxx                                         |    6 
 sc/source/ui/attrdlg/scabstdlg.cxx                                    |    5 
 sc/source/ui/dbgui/pfiltdlg.cxx                                       |    7 
 sc/source/ui/docshell/documentlinkmgr.cxx                             |   20 
 sc/source/ui/formdlg/formula.cxx                                      |    7 
 sc/source/ui/miscdlgs/datafdlg.cxx                                    |   10 
 sc/source/ui/navipi/content.cxx                                       |    6 
 sc/source/ui/view/viewfun6.cxx                                        |   17 
 sd/qa/unit/sdmodeltestbase.hxx                                        |    7 
 sd/source/core/sdpage2.cxx                                            |    4 
 sd/source/ui/remotecontrol/Communicator.cxx                           |    5 
 sd/source/ui/remotecontrol/ImagePreparer.cxx                          |   21 
 sd/source/ui/remotecontrol/Listener.cxx                               |   17 
 sd/source/ui/unoidl/unoobj.cxx                                        |   15 
 sd/source/ui/unoidl/unopage.cxx                                       |   11 
 sdext/source/minimizer/pppoptimizerdialog.cxx                         |   11 
 sdext/source/pdfimport/odf/odfemitter.cxx                             |   17 
 sdext/source/pdfimport/test/pdfunzip.cxx                              |   20 
 sfx2/source/appl/appserv.cxx                                          |    7 
 sfx2/source/appl/appuno.cxx                                           |    3 
 sfx2/source/control/thumbnailviewacc.cxx                              |    4 
 sfx2/source/doc/Metadatable.cxx                                       |    6 
 sfx2/source/notebookbar/SfxNotebookBar.cxx                            |   10 
 sfx2/source/sidebar/ResourceManager.cxx                               |    8 
 slideshow/source/engine/animationnodes/nodetools.cxx                  |    8 
 solenv/CompilerTest_compilerplugins_clang.mk                          |    1 
 stoc/source/servicemanager/servicemanager.cxx                         |    6 
 svl/qa/unit/test_lngmisc.cxx                                          |    6 
 svx/source/accessibility/lookupcolorname.cxx                          |    5 
 svx/source/form/fmscriptingenv.cxx                                    |   13 
 sw/qa/core/macros-test.cxx                                            |    5 
 sw/qa/core/uwriter.cxx                                                |    9 
 sw/source/core/crsr/bookmrk.cxx                                       |    3 
 sw/source/core/doc/docbm.cxx                                          |    3 
 sw/source/filter/html/swhtml.cxx                                      |    5 
 sw/source/filter/ww8/docxattributeoutput.cxx                          |    9 
 sw/source/filter/ww8/docxexport.cxx                                   |   13 
 sw/source/filter/ww8/wrtw8esh.cxx                                     |    5 
 sw/source/uibase/dbui/dbmgr.cxx                                       |    5 
 test/source/bootstrapfixture.cxx                                      |    8 
 toolkit/source/controls/grid/defaultgridcolumnmodel.cxx               |    6 
 ucb/source/core/ucb.cxx                                               |   12 
 ucb/source/ucp/ext/ucpext_content.cxx                                 |    6 
 ucb/source/ucp/tdoc/tdoc_provider.cxx                                 |    6 
 unotools/source/i18n/localedatawrapper.cxx                            |    6 
 unoxml/source/rdf/CLiteral.cxx                                        |   10 
 uui/source/iahndl.cxx                                                 |    6 
 vcl/source/filter/ipdf/pdfdocument.cxx                                |    6 
 vcl/source/gdi/pdfwriter_impl.cxx                                     |   16 
 vcl/unx/generic/print/printerjob.cxx                                  |    6 
 xmloff/source/core/nmspmap.cxx                                        |    6 
 xmloff/source/style/styleexp.cxx                                      |    4 
 xmloff/source/text/XMLSectionExport.cxx                               |    4 
 xmloff/source/text/txtflde.cxx                                        |   11 
 xmloff/source/text/txtfldi.cxx                                        |    7 
 xmloff/source/text/txtftne.cxx                                        |    5 
 xmloff/source/text/txtparae.cxx                                       |   23 
 xmloff/source/text/txtvfldi.cxx                                       |   23 
 xmloff/source/xforms/xformsexport.cxx                                 |    5 
 126 files changed, 1027 insertions(+), 861 deletions(-)

New commits:
commit f13c6ad5f020a196a0e3aa6f28bda3dc185d465b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Oct 14 14:27:57 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Oct 15 14:33:57 2019 +0200

    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 at collabora.co.uk>

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 at +1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
+    OUStringBuffer v;
+    v.append("xxx");
+    v.append("xxx");
+}
+void f2()
+{
+    // expected-error at +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 at 4@5l at 4@11 at 9@11 at 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 at 4@5l at 4@11 at 9@11 at 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(

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list