[PATCH] fdo#57950: Remove some chained appends in shell
Marcos Souza (via Code Review)
gerrit at gerrit.libreoffice.org
Mon Jan 14 17:12:17 PST 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/1682
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/82/1682/1
fdo#57950: Remove some chained appends in shell
And remove some *STRINGPARAM macros.
Change-Id: Idebee475e4b383f5f390040515bdfa7c49a24c1d
---
M shell/source/backends/gconfbe/gconfaccess.cxx
M shell/source/backends/localebe/localebackend.cxx
M shell/source/cmdmail/cmdmailentry.cxx
M shell/source/cmdmail/cmdmailsuppl.cxx
M shell/source/unix/exec/shellexec.cxx
M shell/source/unix/exec/shellexecentry.cxx
M shell/source/unix/sysshell/recently_used_file_handler.cxx
7 files changed, 57 insertions(+), 84 deletions(-)
diff --git a/shell/source/backends/gconfbe/gconfaccess.cxx b/shell/source/backends/gconfbe/gconfaccess.cxx
index 205a2cf..4705013 100644
--- a/shell/source/backends/gconfbe/gconfaccess.cxx
+++ b/shell/source/backends/gconfbe/gconfaccess.cxx
@@ -57,13 +57,12 @@
GError* aError = NULL;
if (!gconf_init(0, NULL, &aError))
{
- rtl::OUStringBuffer msg;
- msg.appendAscii("GconfBackend:GconfLayer: Cannot Initialize Gconf connection - " );
- msg.appendAscii(aError->message);
+ OUString msg("GconfBackend:GconfLayer: Cannot Initialize Gconf connection - " +
+ OUString::createFromAscii(aError->message));
g_error_free(aError);
aError = NULL;
- throw uno::RuntimeException(msg.makeStringAndClear(),NULL);
+ throw uno::RuntimeException(msg, NULL);
}
mClient = gconf_client_get_default();
@@ -116,13 +115,11 @@
config_home = getenv ("XDG_CONFIG_HOME");
if (config_home == NULL || config_home[0] == 0)
{
- aConfigFileURL = OUString(aHomeDirURL);
- aConfigFileURL += OUString("/.config/user-dirs.dirs");
+ aConfigFileURL = aHomeDirURL + "/.config/user-dirs.dirs";
}
else
{
- aConfigFileURL = OUString::createFromAscii(config_home);
- aConfigFileURL += OUString("/user-dirs.dirs");
+ aConfigFileURL = OUString::createFromAscii(config_home) + "/user-dirs.dirs";
}
if(osl_File_E_None == osl_openFile(aConfigFileURL.pData, &handle, osl_File_OpenFlag_Read))
@@ -167,8 +164,7 @@
continue;
if (relative)
{
- aUserDirBuf = OUStringBuffer(aHomeDirURL);
- aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) );
+ aUserDirBuf = OUStringBuffer(aHomeDirURL + "/");
}
else
{
@@ -195,15 +191,11 @@
/* Special case desktop for historical compatibility */
if (strcmp (type, "DESKTOP") == 0)
{
- aUserDirBuf = OUStringBuffer(aHomeDirURL);
- aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Desktop" ) );
- return aUserDirBuf.makeStringAndClear();
+ return aHomeDirURL + "/Desktop";
}
else
{
- aUserDirBuf = OUStringBuffer(aHomeDirURL);
- aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Documents" ) );
- return aUserDirBuf.makeStringAndClear();
+ return aHomeDirURL + "/Documents";
}
}
@@ -277,8 +269,7 @@
GSList * list = gconf_value_get_list(pGconfValue);
for(; list; list = g_slist_next(list))
{
- aBuffer.append(gconf_value_get_string((GConfValue *) list->data));
- aBuffer.append(";");
+ aBuffer.append(gconf_value_get_string((GConfValue *) list->data) + OString(";"));
}
// Remove trailing ";"
aBuffer.setLength(aBuffer.getLength()-1);
diff --git a/shell/source/backends/localebe/localebackend.cxx b/shell/source/backends/localebe/localebackend.cxx
index 544cb42..5e38f3a 100644
--- a/shell/source/backends/localebe/localebackend.cxx
+++ b/shell/source/backends/localebe/localebackend.cxx
@@ -289,14 +289,12 @@
return css::uno::makeAny(
css::beans::Optional< css::uno::Any >(
true, css::uno::makeAny(getLocale())));
- } else if (PropertyName.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM("SystemLocale")))
+ } else if (PropertyName.equals("SystemLocale"))
{
return css::uno::makeAny(
css::beans::Optional< css::uno::Any >(
true, css::uno::makeAny(getSystemLocale())));
- } else if (PropertyName.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM("UILocale")))
+ } else if (PropertyName.equals("UILocale"))
{
return css::uno::makeAny(
css::beans::Optional< css::uno::Any >(
diff --git a/shell/source/cmdmail/cmdmailentry.cxx b/shell/source/cmdmail/cmdmailentry.cxx
index a0de1f3..4448d1d 100644
--- a/shell/source/cmdmail/cmdmailentry.cxx
+++ b/shell/source/cmdmail/cmdmailentry.cxx
@@ -62,11 +62,11 @@
if (0 == ::rtl_str_compare( pImplName, COMP_IMPL_NAME ))
{
- OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(COMP_SERVICE_NAME) );
+ OUString serviceName(COMP_SERVICE_NAME);
xFactory = ::cppu::createSingleComponentFactory(
createInstance,
- OUString( RTL_CONSTASCII_USTRINGPARAM(COMP_IMPL_NAME) ),
+ OUString( COMP_IMPL_NAME ),
Sequence< OUString >( &serviceName, 1 ) );
}
diff --git a/shell/source/cmdmail/cmdmailsuppl.cxx b/shell/source/cmdmail/cmdmailsuppl.cxx
index d64f0d1..c12bf98 100644
--- a/shell/source/cmdmail/cmdmailsuppl.cxx
+++ b/shell/source/cmdmail/cmdmailsuppl.cxx
@@ -71,7 +71,7 @@
Sequence< OUString > SAL_CALL Component_getSupportedServiceNames()
{
Sequence< OUString > aRet(1);
- aRet[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.system.SimpleCommandMail"));
+ aRet[0] = "com.sun.star.system.SimpleCommandMail";
return aRet;
}
@@ -114,45 +114,38 @@
{
if ( ! xSimpleMailMessage.is() )
{
- throw ::com::sun::star::lang::IllegalArgumentException(
- OUString(RTL_CONSTASCII_USTRINGPARAM( "No message specified" )),
+ throw ::com::sun::star::lang::IllegalArgumentException( "No message specified" ,
static_cast < XSimpleMailClient * > (this), 1 );
}
if( ! m_xConfigurationProvider.is() )
{
- throw ::com::sun::star::uno::Exception(
- OUString(RTL_CONSTASCII_USTRINGPARAM( "Can not access configuration" )),
+ throw ::com::sun::star::uno::Exception( "Can not access configuration" ,
static_cast < XSimpleMailClient * > (this) );
}
- OStringBuffer aBuffer;
- aBuffer.append("\"");
- OUString aProgramURL(RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program/senddoc"));
+ OUString aProgramURL("$BRAND_BASE_DIR/program/senddoc");
rtl::Bootstrap::expandMacros(aProgramURL);
OUString aProgram;
if ( FileBase::E_None != FileBase::getSystemPathFromFileURL(aProgramURL, aProgram))
{
- throw ::com::sun::star::uno::Exception(
- OUString(RTL_CONSTASCII_USTRINGPARAM("Cound not convert executable path")),
+ throw ::com::sun::star::uno::Exception("Cound not convert executable path",
static_cast < XSimpleMailClient * > (this));
}
- aBuffer.append(OUStringToOString(aProgram, osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
+ OStringBuffer aBuffer("\"" + OUStringToOString(aProgram, osl_getThreadTextEncoding()) + "\" ");
try
{
// Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer
// configuration node to retriece the users preferred email application. This may
// transparently by redirected to e.g. the corresponding GConf setting in GNOME.
- OUString aConfigRoot = OUString(
- RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer" ) );
+ OUString aConfigRoot = "org.openoffice.Office.Common/ExternalMailer";
PropertyValue aProperty;
- aProperty.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath"));
+ aProperty.Name = OUString("nodepath");
aProperty.Value = makeAny( aConfigRoot );
Sequence< Any > aArgumentList( 1 );
@@ -161,7 +154,7 @@
Reference< XNameAccess > xNameAccess =
Reference< XNameAccess > (
m_xConfigurationProvider->createInstanceWithArguments(
- OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")),
+ OUString("com.sun.star.configuration.ConfigurationAccess"),
aArgumentList ),
UNO_QUERY );
@@ -171,16 +164,15 @@
// Retrieve the value for "Program" node and append it feed senddoc with it
// using the (undocumented) --mailclient switch
- xNameAccess->getByName( OUString(RTL_CONSTASCII_USTRINGPARAM("Program")) ) >>= aMailer;
+ xNameAccess->getByName( OUString("Program") ) >>= aMailer;
if( !aMailer.isEmpty() )
{
// make sure we have a system path
FileBase::getSystemPathFromFileURL( aMailer, aMailer );
- aBuffer.append("--mailclient ");
- aBuffer.append(OUStringToOString( aMailer, osl_getThreadTextEncoding() ));
- aBuffer.append(" ");
+ aBuffer.append("--mailclient " + OUStringToOString( aMailer, osl_getThreadTextEncoding() ) +
+ " ");
}
#ifdef MACOSX
else
@@ -201,17 +193,17 @@
// Append originator if set in the message
if ( !xSimpleMailMessage->getOriginator().isEmpty() )
{
- aBuffer.append("--from \"");
- aBuffer.append(OUStringToOString(xSimpleMailMessage->getOriginator(), osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
+ aBuffer.append("--from \"" +
+ OUStringToOString(xSimpleMailMessage->getOriginator(), osl_getThreadTextEncoding()) +
+ "\" ");
}
// Append receipient if set in the message
if ( !xSimpleMailMessage->getRecipient().isEmpty() )
{
- aBuffer.append("--to \"");
- aBuffer.append(OUStringToOString(xSimpleMailMessage->getRecipient(), osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
+ aBuffer.append("--to \"" +
+ OUStringToOString(xSimpleMailMessage->getRecipient(), osl_getThreadTextEncoding()) +
+ "\" ");
}
// Append carbon copy receipients set in the message
@@ -219,9 +211,9 @@
sal_Int32 n, nmax = aStringList.getLength();
for ( n = 0; n < nmax; n++ )
{
- aBuffer.append("--cc \"");
- aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
+ aBuffer.append("--cc \"" +
+ OUStringToOString(aStringList[n], osl_getThreadTextEncoding()) +
+ "\" ");
}
// Append blind carbon copy receipients set in the message
@@ -229,17 +221,17 @@
nmax = aStringList.getLength();
for ( n = 0; n < nmax; n++ )
{
- aBuffer.append("--bcc \"");
- aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
+ aBuffer.append("--bcc \"" +
+ OUStringToOString(aStringList[n], osl_getThreadTextEncoding()) +
+ "\" ");
}
// Append subject if set in the message
if ( !xSimpleMailMessage->getSubject().isEmpty() )
{
- aBuffer.append("--subject \"");
- aBuffer.append(OUStringToOString(xSimpleMailMessage->getSubject(), osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
+ aBuffer.append("--subject \"" +
+ OUStringToOString(xSimpleMailMessage->getSubject(), osl_getThreadTextEncoding()) +
+ "\" ");
}
// Append attachments set in the message
@@ -250,17 +242,16 @@
OUString aSystemPath;
if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) )
{
- aBuffer.append("--attach \"");
- aBuffer.append(OUStringToOString(aSystemPath, osl_getThreadTextEncoding()));
- aBuffer.append("\" ");
+ aBuffer.append("--attach \"" +
+ OUStringToOString(aSystemPath, osl_getThreadTextEncoding()) +
+ "\" ");
}
}
OString cmd = aBuffer.makeStringAndClear();
if ( 0 != pclose(popen(cmd.getStr(), "w")) )
{
- throw ::com::sun::star::uno::Exception(
- OUString(RTL_CONSTASCII_USTRINGPARAM( "No mail client configured" )),
+ throw ::com::sun::star::uno::Exception("No mail client configured",
static_cast < XSimpleMailClient * > (this) );
}
}
@@ -272,7 +263,7 @@
OUString SAL_CALL CmdMailSuppl::getImplementationName( )
throw( RuntimeException )
{
- return OUString(RTL_CONSTASCII_USTRINGPARAM( COMP_IMPL_NAME ));
+ return OUString(COMP_IMPL_NAME);
}
// -------------------------------------------------
diff --git a/shell/source/unix/exec/shellexec.cxx b/shell/source/unix/exec/shellexec.cxx
index 4c69d77..be926bf 100644
--- a/shell/source/unix/exec/shellexec.cxx
+++ b/shell/source/unix/exec/shellexec.cxx
@@ -216,13 +216,11 @@
OString aDesktopEnvironment(m_aDesktopEnvironment.toAsciiLowerCase());
OStringBuffer aCopy(aTmp);
- aCopy.append(aDesktopEnvironment);
- aCopy.append("-open-url");
+ aCopy.append(aDesktopEnvironment + "-open-url");
if ( 0 == access( aCopy.getStr(), X_OK) )
{
- aBuffer.append(aDesktopEnvironment);
- aBuffer.append("-");
+ aBuffer.append(aDesktopEnvironment + "-");
}
}
@@ -233,8 +231,7 @@
if ( pDesktopLaunch && *pDesktopLaunch )
{
- aLaunchBuffer.append( pDesktopLaunch );
- aLaunchBuffer.append(" ");
+ aLaunchBuffer.append( OString(pDesktopLaunch) + " ");
escapeForShell(aLaunchBuffer, OUStringToOString(aURL, osl_getThreadTextEncoding()));
}
} else if ((nFlags & css::system::SystemShellExecuteFlags::URIS_ONLY) != 0)
@@ -270,7 +267,7 @@
OString cmd =
#ifdef LINUX
// avoid blocking (call it in background)
- OStringBuffer().append( "( " ).append( aBuffer.makeStringAndClear() ).append( " ) &" ).makeStringAndClear();
+ "( " + aBuffer.makeStringAndClear() + " ) &";
#else
aBuffer.makeStringAndClear();
#endif
diff --git a/shell/source/unix/exec/shellexecentry.cxx b/shell/source/unix/exec/shellexecentry.cxx
index 96f8e52..ca4caf4 100644
--- a/shell/source/unix/exec/shellexecentry.cxx
+++ b/shell/source/unix/exec/shellexecentry.cxx
@@ -60,11 +60,11 @@
if (0 == ::rtl_str_compare( pImplName, SHELLEXEC_IMPL_NAME ))
{
- OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_SERVICE_NAME) );
+ OUString serviceName( SHELLEXEC_SERVICE_NAME );
xFactory = ::cppu::createSingleComponentFactory(
createInstance,
- OUString( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_IMPL_NAME) ),
+ OUString( SHELLEXEC_IMPL_NAME ),
Sequence< OUString >( &serviceName, 1 ) );
}
diff --git a/shell/source/unix/sysshell/recently_used_file_handler.cxx b/shell/source/unix/sysshell/recently_used_file_handler.cxx
index 4387e60..21c467d 100644
--- a/shell/source/unix/sysshell/recently_used_file_handler.cxx
+++ b/shell/source/unix/sysshell/recently_used_file_handler.cxx
@@ -148,19 +148,15 @@
rtl::OStringBuffer aBuf;
for (sal_uInt32 i = 0; i < text.length(); i++)
{
-# define MAP(a,b) case a: aBuf.append(b); break
switch (text[i])
{
- MAP ('&', "&");
- MAP ('<', "<");
- MAP ('>', ">");
- MAP ('\'', "'");
- MAP ('"', """);
- default:
- aBuf.append(text[i]);
- break;
+ case '&': aBuf.append("&"); break;
+ case '<': aBuf.append("<"); break;
+ case '>': aBuf.append(">"); break;
+ case '\'': aBuf.append("'"); break;
+ case '"': aBuf.append("""); break;
+ default: aBuf.append(text[i]); break;
}
-# undef MAP
}
return aBuf.makeStringAndClear();
}
--
To view, visit https://gerrit.libreoffice.org/1682
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idebee475e4b383f5f390040515bdfa7c49a24c1d
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Marcos Souza <marcos.souza.org at gmail.com>
More information about the LibreOffice
mailing list