1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef _DESKTOP_COMMANDLINEARGS_HXX_ 25*b1cdbd2cSJim Jagielski #define _DESKTOP_COMMANDLINEARGS_HXX_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <rtl/ustring.hxx> 28*b1cdbd2cSJim Jagielski #include <osl/mutex.hxx> 29*b1cdbd2cSJim Jagielski #include "boost/optional.hpp" 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski namespace desktop 32*b1cdbd2cSJim Jagielski { 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski class CommandLineArgs 35*b1cdbd2cSJim Jagielski { 36*b1cdbd2cSJim Jagielski public: 37*b1cdbd2cSJim Jagielski enum BoolParam // must be zero based! 38*b1cdbd2cSJim Jagielski { 39*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_MINIMIZED, 40*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_INVISIBLE, 41*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_NORESTORE, 42*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_BEAN, 43*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_PLUGIN, 44*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_SERVER, 45*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HEADLESS, 46*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_CONVERSIONMODE, 47*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_QUICKSTART, 48*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_NOQUICKSTART, 49*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_TERMINATEAFTERINIT, 50*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_NOFIRSTSTARTWIZARD, 51*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_NOLOGO, 52*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_NOLOCKCHECK, 53*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_NODEFAULT, 54*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HELP, 55*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_WRITER, 56*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_CALC, 57*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_DRAW, 58*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_IMPRESS, 59*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_GLOBAL, 60*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_MATH, 61*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_WEB, 62*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_BASE, 63*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HELPWRITER, 64*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HELPCALC, 65*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HELPDRAW, 66*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HELPBASIC, 67*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HELPMATH, 68*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HELPIMPRESS, 69*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_HELPBASE, 70*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_PSN, 71*b1cdbd2cSJim Jagielski CMD_BOOLPARAM_COUNT // must be last element! 72*b1cdbd2cSJim Jagielski }; 73*b1cdbd2cSJim Jagielski 74*b1cdbd2cSJim Jagielski enum StringParam // must be zero based! 75*b1cdbd2cSJim Jagielski { 76*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_PORTAL, 77*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_ACCEPT, 78*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_UNACCEPT, 79*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_USERDIR, 80*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_CLIENTDISPLAY, 81*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_OPENLIST, 82*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_VIEWLIST, 83*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_STARTLIST, 84*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_FORCEOPENLIST, 85*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_FORCENEWLIST, 86*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_PRINTLIST, 87*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_VERSION, 88*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_PRINTTOLIST, 89*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_PRINTERNAME, 90*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_DISPLAY, 91*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_LANGUAGE, 92*b1cdbd2cSJim Jagielski CMD_STRINGPARAM_COUNT // must be last element! 93*b1cdbd2cSJim Jagielski }; 94*b1cdbd2cSJim Jagielski 95*b1cdbd2cSJim Jagielski enum GroupParamId 96*b1cdbd2cSJim Jagielski { 97*b1cdbd2cSJim Jagielski CMD_GRPID_MODULE, 98*b1cdbd2cSJim Jagielski CMD_GRPID_COUNT 99*b1cdbd2cSJim Jagielski }; 100*b1cdbd2cSJim Jagielski 101*b1cdbd2cSJim Jagielski struct Supplier 102*b1cdbd2cSJim Jagielski { 103*b1cdbd2cSJim Jagielski // Thrown from constructors and next: 104*b1cdbd2cSJim Jagielski class Exception { 105*b1cdbd2cSJim Jagielski public: 106*b1cdbd2cSJim Jagielski Exception(); 107*b1cdbd2cSJim Jagielski Exception(Exception const &); 108*b1cdbd2cSJim Jagielski virtual ~Exception(); 109*b1cdbd2cSJim Jagielski Exception & operator =(Exception const &); 110*b1cdbd2cSJim Jagielski }; 111*b1cdbd2cSJim Jagielski 112*b1cdbd2cSJim Jagielski virtual ~Supplier(); 113*b1cdbd2cSJim Jagielski virtual boost::optional< rtl::OUString > getCwdUrl() = 0; 114*b1cdbd2cSJim Jagielski virtual bool next(rtl::OUString * argument) = 0; 115*b1cdbd2cSJim Jagielski }; 116*b1cdbd2cSJim Jagielski 117*b1cdbd2cSJim Jagielski CommandLineArgs(); 118*b1cdbd2cSJim Jagielski CommandLineArgs( Supplier& supplier ); 119*b1cdbd2cSJim Jagielski getCwdUrl() const120*b1cdbd2cSJim Jagielski boost::optional< rtl::OUString > getCwdUrl() const { return m_cwdUrl; } 121*b1cdbd2cSJim Jagielski 122*b1cdbd2cSJim Jagielski // generic methods to access parameter 123*b1cdbd2cSJim Jagielski void SetBoolParam( BoolParam eParam, sal_Bool bNewValue ); 124*b1cdbd2cSJim Jagielski 125*b1cdbd2cSJim Jagielski // Access to bool parameters 126*b1cdbd2cSJim Jagielski sal_Bool IsMinimized() const; 127*b1cdbd2cSJim Jagielski sal_Bool IsInvisible() const; 128*b1cdbd2cSJim Jagielski sal_Bool IsNoRestore() const; 129*b1cdbd2cSJim Jagielski sal_Bool IsNoDefault() const; 130*b1cdbd2cSJim Jagielski sal_Bool IsBean() const; 131*b1cdbd2cSJim Jagielski sal_Bool IsServer() const; 132*b1cdbd2cSJim Jagielski sal_Bool IsHeadless() const; 133*b1cdbd2cSJim Jagielski sal_Bool IsConversionMode() const; 134*b1cdbd2cSJim Jagielski sal_Bool IsQuickstart() const; 135*b1cdbd2cSJim Jagielski sal_Bool IsNoQuickstart() const; 136*b1cdbd2cSJim Jagielski sal_Bool IsTerminateAfterInit() const; 137*b1cdbd2cSJim Jagielski sal_Bool IsNoFirstStartWizard() const; 138*b1cdbd2cSJim Jagielski sal_Bool IsNoLogo() const; 139*b1cdbd2cSJim Jagielski sal_Bool IsNoLockcheck() const; 140*b1cdbd2cSJim Jagielski sal_Bool IsHelp() const; 141*b1cdbd2cSJim Jagielski sal_Bool IsHelpWriter() const; 142*b1cdbd2cSJim Jagielski sal_Bool IsHelpCalc() const; 143*b1cdbd2cSJim Jagielski sal_Bool IsHelpDraw() const; 144*b1cdbd2cSJim Jagielski sal_Bool IsHelpImpress() const; 145*b1cdbd2cSJim Jagielski sal_Bool IsHelpBase() const; 146*b1cdbd2cSJim Jagielski sal_Bool IsHelpMath() const; 147*b1cdbd2cSJim Jagielski sal_Bool IsHelpBasic() const; 148*b1cdbd2cSJim Jagielski sal_Bool IsWriter() const; 149*b1cdbd2cSJim Jagielski sal_Bool IsCalc() const; 150*b1cdbd2cSJim Jagielski sal_Bool IsDraw() const; 151*b1cdbd2cSJim Jagielski sal_Bool IsImpress() const; 152*b1cdbd2cSJim Jagielski sal_Bool IsBase() const; 153*b1cdbd2cSJim Jagielski sal_Bool IsGlobal() const; 154*b1cdbd2cSJim Jagielski sal_Bool IsMath() const; 155*b1cdbd2cSJim Jagielski sal_Bool IsWeb() const; 156*b1cdbd2cSJim Jagielski sal_Bool HasModuleParam() const; 157*b1cdbd2cSJim Jagielski sal_Bool WantsToLoadDocument() const; 158*b1cdbd2cSJim Jagielski 159*b1cdbd2cSJim Jagielski // Access to string parameters 160*b1cdbd2cSJim Jagielski sal_Bool GetPortalConnectString( ::rtl::OUString& rPara) const; 161*b1cdbd2cSJim Jagielski sal_Bool GetAcceptString( ::rtl::OUString& rPara) const; 162*b1cdbd2cSJim Jagielski sal_Bool GetUnAcceptString( ::rtl::OUString& rPara) const; 163*b1cdbd2cSJim Jagielski sal_Bool GetOpenList( ::rtl::OUString& rPara) const; 164*b1cdbd2cSJim Jagielski sal_Bool GetViewList( ::rtl::OUString& rPara) const; 165*b1cdbd2cSJim Jagielski sal_Bool GetStartList( ::rtl::OUString& rPara) const; 166*b1cdbd2cSJim Jagielski sal_Bool GetForceOpenList( ::rtl::OUString& rPara) const; 167*b1cdbd2cSJim Jagielski sal_Bool GetForceNewList( ::rtl::OUString& rPara) const; 168*b1cdbd2cSJim Jagielski sal_Bool GetPrintList( ::rtl::OUString& rPara) const; 169*b1cdbd2cSJim Jagielski sal_Bool GetPrintToList( ::rtl::OUString& rPara ) const; 170*b1cdbd2cSJim Jagielski sal_Bool GetPrinterName( ::rtl::OUString& rPara ) const; 171*b1cdbd2cSJim Jagielski sal_Bool GetLanguage( ::rtl::OUString& rPara ) const; 172*b1cdbd2cSJim Jagielski 173*b1cdbd2cSJim Jagielski // Special analyzed states (does not match directly to a command line parameter!) 174*b1cdbd2cSJim Jagielski sal_Bool IsPrinting() const; 175*b1cdbd2cSJim Jagielski sal_Bool IsEmpty() const; 176*b1cdbd2cSJim Jagielski sal_Bool IsEmptyOrAcceptOnly() const; 177*b1cdbd2cSJim Jagielski 178*b1cdbd2cSJim Jagielski private: 179*b1cdbd2cSJim Jagielski enum Count { NONE, ONE, MANY }; 180*b1cdbd2cSJim Jagielski 181*b1cdbd2cSJim Jagielski struct GroupDefinition 182*b1cdbd2cSJim Jagielski { 183*b1cdbd2cSJim Jagielski sal_Int32 nCount; 184*b1cdbd2cSJim Jagielski BoolParam* pGroupMembers; 185*b1cdbd2cSJim Jagielski }; 186*b1cdbd2cSJim Jagielski 187*b1cdbd2cSJim Jagielski // no copy and operator= 188*b1cdbd2cSJim Jagielski CommandLineArgs( const CommandLineArgs& ); 189*b1cdbd2cSJim Jagielski CommandLineArgs operator=( const CommandLineArgs& ); 190*b1cdbd2cSJim Jagielski 191*b1cdbd2cSJim Jagielski sal_Bool InterpretCommandLineParameter( const ::rtl::OUString& ); 192*b1cdbd2cSJim Jagielski void ParseCommandLine_Impl( Supplier& supplier ); 193*b1cdbd2cSJim Jagielski void ResetParamValues(); 194*b1cdbd2cSJim Jagielski sal_Bool CheckGroupMembers( GroupParamId nGroup, BoolParam nExcludeMember ) const; 195*b1cdbd2cSJim Jagielski 196*b1cdbd2cSJim Jagielski void AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam ); 197*b1cdbd2cSJim Jagielski void SetBoolParam_Impl( BoolParam eParam, sal_Bool bValue ); 198*b1cdbd2cSJim Jagielski 199*b1cdbd2cSJim Jagielski boost::optional< rtl::OUString > m_cwdUrl; 200*b1cdbd2cSJim Jagielski sal_Bool m_aBoolParams[ CMD_BOOLPARAM_COUNT ]; // Stores boolean parameters 201*b1cdbd2cSJim Jagielski rtl::OUString m_aStrParams[ CMD_STRINGPARAM_COUNT ]; // Stores string parameters 202*b1cdbd2cSJim Jagielski sal_Bool m_aStrSetParams[ CMD_STRINGPARAM_COUNT ]; // Stores if string parameters are provided on cmdline 203*b1cdbd2cSJim Jagielski Count m_eArgumentCount; // Number of Args 204*b1cdbd2cSJim Jagielski bool m_bDocumentArgs; // A document creation/open/load arg is used 205*b1cdbd2cSJim Jagielski mutable ::osl::Mutex m_aMutex; 206*b1cdbd2cSJim Jagielski 207*b1cdbd2cSJim Jagielski // static definition for groups where only one member can be true 208*b1cdbd2cSJim Jagielski static GroupDefinition m_pGroupDefinitions[ CMD_GRPID_COUNT ]; 209*b1cdbd2cSJim Jagielski }; 210*b1cdbd2cSJim Jagielski 211*b1cdbd2cSJim Jagielski } 212*b1cdbd2cSJim Jagielski 213*b1cdbd2cSJim Jagielski #endif 214