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.hxx,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 #ifndef _DESKTOP_COMMANDLINEARGS_HXX_
32 #define _DESKTOP_COMMANDLINEARGS_HXX_
34 #include <rtl/ustring.hxx>
35 #include <osl/mutex.hxx>
36 #include "boost/optional.hpp"
44 enum BoolParam
// must be zero based!
46 CMD_BOOLPARAM_MINIMIZED
,
47 CMD_BOOLPARAM_INVISIBLE
,
48 CMD_BOOLPARAM_NORESTORE
,
52 CMD_BOOLPARAM_HEADLESS
,
53 CMD_BOOLPARAM_QUICKSTART
,
54 CMD_BOOLPARAM_TERMINATEAFTERINIT
,
55 CMD_BOOLPARAM_NOFIRSTSTARTWIZARD
,
57 CMD_BOOLPARAM_NOLOCKCHECK
,
58 CMD_BOOLPARAM_NODEFAULT
,
63 CMD_BOOLPARAM_IMPRESS
,
68 CMD_BOOLPARAM_HELPWRITER
,
69 CMD_BOOLPARAM_HELPCALC
,
70 CMD_BOOLPARAM_HELPDRAW
,
71 CMD_BOOLPARAM_HELPBASIC
,
72 CMD_BOOLPARAM_HELPMATH
,
73 CMD_BOOLPARAM_HELPIMPRESS
,
74 CMD_BOOLPARAM_HELPBASE
,
76 CMD_BOOLPARAM_COUNT
// must be last element!
79 enum StringParam
// must be zero based!
81 CMD_STRINGPARAM_PORTAL
,
82 CMD_STRINGPARAM_SPLASHPIPE
,
83 CMD_STRINGPARAM_ACCEPT
,
84 CMD_STRINGPARAM_UNACCEPT
,
85 CMD_STRINGPARAM_USERDIR
,
86 CMD_STRINGPARAM_CLIENTDISPLAY
,
87 CMD_STRINGPARAM_OPENLIST
,
88 CMD_STRINGPARAM_VIEWLIST
,
89 CMD_STRINGPARAM_STARTLIST
,
90 CMD_STRINGPARAM_FORCEOPENLIST
,
91 CMD_STRINGPARAM_FORCENEWLIST
,
92 CMD_STRINGPARAM_PRINTLIST
,
93 CMD_STRINGPARAM_VERSION
,
94 CMD_STRINGPARAM_PRINTTOLIST
,
95 CMD_STRINGPARAM_PRINTERNAME
,
96 CMD_STRINGPARAM_DISPLAY
,
97 CMD_STRINGPARAM_COUNT
// must be last element!
107 // Thrown from constructors and next:
111 Exception(Exception
const &);
112 virtual ~Exception();
113 Exception
& operator =(Exception
const &);
117 virtual boost::optional
< rtl::OUString
> getCwdUrl() = 0;
118 virtual bool next(rtl::OUString
* argument
) = 0;
122 CommandLineArgs( Supplier
& supplier
);
124 boost::optional
< rtl::OUString
> getCwdUrl() const { return m_cwdUrl
; }
126 // generic methods to access parameter
127 void SetBoolParam( BoolParam eParam
, sal_Bool bNewValue
);
129 const rtl::OUString
& GetStringParam( StringParam eParam
) const;
131 // Access to bool parameters
132 sal_Bool
IsMinimized() const;
133 sal_Bool
IsInvisible() const;
134 sal_Bool
IsNoRestore() const;
135 sal_Bool
IsNoDefault() const;
136 sal_Bool
IsBean() const;
137 sal_Bool
IsServer() const;
138 sal_Bool
IsHeadless() const;
139 sal_Bool
IsQuickstart() const;
140 sal_Bool
IsTerminateAfterInit() const;
141 sal_Bool
IsNoFirstStartWizard() const;
142 sal_Bool
IsNoLogo() const;
143 sal_Bool
IsNoLockcheck() const;
144 sal_Bool
IsHelp() const;
145 sal_Bool
IsHelpWriter() const;
146 sal_Bool
IsHelpCalc() const;
147 sal_Bool
IsHelpDraw() const;
148 sal_Bool
IsHelpImpress() const;
149 sal_Bool
IsHelpBase() const;
150 sal_Bool
IsHelpMath() const;
151 sal_Bool
IsHelpBasic() const;
152 sal_Bool
IsWriter() const;
153 sal_Bool
IsCalc() const;
154 sal_Bool
IsDraw() const;
155 sal_Bool
IsImpress() const;
156 sal_Bool
IsBase() const;
157 sal_Bool
IsGlobal() const;
158 sal_Bool
IsMath() const;
159 sal_Bool
IsWeb() const;
160 sal_Bool
HasModuleParam() const;
162 // Access to string parameters
163 sal_Bool
GetPortalConnectString( ::rtl::OUString
& rPara
) const;
164 sal_Bool
GetAcceptString( ::rtl::OUString
& rPara
) const;
165 sal_Bool
GetUnAcceptString( ::rtl::OUString
& rPara
) const;
166 sal_Bool
GetOpenList( ::rtl::OUString
& rPara
) const;
167 sal_Bool
GetViewList( ::rtl::OUString
& rPara
) const;
168 sal_Bool
GetStartList( ::rtl::OUString
& rPara
) const;
169 sal_Bool
GetForceOpenList( ::rtl::OUString
& rPara
) const;
170 sal_Bool
GetForceNewList( ::rtl::OUString
& rPara
) const;
171 sal_Bool
GetPrintList( ::rtl::OUString
& rPara
) const;
172 sal_Bool
GetPrintToList( ::rtl::OUString
& rPara
) const;
173 sal_Bool
GetPrinterName( ::rtl::OUString
& rPara
) const;
175 // Special analyzed states (does not match directly to a command line parameter!)
176 sal_Bool
IsPrinting() const;
177 sal_Bool
IsEmpty() const;
178 sal_Bool
IsEmptyOrAcceptOnly() const;
181 enum Count
{ NONE
, ONE
, MANY
};
183 struct GroupDefinition
186 BoolParam
* pGroupMembers
;
189 // no copy and operator=
190 CommandLineArgs( const CommandLineArgs
& );
191 CommandLineArgs
operator=( const CommandLineArgs
& );
193 sal_Bool
InterpretCommandLineParameter( const ::rtl::OUString
& );
194 void ParseCommandLine_Impl( Supplier
& supplier
);
195 void ResetParamValues();
196 sal_Bool
CheckGroupMembers( GroupParamId nGroup
, BoolParam nExcludeMember
) const;
198 void AddStringListParam_Impl( StringParam eParam
, const rtl::OUString
& aParam
);
199 void SetBoolParam_Impl( BoolParam eParam
, sal_Bool bValue
);
201 boost::optional
< rtl::OUString
> m_cwdUrl
;
202 sal_Bool m_aBoolParams
[ CMD_BOOLPARAM_COUNT
]; // Stores boolean parameters
203 rtl::OUString m_aStrParams
[ CMD_STRINGPARAM_COUNT
]; // Stores string parameters
204 sal_Bool m_aStrSetParams
[ CMD_STRINGPARAM_COUNT
]; // Stores if string parameters are provided on cmdline
205 Count m_eArgumentCount
; // Number of Args
206 mutable ::osl::Mutex m_aMutex
;
208 // static definition for groups where only one member can be true
209 static GroupDefinition m_pGroupDefinitions
[ CMD_GRPID_COUNT
];