diff options
author | Carsten Driesner <cd@openoffice.org> | 2001-07-20 08:37:43 +0000 |
---|---|---|
committer | Carsten Driesner <cd@openoffice.org> | 2001-07-20 08:37:43 +0000 |
commit | 4e66d684e02353304082c8c1a7bdfb8bbc2d476b (patch) | |
tree | 4af2d63f6986a309822b76078f283be05b658ac3 /desktop | |
parent | bef13bfd70ab8e2f8c6a0264cd06b313f7263bf4 (diff) |
#88595# quickstarter should work if soffice is already running
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/cmdlineargs.cxx | 271 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.hxx | 8 | ||||
-rw-r--r-- | desktop/source/app/officeipcthread.cxx | 67 |
3 files changed, 208 insertions, 138 deletions
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index ac1e2e26986d..9ba2b8580264 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cmdlineargs.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: cd $ $Date: 2001-07-16 12:52:33 $ + * last change: $Author: cd $ $Date: 2001-07-20 09:37:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,50 +72,31 @@ namespace desktop { -CommandLineArgs::CommandLineArgs() : - m_bMinimized( sal_False ), - m_bInvisible( sal_False ), - m_bEmbedding( sal_False ), - m_bBean( sal_False ), - m_bPlugin( sal_False ), - m_bHeadless( sal_False ), - m_bServer( sal_False ), - m_bQuickstart( sal_False ), - m_bOpenList( sal_False ), - m_bPrintList( sal_False ), - m_bPortalConnectString( sal_False ), - m_bAcceptString( sal_False ), - m_bUserDir( sal_False ), - m_bClientDisplay( sal_False ), - m_bTerminateAfterInit( sal_False ) +CommandLineArgs::CommandLineArgs() { + ResetParamValues(); } -CommandLineArgs::CommandLineArgs( const ::vos::OExtCommandLine& aExtCmdLine ) : - m_bMinimized( sal_False ), - m_bInvisible( sal_False ), - m_bEmbedding( sal_False ), - m_bBean( sal_False ), - m_bPlugin( sal_False ), - m_bHeadless( sal_False ), - m_bServer( sal_False ), - m_bQuickstart( sal_False ), - m_bOpenList( sal_False ), - m_bPrintList( sal_False ), - m_bPortalConnectString( sal_False ), - m_bAcceptString( sal_False ), - m_bUserDir( sal_False ), - m_bClientDisplay( sal_False ), - m_bTerminateAfterInit( sal_False ) +// intialize class with command line parameters from process environment +CommandLineArgs::CommandLineArgs( const ::vos::OExtCommandLine& aExtCmdLine ) { + ResetParamValues(); ParseCommandLine_Impl( aExtCmdLine ); } +// intialize class with command line parameters from interprocess communication (officeipcthread) +CommandLineArgs::CommandLineArgs( const ::rtl::OUString& aCmdLineArgs ) +{ + ResetParamValues(); + ParseCommandLine_String( aCmdLineArgs ); +} + +// ---------------------------------------------------------------------------- void CommandLineArgs::ParseCommandLine_Impl( const ::vos::OExtCommandLine& aExtCmdLine ) { - BOOL bPrintEvent = FALSE; - BOOL bOpenEvent = TRUE; + sal_Bool bPrintEvent = sal_False; + sal_Bool bOpenEvent = sal_True; ::vos::OExtCommandLine aCmdLine; sal_uInt32 nCount = aCmdLine.getCommandArgCount(); @@ -125,56 +106,8 @@ void CommandLineArgs::ParseCommandLine_Impl( const ::vos::OExtCommandLine& aExtC aCmdLine.getCommandArg( i, aArg ); String aArgStr = aArg; - if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-minimized" )) == sal_True ) - m_bMinimized = sal_True; - else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-invisible" )) == sal_True ) - m_bInvisible = sal_True; - else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-embedding" )) == sal_True ) - m_bEmbedding = sal_True; - else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-bean" )) == sal_True ) - m_bBean = sal_True; - else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-plugin" )) == sal_True ) - m_bPlugin = sal_True; - else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-server" )) == sal_True ) - m_bServer = sal_True; - else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-headless" )) == sal_True ) - m_bHeadless = sal_True; - else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-quickstart" )) == sal_True ) - m_bQuickstart = sal_True; - else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-terminate_after_init" )) == sal_True ) - m_bTerminateAfterInit; - else if ( aArgStr.Copy(0, 8).EqualsIgnoreCaseAscii( "-accept=" )) - { - m_aAcceptString = aArgStr.Copy( 8 ); - m_bAcceptString = sal_True; - } - else if ( aArgStr.CompareIgnoreCaseToAscii( "-portal," , - RTL_CONSTASCII_LENGTH( "-portal," )) == COMPARE_EQUAL ) - { - m_aPortalConnectString = aArgStr.Copy( RTL_CONSTASCII_LENGTH( "-portal," )); - m_bPortalConnectString = sal_True; - } - else if ( aArgStr.Copy( 0, 7 ).EqualsIgnoreCaseAscii( "-userid" )) - { - ::rtl::OUString aUserId = aArgStr; - - sal_Int32 nPos = aUserId.indexOf( '[' ); - sal_Int32 nEndpos = aUserId.lastIndexOf( ']' ); - if( nPos != -1 && nEndpos != -1 ) - { - m_aUserDir = ::rtl::Uri::decode( - aUserId.copy( nPos + 1, nEndpos - nPos - 1 ), - rtl_UriDecodeWithCharset, - RTL_TEXTENCODING_UTF8 ); - m_bUserDir = sal_True; - } - } - else if ( aArgStr.Copy( 0, 15).EqualsIgnoreCaseAscii( "-clientdisplay=" )) - { - m_aClientDisplay = aArgStr.Copy( 15 ); - m_bClientDisplay = sal_True; - } - else + // unknown command line parameter ? + if ( !InterpretCommandLineParameter( aArg )) { const xub_Unicode* pArg = aArgStr.GetBuffer(); @@ -198,16 +131,16 @@ void CommandLineArgs::ParseCommandLine_Impl( const ::vos::OExtCommandLine& aExtC { // append open event if ( m_aOpenList.getLength() > 0 ) - m_aOpenList = m_aOpenList + APPEVENT_PARAM_DELIMITER; - m_aOpenList = m_aOpenList + aArgStr; + m_aOpenList += ::rtl::OUString::valueOf( (sal_Unicode)APPEVENT_PARAM_DELIMITER ); + m_aOpenList += aArgStr; m_bOpenList = sal_True; } else if ( bPrintEvent ) { // append print event if( m_aPrintList.getLength() ) - m_aPrintList = m_aPrintList + APPEVENT_PARAM_DELIMITER; - m_aPrintList = m_aPrintList + aArgStr; + m_aPrintList += ::rtl::OUString::valueOf( (sal_Unicode)APPEVENT_PARAM_DELIMITER ); + m_aPrintList += aArgStr; m_bPrintList = sal_True; } } @@ -215,4 +148,162 @@ void CommandLineArgs::ParseCommandLine_Impl( const ::vos::OExtCommandLine& aExtC } } +void CommandLineArgs::ParseCommandLine_String( const ::rtl::OUString& aCmdLineString ) +{ + // parse command line arguments + sal_Bool bPrintEvent = sal_False; + sal_Bool bOpenEvent = sal_True; + + sal_Int32 nIndex = 0; + do + { + ::rtl::OUString aArg = aCmdLineString.getToken( 0, '|', nIndex ); + String aArgStr = aArg; + + if ( aArg.getLength() > 0 ) + { + if ( !InterpretCommandLineParameter( aArg )) + { + if ( aArgStr.GetChar(0) == '-' ) + { + // handle this argument as an option + if ( aArgStr.EqualsIgnoreCaseAscii( "-p" )) + { + bPrintEvent = sal_True; + bOpenEvent = sal_False; // Ab hier keine OpenEvents mehr + } + } + else + { + // handle this argument as a filename + if ( bOpenEvent ) + { + // Open Event anhaengen + if ( m_aOpenList.getLength() ) + m_aOpenList += ::rtl::OUString::valueOf( (sal_Unicode)APPEVENT_PARAM_DELIMITER ); + m_aOpenList += aArgStr; + m_bOpenList = sal_True; + } + else if ( bPrintEvent ) + { + // Print Event anhaengen + if( m_aPrintList.getLength() ) + m_aPrintList += ::rtl::OUString::valueOf( (sal_Unicode)APPEVENT_PARAM_DELIMITER ); + m_aPrintList += aArgStr; + m_bPrintList = sal_True; + } + } + } + } + } + while ( nIndex >= 0 ); +} + +sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& aArg ) +{ + String aArgStr( aArg ); + + if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-minimized" )) == sal_True ) + { + m_bMinimized = sal_True; + return sal_True; + } + else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-invisible" )) == sal_True ) + { + m_bInvisible = sal_True; + return sal_True; + } + else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-embedding" )) == sal_True ) + { + m_bEmbedding = sal_True; + return sal_True; + } + else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-bean" )) == sal_True ) + { + m_bBean = sal_True; + return sal_True; + } + else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-plugin" )) == sal_True ) + { + m_bPlugin = sal_True; + return sal_True; + } + else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-server" )) == sal_True ) + { + m_bServer = sal_True; + return sal_True; + } + else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-headless" )) == sal_True ) + { + m_bHeadless = sal_True; + return sal_True; + } + else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-quickstart" )) == sal_True ) + { + m_bQuickstart = sal_True; + return sal_True; + } + else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-terminate_after_init" )) == sal_True ) + { + m_bTerminateAfterInit; + return sal_True; + } + else if ( aArgStr.Copy(0, 8).EqualsIgnoreCaseAscii( "-accept=" )) + { + m_aAcceptString = aArgStr.Copy( 8 ); + m_bAcceptString = sal_True; + return sal_True; + } + else if ( aArgStr.CompareIgnoreCaseToAscii( "-portal," , + RTL_CONSTASCII_LENGTH( "-portal," )) == COMPARE_EQUAL ) + { + m_aPortalConnectString = aArgStr.Copy( RTL_CONSTASCII_LENGTH( "-portal," )); + m_bPortalConnectString = sal_True; + return sal_True; + } + else if ( aArgStr.Copy( 0, 7 ).EqualsIgnoreCaseAscii( "-userid" )) + { + ::rtl::OUString aUserId = aArgStr; + + sal_Int32 nPos = aUserId.indexOf( '[' ); + sal_Int32 nEndpos = aUserId.lastIndexOf( ']' ); + if( nPos != -1 && nEndpos != -1 ) + { + m_aUserDir = ::rtl::Uri::decode( + aUserId.copy( nPos + 1, nEndpos - nPos - 1 ), + rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8 ); + m_bUserDir = sal_True; + } + return sal_True; + } + else if ( aArgStr.Copy( 0, 15).EqualsIgnoreCaseAscii( "-clientdisplay=" )) + { + m_aClientDisplay = aArgStr.Copy( 15 ); + m_bClientDisplay = sal_True; + return sal_True; + } + + return sal_False; +} + +void CommandLineArgs::ResetParamValues() +{ + m_bMinimized = sal_False; + m_bInvisible = sal_False; + m_bEmbedding = sal_False; + m_bBean = sal_False; + m_bPlugin = sal_False; + m_bHeadless = sal_False; + m_bServer = sal_False; + m_bQuickstart = sal_False; + m_bOpenList = sal_False; + m_bPrintList = sal_False; + m_bPortalConnectString = sal_False; + m_bAcceptString = sal_False; + m_bUserDir = sal_False; + m_bClientDisplay = sal_False; + m_bTerminateAfterInit = sal_False; +} + } // namespace desktop diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx index be8d75971ba3..311e1545befc 100644 --- a/desktop/source/app/cmdlineargs.hxx +++ b/desktop/source/app/cmdlineargs.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cmdlineargs.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: cd $ $Date: 2001-07-16 12:52:33 $ + * last change: $Author: cd $ $Date: 2001-07-20 09:37:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,7 +75,10 @@ namespace desktop class CommandLineArgs { private: + sal_Bool InterpretCommandLineParameter( const ::rtl::OUString& ); void ParseCommandLine_Impl( const ::vos::OExtCommandLine& ); + void ParseCommandLine_String( const ::rtl::OUString& ); + void ResetParamValues(); sal_Bool m_bMinimized; sal_Bool m_bInvisible; @@ -102,6 +105,7 @@ class CommandLineArgs public: CommandLineArgs(); CommandLineArgs( const ::vos::OExtCommandLine& aExtCmdLine ); + CommandLineArgs( const ::rtl::OUString& aIPCThreadCmdLine ); sal_Bool IsMinimized(){ return m_bMinimized; } sal_Bool IsInvisible(){ return m_bInvisible; } diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index 6b10ca996223..540b849eedd7 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -2,9 +2,9 @@ * * $RCSfile: officeipcthread.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: cd $ $Date: 2001-07-16 12:52:33 $ + * last change: $Author: cd $ $Date: 2001-07-20 09:37:43 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,7 @@ #include "app.hxx" #include "officeipcthread.hxx" +#include "cmdlineargs.hxx" #include <stdio.h> #ifndef _VOS_PROCESS_HXX_ @@ -75,6 +76,7 @@ using namespace vos; using namespace rtl; +using namespace desktop; #define TERMINATION_SEQUENCE "InternalIPC::TerminateThread" #define TERMINATION_LENGTH 28 @@ -223,51 +225,24 @@ void SAL_CALL OfficeIPCThread::run() TERMINATION_LENGTH ) == COMPARE_EQUAL ) return; - // parse command line arguments - // dispatch open and print events - int nToken = aArguments.GetTokenCount( '|' ); - BOOL bPrintEvent = FALSE; - BOOL bOpenEvent = TRUE; - String aOpenList; - String aPrintList; - String aEmpty; + ::rtl::OUString aOpenList; + ::rtl::OUString aPrintList; + String aEmpty; + CommandLineArgs aCmdLineArgs( OUString( aArguments.GetBuffer(), aArguments.Len(), gsl_getSystemTextEncoding() )); - for( int n=0; n<nToken; n++ ) + if ( aCmdLineArgs.IsQuickstart() ) { - String aArg( aArguments.GetToken( n, '|' ), gsl_getSystemTextEncoding() ); - if ( aArg.Len() > 0 ) - { - if ( aArg.GetChar(0) == '-' ) - { - // handle this argument as an option - if ( aArg.EqualsIgnoreCaseAscii( "-p" )) - { - bPrintEvent = TRUE; - bOpenEvent = FALSE; // Ab hier keine OpenEvents mehr - } - } - else - { - // handle this argument as a filename - if ( bOpenEvent ) - { - // Open Event anhaengen - if ( aOpenList.Len() ) - aOpenList += APPEVENT_PARAM_DELIMITER; - aOpenList += aArg; - } - else if ( bPrintEvent ) - { - // Print Event anhaengen - if( aPrintList.Len() ) - aPrintList += APPEVENT_PARAM_DELIMITER; - aPrintList += aArg; - } - } - } + // we have to use application event, because we have to start quickstart service in main thread!! + ApplicationEvent* pAppEvent = + new ApplicationEvent( aEmpty, aEmpty, + "QUICKSTART", aEmpty ); + ImplPostForeignAppEvent( pAppEvent ); } - if( aOpenList.Len() ) + aCmdLineArgs.GetOpenList( aOpenList ); + aCmdLineArgs.GetPrintList( aPrintList ); + + if( aOpenList.getLength() ) { // open file(s) ApplicationEvent* pAppEvent = @@ -276,7 +251,7 @@ void SAL_CALL OfficeIPCThread::run() ImplPostForeignAppEvent( pAppEvent ); } - if ( aPrintList.Len() ) + if ( aPrintList.getLength() ) { // print file(s) ApplicationEvent* pAppEvent = @@ -285,7 +260,7 @@ void SAL_CALL OfficeIPCThread::run() ImplPostForeignAppEvent( pAppEvent ); } - if ( aPrintList.Len() == 0 && aOpenList.Len() == 0 ) + if ( aPrintList.getLength() == 0 && aOpenList.getLength() == 0 ) { // no document was send, just bring Office to front ApplicationEvent* pAppEvent = @@ -305,4 +280,4 @@ void SAL_CALL OfficeIPCThread::run() sleep( tval ); } } -}; +} |