cmcfixes76: #i112656# osl_setEnvironment/osl_clearEnvironment

This commit is contained in:
Caol?n McNamara
2010-06-24 20:59:17 +01:00
parent 49b06312d1
commit 594aabf05f
6 changed files with 53 additions and 43 deletions

View File

@@ -464,8 +464,10 @@ void SAL_CALL ODriver::createCatalog( const Sequence< PropertyValue >& info ) th
{
TDatabaseStruct aDBInfo;
fillInfo(info,aDBInfo);
static char envName[] = "DBSERVICE=0";
putenv( envName );
::rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("DBSERVICE"));
::rtl::OUString envData(RTL_CONSTASCII_USTRINGPARAM("0"));
osl_setEnvironment(envVar.pData, envData.pData);
m_sDbRunDir = m_sDbWorkURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/wrk/")) + aDBInfo.sDBName;
String sTemp;

View File

@@ -33,13 +33,13 @@
//------------------------------------------------------------------------
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <cppuhelper/interfacecontainer.h>
#include <osl/diagnose.h>
#include <osl/process.h>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
#include <com/sun/star/ui/dialogs/ControlActions.hpp>
#include <com/sun/star/uno/Any.hxx>
@@ -126,41 +126,8 @@ void SalGtkFilePicker::InitialMapping()
gtk_widget_set_size_request (m_pPreview, -1, -1);
}
static void lcl_setGTKLanguage(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr)
{
static bool bSet = false;
if (bSet)
return;
OUString sUILocale;
try
{
uno::Reference<lang::XMultiServiceFactory> xConfigMgr =
uno::Reference<lang::XMultiServiceFactory>(xServiceMgr->createInstance(
OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
UNO_QUERY_THROW );
Sequence< Any > theArgs(1);
theArgs[ 0 ] <<= OUString::createFromAscii("org.openoffice.Office.Linguistic/General");
uno::Reference< container::XNameAccess > xNameAccess =
uno::Reference< container::XNameAccess >(xConfigMgr->createInstanceWithArguments(
OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), theArgs ),
UNO_QUERY_THROW );
if (xNameAccess.is())
xNameAccess->getByName(OUString::createFromAscii("UILocale")) >>= sUILocale;
} catch (...) {}
if (sUILocale.getLength())
{
sUILocale = rtl::OUString::createFromAscii("LANGUAGE=") + sUILocale.replace('-', '_');
putenv(strdup(rtl::OUStringToOString(sUILocale, osl_getThreadTextEncoding()).getStr()));
}
bSet = true;
}
SalGtkFilePicker::SalGtkFilePicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr ) :
SalGtkPicker(xServiceMgr),
cppu::WeakComponentImplHelper10<
XFilterManager,
XFilterGroupManager,
@@ -184,8 +151,6 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference<lang::XMultiServiceFact
m_PreviewImageWidth( 256 ),
m_PreviewImageHeight( 256 )
{
lcl_setGTKLanguage(xServiceMgr);
int i;
for( i = 0; i < TOGGLE_LAST; i++ )

View File

@@ -84,7 +84,8 @@ namespace
// constructor
//-----------------------------------------------------------------------------------------
SalGtkFolderPicker::SalGtkFolderPicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr ) :
m_xServiceMgr( xServiceMgr )
SalGtkPicker(xServiceMgr),
m_xServiceMgr(xServiceMgr)
{
CResourceProvider aResProvider;

View File

@@ -38,6 +38,7 @@
#include <com/sun/star/awt/XSystemDependentWindowPeer.hpp>
#include <com/sun/star/awt/SystemDependentXWindow.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <rtl/process.h>
@@ -202,6 +203,46 @@ gint RunDialog::run()
return nStatus;
}
static void lcl_setGTKLanguage(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr)
{
static bool bSet = false;
if (bSet)
return;
OUString sUILocale;
try
{
uno::Reference<lang::XMultiServiceFactory> xConfigMgr =
uno::Reference<lang::XMultiServiceFactory>(xServiceMgr->createInstance(
OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
UNO_QUERY_THROW );
Sequence< Any > theArgs(1);
theArgs[ 0 ] <<= OUString::createFromAscii("org.openoffice.Office.Linguistic/General");
uno::Reference< container::XNameAccess > xNameAccess =
uno::Reference< container::XNameAccess >(xConfigMgr->createInstanceWithArguments(
OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"), theArgs ),
UNO_QUERY_THROW );
if (xNameAccess.is())
xNameAccess->getByName(OUString::createFromAscii("UILocale")) >>= sUILocale;
} catch (...) {}
if (sUILocale.getLength())
{
sUILocale = sUILocale.replace('-', '_');
rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("LANGUAGE"));
osl_setEnvironment(envVar.pData, sUILocale.pData);
}
bSet = true;
}
SalGtkPicker::SalGtkPicker(const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr) : m_pDialog(0)
{
lcl_setGTKLanguage(xServiceMgr);
}
SalGtkPicker::~SalGtkPicker()
{
if (m_pDialog)

View File

@@ -53,7 +53,7 @@
class SalGtkPicker
{
public:
SalGtkPicker() : m_pDialog(0) {}
SalGtkPicker(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& xServiceMgr);
virtual ~SalGtkPicker();
protected:
osl::Mutex m_rbHelperMtx;

View File

@@ -241,8 +241,9 @@ void GalApp::Init()
#endif
rtl::OUString baseBinDir = fileName.copy( 0, lastSlash );
rtl::OUString installPrefix = baseBinDir + rtl::OUString::createFromAscii( "/../.." );
rtl::OUString assignment = rtl::OUString::createFromAscii( "OOO_INSTALL_PREFIX=" ) + installPrefix;
putenv( strdup( OUSTRING_CSTR( assignment )));
rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("OOO_INSTALL_PREFIX"));
osl_setEnvironment(envVar.pData, installPrefix.pData);
}
OSL_TRACE( "OOO_INSTALL_PREFIX=%s", getenv( "OOO_INSTALL_PREFIX" ) );