diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-11-01 13:27:39 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2007-11-01 13:27:39 +0000 |
commit | 3892cb462f5d7653b09af656a348da62db124e3e (patch) | |
tree | a91931db40f607c66f539c72f7d4cd56eecba070 /desktop/source/deployment/misc | |
parent | 66b908b45cde78af020b35e817e67bc40b8493f0 (diff) |
INTEGRATION: CWS jl81_SRC680 (1.14.52); FILE MERGED
2007/10/23 13:15:55 jl 1.14.52.4: #i81988# removing OSL_ENSURE
2007/10/19 15:29:14 jl 1.14.52.3: #i81988#
2007/10/19 15:04:36 jl 1.14.52.2: #i81988#
2007/10/19 13:21:55 jl 1.14.52.1: #i81988# office_is_running checks does not open pipe when runngin in soffice.bin
Diffstat (limited to 'desktop/source/deployment/misc')
-rw-r--r-- | desktop/source/deployment/misc/dp_misc.cxx | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 49abeaf3ab39..fcdb10957035 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -4,9 +4,9 @@ * * $RCSfile: dp_misc.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: rt $ $Date: 2007-07-26 08:54:46 $ + * last change: $Author: hr $ $Date: 2007-11-01 14:27:39 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -59,6 +59,15 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using ::rtl::OUString; + +#define SOFFICE1 "soffice.exe" +#define SOFFICE2 "soffice.bin" +#define SBASE "sbase.exe" +#define SCALC "scalc.exe" +#define SDRAW "sdraw.exe" +#define SIMPRESS "simpress.exe" +#define SWRITER "swriter.exe" + namespace dp_misc { namespace { @@ -139,6 +148,16 @@ const OUString OfficePipeId::operator () () return buf.makeStringAndClear(); } +bool existsOfficePipe() +{ + OUString const & pipeId = OfficePipeId::get(); + if (pipeId.getLength() == 0) + return false; + ::osl::Security sec; + ::osl::Pipe pipe( pipeId, osl_Pipe_OPEN, sec ); + return pipe.is(); +} + } // anon namespace //============================================================================== @@ -252,12 +271,44 @@ OUString expandUnoRcUrl( OUString const & url ) //============================================================================== bool office_is_running() { - OUString const & pipeId = OfficePipeId::get(); - if (pipeId.getLength() == 0) - return false; - ::osl::Security sec; - ::osl::Pipe pipe( pipeId, osl_Pipe_OPEN, sec ); - return pipe.is(); + //We need to check if we run within the office process. Then we must not use the pipe, because + //this could cause a deadlock. This is actually a workaround for i82778 + OUString sFile; + oslProcessError err = osl_getExecutableFile(& sFile.pData); + bool ret = false; + if (osl_Process_E_None == err) + { + sFile = sFile.copy(sFile.lastIndexOf('/') + 1); + if ( +#if defined UNIX + sFile.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(SOFFICE2))) +#elif defined WNT + //osl_getExecutableFile should deliver "soffice.bin" on windows + //even if swriter.exe, scalc.exe etc. was started. This is a bug + //in osl_getExecutableFile + sFile.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(SOFFICE1))) + || sFile.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(SOFFICE2))) + || sFile.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(SBASE))) + || sFile.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(SCALC))) + || sFile.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(SDRAW))) + || sFile.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(SIMPRESS))) + || sFile.equals(OUString(RTL_CONSTASCII_USTRINGPARAM(SWRITER))) +#else +#error "Unsupported platform" +#endif + + ) + ret = true; + else + ret = existsOfficePipe(); + } + else + { + OSL_ENSURE(0, "NOT osl_Process_E_None "); + //if osl_getExecutable file than we take the risk of creating a pipe + ret = existsOfficePipe(); + } + return ret; } //============================================================================== |