summaryrefslogtreecommitdiff
path: root/desktop/win32
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2005-11-11 12:09:54 +0000
committerRüdiger Timm <rt@openoffice.org>2005-11-11 12:09:54 +0000
commitff95700a658024c61df910e33aa0696554acfa45 (patch)
treeb366f71934f4d8d9d49c19120522a6f72b59ffa1 /desktop/win32
parentb98a455451428c36e0bdfe425e17e2bbf0650208 (diff)
INTEGRATION: CWS c06 (1.3.82); FILE MERGED
2005/11/08 09:55:41 hro 1.3.82.3: #i54955# Always pass image name as first argument in command line 2005/11/08 09:47:07 hro 1.3.82.2: #i54955# Always pass image name as first argument in command line 2005/09/28 13:37:27 hro 1.3.82.1: #i54955# On restart after a crash forward bootstrap args
Diffstat (limited to 'desktop/win32')
-rw-r--r--desktop/win32/source/officeloader/officeloader.cxx70
1 files changed, 65 insertions, 5 deletions
diff --git a/desktop/win32/source/officeloader/officeloader.cxx b/desktop/win32/source/officeloader/officeloader.cxx
index 81b26ea4018d..da94d814404d 100644
--- a/desktop/win32/source/officeloader/officeloader.cxx
+++ b/desktop/win32/source/officeloader/officeloader.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: officeloader.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: rt $ $Date: 2005-10-19 12:20:52 $
+ * last change: $Author: rt $ $Date: 2005-11-11 13:09:54 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -33,11 +33,12 @@
*
************************************************************************/
#define UNICODE
+#define _UNICODE
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <shellapi.h>
-#define _UNICODE
#include <tchar.h>
#include <malloc.h>
@@ -119,6 +120,18 @@ BOOL WINAPI ConvertSidToStringSid( PSID pSid, LPTSTR* StringSid )
//---------------------------------------------------------------------------
+static LPTSTR *GetCommandArgs( int *pArgc )
+{
+#ifdef UNICODE
+ return CommandLineToArgvW( GetCommandLineW(), pArgc );
+#else
+ *pArgc = __argc;
+ return __argv;
+#endif
+}
+
+//---------------------------------------------------------------------------
+
int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
{
TCHAR szTargetFileName[MAX_PATH] = TEXT("");
@@ -154,7 +167,10 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
// are directed to the created pipes
DWORD dwExitCode = (DWORD)-1;
+
+ // FALSE indicates first start
BOOL fSuccess = FALSE;
+ LPTSTR lpCommandLine = NULL;
do
{
@@ -251,13 +267,51 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
}
}
+ if ( fSuccess && !lpCommandLine )
+ {
+ int argc;
+ LPTSTR *argv = GetCommandArgs( &argc );
+
+ if ( argc > 1 )
+ {
+ int n;
+ int nBufferChars = _tcslen( argv[0] ) + 2;
+
+ for ( n = 1; n < argc; n++ )
+ {
+ if ( 0 == _tcsnicmp( argv[n], _T("-env:"), 5 ) )
+ nBufferChars += _tcslen( argv[n] ) + 3;
+ }
+
+ if ( nBufferChars )
+ {
+ lpCommandLine = new TCHAR[nBufferChars + 1];
+
+ _tcscpy( lpCommandLine, _T("\"") );
+ _tcscat( lpCommandLine, argv[0] );
+ _tcscat( lpCommandLine, _T("\"") );
+
+ for ( n = 1; n < argc; n++ )
+ {
+ if ( 0 == _tcsnicmp( argv[n], _T("-env:"), 5 ) )
+ {
+ _tcscat( lpCommandLine, _T(" ") );
+ _tcscat( lpCommandLine, _T("\"") );
+ _tcscat( lpCommandLine, argv[n] );
+ _tcscat( lpCommandLine, _T("\"") );
+ }
+ }
+ }
+ }
+ }
+
PROCESS_INFORMATION aProcessInfo;
fSuccess = FALSE;
fSuccess = CreateProcess(
szTargetFileName,
- // When restarting office process do not pass a command line
- fSuccess ? NULL : GetCommandLine(),
+ // When restarting office process only reuse bootstrap parameters
+ fSuccess ? lpCommandLine : GetCommandLine(),
NULL,
NULL,
TRUE,
@@ -291,6 +345,12 @@ int WINAPI _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
CloseHandle( aProcessInfo.hProcess );
CloseHandle( aProcessInfo.hThread );
+
+ if ( lpCommandLine )
+ {
+ delete lpCommandLine;
+ lpCommandLine = 0;
+ }
}
} while ( fSuccess && ::desktop::ExitHelper::E_CRASH_WITH_RESTART == dwExitCode );