1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cmdlineargs.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_desktop.hxx"
33 #include <cmdlineargs.hxx>
34 #include <vcl/svapp.hxx>
35 #include <rtl/uri.hxx>
36 #include <rtl/ustring.hxx>
37 #include "rtl/process.h"
38 #include <comphelper/processfactory.hxx>
39 #include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/uno/Reference.hxx>
42 #include "tools/getprocessworkingdir.hxx"
44 #include <svtools/documentlockfile.hxx>
47 using namespace com::sun::star::lang
;
48 using namespace com::sun::star::uri
;
49 using namespace com::sun::star::uno
;
56 class ExtCommandLineSupplier
: public CommandLineArgs::Supplier
{
58 explicit ExtCommandLineSupplier():
59 m_count(rtl_getAppCommandArgCount()),
63 if (tools::getProcessWorkingDir(&url
)) {
68 virtual ~ExtCommandLineSupplier() {}
70 virtual boost::optional
< rtl::OUString
> getCwdUrl() { return m_cwdUrl
; }
72 virtual bool next(rtl::OUString
* argument
) {
73 OSL_ASSERT(argument
!= NULL
);
74 if (m_index
< m_count
) {
75 rtl_getAppCommandArg(m_index
++, &argument
->pData
);
83 boost::optional
< rtl::OUString
> m_cwdUrl
;
90 static CommandLineArgs::BoolParam aModuleGroupDefinition
[] =
92 CommandLineArgs::CMD_BOOLPARAM_WRITER
,
93 CommandLineArgs::CMD_BOOLPARAM_CALC
,
94 CommandLineArgs::CMD_BOOLPARAM_DRAW
,
95 CommandLineArgs::CMD_BOOLPARAM_IMPRESS
,
96 CommandLineArgs::CMD_BOOLPARAM_GLOBAL
,
97 CommandLineArgs::CMD_BOOLPARAM_MATH
,
98 CommandLineArgs::CMD_BOOLPARAM_WEB
,
99 CommandLineArgs::CMD_BOOLPARAM_BASE
102 CommandLineArgs::GroupDefinition
CommandLineArgs::m_pGroupDefinitions
[ CommandLineArgs::CMD_GRPID_COUNT
] =
104 { 8, aModuleGroupDefinition
}
107 CommandLineArgs::Supplier::Exception::Exception() {}
109 CommandLineArgs::Supplier::Exception::Exception(Exception
const &) {}
111 CommandLineArgs::Supplier::Exception::~Exception() {}
113 CommandLineArgs::Supplier::Exception
&
114 CommandLineArgs::Supplier::Exception::operator =(Exception
const &)
117 CommandLineArgs::Supplier::~Supplier() {}
119 // intialize class with command line parameters from process environment
120 CommandLineArgs::CommandLineArgs()
123 ExtCommandLineSupplier s
;
124 ParseCommandLine_Impl( s
);
127 CommandLineArgs::CommandLineArgs( Supplier
& supplier
)
130 ParseCommandLine_Impl( supplier
);
133 // ----------------------------------------------------------------------------
135 void CommandLineArgs::ParseCommandLine_Impl( Supplier
& supplier
)
137 m_cwdUrl
= supplier
.getCwdUrl();
138 Reference
<XMultiServiceFactory
> xMS(comphelper::getProcessServiceFactory(), UNO_QUERY
);
139 OSL_ENSURE(xMS
.is(), "CommandLineArgs: no ProcessServiceFactory.");
141 Reference
< XExternalUriReferenceTranslator
> xTranslator(
143 OUString::createFromAscii(
144 "com.sun.star.uri.ExternalUriReferenceTranslator")),
147 // parse command line arguments
148 sal_Bool bPrintEvent
= sal_False
;
149 sal_Bool bOpenEvent
= sal_True
;
150 sal_Bool bViewEvent
= sal_False
;
151 sal_Bool bStartEvent
= sal_False
;
152 sal_Bool bPrintToEvent
= sal_False
;
153 sal_Bool bPrinterName
= sal_False
;
154 sal_Bool bForceOpenEvent
= sal_False
;
155 sal_Bool bForceNewEvent
= sal_False
;
156 sal_Bool bDisplaySpec
= sal_False
;
158 m_eArgumentCount
= NONE
;
162 ::rtl::OUString aArg
;
163 if ( !supplier
.next( &aArg
) )
167 // convert file URLs to internal form #112849#
168 if (aArg
.indexOf(OUString::createFromAscii("file:"))==0 &&
171 OUString
tmp(xTranslator
->translateToInternal(aArg
));
172 if (tmp
.getLength() > 0)
175 String aArgStr
= aArg
;
177 if ( aArg
.getLength() > 0 )
179 m_eArgumentCount
= m_eArgumentCount
== NONE
? ONE
: MANY
;
180 if ( !InterpretCommandLineParameter( aArg
))
182 if ( aArgStr
.GetChar(0) == '-' )
184 // handle this argument as an option
185 if ( aArgStr
.EqualsIgnoreCaseAscii( "-n" ))
187 // force new documents based on the following documents
188 bForceNewEvent
= sal_True
;
189 bOpenEvent
= sal_False
;
190 bForceOpenEvent
= sal_False
;
191 bPrintToEvent
= sal_False
;
192 bPrintEvent
= sal_False
;
193 bViewEvent
= sal_False
;
194 bStartEvent
= sal_False
;
195 bDisplaySpec
= sal_False
;
197 else if ( aArgStr
.EqualsIgnoreCaseAscii( "-o" ))
199 // force open documents regards if they are templates or not
200 bForceOpenEvent
= sal_True
;
201 bOpenEvent
= sal_False
;
202 bForceNewEvent
= sal_False
;
203 bPrintToEvent
= sal_False
;
204 bPrintEvent
= sal_False
;
205 bViewEvent
= sal_False
;
206 bStartEvent
= sal_False
;
207 bDisplaySpec
= sal_False
;
209 else if ( aArgStr
.EqualsIgnoreCaseAscii( "-pt" ))
211 // Print to special printer
212 bPrintToEvent
= sal_True
;
213 bPrinterName
= sal_True
;
214 bPrintEvent
= sal_False
;
215 bOpenEvent
= sal_False
;
216 bForceNewEvent
= sal_False
;
217 bViewEvent
= sal_False
;
218 bStartEvent
= sal_False
;
219 bDisplaySpec
= sal_False
;
220 bForceOpenEvent
= sal_False
;
222 else if ( aArgStr
.EqualsIgnoreCaseAscii( "-p" ))
224 // Print to default printer
225 bPrintEvent
= sal_True
;
226 bPrintToEvent
= sal_False
;
227 bOpenEvent
= sal_False
;
228 bForceNewEvent
= sal_False
;
229 bForceOpenEvent
= sal_False
;
230 bViewEvent
= sal_False
;
231 bStartEvent
= sal_False
;
232 bDisplaySpec
= sal_False
;
234 else if ( aArgStr
.EqualsIgnoreCaseAscii( "-view" ))
237 bOpenEvent
= sal_False
;
238 bPrintEvent
= sal_False
;
239 bPrintToEvent
= sal_False
;
240 bForceNewEvent
= sal_False
;
241 bForceOpenEvent
= sal_False
;
242 bViewEvent
= sal_True
;
243 bStartEvent
= sal_False
;
244 bDisplaySpec
= sal_False
;
246 else if ( aArgStr
.EqualsIgnoreCaseAscii( "-show" ))
249 bOpenEvent
= sal_False
;
250 bViewEvent
= sal_False
;
251 bStartEvent
= sal_True
;
252 bPrintEvent
= sal_False
;
253 bPrintToEvent
= sal_False
;
254 bForceNewEvent
= sal_False
;
255 bForceOpenEvent
= sal_False
;
256 bDisplaySpec
= sal_False
;
258 else if ( aArgStr
.EqualsIgnoreCaseAscii( "-display" ))
261 bOpenEvent
= sal_False
;
262 bPrintEvent
= sal_False
;
263 bForceOpenEvent
= sal_False
;
264 bPrintToEvent
= sal_False
;
265 bForceNewEvent
= sal_False
;
266 bViewEvent
= sal_False
;
267 bStartEvent
= sal_False
;
268 bDisplaySpec
= sal_True
;
271 /* #i84053# ignore -psn on Mac
272 Platform dependent #ifdef here is ugly, however this is currently
273 the only platform dependent parameter. Should more appear
274 we should find a better solution
276 else if ( aArgStr
.CompareToAscii( "-psn", 4 ) == COMPARE_EQUAL
)
278 // finder argument from MacOSX
279 bOpenEvent
= sal_False
;
280 bPrintEvent
= sal_False
;
281 bForceOpenEvent
= sal_False
;
282 bPrintToEvent
= sal_False
;
283 bForceNewEvent
= sal_False
;
284 bViewEvent
= sal_False
;
285 bStartEvent
= sal_False
;
286 bDisplaySpec
= sal_False
;
292 if ( bPrinterName
&& bPrintToEvent
)
294 // first argument after "-pt" this must be the printer name
295 AddStringListParam_Impl( CMD_STRINGPARAM_PRINTERNAME
, aArgStr
);
296 bPrinterName
= sal_False
;
300 if( bOpenEvent
|| bViewEvent
|| bForceNewEvent
|| bForceOpenEvent
)
302 if( ::rtl::OUString(aArgStr
).matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("::ODMA")) )
304 ::rtl::OUString sArg
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.odma:/"));
309 // handle this argument as a filename
311 AddStringListParam_Impl( CMD_STRINGPARAM_OPENLIST
, aArgStr
);
312 else if ( bViewEvent
)
313 AddStringListParam_Impl( CMD_STRINGPARAM_VIEWLIST
, aArgStr
);
314 else if ( bStartEvent
)
315 AddStringListParam_Impl( CMD_STRINGPARAM_STARTLIST
, aArgStr
);
316 else if ( bPrintEvent
)
317 AddStringListParam_Impl( CMD_STRINGPARAM_PRINTLIST
, aArgStr
);
318 else if ( bPrintToEvent
)
319 AddStringListParam_Impl( CMD_STRINGPARAM_PRINTTOLIST
, aArgStr
);
320 else if ( bForceNewEvent
)
321 AddStringListParam_Impl( CMD_STRINGPARAM_FORCENEWLIST
, aArgStr
);
322 else if ( bForceOpenEvent
)
323 AddStringListParam_Impl( CMD_STRINGPARAM_FORCEOPENLIST
, aArgStr
);
324 else if ( bDisplaySpec
){
325 AddStringListParam_Impl( CMD_STRINGPARAM_DISPLAY
, aArgStr
);
326 bDisplaySpec
= sal_False
; // only one display, not a lsit
327 bOpenEvent
= sal_True
; // set back to standard
336 void CommandLineArgs::AddStringListParam_Impl( StringParam eParam
, const rtl::OUString
& aParam
)
338 OSL_ASSERT( eParam
>= 0 && eParam
< CMD_STRINGPARAM_COUNT
);
339 if ( m_aStrParams
[eParam
].getLength() )
340 m_aStrParams
[eParam
] += ::rtl::OUString::valueOf( (sal_Unicode
)APPEVENT_PARAM_DELIMITER
);
341 m_aStrParams
[eParam
] += aParam
;
342 m_aStrSetParams
[eParam
] = sal_True
;
345 void CommandLineArgs::SetBoolParam_Impl( BoolParam eParam
, sal_Bool bValue
)
347 OSL_ASSERT( eParam
>= 0 && eParam
< CMD_BOOLPARAM_COUNT
);
348 m_aBoolParams
[eParam
] = bValue
;
351 sal_Bool
CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString
& aArg
)
353 String
aArgStr( aArg
);
355 if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-minimized" )) == sal_True
)
357 SetBoolParam_Impl( CMD_BOOLPARAM_MINIMIZED
, sal_True
);
360 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-invisible" )) == sal_True
)
362 SetBoolParam_Impl( CMD_BOOLPARAM_INVISIBLE
, sal_True
);
365 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-norestore" )) == sal_True
)
367 SetBoolParam_Impl( CMD_BOOLPARAM_NORESTORE
, sal_True
);
370 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nodefault" )) == sal_True
)
372 SetBoolParam_Impl( CMD_BOOLPARAM_NODEFAULT
, sal_True
);
375 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-bean" )) == sal_True
)
377 SetBoolParam_Impl( CMD_BOOLPARAM_BEAN
, sal_True
);
380 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-plugin" )) == sal_True
)
382 SetBoolParam_Impl( CMD_BOOLPARAM_PLUGIN
, sal_True
);
385 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-server" )) == sal_True
)
387 SetBoolParam_Impl( CMD_BOOLPARAM_SERVER
, sal_True
);
390 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-headless" )) == sal_True
)
392 // Headless means also invisibile, so set this parameter to true!
393 SetBoolParam_Impl( CMD_BOOLPARAM_HEADLESS
, sal_True
);
394 SetBoolParam_Impl( CMD_BOOLPARAM_INVISIBLE
, sal_True
);
397 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-quickstart" )) == sal_True
)
399 #if defined(WNT) || defined(OS2) || defined(QUARTZ)
400 SetBoolParam_Impl( CMD_BOOLPARAM_QUICKSTART
, sal_True
);
404 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-terminate_after_init" )) == sal_True
)
406 SetBoolParam_Impl( CMD_BOOLPARAM_TERMINATEAFTERINIT
, sal_True
);
409 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nofirststartwizard" )) == sal_True
)
411 SetBoolParam_Impl( CMD_BOOLPARAM_NOFIRSTSTARTWIZARD
, sal_True
);
414 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nologo" )) == sal_True
)
416 SetBoolParam_Impl( CMD_BOOLPARAM_NOLOGO
, sal_True
);
419 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-nolockcheck" )) == sal_True
)
421 SetBoolParam_Impl( CMD_BOOLPARAM_NOLOCKCHECK
, sal_True
);
422 // Workaround for automated testing
423 ::svt::DocumentLockFile::AllowInteraction( sal_False
);
427 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-help" ))
428 || aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" ))
429 || aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-?" )))
431 SetBoolParam_Impl( CMD_BOOLPARAM_HELP
, sal_True
);
434 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpwriter" )) == sal_True
)
436 SetBoolParam_Impl( CMD_BOOLPARAM_HELPWRITER
, sal_True
);
439 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpcalc" )) == sal_True
)
441 SetBoolParam_Impl( CMD_BOOLPARAM_HELPCALC
, sal_True
);
444 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpdraw" )) == sal_True
)
446 SetBoolParam_Impl( CMD_BOOLPARAM_HELPDRAW
, sal_True
);
449 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpimpress" )) == sal_True
)
451 SetBoolParam_Impl( CMD_BOOLPARAM_HELPIMPRESS
, sal_True
);
454 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpbase" )) == sal_True
)
456 SetBoolParam_Impl( CMD_BOOLPARAM_HELPBASE
, sal_True
);
459 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpbasic" )) == sal_True
)
461 SetBoolParam_Impl( CMD_BOOLPARAM_HELPBASIC
, sal_True
);
464 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-helpmath" )) == sal_True
)
466 SetBoolParam_Impl( CMD_BOOLPARAM_HELPMATH
, sal_True
);
469 else if ( aArgStr
.Copy(0, 13).EqualsIgnoreCaseAscii( "-splash-pipe=" ))
471 AddStringListParam_Impl( CMD_STRINGPARAM_SPLASHPIPE
, aArgStr
.Copy( 13 ) );
475 /* #i84053# ignore -psn on Mac
476 Platform dependent #ifdef here is ugly, however this is currently
477 the only platform dependent parameter. Should more appear
478 we should find a better solution
480 else if ( aArg
.compareToAscii( "-psn", 4 ) == 0 )
482 SetBoolParam_Impl( CMD_BOOLPARAM_PSN
, sal_True
);
486 else if ( aArgStr
.Copy(0, 8).EqualsIgnoreCaseAscii( "-accept=" ))
488 AddStringListParam_Impl( CMD_STRINGPARAM_ACCEPT
, aArgStr
.Copy( 8 ) );
491 else if ( aArgStr
.Copy(0, 10).EqualsIgnoreCaseAscii( "-unaccept=" ))
493 AddStringListParam_Impl( CMD_STRINGPARAM_UNACCEPT
, aArgStr
.Copy( 10 ) );
496 else if ( aArgStr
.CompareIgnoreCaseToAscii( "-portal," ,
497 RTL_CONSTASCII_LENGTH( "-portal," )) == COMPARE_EQUAL
)
499 AddStringListParam_Impl( CMD_STRINGPARAM_PORTAL
, aArgStr
.Copy( RTL_CONSTASCII_LENGTH( "-portal," )) );
502 else if ( aArgStr
.Copy( 0, 7 ).EqualsIgnoreCaseAscii( "-userid" ))
504 if ( aArgStr
.Len() > 8 )
506 rtl::OUString aUserDir
= aArgStr
;
507 AddStringListParam_Impl(
508 CMD_STRINGPARAM_USERDIR
,
509 ::rtl::Uri::decode( aUserDir
.copy( 8 ),
510 rtl_UriDecodeWithCharset
,
511 RTL_TEXTENCODING_UTF8
) );
515 else if ( aArgStr
.Copy( 0, 15).EqualsIgnoreCaseAscii( "-clientdisplay=" ))
517 AddStringListParam_Impl( CMD_STRINGPARAM_CLIENTDISPLAY
, aArgStr
.Copy( 15 ) );
520 else if ( aArgStr
.Copy(0, 9).EqualsIgnoreCaseAscii( "-version=" ))
522 AddStringListParam_Impl( CMD_STRINGPARAM_VERSION
, aArgStr
.Copy( 15 ) );
525 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-writer" )) == sal_True
)
527 sal_Bool bAlreadySet
= CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_WRITER
);
529 SetBoolParam_Impl( CMD_BOOLPARAM_WRITER
, sal_True
);
532 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-calc" )) == sal_True
)
534 sal_Bool bAlreadySet
= CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_CALC
);
536 SetBoolParam_Impl( CMD_BOOLPARAM_CALC
, sal_True
);
539 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-draw" )) == sal_True
)
541 sal_Bool bAlreadySet
= CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_DRAW
);
543 SetBoolParam_Impl( CMD_BOOLPARAM_DRAW
, sal_True
);
546 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-impress" )) == sal_True
)
548 sal_Bool bAlreadySet
= CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_IMPRESS
);
550 SetBoolParam_Impl( CMD_BOOLPARAM_IMPRESS
, sal_True
);
553 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-base" )) == sal_True
)
555 sal_Bool bAlreadySet
= CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_BASE
);
557 SetBoolParam_Impl( CMD_BOOLPARAM_BASE
, sal_True
);
560 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-global" )) == sal_True
)
562 sal_Bool bAlreadySet
= CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_GLOBAL
);
564 SetBoolParam_Impl( CMD_BOOLPARAM_GLOBAL
, sal_True
);
567 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-math" )) == sal_True
)
569 sal_Bool bAlreadySet
= CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_MATH
);
571 SetBoolParam_Impl( CMD_BOOLPARAM_MATH
, sal_True
);
574 else if ( aArg
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-web" )) == sal_True
)
576 sal_Bool bAlreadySet
= CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_WEB
);
578 SetBoolParam_Impl( CMD_BOOLPARAM_WEB
, sal_True
);
585 sal_Bool
CommandLineArgs::CheckGroupMembers( GroupParamId nGroupId
, BoolParam nExcludeMember
) const
587 // Check if at least one bool param out of a group is set. An exclude member can be provided.
588 for ( int i
= 0; i
< m_pGroupDefinitions
[nGroupId
].nCount
; i
++ )
590 BoolParam nParam
= m_pGroupDefinitions
[nGroupId
].pGroupMembers
[i
];
591 if ( nParam
!= nExcludeMember
&& m_aBoolParams
[nParam
] )
598 void CommandLineArgs::ResetParamValues()
602 for ( i
= 0; i
< CMD_BOOLPARAM_COUNT
; i
++ )
603 m_aBoolParams
[i
] = sal_False
;
604 for ( i
= 0; i
< CMD_STRINGPARAM_COUNT
; i
++ )
605 m_aStrSetParams
[i
] = sal_False
;
606 m_eArgumentCount
= NONE
;
609 void CommandLineArgs::SetBoolParam( BoolParam eParam
, sal_Bool bNewValue
)
611 osl::MutexGuard
aMutexGuard( m_aMutex
);
613 OSL_ASSERT( ( eParam
>= 0 && eParam
< CMD_BOOLPARAM_COUNT
) );
614 m_aBoolParams
[eParam
] = bNewValue
;
617 const rtl::OUString
& CommandLineArgs::GetStringParam( StringParam eParam
) const
619 osl::MutexGuard
aMutexGuard( m_aMutex
);
621 OSL_ASSERT( ( eParam
>= 0 && eParam
< CMD_STRINGPARAM_COUNT
) );
622 return m_aStrParams
[eParam
];
625 sal_Bool
CommandLineArgs::IsMinimized() const
627 osl::MutexGuard
aMutexGuard( m_aMutex
);
628 return m_aBoolParams
[ CMD_BOOLPARAM_MINIMIZED
];
631 sal_Bool
CommandLineArgs::IsInvisible() const
633 osl::MutexGuard
aMutexGuard( m_aMutex
);
634 return m_aBoolParams
[ CMD_BOOLPARAM_INVISIBLE
];
637 sal_Bool
CommandLineArgs::IsNoRestore() const
639 osl::MutexGuard
aMutexGuard( m_aMutex
);
640 return m_aBoolParams
[ CMD_BOOLPARAM_NORESTORE
];
643 sal_Bool
CommandLineArgs::IsNoDefault() const
645 osl::MutexGuard
aMutexGuard( m_aMutex
);
646 return m_aBoolParams
[ CMD_BOOLPARAM_NODEFAULT
];
649 sal_Bool
CommandLineArgs::IsBean() const
651 osl::MutexGuard
aMutexGuard( m_aMutex
);
652 return m_aBoolParams
[ CMD_BOOLPARAM_BEAN
];
655 sal_Bool
CommandLineArgs::IsServer() const
657 osl::MutexGuard
aMutexGuard( m_aMutex
);
658 return m_aBoolParams
[ CMD_BOOLPARAM_SERVER
];
661 sal_Bool
CommandLineArgs::IsHeadless() const
663 osl::MutexGuard
aMutexGuard( m_aMutex
);
664 return m_aBoolParams
[ CMD_BOOLPARAM_HEADLESS
];
667 sal_Bool
CommandLineArgs::IsQuickstart() const
669 osl::MutexGuard
aMutexGuard( m_aMutex
);
670 return m_aBoolParams
[ CMD_BOOLPARAM_QUICKSTART
];
673 sal_Bool
CommandLineArgs::IsTerminateAfterInit() const
675 osl::MutexGuard
aMutexGuard( m_aMutex
);
676 return m_aBoolParams
[ CMD_BOOLPARAM_TERMINATEAFTERINIT
];
679 sal_Bool
CommandLineArgs::IsNoFirstStartWizard() const
681 osl::MutexGuard
aMutexGuard( m_aMutex
);
682 return m_aBoolParams
[ CMD_BOOLPARAM_NOFIRSTSTARTWIZARD
];
685 sal_Bool
CommandLineArgs::IsNoLogo() const
687 osl::MutexGuard
aMutexGuard( m_aMutex
);
688 return m_aBoolParams
[ CMD_BOOLPARAM_NOLOGO
];
691 sal_Bool
CommandLineArgs::IsNoLockcheck() const
693 osl::MutexGuard
aMutexGuard( m_aMutex
);
694 return m_aBoolParams
[ CMD_BOOLPARAM_NOLOCKCHECK
];
697 sal_Bool
CommandLineArgs::IsHelp() const
699 osl::MutexGuard
aMutexGuard( m_aMutex
);
700 return m_aBoolParams
[ CMD_BOOLPARAM_HELP
];
702 sal_Bool
CommandLineArgs::IsHelpWriter() const
704 osl::MutexGuard
aMutexGuard( m_aMutex
);
705 return m_aBoolParams
[ CMD_BOOLPARAM_HELPWRITER
];
708 sal_Bool
CommandLineArgs::IsHelpCalc() const
710 osl::MutexGuard
aMutexGuard( m_aMutex
);
711 return m_aBoolParams
[ CMD_BOOLPARAM_HELPCALC
];
714 sal_Bool
CommandLineArgs::IsHelpDraw() const
716 osl::MutexGuard
aMutexGuard( m_aMutex
);
717 return m_aBoolParams
[ CMD_BOOLPARAM_HELPDRAW
];
720 sal_Bool
CommandLineArgs::IsHelpImpress() const
722 osl::MutexGuard
aMutexGuard( m_aMutex
);
723 return m_aBoolParams
[ CMD_BOOLPARAM_HELPIMPRESS
];
726 sal_Bool
CommandLineArgs::IsHelpBase() const
728 osl::MutexGuard
aMutexGuard( m_aMutex
);
729 return m_aBoolParams
[ CMD_BOOLPARAM_HELPBASE
];
731 sal_Bool
CommandLineArgs::IsHelpMath() const
733 osl::MutexGuard
aMutexGuard( m_aMutex
);
734 return m_aBoolParams
[ CMD_BOOLPARAM_HELPMATH
];
736 sal_Bool
CommandLineArgs::IsHelpBasic() const
738 osl::MutexGuard
aMutexGuard( m_aMutex
);
739 return m_aBoolParams
[ CMD_BOOLPARAM_HELPBASIC
];
742 sal_Bool
CommandLineArgs::IsWriter() const
744 osl::MutexGuard
aMutexGuard( m_aMutex
);
745 return m_aBoolParams
[ CMD_BOOLPARAM_WRITER
];
748 sal_Bool
CommandLineArgs::IsCalc() const
750 osl::MutexGuard
aMutexGuard( m_aMutex
);
751 return m_aBoolParams
[ CMD_BOOLPARAM_CALC
];
754 sal_Bool
CommandLineArgs::IsDraw() const
756 osl::MutexGuard
aMutexGuard( m_aMutex
);
757 return m_aBoolParams
[ CMD_BOOLPARAM_DRAW
];
760 sal_Bool
CommandLineArgs::IsImpress() const
762 osl::MutexGuard
aMutexGuard( m_aMutex
);
763 return m_aBoolParams
[ CMD_BOOLPARAM_IMPRESS
];
766 sal_Bool
CommandLineArgs::IsBase() const
768 osl::MutexGuard
aMutexGuard( m_aMutex
);
769 return m_aBoolParams
[ CMD_BOOLPARAM_BASE
];
772 sal_Bool
CommandLineArgs::IsGlobal() const
774 osl::MutexGuard
aMutexGuard( m_aMutex
);
775 return m_aBoolParams
[ CMD_BOOLPARAM_GLOBAL
];
778 sal_Bool
CommandLineArgs::IsMath() const
780 osl::MutexGuard
aMutexGuard( m_aMutex
);
781 return m_aBoolParams
[ CMD_BOOLPARAM_MATH
];
784 sal_Bool
CommandLineArgs::IsWeb() const
786 osl::MutexGuard
aMutexGuard( m_aMutex
);
787 return m_aBoolParams
[ CMD_BOOLPARAM_WEB
];
790 sal_Bool
CommandLineArgs::HasModuleParam() const
792 osl::MutexGuard
aMutexGuard( m_aMutex
);
793 return CheckGroupMembers( CMD_GRPID_MODULE
, CMD_BOOLPARAM_COUNT
);
796 sal_Bool
CommandLineArgs::GetPortalConnectString( ::rtl::OUString
& rPara
) const
798 osl::MutexGuard
aMutexGuard( m_aMutex
);
799 rPara
= m_aStrParams
[ CMD_STRINGPARAM_PORTAL
];
800 return m_aStrSetParams
[ CMD_STRINGPARAM_PORTAL
];
803 sal_Bool
CommandLineArgs::GetAcceptString( ::rtl::OUString
& rPara
) const
805 osl::MutexGuard
aMutexGuard( m_aMutex
);
806 rPara
= m_aStrParams
[ CMD_STRINGPARAM_ACCEPT
];
807 return m_aStrSetParams
[ CMD_STRINGPARAM_ACCEPT
];
810 sal_Bool
CommandLineArgs::GetUnAcceptString( ::rtl::OUString
& rPara
) const
812 osl::MutexGuard
aMutexGuard( m_aMutex
);
813 rPara
= m_aStrParams
[ CMD_STRINGPARAM_UNACCEPT
];
814 return m_aStrSetParams
[ CMD_STRINGPARAM_UNACCEPT
];
817 sal_Bool
CommandLineArgs::GetOpenList( ::rtl::OUString
& rPara
) const
819 osl::MutexGuard
aMutexGuard( m_aMutex
);
820 rPara
= m_aStrParams
[ CMD_STRINGPARAM_OPENLIST
];
821 return m_aStrSetParams
[ CMD_STRINGPARAM_OPENLIST
];
824 sal_Bool
CommandLineArgs::GetViewList( ::rtl::OUString
& rPara
) const
826 osl::MutexGuard
aMutexGuard( m_aMutex
);
827 rPara
= m_aStrParams
[ CMD_STRINGPARAM_VIEWLIST
];
828 return m_aStrSetParams
[ CMD_STRINGPARAM_VIEWLIST
];
831 sal_Bool
CommandLineArgs::GetStartList( ::rtl::OUString
& rPara
) const
833 osl::MutexGuard
aMutexGuard( m_aMutex
);
834 rPara
= m_aStrParams
[ CMD_STRINGPARAM_STARTLIST
];
835 return m_aStrSetParams
[ CMD_STRINGPARAM_STARTLIST
];
838 sal_Bool
CommandLineArgs::GetForceOpenList( ::rtl::OUString
& rPara
) const
840 osl::MutexGuard
aMutexGuard( m_aMutex
);
841 rPara
= m_aStrParams
[ CMD_STRINGPARAM_FORCEOPENLIST
];
842 return m_aStrSetParams
[ CMD_STRINGPARAM_FORCEOPENLIST
];
845 sal_Bool
CommandLineArgs::GetForceNewList( ::rtl::OUString
& rPara
) const
847 osl::MutexGuard
aMutexGuard( m_aMutex
);
848 rPara
= m_aStrParams
[ CMD_STRINGPARAM_FORCENEWLIST
];
849 return m_aStrSetParams
[ CMD_STRINGPARAM_FORCENEWLIST
];
852 sal_Bool
CommandLineArgs::GetPrintList( ::rtl::OUString
& rPara
) const
854 osl::MutexGuard
aMutexGuard( m_aMutex
);
855 rPara
= m_aStrParams
[ CMD_STRINGPARAM_PRINTLIST
];
856 return m_aStrSetParams
[ CMD_STRINGPARAM_PRINTLIST
];
859 sal_Bool
CommandLineArgs::GetPrintToList( ::rtl::OUString
& rPara
) const
861 osl::MutexGuard
aMutexGuard( m_aMutex
);
862 rPara
= m_aStrParams
[ CMD_STRINGPARAM_PRINTTOLIST
];
863 return m_aStrSetParams
[ CMD_STRINGPARAM_PRINTTOLIST
];
866 sal_Bool
CommandLineArgs::GetPrinterName( ::rtl::OUString
& rPara
) const
868 osl::MutexGuard
aMutexGuard( m_aMutex
);
869 rPara
= m_aStrParams
[ CMD_STRINGPARAM_PRINTERNAME
];
870 return m_aStrSetParams
[ CMD_STRINGPARAM_PRINTERNAME
];
873 sal_Bool
CommandLineArgs::IsEmpty() const
875 osl::MutexGuard
aMutexGuard( m_aMutex
);
876 return m_eArgumentCount
== NONE
;
879 sal_Bool
CommandLineArgs::IsEmptyOrAcceptOnly() const
881 osl::MutexGuard
aMutexGuard( m_aMutex
);
883 return m_eArgumentCount
== NONE
||
884 ( ( m_eArgumentCount
== ONE
) && ( m_aStrParams
[ CMD_STRINGPARAM_SPLASHPIPE
].getLength() )) ||
885 ( ( m_eArgumentCount
== ONE
) && ( m_aStrParams
[ CMD_STRINGPARAM_ACCEPT
].getLength() )) ||
886 ( ( m_eArgumentCount
== ONE
) && m_aBoolParams
[ CMD_BOOLPARAM_PSN
] );
889 } // namespace desktop