diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-29 12:24:31 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-29 18:25:31 +0200 |
commit | 04aafba860f613c20e7078d038cc83eb02de0b54 (patch) | |
tree | 8153152b87089419bde17313d9ac7b9de6fcce32 /vcl | |
parent | 76c793d2acf66f46e9edcda43d2f4327e8374841 (diff) |
loplugin:stringadd simplify some *StringBuffer operations
pulled from a larger patch which I created with a more permissive
variant of this plugin
Change-Id: I7abf1f3f09e84703b6e0e52fe9587dff691b2187
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114875
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/dialog.cxx | 9 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 63 | ||||
-rw-r--r-- | vcl/unx/generic/app/sm.cxx | 4 |
3 files changed, 33 insertions, 43 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index d5fcad21571e..a8bd2d5dc37e 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -70,8 +70,7 @@ static OString ImplGetDialogText( Dialog* pDialog ) { - OStringBuffer aErrorStr(OUStringToOString( - pDialog->GetText(), RTL_TEXTENCODING_UTF8)); + OUString aErrorStr(pDialog->GetText()); OUString sMessage; if (MessageDialog* pMessDialog = dynamic_cast<MessageDialog*>(pDialog)) @@ -81,11 +80,9 @@ static OString ImplGetDialogText( Dialog* pDialog ) if (!sMessage.isEmpty()) { - aErrorStr.append(", "); - aErrorStr.append(OUStringToOString( - sMessage, RTL_TEXTENCODING_UTF8)); + aErrorStr += ", " + sMessage; } - return aErrorStr.makeStringAndClear(); + return OUStringToOString(aErrorStr, RTL_TEXTENCODING_UTF8); } static bool ImplIsMnemonicCtrl( vcl::Window* pWindow ) diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index a7aeb0c7f9c3..94c8cc2df391 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -124,18 +124,14 @@ namespace pWindow = pTempWin; } - OStringBuffer aErrorString; - aErrorString.append(' '); - aErrorString.append(typeid( *pWindow ).name()); - aErrorString.append("("); - aErrorString.append( - OUStringToOString( - pWindow->GetText(), - RTL_TEXTENCODING_UTF8 - ) - ); - aErrorString.append(")"); - return aErrorString.makeStringAndClear(); + return OString::Concat(" ") + + typeid( *pWindow ).name() + + "(" + + OUStringToOString( + pWindow->GetText(), + RTL_TEXTENCODING_UTF8 + ) + + ")"; } } #endif @@ -264,9 +260,9 @@ void Window::dispose() if ( mpWindowImpl->mpFirstChild ) { - OStringBuffer aTempStr("Window ("); - aTempStr.append(lcl_createWindowInfo(this)); - aTempStr.append(") with live children destroyed: "); + OStringBuffer aTempStr = "Window (" + + lcl_createWindowInfo(this) + + ") with live children destroyed: "; pTempWin = mpWindowImpl->mpFirstChild; while ( pTempWin ) { @@ -291,15 +287,14 @@ void Window::dispose() } if ( bError ) { - OStringBuffer aTempStr; - aTempStr.append("Window ("); - aTempStr.append(lcl_createWindowInfo(this)); - aTempStr.append(") with live SystemWindows destroyed: "); - aTempStr.append(aErrorStr); + OString aTempStr = + "Window (" + + lcl_createWindowInfo(this) + + ") with live SystemWindows destroyed: " + + aErrorStr; OSL_FAIL(aTempStr.getStr()); // abort in debug builds, must be fixed! - Application::Abort(OStringToOUString( - aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); + Application::Abort(OStringToOUString(aTempStr, RTL_TEXTENCODING_UTF8)); } } @@ -316,19 +311,19 @@ void Window::dispose() } if ( bError ) { - OStringBuffer aTempStr( "Window (" ); - aTempStr.append(lcl_createWindowInfo(this)); - aTempStr.append(") with live SystemWindows destroyed: "); - aTempStr.append(aErrorStr); + OString aTempStr = "Window (" + + lcl_createWindowInfo(this) + + ") with live SystemWindows destroyed: " + + aErrorStr; OSL_FAIL( aTempStr.getStr() ); - Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed! + Application::Abort(OStringToOUString(aTempStr, RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed! } if ( mpWindowImpl->mpFirstOverlap ) { - OStringBuffer aTempStr("Window ("); - aTempStr.append(lcl_createWindowInfo(this)); - aTempStr.append(") with live SystemWindows destroyed: "); + OStringBuffer aTempStr = "Window (" + + lcl_createWindowInfo(this) + + ") with live SystemWindows destroyed: "; pTempWin = mpWindowImpl->mpFirstOverlap; while ( pTempWin ) { @@ -352,11 +347,11 @@ void Window::dispose() } if ( pMySysWin && pMySysWin->ImplIsInTaskPaneList( this ) ) { - OStringBuffer aTempStr("Window ("); - aTempStr.append(lcl_createWindowInfo(this)); - aTempStr.append(") still in TaskPanelList!"); + OString aTempStr = "Window (" + + lcl_createWindowInfo(this) + + ") still in TaskPanelList!"; OSL_FAIL( aTempStr.getStr() ); - Application::Abort(OStringToOUString(aTempStr.makeStringAndClear(), RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed! + Application::Abort(OStringToOUString(aTempStr, RTL_TEXTENCODING_UTF8)); // abort in debug builds, this must be fixed! } } #endif diff --git a/vcl/unx/generic/app/sm.cxx b/vcl/unx/generic/app/sm.cxx index 136cf0d2559b..b6a4c4ad474f 100644 --- a/vcl/unx/generic/app/sm.cxx +++ b/vcl/unx/generic/app/sm.cxx @@ -224,9 +224,7 @@ static void BuildSmPropertyList() pSmProps[ eRestartCommand ].vals = new SmPropValue[3]; pSmProps[ eRestartCommand ].vals[0].length = aExec.getLength()+1; pSmProps[ eRestartCommand ].vals[0].value = strdup( aExec.getStr() ); - OStringBuffer aRestartOption; - aRestartOption.append("--session="); - aRestartOption.append(SessionManagerClient::getSessionID()); + OString aRestartOption = "--session=" + SessionManagerClient::getSessionID(); pSmProps[ eRestartCommand ].vals[1].length = aRestartOption.getLength()+1; pSmProps[ eRestartCommand ].vals[1].value = strdup(aRestartOption.getStr()); OString aRestartOptionNoLogo("--nologo"); |