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 #pragma once
21 
22 #include <sal/config.h>
23 
24 #include <vector>
25 
26 #include <rtl/ustring.hxx>
27 #include <optional>
28 
29 namespace desktop
30 {
31 
33 {
34  public:
35  struct Supplier
36  {
37  // Thrown from constructors and next:
38  class Exception final
39  {
40  public:
41  Exception();
42  Exception(Exception const &);
43  ~Exception();
44  Exception & operator =(Exception const &);
45  };
46 
47  virtual ~Supplier();
48  virtual std::optional< OUString > getCwdUrl() = 0;
49  virtual bool next(OUString * argument) = 0;
50  };
51 
53  explicit CommandLineArgs( Supplier& supplier );
54 
55  CommandLineArgs(const CommandLineArgs&) = delete;
56  const CommandLineArgs& operator=(const CommandLineArgs&) = delete;
57 
58  const std::optional< OUString >& getCwdUrl() const { return m_cwdUrl; }
59 
60  // Access to bool parameters
61  bool IsMinimized() const { return m_minimized;}
62  bool IsInvisible() const
63  {
64  return m_invisible || (m_headless && !m_eventtesting);
65  }
66  bool IsNoRestore() const { return m_norestore;}
67  bool IsNoDefault() const { return m_nodefault;}
68  bool IsHeadless() const { return m_headless;}
69  bool IsEventTesting() const { return m_eventtesting;}
70  bool IsQuickstart() const { return m_quickstart;}
71  bool IsNoQuickstart() const { return m_noquickstart;}
73  bool IsNoLogo() const { return m_nologo;}
74  bool IsNoLockcheck() const { return m_nolockcheck;}
75  bool IsHelp() const { return m_help;}
76  bool IsHelpWriter() const { return m_helpwriter;}
77  bool IsHelpCalc() const { return m_helpcalc;}
78  bool IsHelpDraw() const { return m_helpdraw;}
79  bool IsHelpImpress() const { return m_helpimpress;}
80  bool IsHelpBase() const { return m_helpbase;}
81  bool IsHelpMath() const { return m_helpmath;}
82  bool IsHelpBasic() const { return m_helpbasic;}
83  bool IsWriter() const { return m_writer;}
84  bool IsCalc() const { return m_calc;}
85  bool IsDraw() const { return m_draw;}
86  bool IsImpress() const { return m_impress;}
87  bool IsBase() const { return m_base;}
88  bool IsGlobal() const { return m_global;}
89  bool IsMath() const { return m_math;}
90  bool IsWeb() const { return m_web;}
91  bool IsVersion() const { return m_version;}
92  bool HasModuleParam() const;
93  bool WantsToLoadDocument() const { return m_bDocumentArgs;}
94  bool IsTextCat() const { return m_textcat;}
95  bool IsScriptCat() const { return m_scriptcat;}
96  bool IsSafeMode() const { return m_safemode; }
97 
98  const OUString& GetUnknown() const { return m_unknown;}
99 
100  // Access to string parameters
101  bool HasSplashPipe() const { return m_splashpipe;}
102  std::vector< OUString > const & GetAccept() const { return m_accept;}
103  std::vector< OUString > const & GetUnaccept() const { return m_unaccept;}
104  std::vector< OUString > GetOpenList() const;
105  std::vector< OUString > GetViewList() const;
106  std::vector< OUString > GetStartList() const;
107  std::vector< OUString > GetForceOpenList() const;
108  std::vector< OUString > GetForceNewList() const;
109  std::vector< OUString > GetPrintList() const;
110  std::vector< OUString > GetPrintToList() const;
111  const OUString& GetPrinterName() const { return m_printername;}
112  const OUString& GetLanguage() const { return m_language;}
113  std::vector< OUString > const & GetInFilter() const { return m_infilter;}
114  std::vector< OUString > GetConversionList() const;
115  const OUString& GetConversionParams() const { return m_conversionparams;}
116  OUString GetConversionOut() const;
117  OUString const & GetImageConversionType() const { return m_convertimages; }
118  const OUString& GetPidfileName() const { return m_pidfile;}
119 
120  // Special analyzed states (does not match directly to a command line parameter!)
121  bool IsEmpty() const { return m_bEmpty;}
122 
123  void setHeadless() { m_headless = true; }
124 
125  private:
126  void ParseCommandLine_Impl( Supplier& supplier );
127  void InitParamValues();
128 
129  std::optional< OUString > m_cwdUrl;
130 
139  bool m_nologo;
142  bool m_help;
143  bool m_writer;
144  bool m_calc;
145  bool m_draw;
146  bool m_impress;
147  bool m_global;
148  bool m_math;
149  bool m_web;
150  bool m_base;
158  bool m_version;
160  bool m_textcat;
163 
164  OUString m_unknown;
165 
166  bool m_bEmpty; // No Args at all
167  bool m_bDocumentArgs; // A document creation/open/load arg is used
168  std::vector< OUString > m_accept;
169  std::vector< OUString > m_unaccept;
170  std::vector< OUString > m_openlist; // contains external URIs
171  std::vector< OUString > m_viewlist; // contains external URIs
172  std::vector< OUString > m_startlist; // contains external URIs
173  std::vector< OUString > m_forceopenlist; // contains external URIs
174  std::vector< OUString > m_forcenewlist; // contains external URIs
175  std::vector< OUString > m_printlist; // contains external URIs
176  std::vector< OUString > m_printtolist; // contains external URIs
177  OUString m_printername;
178  std::vector< OUString > m_conversionlist; // contains external URIs
180  OUString m_conversionout; // contains external URIs
181  OUString m_convertimages; // The format in which images should be converted
182  std::vector< OUString > m_infilter;
183  OUString m_language;
184  OUString m_pidfile;
185 };
186 
187 }
188 
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< OUString > m_forceopenlist
std::vector< OUString > GetViewList() const
const CommandLineArgs & operator=(const CommandLineArgs &)=delete
const std::optional< OUString > & getCwdUrl() const
Definition: cmdlineargs.hxx:58
bool HasModuleParam() const
bool IsScriptCat() const
Definition: cmdlineargs.hxx:95
std::vector< OUString > GetStartList() const
std::vector< OUString > GetPrintToList() const
bool IsHelpImpress() const
Definition: cmdlineargs.hxx:79
std::vector< OUString > const & GetInFilter() const
std::vector< OUString > m_openlist
bool IsHelpMath() const
Definition: cmdlineargs.hxx:81
const OUString & GetConversionParams() const
std::vector< OUString > m_startlist
Definition: app.cxx:159
bool IsHeadless() const
Definition: cmdlineargs.hxx:68
bool IsNoDefault() const
Definition: cmdlineargs.hxx:67
bool IsSafeMode() const
Definition: cmdlineargs.hxx:96
Exception & operator=(Exception const &)
std::vector< OUString > GetForceNewList() const
virtual std::optional< OUString > getCwdUrl()=0
const OUString & GetLanguage() const
std::optional< OUString > m_cwdUrl
bool WantsToLoadDocument() const
Definition: cmdlineargs.hxx:93
std::vector< OUString > const & GetUnaccept() const
std::vector< OUString > m_conversionlist
OUString GetConversionOut() const
const OUString & GetUnknown() const
Definition: cmdlineargs.hxx:98
bool IsHelpBase() const
Definition: cmdlineargs.hxx:80
bool IsHelpDraw() const
Definition: cmdlineargs.hxx:78
bool IsHelpCalc() const
Definition: cmdlineargs.hxx:77
std::vector< OUString > GetPrintList() const
const OUString & GetPrinterName() const
bool IsHelpBasic() const
Definition: cmdlineargs.hxx:82
bool IsTerminateAfterInit() const
Definition: cmdlineargs.hxx:72
bool HasSplashPipe() const
bool IsEventTesting() const
Definition: cmdlineargs.hxx:69
const OUString & GetPidfileName() const
bool IsInvisible() const
Definition: cmdlineargs.hxx:62
std::vector< OUString > GetConversionList() const
std::vector< OUString > m_accept
std::vector< OUString > m_printlist
bool IsHelpWriter() const
Definition: cmdlineargs.hxx:76
std::vector< OUString > m_printtolist
std::vector< OUString > const & GetAccept() const
std::vector< OUString > GetOpenList() const
bool IsNoQuickstart() const
Definition: cmdlineargs.hxx:71
std::vector< OUString > m_unaccept
std::vector< OUString > m_viewlist
OUString const & GetImageConversionType() const
bool IsNoLockcheck() const
Definition: cmdlineargs.hxx:74
bool IsQuickstart() const
Definition: cmdlineargs.hxx:70
std::vector< OUString > m_forcenewlist
bool IsMinimized() const
Definition: cmdlineargs.hxx:61
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:66