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