LibreOffice Module desktop (master)  1
cmdlineargs.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_DESKTOP_SOURCE_APP_CMDLINEARGS_HXX
21 #define INCLUDED_DESKTOP_SOURCE_APP_CMDLINEARGS_HXX
22 
23 #include <sal/config.h>
24 
25 #include <vector>
26 
27 #include <rtl/ustring.hxx>
28 #include <boost/optional.hpp>
29 
30 namespace desktop
31 {
32 
34 {
35  public:
36  struct Supplier
37  {
38  // Thrown from constructors and next:
39  class Exception final
40  {
41  public:
42  Exception();
43  Exception(Exception const &);
44  ~Exception();
45  Exception & operator =(Exception const &);
46  };
47 
48  virtual ~Supplier();
50  virtual bool next(OUString * argument) = 0;
51  };
52 
54  explicit CommandLineArgs( Supplier& supplier );
55 
56  CommandLineArgs(const CommandLineArgs&) = delete;
57  const CommandLineArgs& operator=(const CommandLineArgs&) = delete;
58 
59  const boost::optional< OUString >& getCwdUrl() const { return m_cwdUrl; }
60 
61  // Access to bool parameters
62  bool IsMinimized() const { return m_minimized;}
63  bool IsInvisible() const
64  {
65  return m_invisible || (m_headless && !m_eventtesting);
66  }
67  bool IsNoRestore() const { return m_norestore;}
68  bool IsNoDefault() const { return m_nodefault;}
69  bool IsHeadless() const { return m_headless;}
70  bool IsEventTesting() const { return m_eventtesting;}
71  bool IsQuickstart() const { return m_quickstart;}
72  bool IsNoQuickstart() const { return m_noquickstart;}
74  bool IsNoLogo() const { return m_nologo;}
75  bool IsNoLockcheck() const { return m_nolockcheck;}
76  bool IsHelp() const { return m_help;}
77  bool IsHelpWriter() const { return m_helpwriter;}
78  bool IsHelpCalc() const { return m_helpcalc;}
79  bool IsHelpDraw() const { return m_helpdraw;}
80  bool IsHelpImpress() const { return m_helpimpress;}
81  bool IsHelpBase() const { return m_helpbase;}
82  bool IsHelpMath() const { return m_helpmath;}
83  bool IsHelpBasic() const { return m_helpbasic;}
84  bool IsWriter() const { return m_writer;}
85  bool IsCalc() const { return m_calc;}
86  bool IsDraw() const { return m_draw;}
87  bool IsImpress() const { return m_impress;}
88  bool IsBase() const { return m_base;}
89  bool IsGlobal() const { return m_global;}
90  bool IsMath() const { return m_math;}
91  bool IsWeb() const { return m_web;}
92  bool IsVersion() const { return m_version;}
93  bool HasModuleParam() const;
94  bool WantsToLoadDocument() const { return m_bDocumentArgs;}
95  bool IsTextCat() const { return m_textcat;}
96  bool IsScriptCat() const { return m_scriptcat;}
97  bool IsSafeMode() const { return m_safemode; }
98 
99  const OUString& GetUnknown() const { return m_unknown;}
100 
101  // Access to string parameters
102  bool HasSplashPipe() const { return m_splashpipe;}
103  std::vector< OUString > const & GetAccept() const { return m_accept;}
104  std::vector< OUString > const & GetUnaccept() const { return m_unaccept;}
105  std::vector< OUString > GetOpenList() const;
106  std::vector< OUString > GetViewList() const;
107  std::vector< OUString > GetStartList() const;
108  std::vector< OUString > GetForceOpenList() const;
109  std::vector< OUString > GetForceNewList() const;
110  std::vector< OUString > GetPrintList() const;
111  std::vector< OUString > GetPrintToList() const;
112  const OUString& GetPrinterName() const { return m_printername;}
113  const OUString& GetLanguage() const { return m_language;}
114  std::vector< OUString > const & GetInFilter() const { return m_infilter;}
115  std::vector< OUString > GetConversionList() const;
116  const OUString& GetConversionParams() const { return m_conversionparams;}
117  OUString GetConversionOut() const;
118  OUString const & GetImageConversionType() const { return m_convertimages; }
119  const OUString& GetPidfileName() const { return m_pidfile;}
120 
121  // Special analyzed states (does not match directly to a command line parameter!)
122  bool IsEmpty() const { return m_bEmpty;}
123 
124  void setHeadless() { m_headless = true; }
125 
126  private:
127  void ParseCommandLine_Impl( Supplier& supplier );
128  void InitParamValues();
129 
131 
140  bool m_nologo;
143  bool m_help;
144  bool m_writer;
145  bool m_calc;
146  bool m_draw;
147  bool m_impress;
148  bool m_global;
149  bool m_math;
150  bool m_web;
151  bool m_base;
159  bool m_version;
161  bool m_textcat;
164 
165  OUString m_unknown;
166 
167  bool m_bEmpty; // No Args at all
168  bool m_bDocumentArgs; // A document creation/open/load arg is used
169  std::vector< OUString > m_accept;
170  std::vector< OUString > m_unaccept;
171  std::vector< OUString > m_openlist; // contains external URIs
172  std::vector< OUString > m_viewlist; // contains external URIs
173  std::vector< OUString > m_startlist; // contains external URIs
174  std::vector< OUString > m_forceopenlist; // contains external URIs
175  std::vector< OUString > m_forcenewlist; // contains external URIs
176  std::vector< OUString > m_printlist; // contains external URIs
177  std::vector< OUString > m_printtolist; // contains external URIs
178  OUString m_printername;
179  std::vector< OUString > m_conversionlist; // contains external URIs
181  OUString m_conversionout; // contains external URIs
182  OUString m_convertimages; // The format in which images should be converted
183  std::vector< OUString > m_infilter;
184  OUString m_language;
185  OUString m_pidfile;
186 };
187 
188 }
189 
190 #endif
191 
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< OUString > m_forceopenlist
boost::optional< OUString > m_cwdUrl
std::vector< OUString > GetViewList() const
const CommandLineArgs & operator=(const CommandLineArgs &)=delete
bool HasModuleParam() const
bool IsScriptCat() const
Definition: cmdlineargs.hxx:96
std::vector< OUString > GetStartList() const
std::vector< OUString > GetPrintToList() const
bool IsHelpImpress() const
Definition: cmdlineargs.hxx:80
std::vector< OUString > const & GetInFilter() const
std::vector< OUString > m_openlist
bool IsHelpMath() const
Definition: cmdlineargs.hxx:82
const OUString & GetConversionParams() const
std::vector< OUString > m_startlist
Definition: app.cxx:167
bool IsHeadless() const
Definition: cmdlineargs.hxx:69
bool IsNoDefault() const
Definition: cmdlineargs.hxx:68
bool IsSafeMode() const
Definition: cmdlineargs.hxx:97
const boost::optional< OUString > & getCwdUrl() const
Definition: cmdlineargs.hxx:59
Exception & operator=(Exception const &)
std::vector< OUString > GetForceNewList() const
const OUString & GetLanguage() const
bool WantsToLoadDocument() const
Definition: cmdlineargs.hxx:94
std::vector< OUString > const & GetUnaccept() const
std::vector< OUString > m_conversionlist
OUString GetConversionOut() const
const OUString & GetUnknown() const
Definition: cmdlineargs.hxx:99
bool IsHelpBase() const
Definition: cmdlineargs.hxx:81
virtual boost::optional< OUString > getCwdUrl()=0
bool IsHelpDraw() const
Definition: cmdlineargs.hxx:79
bool IsHelpCalc() const
Definition: cmdlineargs.hxx:78
std::vector< OUString > GetPrintList() const
const OUString & GetPrinterName() const
bool IsHelpBasic() const
Definition: cmdlineargs.hxx:83
bool IsTerminateAfterInit() const
Definition: cmdlineargs.hxx:73
bool HasSplashPipe() const
bool IsEventTesting() const
Definition: cmdlineargs.hxx:70
const OUString & GetPidfileName() const
bool IsInvisible() const
Definition: cmdlineargs.hxx:63
std::vector< OUString > GetConversionList() const
std::vector< OUString > m_accept
std::vector< OUString > m_printlist
bool IsHelpWriter() const
Definition: cmdlineargs.hxx:77
std::vector< OUString > m_printtolist
std::vector< OUString > const & GetAccept() const
std::vector< OUString > GetOpenList() const
bool IsNoQuickstart() const
Definition: cmdlineargs.hxx:72
std::vector< OUString > m_unaccept
std::vector< OUString > m_viewlist
OUString const & GetImageConversionType() const
bool IsNoLockcheck() const
Definition: cmdlineargs.hxx:75
bool IsQuickstart() const
Definition: cmdlineargs.hxx:71
std::vector< OUString > m_forcenewlist
bool IsMinimized() const
Definition: cmdlineargs.hxx:62
void ParseCommandLine_Impl(Supplier &supplier)
virtual bool next(OUString *argument)=0
std::vector< OUString > m_infilter
std::vector< OUString > GetForceOpenList() const
bool IsNoRestore() const
Definition: cmdlineargs.hxx:67