28#if !defined WIN32_LEAN_AND_MEAN
29# define WIN32_LEAN_AND_MEAN
39 u"%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"
42 u"Usage: %CMDNAME [argument...]\n"
43 " argument - switches, switch parameters and document URIs (filenames). \n\n"
44 "Using without special arguments: \n"
45 "Opens the start center, if it is used without any arguments. \n"
46 " {file} Tries to open the file (files) in the components \n"
47 " suitable for them. \n"
48 " {file} {macro:///Library.Module.MacroName} \n"
49 " Opens the file and runs specified macro from \n"
50 " My Macros container. \n"
51 " {file} {macro://./Library.Module.MacroName} \n"
52 " Opens the file and runs specified macro from \n"
54 "Getting help and information: \n"
55 " --help | -h | -? Shows this help and quits. \n"
56 " --helpwriter Opens built-in or online Help on Writer. \n"
57 " --helpcalc Opens built-in or online Help on Calc. \n"
58 " --helpdraw Opens built-in or online Help on Draw. \n"
59 " --helpimpress Opens built-in or online Help on Impress. \n"
60 " --helpbase Opens built-in or online Help on Base. \n"
61 " --helpbasic Opens built-in or online Help on Basic scripting \n"
63 " --helpmath Opens built-in or online Help on Math. \n"
64 " --version Shows the version and quits. \n"
65 " --nstemporarydirectory \n"
66 " (MacOS X sandbox only) Returns path of the temporary \n"
67 " directory for the current user and exits. Overrides \n"
68 " all other arguments. \n\n"
69 "General arguments: \n"
70 " --quickstart[=no] Activates[Deactivates] the Quickstarter service. \n"
71 " --nolockcheck Disables check for remote instances using one \n"
73 " --infilter={filter} Force an input filter type if possible. For example: \n"
74 " --infilter=\"Calc Office Open XML\" \n"
75 " --infilter=\"Text (encoded):UTF8,LF,,,\" \n"
76 " --pidfile={file} Store soffice.bin pid to {file}. \n"
77 " --display {display} Sets the DISPLAY environment variable on UNIX-like \n"
78 " platforms to the value {display} (only supported by a \n"
79 " start script). \n\n"
80 "User/programmatic interface control: \n"
81 " --nologo Disables the splash screen at program start. \n"
82 " --minimized Starts minimized. The splash screen is not displayed. \n"
83 " --nodefault Starts without displaying anything except the splash \n"
84 " screen (do not display initial window). \n"
85 " --invisible Starts in invisible mode. Neither the start-up logo nor \n"
86 " the initial program window will be visible. Application \n"
87 " can be controlled, and documents and dialogs can be \n"
88 " controlled and opened via the API. Using the parameter, \n"
89 " the process can only be ended using the taskmanager \n"
90 " (Windows) or the kill command (UNIX-like systems). It \n"
91 " cannot be used in conjunction with --quickstart. \n"
92 " --headless Starts in \"headless mode\" which allows using the \n"
93 " application without GUI. This special mode can be used \n"
94 " when the application is controlled by external clients \n"
96 " --norestore Disables restart and file recovery after a system crash.\n"
97 " --safe-mode Starts in a safe mode, i.e. starts temporarily with a \n"
98 " fresh user profile and helps to restore a broken \n"
100 " --accept={connect-string} Specifies a UNO connect-string to create a UNO \n"
101 " acceptor through which other programs can connect to \n"
102 " access the API. Note that API access allows execution \n"
103 " of arbitrary commands. \n"
104 " The syntax of the {connect-string} is: \n"
105 " connection-type,params;protocol-name,params \n"
106 " e.g. pipe,name={some name};urp \n"
107 " or socket,host=localhost,port=54321;urp \n"
108 " --unaccept={connect-string} Closes an acceptor that was created with \n"
109 " --accept. Use --unaccept=all to close all acceptors. \n"
110 " --language={lang} Uses specified language, if language is not selected \n"
111 " yet for UI. The lang is a tag of the language in IETF \n"
112 " language tag. \n\n"
113 "Developer arguments: \n"
114 " --terminate_after_init \n"
115 " Exit after initialization complete (no documents loaded)\n"
116 " --eventtesting Exit after loading documents. \n\n"
117 "New document creation arguments: \n"
118 "The arguments create an empty document of specified kind. Only one of them may \n"
119 "be used in one command line. If filenames are specified after an argument, \n"
120 "then it tries to open those files in the specified component. \n"
121 " --writer Creates an empty Writer document. \n"
122 " --calc Creates an empty Calc document. \n"
123 " --draw Creates an empty Draw document. \n"
124 " --impress Creates an empty Impress document. \n"
125 " --base Creates a new database. \n"
126 " --global Creates an empty Writer master (global) document. \n"
127 " --math Creates an empty Math document (formula). \n"
128 " --web Creates an empty HTML document. \n\n"
129 "File open arguments: \n"
130 "The arguments define how following filenames are treated. New treatment begins \n"
131 "after the argument and ends at the next argument. The default treatment is to \n"
132 "open documents for editing, and create new documents from document templates. \n"
133 " -n Treats following files as templates for creation of new \n"
135 " -o Opens following files for editing, regardless whether \n"
136 " they are templates or not. \n"
137 " --pt {Printername} Prints following files to the printer {Printername}, \n"
138 " after which those files are closed. The splash screen \n"
139 " does not appear. If used multiple times, only last \n"
140 " {Printername} is effective for all documents of all \n"
141 " --pt runs. Also, --printer-name argument of \n"
142 " --print-to-file switch interferes with {Printername}. \n"
143 " -p Prints following files to the default printer, after \n"
144 " which those files are closed. The splash screen does \n"
145 " not appear. If the file name contains spaces, then it \n"
146 " must be enclosed in quotation marks. \n"
147 " --view Opens following files in viewer mode (read-only). \n"
148 " --show Opens and starts the following presentation documents \n"
149 " of each immediately. Files are closed after the showing.\n"
150 " Files other than Impress documents are opened in \n"
151 " default mode , regardless of previous mode. \n"
152 " --convert-to OutputFileExtension[:OutputFilterName] \\ \n"
153 " [--outdir output_dir] [--convert-images-to] \n"
154 " Batch convert files (implies --headless). If --outdir \n"
155 " isn't specified, then current working directory is used \n"
156 " as output_dir. If --convert-images-to is given, its \n"
157 " parameter is taken as the target filter format for *all*\n"
158 " images written to the output format. If --convert-to is \n"
159 " used more than once, the last value of \n"
160 " OutputFileExtension[:OutputFilterName] is effective. If \n"
161 " --outdir is used more than once, only its last value is \n"
162 " effective. For example: \n"
163 " --convert-to pdf *.odt \n"
164 " --convert-to epub *.doc \n"
165 " --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc\n"
166 " --convert-to \"html:XHTML Writer File:UTF8\" \\ \n"
167 " --convert-images-to \"jpg\" *.doc \n"
168 " --convert-to \"txt:Text (encoded):UTF8\" *.doc \n"
169 " --print-to-file [--printer-name printer_name] [--outdir output_dir] \n"
170 " Batch print files to file. If --outdir is not specified,\n"
171 " then current working directory is used as output_dir. \n"
172 " If --printer-name or --outdir used multiple times, only \n"
173 " last value of each is effective. Also, {Printername} of \n"
174 " --pt switch interferes with --printer-name. \n"
175 " --cat Dump text content of the following files to console \n"
176 " (implies --headless). Cannot be used with --convert-to. \n"
177 " --script-cat Dump text content of any scripts embedded in the files \n"
178 " to console (implies --headless). Cannot be used with \n"
180 " -env:<VAR>[=<VALUE>] Set a bootstrap variable. For example: to set \n"
181 " a non-default user profile path: \n"
182 " -env:UserInstallation=file:///tmp/test \n\n"
183 "Ignored switches: \n"
184 " -psn Ignored (MacOS X only). \n"
185 " -Embedding Ignored (COM+ related; Windows only). \n"
186 " --nofirststartwizard Does nothing, accepted only for backward compatibility.\n"
187 " --protector {arg1} {arg2} \n"
188 " Used only in unit tests and should have two arguments. \n\n";
197 explicit lcl_Console(
short nBufHeight)
198 : m_bOwnConsole(AllocConsole() !=
FALSE)
202 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
205 CONSOLE_SCREEN_BUFFER_INFO cinfo;
206 GetConsoleScreenBufferInfo(hOut, &cinfo);
207 if (cinfo.dwSize.Y < nBufHeight)
209 cinfo.dwSize.Y = nBufHeight;
210 SetConsoleScreenBufferSize(hOut, cinfo.dwSize);
213 (void)freopen(
"CON",
"r", stdin);
214 (void)freopen(
"CON",
"w", stdout);
215 (void)freopen(
"CON",
"w", stderr);
217 std::ios::sync_with_stdio(
true);
226 fprintf(stdout,
"Press Enter to continue...");
240 OUString aHelpMessage(OUString(
aCmdLineHelp).replaceFirst(
"%CMDNAME",
"soffice"));
243 aHelpMessage =
"Error in option: " +
unknown +
"\n\n"
248 lcl_Console aConsole(
short(
n*2));
250 fprintf(stdout,
"%s%s",
260 lcl_Console aConsole(
short(10));
262 fprintf(stdout,
"%s",
OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
constexpr OUStringLiteral aCmdLineHelp_version
constexpr OUStringLiteral aCmdLineHelp
OUString ReplaceStringHookProc(const OUString &rStr)
void displayCmdlineHelp(OUString const &unknown)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)