From f13c6ad5f020a196a0e3aa6f28bda3dc185d465b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 14 Oct 2019 14:27:57 +0200 Subject: 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 --- desktop/source/deployment/misc/dp_identifier.cxx | 5 +---- .../deployment/registry/configuration/dp_configuration.cxx | 6 +++--- desktop/source/lib/init.cxx | 8 ++++---- desktop/source/pkgchk/unopkg/unopkg_misc.cxx | 14 ++++---------- 4 files changed, 12 insertions(+), 21 deletions(-) (limited to 'desktop/source') 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 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 args { "--nologo", "--nodefault", buf.makeStringAndClear() }; + Sequence args { "--nologo", "--nodefault", acceptArg }; OUString appURL( getExecutableDir() + "/soffice" ); if (verbose) @@ -377,13 +374,10 @@ Reference 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 xRet( ::dp_misc::resolveUnoURL( - buf.makeStringAndClear(), xLocalComponentContext ), + sUnoUrl, xLocalComponentContext ), UNO_QUERY_THROW ); if (verbose) dp_misc::writeConsole("OK.\n"); -- cgit