xref: /aoo41x/main/desktop/source/app/cmdlineargs.cxx (revision 2ad018be)
1cdf0e10cSrcweir /*************************************************************************
2cdf0e10cSrcweir  *
3cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4cdf0e10cSrcweir  *
5cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6cdf0e10cSrcweir  *
7cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8cdf0e10cSrcweir  *
9cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10cdf0e10cSrcweir  *
11cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14cdf0e10cSrcweir  *
15cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20cdf0e10cSrcweir  *
21cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25cdf0e10cSrcweir  *
26cdf0e10cSrcweir  ************************************************************************/
27cdf0e10cSrcweir 
28cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29cdf0e10cSrcweir #include "precompiled_desktop.hxx"
30cdf0e10cSrcweir #include <cmdlineargs.hxx>
31cdf0e10cSrcweir #include <vcl/svapp.hxx>
32cdf0e10cSrcweir #include <rtl/uri.hxx>
33cdf0e10cSrcweir #include <rtl/ustring.hxx>
34cdf0e10cSrcweir #include "rtl/process.h"
35cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
36cdf0e10cSrcweir #include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
37cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
39cdf0e10cSrcweir #include "tools/getprocessworkingdir.hxx"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <svl/documentlockfile.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir using namespace rtl;
44cdf0e10cSrcweir using namespace com::sun::star::lang;
45cdf0e10cSrcweir using namespace com::sun::star::uri;
46cdf0e10cSrcweir using namespace com::sun::star::uno;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace desktop
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 
51cdf0e10cSrcweir namespace {
52cdf0e10cSrcweir 
53cdf0e10cSrcweir class ExtCommandLineSupplier: public CommandLineArgs::Supplier {
54cdf0e10cSrcweir public:
55cdf0e10cSrcweir     explicit ExtCommandLineSupplier():
56cdf0e10cSrcweir         m_count(rtl_getAppCommandArgCount()),
57cdf0e10cSrcweir         m_index(0)
58cdf0e10cSrcweir     {
59cdf0e10cSrcweir         rtl::OUString url;
60cdf0e10cSrcweir         if (tools::getProcessWorkingDir(&url)) {
61cdf0e10cSrcweir             m_cwdUrl.reset(url);
62cdf0e10cSrcweir         }
63cdf0e10cSrcweir     }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     virtual ~ExtCommandLineSupplier() {}
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     virtual boost::optional< rtl::OUString > getCwdUrl() { return m_cwdUrl; }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     virtual bool next(rtl::OUString * argument) {
70cdf0e10cSrcweir         OSL_ASSERT(argument != NULL);
71cdf0e10cSrcweir         if (m_index < m_count) {
72cdf0e10cSrcweir             rtl_getAppCommandArg(m_index++, &argument->pData);
73cdf0e10cSrcweir             return true;
74cdf0e10cSrcweir         } else {
75cdf0e10cSrcweir             return false;
76cdf0e10cSrcweir         }
77cdf0e10cSrcweir     }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir private:
80cdf0e10cSrcweir     boost::optional< rtl::OUString > m_cwdUrl;
81cdf0e10cSrcweir     sal_uInt32 m_count;
82cdf0e10cSrcweir     sal_uInt32 m_index;
83cdf0e10cSrcweir };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir static CommandLineArgs::BoolParam aModuleGroupDefinition[] =
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	CommandLineArgs::CMD_BOOLPARAM_WRITER,
90cdf0e10cSrcweir 	CommandLineArgs::CMD_BOOLPARAM_CALC,
91cdf0e10cSrcweir 	CommandLineArgs::CMD_BOOLPARAM_DRAW,
92cdf0e10cSrcweir 	CommandLineArgs::CMD_BOOLPARAM_IMPRESS,
93cdf0e10cSrcweir 	CommandLineArgs::CMD_BOOLPARAM_GLOBAL,
94cdf0e10cSrcweir 	CommandLineArgs::CMD_BOOLPARAM_MATH,
95cdf0e10cSrcweir 	CommandLineArgs::CMD_BOOLPARAM_WEB,
96cdf0e10cSrcweir 	CommandLineArgs::CMD_BOOLPARAM_BASE
97cdf0e10cSrcweir };
98cdf0e10cSrcweir 
99cdf0e10cSrcweir CommandLineArgs::GroupDefinition CommandLineArgs::m_pGroupDefinitions[ CommandLineArgs::CMD_GRPID_COUNT ] =
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	{ 8, aModuleGroupDefinition }
102cdf0e10cSrcweir };
103cdf0e10cSrcweir 
104cdf0e10cSrcweir CommandLineArgs::Supplier::Exception::Exception() {}
105cdf0e10cSrcweir 
106cdf0e10cSrcweir CommandLineArgs::Supplier::Exception::Exception(Exception const &) {}
107cdf0e10cSrcweir 
108cdf0e10cSrcweir CommandLineArgs::Supplier::Exception::~Exception() {}
109cdf0e10cSrcweir 
110cdf0e10cSrcweir CommandLineArgs::Supplier::Exception &
111cdf0e10cSrcweir CommandLineArgs::Supplier::Exception::operator =(Exception const &)
112cdf0e10cSrcweir { return *this; }
113cdf0e10cSrcweir 
114cdf0e10cSrcweir CommandLineArgs::Supplier::~Supplier() {}
115cdf0e10cSrcweir 
116cdf0e10cSrcweir // intialize class with command line parameters from process environment
117cdf0e10cSrcweir CommandLineArgs::CommandLineArgs()
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	ResetParamValues();
120cdf0e10cSrcweir     ExtCommandLineSupplier s;
121cdf0e10cSrcweir 	ParseCommandLine_Impl( s );
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir CommandLineArgs::CommandLineArgs( Supplier& supplier )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	ResetParamValues();
127cdf0e10cSrcweir 	ParseCommandLine_Impl( supplier );
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir // ----------------------------------------------------------------------------
131cdf0e10cSrcweir 
132cdf0e10cSrcweir void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir     m_cwdUrl = supplier.getCwdUrl();
135cdf0e10cSrcweir 	Reference<XMultiServiceFactory> xMS(comphelper::getProcessServiceFactory(), UNO_QUERY);
136cdf0e10cSrcweir 	OSL_ENSURE(xMS.is(), "CommandLineArgs: no ProcessServiceFactory.");
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     Reference< XExternalUriReferenceTranslator > xTranslator(
139cdf0e10cSrcweir         xMS->createInstance(
140cdf0e10cSrcweir         OUString::createFromAscii(
141cdf0e10cSrcweir         "com.sun.star.uri.ExternalUriReferenceTranslator")),
142cdf0e10cSrcweir         UNO_QUERY);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	// parse command line arguments
145cdf0e10cSrcweir     bool bOpenEvent(true);
146cdf0e10cSrcweir     bool bPrintEvent(false);
147cdf0e10cSrcweir     bool bViewEvent(false);
148cdf0e10cSrcweir     bool bStartEvent(false);
149cdf0e10cSrcweir     bool bPrintToEvent(false);
150cdf0e10cSrcweir     bool bPrinterName(false);
151cdf0e10cSrcweir     bool bForceOpenEvent(false);
152cdf0e10cSrcweir     bool bForceNewEvent(false);
153cdf0e10cSrcweir     bool bDisplaySpec(false);
154cdf0e10cSrcweir     bool bOpenDoc(false);
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     m_eArgumentCount = NONE;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     for (;;)
159cdf0e10cSrcweir     {
160cdf0e10cSrcweir         ::rtl::OUString	aArg;
161cdf0e10cSrcweir         if ( !supplier.next( &aArg ) )
162cdf0e10cSrcweir         {
163cdf0e10cSrcweir             break;
164cdf0e10cSrcweir         }
165cdf0e10cSrcweir         // convert file URLs to internal form #112849#
166cdf0e10cSrcweir         if (aArg.indexOf(OUString::createFromAscii("file:"))==0 &&
167cdf0e10cSrcweir             xTranslator.is())
168cdf0e10cSrcweir         {
169cdf0e10cSrcweir             OUString tmp(xTranslator->translateToInternal(aArg));
170cdf0e10cSrcweir             if (tmp.getLength() > 0)
171cdf0e10cSrcweir                 aArg = tmp;
172cdf0e10cSrcweir         }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         String aArgStr = aArg;
175cdf0e10cSrcweir         if ( aArg.getLength() > 0 )
176cdf0e10cSrcweir         {
177cdf0e10cSrcweir             m_eArgumentCount = m_eArgumentCount == NONE ? ONE : MANY;
178cdf0e10cSrcweir             if ( !InterpretCommandLineParameter( aArg ))
179cdf0e10cSrcweir             {
180cdf0e10cSrcweir                 if ( aArgStr.GetChar(0) == '-' )
181cdf0e10cSrcweir                 {
182cdf0e10cSrcweir                     // handle this argument as an option
183cdf0e10cSrcweir                     if ( aArgStr.EqualsIgnoreCaseAscii( "-n" ))
184cdf0e10cSrcweir                     {
185cdf0e10cSrcweir                         // force new documents based on the following documents
186cdf0e10cSrcweir                         bForceNewEvent  = true;
187cdf0e10cSrcweir                         bOpenEvent      = false;
188cdf0e10cSrcweir                         bForceOpenEvent = false;
189cdf0e10cSrcweir                         bPrintToEvent   = false;
190cdf0e10cSrcweir                         bPrintEvent     = false;
191cdf0e10cSrcweir                         bViewEvent      = false;
192cdf0e10cSrcweir                         bStartEvent     = false;
193cdf0e10cSrcweir                         bDisplaySpec    = false;
194cdf0e10cSrcweir                     }
195cdf0e10cSrcweir                     else if ( aArgStr.EqualsIgnoreCaseAscii( "-o" ))
196cdf0e10cSrcweir                     {
197cdf0e10cSrcweir                         // force open documents regardless if they are templates or not
198cdf0e10cSrcweir                         bForceOpenEvent = true;
199cdf0e10cSrcweir                         bOpenEvent      = false;
200cdf0e10cSrcweir                         bForceNewEvent  = false;
201cdf0e10cSrcweir                         bPrintToEvent   = false;
202cdf0e10cSrcweir                         bPrintEvent     = false;
203cdf0e10cSrcweir                         bViewEvent      = false;
204cdf0e10cSrcweir                         bStartEvent     = false;
205cdf0e10cSrcweir                         bDisplaySpec    = false;
206cdf0e10cSrcweir                     }
207cdf0e10cSrcweir                     else if ( aArgStr.EqualsIgnoreCaseAscii( "-pt" ))
208cdf0e10cSrcweir                     {
209cdf0e10cSrcweir                         // Print to special printer
210cdf0e10cSrcweir                         bPrintToEvent   = true;
211cdf0e10cSrcweir                         bPrinterName    = true;
212cdf0e10cSrcweir                         bPrintEvent     = false;
213cdf0e10cSrcweir                         bOpenEvent      = false;
214cdf0e10cSrcweir                         bForceNewEvent  = false;
215cdf0e10cSrcweir                         bViewEvent      = false;
216cdf0e10cSrcweir                         bStartEvent     = false;
217cdf0e10cSrcweir                         bDisplaySpec    = false;
218cdf0e10cSrcweir                         bForceOpenEvent = false;
219cdf0e10cSrcweir                    }
220cdf0e10cSrcweir                    else if ( aArgStr.EqualsIgnoreCaseAscii( "-p" ))
221cdf0e10cSrcweir                    {
222cdf0e10cSrcweir                         // Print to default printer
223cdf0e10cSrcweir                         bPrintEvent     = true;
224cdf0e10cSrcweir                         bPrintToEvent   = false;
225cdf0e10cSrcweir                         bOpenEvent      = false;
226cdf0e10cSrcweir                         bForceNewEvent  = false;
227cdf0e10cSrcweir                         bForceOpenEvent = false;
228cdf0e10cSrcweir                         bViewEvent      = false;
229cdf0e10cSrcweir                         bStartEvent     = false;
230cdf0e10cSrcweir                         bDisplaySpec    = false;
231cdf0e10cSrcweir                    }
232cdf0e10cSrcweir                    else if ( aArgStr.EqualsIgnoreCaseAscii( "-view" ))
233cdf0e10cSrcweir                    {
234cdf0e10cSrcweir                         // open in viewmode
235cdf0e10cSrcweir                         bOpenEvent      = false;
236cdf0e10cSrcweir                         bPrintEvent     = false;
237cdf0e10cSrcweir                         bPrintToEvent   = false;
238cdf0e10cSrcweir                         bForceNewEvent  = false;
239cdf0e10cSrcweir                         bForceOpenEvent = false;
240cdf0e10cSrcweir                         bViewEvent      = true;
241cdf0e10cSrcweir                         bStartEvent     = false;
242cdf0e10cSrcweir                         bDisplaySpec    = false;
243cdf0e10cSrcweir  		    }
244cdf0e10cSrcweir                     else if ( aArgStr.EqualsIgnoreCaseAscii( "-show" ))
245cdf0e10cSrcweir                     {
246cdf0e10cSrcweir                         // open in viewmode
247cdf0e10cSrcweir                         bOpenEvent      = false;
248cdf0e10cSrcweir                         bViewEvent      = false;
249cdf0e10cSrcweir                         bStartEvent     = true;
250cdf0e10cSrcweir                         bPrintEvent     = false;
251cdf0e10cSrcweir                         bPrintToEvent   = false;
252cdf0e10cSrcweir                         bForceNewEvent  = false;
253cdf0e10cSrcweir                         bForceOpenEvent = false;
254cdf0e10cSrcweir                         bDisplaySpec    = false;
255cdf0e10cSrcweir                     }
256cdf0e10cSrcweir                     else if ( aArgStr.EqualsIgnoreCaseAscii( "-display" ))
257cdf0e10cSrcweir                     {
258cdf0e10cSrcweir                         // set display
259cdf0e10cSrcweir                         bOpenEvent      = false;
260cdf0e10cSrcweir                         bPrintEvent     = false;
261cdf0e10cSrcweir                         bForceOpenEvent = false;
262cdf0e10cSrcweir                         bPrintToEvent   = false;
263cdf0e10cSrcweir                         bForceNewEvent  = false;
264cdf0e10cSrcweir                         bViewEvent      = false;
265cdf0e10cSrcweir                         bStartEvent     = false;
266cdf0e10cSrcweir                         bDisplaySpec    = true;
267cdf0e10cSrcweir                     }
268cdf0e10cSrcweir                     else if ( aArgStr.EqualsIgnoreCaseAscii( "-language" ))
269cdf0e10cSrcweir                     {
270cdf0e10cSrcweir                         bOpenEvent      = false;
271cdf0e10cSrcweir                         bPrintEvent     = false;
272cdf0e10cSrcweir                         bForceOpenEvent = false;
273cdf0e10cSrcweir                         bPrintToEvent   = false;
274cdf0e10cSrcweir                         bForceNewEvent  = false;
275cdf0e10cSrcweir                         bViewEvent      = false;
276cdf0e10cSrcweir                         bStartEvent     = false;
277cdf0e10cSrcweir                         bDisplaySpec    = false;
278cdf0e10cSrcweir                     }
279cdf0e10cSrcweir 
280cdf0e10cSrcweir                     #ifdef MACOSX
281cdf0e10cSrcweir                     /* #i84053# ignore -psn on Mac
282cdf0e10cSrcweir                        Platform dependent #ifdef here is ugly, however this is currently
283cdf0e10cSrcweir                        the only platform dependent parameter. Should more appear
284cdf0e10cSrcweir                        we should find a better solution
285cdf0e10cSrcweir                     */
286cdf0e10cSrcweir                     else if ( aArgStr.CompareToAscii( "-psn", 4 ) == COMPARE_EQUAL )
287cdf0e10cSrcweir                     {
288cdf0e10cSrcweir                         // finder argument from MacOSX
289cdf0e10cSrcweir                         bOpenEvent      = false;
290cdf0e10cSrcweir                        	bPrintEvent     = false;
291cdf0e10cSrcweir                         bForceOpenEvent = false;
292cdf0e10cSrcweir                         bPrintToEvent   = false;
293cdf0e10cSrcweir                         bForceNewEvent  = false;
294cdf0e10cSrcweir                         bViewEvent      = false;
295cdf0e10cSrcweir                         bStartEvent     = false;
296cdf0e10cSrcweir                         bDisplaySpec    = false;
297cdf0e10cSrcweir                     }
298cdf0e10cSrcweir                     #endif
299cdf0e10cSrcweir                 }
300cdf0e10cSrcweir                 else
301cdf0e10cSrcweir                 {
302cdf0e10cSrcweir                     if ( bPrinterName && bPrintToEvent )
303cdf0e10cSrcweir                     {
304cdf0e10cSrcweir                         // first argument after "-pt" this must be the printer name
305cdf0e10cSrcweir                         AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME, aArgStr );
306cdf0e10cSrcweir                         bPrinterName = sal_False;
307cdf0e10cSrcweir                     }
308cdf0e10cSrcweir                     else
309cdf0e10cSrcweir                     {
310cdf0e10cSrcweir                         // handle this argument as a filename
311cdf0e10cSrcweir                         if ( bOpenEvent )
312cdf0e10cSrcweir                         {
313cdf0e10cSrcweir                             AddStringListParam_Impl( CMD_STRINGPARAM_OPENLIST, aArgStr );
314cdf0e10cSrcweir                             bOpenDoc = true;
315cdf0e10cSrcweir                         }
316cdf0e10cSrcweir                         else if ( bViewEvent )
317cdf0e10cSrcweir 	                {
318cdf0e10cSrcweir                             AddStringListParam_Impl( CMD_STRINGPARAM_VIEWLIST, aArgStr );
319cdf0e10cSrcweir                             bOpenDoc = true;
320cdf0e10cSrcweir                         }
321cdf0e10cSrcweir                         else if ( bStartEvent )
322cdf0e10cSrcweir                         {
323cdf0e10cSrcweir                             AddStringListParam_Impl( CMD_STRINGPARAM_STARTLIST, aArgStr );
324cdf0e10cSrcweir                             bOpenDoc = true;
325cdf0e10cSrcweir                         }
326cdf0e10cSrcweir                         else if ( bPrintEvent )
327cdf0e10cSrcweir                         {
328cdf0e10cSrcweir                             AddStringListParam_Impl( CMD_STRINGPARAM_PRINTLIST, aArgStr );
329cdf0e10cSrcweir                             bOpenDoc = true;
330cdf0e10cSrcweir                         }
331cdf0e10cSrcweir                         else if ( bPrintToEvent )
332cdf0e10cSrcweir                         {
333cdf0e10cSrcweir                             AddStringListParam_Impl( CMD_STRINGPARAM_PRINTTOLIST, aArgStr );
334cdf0e10cSrcweir                             bOpenDoc = true;
335cdf0e10cSrcweir                         }
336cdf0e10cSrcweir                         else if ( bForceNewEvent )
337cdf0e10cSrcweir                         {
338cdf0e10cSrcweir                             AddStringListParam_Impl( CMD_STRINGPARAM_FORCENEWLIST, aArgStr );
339cdf0e10cSrcweir                             bOpenDoc = true;
340cdf0e10cSrcweir                         }
341cdf0e10cSrcweir                         else if ( bForceOpenEvent )
342cdf0e10cSrcweir                         {
343cdf0e10cSrcweir                             AddStringListParam_Impl( CMD_STRINGPARAM_FORCEOPENLIST, aArgStr );
344cdf0e10cSrcweir                             bOpenDoc = true;
345cdf0e10cSrcweir                         }
346cdf0e10cSrcweir                         else if ( bDisplaySpec )
347cdf0e10cSrcweir                         {
348cdf0e10cSrcweir                             AddStringListParam_Impl( CMD_STRINGPARAM_DISPLAY, aArgStr );
349cdf0e10cSrcweir                             bDisplaySpec = false; // only one display, not a lsit
350cdf0e10cSrcweir                             bOpenEvent = true;    // set back to standard
351cdf0e10cSrcweir                         }
352cdf0e10cSrcweir                     }
353cdf0e10cSrcweir                 }
354cdf0e10cSrcweir             }
355cdf0e10cSrcweir         }
356cdf0e10cSrcweir     }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir     if ( bOpenDoc )
359cdf0e10cSrcweir         m_bDocumentArgs = true;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir void CommandLineArgs::AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir 	OSL_ASSERT( eParam >= 0 && eParam < CMD_STRINGPARAM_COUNT );
365cdf0e10cSrcweir 	if ( m_aStrParams[eParam].getLength() )
366cdf0e10cSrcweir 		m_aStrParams[eParam] += ::rtl::OUString::valueOf( (sal_Unicode)APPEVENT_PARAM_DELIMITER );
367cdf0e10cSrcweir 	m_aStrParams[eParam] += aParam;
368cdf0e10cSrcweir 	m_aStrSetParams[eParam] = sal_True;
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
371cdf0e10cSrcweir void CommandLineArgs::SetBoolParam_Impl( BoolParam eParam, sal_Bool bValue )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir 	OSL_ASSERT( eParam >= 0 && eParam < CMD_BOOLPARAM_COUNT );
374cdf0e10cSrcweir 	m_aBoolParams[eParam] = bValue;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir 
377cdf0e10cSrcweir sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& aArg )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir     String aArgStr( aArg );
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-minimized" )) == sal_True )
382cdf0e10cSrcweir     {
383cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_MINIMIZED, sal_True );
384cdf0e10cSrcweir         return sal_True;
385cdf0e10cSrcweir     }
386cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-invisible" )) == sal_True )
387cdf0e10cSrcweir     {
388cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_INVISIBLE, sal_True );
389cdf0e10cSrcweir         return sal_True;
390cdf0e10cSrcweir     }
391cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-norestore" )) == sal_True )
392cdf0e10cSrcweir     {
393cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_NORESTORE, sal_True );
394cdf0e10cSrcweir         return sal_True;
395cdf0e10cSrcweir     }
396cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nodefault" )) == sal_True )
397cdf0e10cSrcweir     {
398cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_NODEFAULT, sal_True );
399cdf0e10cSrcweir         return sal_True;
400cdf0e10cSrcweir     }
401cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-bean" )) == sal_True )
402cdf0e10cSrcweir     {
403cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_BEAN, sal_True );
404cdf0e10cSrcweir         return sal_True;
405cdf0e10cSrcweir     }
406cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-plugin" )) == sal_True )
407cdf0e10cSrcweir     {
408cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_PLUGIN, sal_True );
409cdf0e10cSrcweir         return sal_True;
410cdf0e10cSrcweir     }
411cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-server" )) == sal_True )
412cdf0e10cSrcweir     {
413cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_SERVER, sal_True );
414cdf0e10cSrcweir         return sal_True;
415cdf0e10cSrcweir     }
416cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-headless" )) == sal_True )
417cdf0e10cSrcweir     {
418cdf0e10cSrcweir         // Headless means also invisibile, so set this parameter to true!
419cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HEADLESS, sal_True );
420cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_INVISIBLE, sal_True );
421cdf0e10cSrcweir         return sal_True;
422cdf0e10cSrcweir     }
423cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-quickstart" )) == sal_True )
424cdf0e10cSrcweir     {
425*2ad018beSPedro Giffuni #if defined(ENABLE_QUICKSTART_APPLET)
426cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_QUICKSTART, sal_True );
427cdf0e10cSrcweir #endif
428cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_NOQUICKSTART, sal_False );
429cdf0e10cSrcweir         return sal_True;
430cdf0e10cSrcweir     }
431cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-quickstart=no" )))
432cdf0e10cSrcweir     {
433cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_NOQUICKSTART, sal_True );
434cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_QUICKSTART, sal_False );
435cdf0e10cSrcweir         return sal_True;
436cdf0e10cSrcweir     }
437cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-terminate_after_init" )) == sal_True )
438cdf0e10cSrcweir     {
439cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_TERMINATEAFTERINIT, sal_True );
440cdf0e10cSrcweir         return sal_True;
441cdf0e10cSrcweir     }
442cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nofirststartwizard" )) == sal_True )
443cdf0e10cSrcweir     {
444cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_NOFIRSTSTARTWIZARD, sal_True );
445cdf0e10cSrcweir         return sal_True;
446cdf0e10cSrcweir     }
447cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nologo" )) == sal_True )
448cdf0e10cSrcweir     {
449cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_NOLOGO, sal_True );
450cdf0e10cSrcweir         return sal_True;
451cdf0e10cSrcweir     }
452cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nolockcheck" )) == sal_True )
453cdf0e10cSrcweir     {
454cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_NOLOCKCHECK, sal_True );
455cdf0e10cSrcweir         // Workaround for automated testing
456cdf0e10cSrcweir         ::svt::DocumentLockFile::AllowInteraction( sal_False );
457cdf0e10cSrcweir 
458cdf0e10cSrcweir         return sal_True;
459cdf0e10cSrcweir     }
460cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-help" ))
461cdf0e10cSrcweir 	      || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" ))
462cdf0e10cSrcweir 	      || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-?" )))
463cdf0e10cSrcweir     {
464cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HELP, sal_True );
465cdf0e10cSrcweir         return sal_True;
466cdf0e10cSrcweir     }
467cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpwriter" )) == sal_True )
468cdf0e10cSrcweir     {
469cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HELPWRITER, sal_True );
470cdf0e10cSrcweir         return sal_True;
471cdf0e10cSrcweir     }
472cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpcalc" )) == sal_True )
473cdf0e10cSrcweir     {
474cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HELPCALC, sal_True );
475cdf0e10cSrcweir         return sal_True;
476cdf0e10cSrcweir     }
477cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpdraw" )) == sal_True )
478cdf0e10cSrcweir     {
479cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HELPDRAW, sal_True );
480cdf0e10cSrcweir         return sal_True;
481cdf0e10cSrcweir     }
482cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpimpress" )) == sal_True )
483cdf0e10cSrcweir     {
484cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HELPIMPRESS, sal_True );
485cdf0e10cSrcweir         return sal_True;
486cdf0e10cSrcweir     }
487cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpbase" )) == sal_True )
488cdf0e10cSrcweir     {
489cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HELPBASE, sal_True );
490cdf0e10cSrcweir         return sal_True;
491cdf0e10cSrcweir     }
492cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpbasic" )) == sal_True )
493cdf0e10cSrcweir     {
494cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HELPBASIC, sal_True );
495cdf0e10cSrcweir         return sal_True;
496cdf0e10cSrcweir     }
497cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpmath" )) == sal_True )
498cdf0e10cSrcweir     {
499cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_HELPMATH, sal_True );
500cdf0e10cSrcweir         return sal_True;
501cdf0e10cSrcweir     }
502cdf0e10cSrcweir #ifdef MACOSX
503cdf0e10cSrcweir   /* #i84053# ignore -psn on Mac
504cdf0e10cSrcweir      Platform dependent #ifdef here is ugly, however this is currently
505cdf0e10cSrcweir      the only platform dependent parameter. Should more appear
506cdf0e10cSrcweir      we should find a better solution
507cdf0e10cSrcweir   */
508cdf0e10cSrcweir     else if ( aArg.compareToAscii( "-psn", 4 ) == 0 )
509cdf0e10cSrcweir     {
510cdf0e10cSrcweir         SetBoolParam_Impl( CMD_BOOLPARAM_PSN, sal_True );
511cdf0e10cSrcweir         return sal_True;
512cdf0e10cSrcweir     }
513cdf0e10cSrcweir #endif
514cdf0e10cSrcweir     else if ( aArgStr.Copy(0, 8).EqualsIgnoreCaseAscii( "-accept=" ))
515cdf0e10cSrcweir     {
516cdf0e10cSrcweir         AddStringListParam_Impl( CMD_STRINGPARAM_ACCEPT, aArgStr.Copy( 8 ) );
517cdf0e10cSrcweir         return sal_True;
518cdf0e10cSrcweir     }
519cdf0e10cSrcweir     else if ( aArgStr.Copy(0, 10).EqualsIgnoreCaseAscii( "-unaccept=" ))
520cdf0e10cSrcweir     {
521cdf0e10cSrcweir         AddStringListParam_Impl( CMD_STRINGPARAM_UNACCEPT, aArgStr.Copy( 10 ) );
522cdf0e10cSrcweir         return sal_True;
523cdf0e10cSrcweir     }
524cdf0e10cSrcweir     else if ( aArgStr.CompareIgnoreCaseToAscii( "-portal," ,
525cdf0e10cSrcweir               RTL_CONSTASCII_LENGTH( "-portal," )) == COMPARE_EQUAL )
526cdf0e10cSrcweir     {
527cdf0e10cSrcweir         AddStringListParam_Impl( CMD_STRINGPARAM_PORTAL, aArgStr.Copy( RTL_CONSTASCII_LENGTH( "-portal," )) );
528cdf0e10cSrcweir         return sal_True;
529cdf0e10cSrcweir     }
530cdf0e10cSrcweir     else if ( aArgStr.Copy( 0, 7 ).EqualsIgnoreCaseAscii( "-userid" ))
531cdf0e10cSrcweir     {
532cdf0e10cSrcweir         if ( aArgStr.Len() > 8 )
533cdf0e10cSrcweir 	{
534cdf0e10cSrcweir 	    rtl::OUString aUserDir = aArgStr;
535cdf0e10cSrcweir 	    AddStringListParam_Impl( CMD_STRINGPARAM_USERDIR,
536cdf0e10cSrcweir 				     ::rtl::Uri::decode( aUserDir.copy( 8 ), rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ) );
537cdf0e10cSrcweir         }
538cdf0e10cSrcweir         return sal_True;
539cdf0e10cSrcweir     }
540cdf0e10cSrcweir     else if ( aArgStr.Copy( 0, 15).EqualsIgnoreCaseAscii( "-clientdisplay=" ))
541cdf0e10cSrcweir     {
542cdf0e10cSrcweir         AddStringListParam_Impl( CMD_STRINGPARAM_CLIENTDISPLAY, aArgStr.Copy( 15 ) );
543cdf0e10cSrcweir         return sal_True;
544cdf0e10cSrcweir     }
545cdf0e10cSrcweir     else if ( aArgStr.Copy(0, 9).EqualsIgnoreCaseAscii( "-version=" ))
546cdf0e10cSrcweir     {
547cdf0e10cSrcweir         AddStringListParam_Impl( CMD_STRINGPARAM_VERSION, aArgStr.Copy( 9 ) );
548cdf0e10cSrcweir         return sal_True;
549cdf0e10cSrcweir     }
550cdf0e10cSrcweir     else if ( aArgStr.Copy(0, 10).EqualsIgnoreCaseAscii( "-language=" ))
551cdf0e10cSrcweir     {
552cdf0e10cSrcweir         AddStringListParam_Impl( CMD_STRINGPARAM_LANGUAGE, aArgStr.Copy( 10 ) );
553cdf0e10cSrcweir         return sal_True;
554cdf0e10cSrcweir     }
555cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-writer" )) == sal_True )
556cdf0e10cSrcweir     {
557cdf0e10cSrcweir         sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_WRITER );
558cdf0e10cSrcweir         if ( !bAlreadySet )
559cdf0e10cSrcweir 	    SetBoolParam_Impl( CMD_BOOLPARAM_WRITER, sal_True );
560cdf0e10cSrcweir         m_bDocumentArgs = true;
561cdf0e10cSrcweir         return sal_True;
562cdf0e10cSrcweir     }
563cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-calc" )) == sal_True )
564cdf0e10cSrcweir     {
565cdf0e10cSrcweir         sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_CALC );
566cdf0e10cSrcweir         if ( !bAlreadySet )
567cdf0e10cSrcweir 	    SetBoolParam_Impl( CMD_BOOLPARAM_CALC, sal_True );
568cdf0e10cSrcweir         m_bDocumentArgs = true;
569cdf0e10cSrcweir         return sal_True;
570cdf0e10cSrcweir     }
571cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-draw" )) == sal_True )
572cdf0e10cSrcweir     {
573cdf0e10cSrcweir         sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_DRAW );
574cdf0e10cSrcweir         if ( !bAlreadySet )
575cdf0e10cSrcweir 	    SetBoolParam_Impl( CMD_BOOLPARAM_DRAW, sal_True );
576cdf0e10cSrcweir         m_bDocumentArgs = true;
577cdf0e10cSrcweir         return sal_True;
578cdf0e10cSrcweir     }
579cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-impress" )) == sal_True )
580cdf0e10cSrcweir     {
581cdf0e10cSrcweir         sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_IMPRESS );
582cdf0e10cSrcweir         if ( !bAlreadySet )
583cdf0e10cSrcweir 	    SetBoolParam_Impl( CMD_BOOLPARAM_IMPRESS, sal_True );
584cdf0e10cSrcweir         m_bDocumentArgs = true;
585cdf0e10cSrcweir         return sal_True;
586cdf0e10cSrcweir     }
587cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-base" )) == sal_True )
588cdf0e10cSrcweir     {
589cdf0e10cSrcweir         sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_BASE );
590cdf0e10cSrcweir         if ( !bAlreadySet )
591cdf0e10cSrcweir 	    SetBoolParam_Impl( CMD_BOOLPARAM_BASE, sal_True );
592cdf0e10cSrcweir         m_bDocumentArgs = true;
593cdf0e10cSrcweir         return sal_True;
594cdf0e10cSrcweir     }
595cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-global" )) == sal_True )
596cdf0e10cSrcweir     {
597cdf0e10cSrcweir         sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_GLOBAL );
598cdf0e10cSrcweir         if ( !bAlreadySet )
599cdf0e10cSrcweir 	    SetBoolParam_Impl( CMD_BOOLPARAM_GLOBAL, sal_True );
600cdf0e10cSrcweir         m_bDocumentArgs = true;
601cdf0e10cSrcweir         return sal_True;
602cdf0e10cSrcweir     }
603cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-math" )) == sal_True )
604cdf0e10cSrcweir     {
605cdf0e10cSrcweir         sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_MATH );
606cdf0e10cSrcweir         if ( !bAlreadySet )
607cdf0e10cSrcweir 	    SetBoolParam_Impl( CMD_BOOLPARAM_MATH, sal_True );
608cdf0e10cSrcweir         m_bDocumentArgs = true;
609cdf0e10cSrcweir         return sal_True;
610cdf0e10cSrcweir     }
611cdf0e10cSrcweir     else if ( aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-web" )) == sal_True )
612cdf0e10cSrcweir     {
613cdf0e10cSrcweir         sal_Bool bAlreadySet = CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_WEB );
614cdf0e10cSrcweir         if ( !bAlreadySet )
615cdf0e10cSrcweir 	    SetBoolParam_Impl( CMD_BOOLPARAM_WEB, sal_True );
616cdf0e10cSrcweir         m_bDocumentArgs = true;
617cdf0e10cSrcweir         return sal_True;
618cdf0e10cSrcweir     }
619cdf0e10cSrcweir 
620cdf0e10cSrcweir     return sal_False;
621cdf0e10cSrcweir }
622cdf0e10cSrcweir 
623cdf0e10cSrcweir sal_Bool CommandLineArgs::CheckGroupMembers( GroupParamId nGroupId, BoolParam nExcludeMember ) const
624cdf0e10cSrcweir {
625cdf0e10cSrcweir     // Check if at least one bool param out of a group is set. An exclude member can be provided.
626cdf0e10cSrcweir     for ( int i = 0; i < m_pGroupDefinitions[nGroupId].nCount; i++ )
627cdf0e10cSrcweir     {
628cdf0e10cSrcweir         BoolParam nParam = m_pGroupDefinitions[nGroupId].pGroupMembers[i];
629cdf0e10cSrcweir         if ( nParam != nExcludeMember && m_aBoolParams[nParam] )
630cdf0e10cSrcweir             return sal_True;
631cdf0e10cSrcweir     }
632cdf0e10cSrcweir 
633cdf0e10cSrcweir     return sal_False;
634cdf0e10cSrcweir }
635cdf0e10cSrcweir 
636cdf0e10cSrcweir void CommandLineArgs::ResetParamValues()
637cdf0e10cSrcweir {
638cdf0e10cSrcweir     int i;
639cdf0e10cSrcweir     for ( i = 0; i < CMD_BOOLPARAM_COUNT; i++ )
640cdf0e10cSrcweir         m_aBoolParams[i] = sal_False;
641cdf0e10cSrcweir     for ( i = 0; i < CMD_STRINGPARAM_COUNT; i++ )
642cdf0e10cSrcweir         m_aStrSetParams[i] = sal_False;
643cdf0e10cSrcweir     m_eArgumentCount = NONE;
644cdf0e10cSrcweir     m_bDocumentArgs  = false;
645cdf0e10cSrcweir }
646cdf0e10cSrcweir 
647cdf0e10cSrcweir void CommandLineArgs::SetBoolParam( BoolParam eParam, sal_Bool bNewValue )
648cdf0e10cSrcweir {
649cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
650cdf0e10cSrcweir 
651cdf0e10cSrcweir 	OSL_ASSERT( ( eParam >= 0 && eParam < CMD_BOOLPARAM_COUNT ) );
652cdf0e10cSrcweir 	m_aBoolParams[eParam] = bNewValue;
653cdf0e10cSrcweir }
654cdf0e10cSrcweir 
655cdf0e10cSrcweir sal_Bool CommandLineArgs::IsMinimized() const
656cdf0e10cSrcweir {
657cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
658cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_MINIMIZED ];
659cdf0e10cSrcweir }
660cdf0e10cSrcweir 
661cdf0e10cSrcweir sal_Bool CommandLineArgs::IsInvisible() const
662cdf0e10cSrcweir {
663cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
664cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_INVISIBLE ];
665cdf0e10cSrcweir }
666cdf0e10cSrcweir 
667cdf0e10cSrcweir sal_Bool CommandLineArgs::IsNoRestore() const
668cdf0e10cSrcweir {
669cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
670cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_NORESTORE ];
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir sal_Bool CommandLineArgs::IsNoDefault() const
674cdf0e10cSrcweir {
675cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
676cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_NODEFAULT ];
677cdf0e10cSrcweir }
678cdf0e10cSrcweir 
679cdf0e10cSrcweir sal_Bool CommandLineArgs::IsBean() const
680cdf0e10cSrcweir {
681cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
682cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_BEAN ];
683cdf0e10cSrcweir }
684cdf0e10cSrcweir 
685cdf0e10cSrcweir sal_Bool CommandLineArgs::IsServer() const
686cdf0e10cSrcweir {
687cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
688cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_SERVER ];
689cdf0e10cSrcweir }
690cdf0e10cSrcweir 
691cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHeadless() const
692cdf0e10cSrcweir {
693cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
694cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HEADLESS ];
695cdf0e10cSrcweir }
696cdf0e10cSrcweir 
697cdf0e10cSrcweir sal_Bool CommandLineArgs::IsQuickstart() const
698cdf0e10cSrcweir {
699cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
700cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_QUICKSTART ];
701cdf0e10cSrcweir }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir sal_Bool CommandLineArgs::IsNoQuickstart() const
704cdf0e10cSrcweir {
705cdf0e10cSrcweir     osl::MutexGuard aMutexGuard( m_aMutex );
706cdf0e10cSrcweir     return m_aBoolParams[ CMD_BOOLPARAM_NOQUICKSTART ];
707cdf0e10cSrcweir }
708cdf0e10cSrcweir 
709cdf0e10cSrcweir sal_Bool CommandLineArgs::IsTerminateAfterInit() const
710cdf0e10cSrcweir {
711cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
712cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_TERMINATEAFTERINIT ];
713cdf0e10cSrcweir }
714cdf0e10cSrcweir 
715cdf0e10cSrcweir sal_Bool CommandLineArgs::IsNoFirstStartWizard() const
716cdf0e10cSrcweir {
717cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
718cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_NOFIRSTSTARTWIZARD ];
719cdf0e10cSrcweir }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir sal_Bool CommandLineArgs::IsNoLogo() const
722cdf0e10cSrcweir {
723cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
724cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_NOLOGO ];
725cdf0e10cSrcweir }
726cdf0e10cSrcweir 
727cdf0e10cSrcweir sal_Bool CommandLineArgs::IsNoLockcheck() const
728cdf0e10cSrcweir {
729cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
730cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_NOLOCKCHECK ];
731cdf0e10cSrcweir }
732cdf0e10cSrcweir 
733cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHelp() const
734cdf0e10cSrcweir {
735cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
736cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HELP ];
737cdf0e10cSrcweir }
738cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHelpWriter() const
739cdf0e10cSrcweir {
740cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
741cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HELPWRITER ];
742cdf0e10cSrcweir }
743cdf0e10cSrcweir 
744cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHelpCalc() const
745cdf0e10cSrcweir {
746cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
747cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HELPCALC ];
748cdf0e10cSrcweir }
749cdf0e10cSrcweir 
750cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHelpDraw() const
751cdf0e10cSrcweir {
752cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
753cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HELPDRAW ];
754cdf0e10cSrcweir }
755cdf0e10cSrcweir 
756cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHelpImpress() const
757cdf0e10cSrcweir {
758cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
759cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HELPIMPRESS ];
760cdf0e10cSrcweir }
761cdf0e10cSrcweir 
762cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHelpBase() const
763cdf0e10cSrcweir {
764cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
765cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HELPBASE ];
766cdf0e10cSrcweir }
767cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHelpMath() const
768cdf0e10cSrcweir {
769cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
770cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HELPMATH ];
771cdf0e10cSrcweir }
772cdf0e10cSrcweir sal_Bool CommandLineArgs::IsHelpBasic() const
773cdf0e10cSrcweir {
774cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
775cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_HELPBASIC ];
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir sal_Bool CommandLineArgs::IsWriter() const
779cdf0e10cSrcweir {
780cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
781cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_WRITER ];
782cdf0e10cSrcweir }
783cdf0e10cSrcweir 
784cdf0e10cSrcweir sal_Bool CommandLineArgs::IsCalc() const
785cdf0e10cSrcweir {
786cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
787cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_CALC ];
788cdf0e10cSrcweir }
789cdf0e10cSrcweir 
790cdf0e10cSrcweir sal_Bool CommandLineArgs::IsDraw() const
791cdf0e10cSrcweir {
792cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
793cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_DRAW ];
794cdf0e10cSrcweir }
795cdf0e10cSrcweir 
796cdf0e10cSrcweir sal_Bool CommandLineArgs::IsImpress() const
797cdf0e10cSrcweir {
798cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
799cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_IMPRESS ];
800cdf0e10cSrcweir }
801cdf0e10cSrcweir 
802cdf0e10cSrcweir sal_Bool CommandLineArgs::IsBase() const
803cdf0e10cSrcweir {
804cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
805cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_BASE ];
806cdf0e10cSrcweir }
807cdf0e10cSrcweir 
808cdf0e10cSrcweir sal_Bool CommandLineArgs::IsGlobal() const
809cdf0e10cSrcweir {
810cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
811cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_GLOBAL ];
812cdf0e10cSrcweir }
813cdf0e10cSrcweir 
814cdf0e10cSrcweir sal_Bool CommandLineArgs::IsMath() const
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
817cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_MATH ];
818cdf0e10cSrcweir }
819cdf0e10cSrcweir 
820cdf0e10cSrcweir sal_Bool CommandLineArgs::IsWeb() const
821cdf0e10cSrcweir {
822cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
823cdf0e10cSrcweir 	return m_aBoolParams[ CMD_BOOLPARAM_WEB ];
824cdf0e10cSrcweir }
825cdf0e10cSrcweir 
826cdf0e10cSrcweir sal_Bool CommandLineArgs::HasModuleParam() const
827cdf0e10cSrcweir {
828cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
829cdf0e10cSrcweir 	return CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_COUNT );
830cdf0e10cSrcweir }
831cdf0e10cSrcweir 
832cdf0e10cSrcweir sal_Bool CommandLineArgs::GetPortalConnectString( ::rtl::OUString& rPara ) const
833cdf0e10cSrcweir {
834cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
835cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_PORTAL ];
836cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_PORTAL ];
837cdf0e10cSrcweir }
838cdf0e10cSrcweir 
839cdf0e10cSrcweir sal_Bool CommandLineArgs::GetAcceptString( ::rtl::OUString& rPara ) const
840cdf0e10cSrcweir {
841cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
842cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_ACCEPT ];
843cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_ACCEPT ];
844cdf0e10cSrcweir }
845cdf0e10cSrcweir 
846cdf0e10cSrcweir sal_Bool CommandLineArgs::GetUnAcceptString( ::rtl::OUString& rPara ) const
847cdf0e10cSrcweir {
848cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
849cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_UNACCEPT ];
850cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_UNACCEPT ];
851cdf0e10cSrcweir }
852cdf0e10cSrcweir 
853cdf0e10cSrcweir sal_Bool CommandLineArgs::GetOpenList( ::rtl::OUString& rPara) const
854cdf0e10cSrcweir {
855cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
856cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_OPENLIST ];
857cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_OPENLIST ];
858cdf0e10cSrcweir }
859cdf0e10cSrcweir 
860cdf0e10cSrcweir sal_Bool CommandLineArgs::GetViewList( ::rtl::OUString& rPara) const
861cdf0e10cSrcweir {
862cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
863cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_VIEWLIST ];
864cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_VIEWLIST ];
865cdf0e10cSrcweir }
866cdf0e10cSrcweir 
867cdf0e10cSrcweir sal_Bool CommandLineArgs::GetStartList( ::rtl::OUString& rPara) const
868cdf0e10cSrcweir {
869cdf0e10cSrcweir       osl::MutexGuard  aMutexGuard( m_aMutex );
870cdf0e10cSrcweir       rPara = m_aStrParams[ CMD_STRINGPARAM_STARTLIST ];
871cdf0e10cSrcweir       return m_aStrSetParams[ CMD_STRINGPARAM_STARTLIST ];
872cdf0e10cSrcweir }
873cdf0e10cSrcweir 
874cdf0e10cSrcweir sal_Bool CommandLineArgs::GetForceOpenList( ::rtl::OUString& rPara) const
875cdf0e10cSrcweir {
876cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
877cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_FORCEOPENLIST ];
878cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_FORCEOPENLIST ];
879cdf0e10cSrcweir }
880cdf0e10cSrcweir 
881cdf0e10cSrcweir sal_Bool CommandLineArgs::GetForceNewList( ::rtl::OUString& rPara) const
882cdf0e10cSrcweir {
883cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
884cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_FORCENEWLIST ];
885cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_FORCENEWLIST ];
886cdf0e10cSrcweir }
887cdf0e10cSrcweir 
888cdf0e10cSrcweir sal_Bool CommandLineArgs::GetPrintList( ::rtl::OUString& rPara) const
889cdf0e10cSrcweir {
890cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
891cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTLIST ];
892cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_PRINTLIST ];
893cdf0e10cSrcweir }
894cdf0e10cSrcweir 
895cdf0e10cSrcweir sal_Bool CommandLineArgs::GetPrintToList( ::rtl::OUString& rPara ) const
896cdf0e10cSrcweir {
897cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
898cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTTOLIST ];
899cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_PRINTTOLIST ];
900cdf0e10cSrcweir }
901cdf0e10cSrcweir 
902cdf0e10cSrcweir sal_Bool CommandLineArgs::GetPrinterName( ::rtl::OUString& rPara ) const
903cdf0e10cSrcweir {
904cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
905cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTERNAME ];
906cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_PRINTERNAME ];
907cdf0e10cSrcweir }
908cdf0e10cSrcweir 
909cdf0e10cSrcweir sal_Bool CommandLineArgs::GetLanguage( ::rtl::OUString& rPara ) const
910cdf0e10cSrcweir {
911cdf0e10cSrcweir 	osl::MutexGuard  aMutexGuard( m_aMutex );
912cdf0e10cSrcweir 	rPara = m_aStrParams[ CMD_STRINGPARAM_LANGUAGE ];
913cdf0e10cSrcweir 	return m_aStrSetParams[ CMD_STRINGPARAM_LANGUAGE ];
914cdf0e10cSrcweir }
915cdf0e10cSrcweir 
916cdf0e10cSrcweir sal_Bool CommandLineArgs::IsEmpty() const
917cdf0e10cSrcweir {
918cdf0e10cSrcweir     osl::MutexGuard  aMutexGuard( m_aMutex );
919cdf0e10cSrcweir     return m_eArgumentCount == NONE;
920cdf0e10cSrcweir }
921cdf0e10cSrcweir 
922cdf0e10cSrcweir sal_Bool CommandLineArgs::IsEmptyOrAcceptOnly() const
923cdf0e10cSrcweir {
924cdf0e10cSrcweir     osl::MutexGuard  aMutexGuard( m_aMutex );
925cdf0e10cSrcweir 
926cdf0e10cSrcweir     return m_eArgumentCount == NONE ||
927cdf0e10cSrcweir            ( ( m_eArgumentCount == ONE ) && ( m_aStrParams[ CMD_STRINGPARAM_ACCEPT ].getLength() )) ||
928cdf0e10cSrcweir            ( ( m_eArgumentCount == ONE ) && m_aBoolParams[ CMD_BOOLPARAM_PSN ] );
929cdf0e10cSrcweir }
930cdf0e10cSrcweir 
931cdf0e10cSrcweir sal_Bool CommandLineArgs::WantsToLoadDocument() const
932cdf0e10cSrcweir {
933cdf0e10cSrcweir     osl::MutexGuard  aMutexGuard( m_aMutex );
934cdf0e10cSrcweir     return m_bDocumentArgs;
935cdf0e10cSrcweir }
936cdf0e10cSrcweir 
937cdf0e10cSrcweir } // namespace desktop
938