Kaydet (Commit) e9aff4b5 authored tarafından Marcos Paulo de Souza's avatar Marcos Paulo de Souza Kaydeden (comit) Luboš Luňák

fdo#57950: Remove some chained appends in shell

And remove some *STRINGPARAM macros.

Change-Id: Idebee475e4b383f5f390040515bdfa7c49a24c1d
Reviewed-on: https://gerrit.libreoffice.org/1682Reviewed-by: 's avatarLuboš Luňák <l.lunak@suse.cz>
Tested-by: 's avatarLuboš Luňák <l.lunak@suse.cz>
üst 279b6f39
...@@ -57,13 +57,12 @@ GConfClient* getGconfClient() ...@@ -57,13 +57,12 @@ GConfClient* getGconfClient()
GError* aError = NULL; GError* aError = NULL;
if (!gconf_init(0, NULL, &aError)) if (!gconf_init(0, NULL, &aError))
{ {
rtl::OUStringBuffer msg; OUString msg("GconfBackend:GconfLayer: Cannot Initialize Gconf connection - " +
msg.appendAscii("GconfBackend:GconfLayer: Cannot Initialize Gconf connection - " ); OUString::createFromAscii(aError->message));
msg.appendAscii(aError->message);
g_error_free(aError); g_error_free(aError);
aError = NULL; aError = NULL;
throw uno::RuntimeException(msg.makeStringAndClear(),NULL); throw uno::RuntimeException(msg, NULL);
} }
mClient = gconf_client_get_default(); mClient = gconf_client_get_default();
...@@ -116,13 +115,11 @@ static OUString xdg_user_dir_lookup (const char *type) ...@@ -116,13 +115,11 @@ static OUString xdg_user_dir_lookup (const char *type)
config_home = getenv ("XDG_CONFIG_HOME"); config_home = getenv ("XDG_CONFIG_HOME");
if (config_home == NULL || config_home[0] == 0) if (config_home == NULL || config_home[0] == 0)
{ {
aConfigFileURL = OUString(aHomeDirURL); aConfigFileURL = aHomeDirURL + "/.config/user-dirs.dirs";
aConfigFileURL += OUString("/.config/user-dirs.dirs");
} }
else else
{ {
aConfigFileURL = OUString::createFromAscii(config_home); aConfigFileURL = OUString::createFromAscii(config_home) + "/user-dirs.dirs";
aConfigFileURL += OUString("/user-dirs.dirs");
} }
if(osl_File_E_None == osl_openFile(aConfigFileURL.pData, &handle, osl_File_OpenFlag_Read)) if(osl_File_E_None == osl_openFile(aConfigFileURL.pData, &handle, osl_File_OpenFlag_Read))
...@@ -167,8 +164,7 @@ static OUString xdg_user_dir_lookup (const char *type) ...@@ -167,8 +164,7 @@ static OUString xdg_user_dir_lookup (const char *type)
continue; continue;
if (relative) if (relative)
{ {
aUserDirBuf = OUStringBuffer(aHomeDirURL); aUserDirBuf = OUStringBuffer(aHomeDirURL + "/");
aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) );
} }
else else
{ {
...@@ -195,15 +191,11 @@ static OUString xdg_user_dir_lookup (const char *type) ...@@ -195,15 +191,11 @@ static OUString xdg_user_dir_lookup (const char *type)
/* Special case desktop for historical compatibility */ /* Special case desktop for historical compatibility */
if (strcmp (type, "DESKTOP") == 0) if (strcmp (type, "DESKTOP") == 0)
{ {
aUserDirBuf = OUStringBuffer(aHomeDirURL); return aHomeDirURL + "/Desktop";
aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Desktop" ) );
return aUserDirBuf.makeStringAndClear();
} }
else else
{ {
aUserDirBuf = OUStringBuffer(aHomeDirURL); return aHomeDirURL + "/Documents";
aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Documents" ) );
return aUserDirBuf.makeStringAndClear();
} }
} }
...@@ -277,8 +269,7 @@ uno::Any translateToOOo( const ConfigurationValue &rValue, GConfValue *pGconfVal ...@@ -277,8 +269,7 @@ uno::Any translateToOOo( const ConfigurationValue &rValue, GConfValue *pGconfVal
GSList * list = gconf_value_get_list(pGconfValue); GSList * list = gconf_value_get_list(pGconfValue);
for(; list; list = g_slist_next(list)) for(; list; list = g_slist_next(list))
{ {
aBuffer.append(gconf_value_get_string((GConfValue *) list->data)); aBuffer.append(gconf_value_get_string((GConfValue *) list->data) + OString(";"));
aBuffer.append(";");
} }
// Remove trailing ";" // Remove trailing ";"
aBuffer.setLength(aBuffer.getLength()-1); aBuffer.setLength(aBuffer.getLength()-1);
......
...@@ -289,14 +289,12 @@ css::uno::Any LocaleBackend::getPropertyValue( ...@@ -289,14 +289,12 @@ css::uno::Any LocaleBackend::getPropertyValue(
return css::uno::makeAny( return css::uno::makeAny(
css::beans::Optional< css::uno::Any >( css::beans::Optional< css::uno::Any >(
true, css::uno::makeAny(getLocale()))); true, css::uno::makeAny(getLocale())));
} else if (PropertyName.equalsAsciiL( } else if (PropertyName.equals("SystemLocale"))
RTL_CONSTASCII_STRINGPARAM("SystemLocale")))
{ {
return css::uno::makeAny( return css::uno::makeAny(
css::beans::Optional< css::uno::Any >( css::beans::Optional< css::uno::Any >(
true, css::uno::makeAny(getSystemLocale()))); true, css::uno::makeAny(getSystemLocale())));
} else if (PropertyName.equalsAsciiL( } else if (PropertyName.equals("UILocale"))
RTL_CONSTASCII_STRINGPARAM("UILocale")))
{ {
return css::uno::makeAny( return css::uno::makeAny(
css::beans::Optional< css::uno::Any >( css::beans::Optional< css::uno::Any >(
......
...@@ -62,11 +62,11 @@ SAL_DLLPUBLIC_EXPORT void* SAL_CALL cmdmail_component_getFactory( ...@@ -62,11 +62,11 @@ SAL_DLLPUBLIC_EXPORT void* SAL_CALL cmdmail_component_getFactory(
if (0 == ::rtl_str_compare( pImplName, COMP_IMPL_NAME )) 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( xFactory = ::cppu::createSingleComponentFactory(
createInstance, createInstance,
OUString( RTL_CONSTASCII_USTRINGPARAM(COMP_IMPL_NAME) ), OUString( COMP_IMPL_NAME ),
Sequence< OUString >( &serviceName, 1 ) ); Sequence< OUString >( &serviceName, 1 ) );
} }
......
...@@ -71,7 +71,7 @@ namespace // private ...@@ -71,7 +71,7 @@ namespace // private
Sequence< OUString > SAL_CALL Component_getSupportedServiceNames() Sequence< OUString > SAL_CALL Component_getSupportedServiceNames()
{ {
Sequence< OUString > aRet(1); Sequence< OUString > aRet(1);
aRet[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.system.SimpleCommandMail")); aRet[0] = "com.sun.star.system.SimpleCommandMail";
return aRet; return aRet;
} }
...@@ -114,45 +114,38 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM ...@@ -114,45 +114,38 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
{ {
if ( ! xSimpleMailMessage.is() ) if ( ! xSimpleMailMessage.is() )
{ {
throw ::com::sun::star::lang::IllegalArgumentException( throw ::com::sun::star::lang::IllegalArgumentException( "No message specified" ,
OUString(RTL_CONSTASCII_USTRINGPARAM( "No message specified" )),
static_cast < XSimpleMailClient * > (this), 1 ); static_cast < XSimpleMailClient * > (this), 1 );
} }
if( ! m_xConfigurationProvider.is() ) if( ! m_xConfigurationProvider.is() )
{ {
throw ::com::sun::star::uno::Exception( throw ::com::sun::star::uno::Exception( "Can not access configuration" ,
OUString(RTL_CONSTASCII_USTRINGPARAM( "Can not access configuration" )),
static_cast < XSimpleMailClient * > (this) ); 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); rtl::Bootstrap::expandMacros(aProgramURL);
OUString aProgram; OUString aProgram;
if ( FileBase::E_None != FileBase::getSystemPathFromFileURL(aProgramURL, aProgram)) if ( FileBase::E_None != FileBase::getSystemPathFromFileURL(aProgramURL, aProgram))
{ {
throw ::com::sun::star::uno::Exception( throw ::com::sun::star::uno::Exception("Cound not convert executable path",
OUString(RTL_CONSTASCII_USTRINGPARAM("Cound not convert executable path")),
static_cast < XSimpleMailClient * > (this)); static_cast < XSimpleMailClient * > (this));
} }
aBuffer.append(OUStringToOString(aProgram, osl_getThreadTextEncoding())); OStringBuffer aBuffer("\"" + OUStringToOString(aProgram, osl_getThreadTextEncoding()) + "\" ");
aBuffer.append("\" ");
try try
{ {
// Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer // Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer
// configuration node to retriece the users preferred email application. This may // configuration node to retriece the users preferred email application. This may
// transparently by redirected to e.g. the corresponding GConf setting in GNOME. // transparently by redirected to e.g. the corresponding GConf setting in GNOME.
OUString aConfigRoot = OUString( OUString aConfigRoot = "org.openoffice.Office.Common/ExternalMailer";
RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer" ) );
PropertyValue aProperty; PropertyValue aProperty;
aProperty.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")); aProperty.Name = OUString("nodepath");
aProperty.Value = makeAny( aConfigRoot ); aProperty.Value = makeAny( aConfigRoot );
Sequence< Any > aArgumentList( 1 ); Sequence< Any > aArgumentList( 1 );
...@@ -161,7 +154,7 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM ...@@ -161,7 +154,7 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
Reference< XNameAccess > xNameAccess = Reference< XNameAccess > xNameAccess =
Reference< XNameAccess > ( Reference< XNameAccess > (
m_xConfigurationProvider->createInstanceWithArguments( m_xConfigurationProvider->createInstanceWithArguments(
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")), OUString("com.sun.star.configuration.ConfigurationAccess"),
aArgumentList ), aArgumentList ),
UNO_QUERY ); UNO_QUERY );
...@@ -171,16 +164,15 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM ...@@ -171,16 +164,15 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
// Retrieve the value for "Program" node and append it feed senddoc with it // Retrieve the value for "Program" node and append it feed senddoc with it
// using the (undocumented) --mailclient switch // using the (undocumented) --mailclient switch
xNameAccess->getByName( OUString(RTL_CONSTASCII_USTRINGPARAM("Program")) ) >>= aMailer; xNameAccess->getByName( OUString("Program") ) >>= aMailer;
if( !aMailer.isEmpty() ) if( !aMailer.isEmpty() )
{ {
// make sure we have a system path // make sure we have a system path
FileBase::getSystemPathFromFileURL( aMailer, aMailer ); FileBase::getSystemPathFromFileURL( aMailer, aMailer );
aBuffer.append("--mailclient "); aBuffer.append("--mailclient " + OUStringToOString( aMailer, osl_getThreadTextEncoding() ) +
aBuffer.append(OUStringToOString( aMailer, osl_getThreadTextEncoding() )); " ");
aBuffer.append(" ");
} }
#ifdef MACOSX #ifdef MACOSX
else else
...@@ -201,17 +193,17 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM ...@@ -201,17 +193,17 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
// Append originator if set in the message // Append originator if set in the message
if ( !xSimpleMailMessage->getOriginator().isEmpty() ) if ( !xSimpleMailMessage->getOriginator().isEmpty() )
{ {
aBuffer.append("--from \""); aBuffer.append("--from \"" +
aBuffer.append(OUStringToOString(xSimpleMailMessage->getOriginator(), osl_getThreadTextEncoding())); OUStringToOString(xSimpleMailMessage->getOriginator(), osl_getThreadTextEncoding()) +
aBuffer.append("\" "); "\" ");
} }
// Append receipient if set in the message // Append receipient if set in the message
if ( !xSimpleMailMessage->getRecipient().isEmpty() ) if ( !xSimpleMailMessage->getRecipient().isEmpty() )
{ {
aBuffer.append("--to \""); aBuffer.append("--to \"" +
aBuffer.append(OUStringToOString(xSimpleMailMessage->getRecipient(), osl_getThreadTextEncoding())); OUStringToOString(xSimpleMailMessage->getRecipient(), osl_getThreadTextEncoding()) +
aBuffer.append("\" "); "\" ");
} }
// Append carbon copy receipients set in the message // Append carbon copy receipients set in the message
...@@ -219,9 +211,9 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM ...@@ -219,9 +211,9 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
sal_Int32 n, nmax = aStringList.getLength(); sal_Int32 n, nmax = aStringList.getLength();
for ( n = 0; n < nmax; n++ ) for ( n = 0; n < nmax; n++ )
{ {
aBuffer.append("--cc \""); aBuffer.append("--cc \"" +
aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding())); OUStringToOString(aStringList[n], osl_getThreadTextEncoding()) +
aBuffer.append("\" "); "\" ");
} }
// Append blind carbon copy receipients set in the message // Append blind carbon copy receipients set in the message
...@@ -229,17 +221,17 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM ...@@ -229,17 +221,17 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
nmax = aStringList.getLength(); nmax = aStringList.getLength();
for ( n = 0; n < nmax; n++ ) for ( n = 0; n < nmax; n++ )
{ {
aBuffer.append("--bcc \""); aBuffer.append("--bcc \"" +
aBuffer.append(OUStringToOString(aStringList[n], osl_getThreadTextEncoding())); OUStringToOString(aStringList[n], osl_getThreadTextEncoding()) +
aBuffer.append("\" "); "\" ");
} }
// Append subject if set in the message // Append subject if set in the message
if ( !xSimpleMailMessage->getSubject().isEmpty() ) if ( !xSimpleMailMessage->getSubject().isEmpty() )
{ {
aBuffer.append("--subject \""); aBuffer.append("--subject \"" +
aBuffer.append(OUStringToOString(xSimpleMailMessage->getSubject(), osl_getThreadTextEncoding())); OUStringToOString(xSimpleMailMessage->getSubject(), osl_getThreadTextEncoding()) +
aBuffer.append("\" "); "\" ");
} }
// Append attachments set in the message // Append attachments set in the message
...@@ -250,17 +242,16 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM ...@@ -250,17 +242,16 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
OUString aSystemPath; OUString aSystemPath;
if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) ) if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) )
{ {
aBuffer.append("--attach \""); aBuffer.append("--attach \"" +
aBuffer.append(OUStringToOString(aSystemPath, osl_getThreadTextEncoding())); OUStringToOString(aSystemPath, osl_getThreadTextEncoding()) +
aBuffer.append("\" "); "\" ");
} }
} }
OString cmd = aBuffer.makeStringAndClear(); OString cmd = aBuffer.makeStringAndClear();
if ( 0 != pclose(popen(cmd.getStr(), "w")) ) if ( 0 != pclose(popen(cmd.getStr(), "w")) )
{ {
throw ::com::sun::star::uno::Exception( throw ::com::sun::star::uno::Exception("No mail client configured",
OUString(RTL_CONSTASCII_USTRINGPARAM( "No mail client configured" )),
static_cast < XSimpleMailClient * > (this) ); static_cast < XSimpleMailClient * > (this) );
} }
} }
...@@ -272,7 +263,7 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM ...@@ -272,7 +263,7 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
OUString SAL_CALL CmdMailSuppl::getImplementationName( ) OUString SAL_CALL CmdMailSuppl::getImplementationName( )
throw( RuntimeException ) throw( RuntimeException )
{ {
return OUString(RTL_CONSTASCII_USTRINGPARAM( COMP_IMPL_NAME )); return OUString(COMP_IMPL_NAME);
} }
// ------------------------------------------------- // -------------------------------------------------
......
...@@ -216,13 +216,11 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar ...@@ -216,13 +216,11 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
OString aDesktopEnvironment(m_aDesktopEnvironment.toAsciiLowerCase()); OString aDesktopEnvironment(m_aDesktopEnvironment.toAsciiLowerCase());
OStringBuffer aCopy(aTmp); OStringBuffer aCopy(aTmp);
aCopy.append(aDesktopEnvironment); aCopy.append(aDesktopEnvironment + "-open-url");
aCopy.append("-open-url");
if ( 0 == access( aCopy.getStr(), X_OK) ) if ( 0 == access( aCopy.getStr(), X_OK) )
{ {
aBuffer.append(aDesktopEnvironment); aBuffer.append(aDesktopEnvironment + "-");
aBuffer.append("-");
} }
} }
...@@ -233,8 +231,7 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar ...@@ -233,8 +231,7 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
if ( pDesktopLaunch && *pDesktopLaunch ) if ( pDesktopLaunch && *pDesktopLaunch )
{ {
aLaunchBuffer.append( pDesktopLaunch ); aLaunchBuffer.append( OString(pDesktopLaunch) + " ");
aLaunchBuffer.append(" ");
escapeForShell(aLaunchBuffer, OUStringToOString(aURL, osl_getThreadTextEncoding())); escapeForShell(aLaunchBuffer, OUStringToOString(aURL, osl_getThreadTextEncoding()));
} }
} else if ((nFlags & css::system::SystemShellExecuteFlags::URIS_ONLY) != 0) } else if ((nFlags & css::system::SystemShellExecuteFlags::URIS_ONLY) != 0)
...@@ -270,7 +267,7 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar ...@@ -270,7 +267,7 @@ void SAL_CALL ShellExec::execute( const OUString& aCommand, const OUString& aPar
OString cmd = OString cmd =
#ifdef LINUX #ifdef LINUX
// avoid blocking (call it in background) // avoid blocking (call it in background)
OStringBuffer().append( "( " ).append( aBuffer.makeStringAndClear() ).append( " ) &" ).makeStringAndClear(); "( " + aBuffer.makeStringAndClear() + " ) &";
#else #else
aBuffer.makeStringAndClear(); aBuffer.makeStringAndClear();
#endif #endif
......
...@@ -60,11 +60,11 @@ SAL_DLLPUBLIC_EXPORT void* SAL_CALL syssh_component_getFactory( ...@@ -60,11 +60,11 @@ SAL_DLLPUBLIC_EXPORT void* SAL_CALL syssh_component_getFactory(
if (0 == ::rtl_str_compare( pImplName, SHELLEXEC_IMPL_NAME )) 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( xFactory = ::cppu::createSingleComponentFactory(
createInstance, createInstance,
OUString( RTL_CONSTASCII_USTRINGPARAM(SHELLEXEC_IMPL_NAME) ), OUString( SHELLEXEC_IMPL_NAME ),
Sequence< OUString >( &serviceName, 1 ) ); Sequence< OUString >( &serviceName, 1 ) );
} }
......
...@@ -148,19 +148,15 @@ namespace /* private */ { ...@@ -148,19 +148,15 @@ namespace /* private */ {
rtl::OStringBuffer aBuf; rtl::OStringBuffer aBuf;
for (sal_uInt32 i = 0; i < text.length(); i++) for (sal_uInt32 i = 0; i < text.length(); i++)
{ {
# define MAP(a,b) case a: aBuf.append(b); break
switch (text[i]) switch (text[i])
{ {
MAP ('&', "&amp;"); case '&': aBuf.append("&amp;"); break;
MAP ('<', "&lt;"); case '<': aBuf.append("&lt;"); break;
MAP ('>', "&gt;"); case '>': aBuf.append("&gt;"); break;
MAP ('\'', "&apos;"); case '\'': aBuf.append("&apos;"); break;
MAP ('"', "&quot;"); case '"': aBuf.append("&quot;"); break;
default: default: aBuf.append(text[i]); break;
aBuf.append(text[i]);
break;
} }
# undef MAP
} }
return aBuf.makeStringAndClear(); return aBuf.makeStringAndClear();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment