Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <cmdlineargs.hxx>
30 : : #include <vcl/svapp.hxx>
31 : : #include <rtl/uri.hxx>
32 : : #include <rtl/ustring.hxx>
33 : : #include "rtl/process.h"
34 : : #include <comphelper/processfactory.hxx>
35 : : #include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
36 : : #include "tools/getprocessworkingdir.hxx"
37 : :
38 : : #include <svl/documentlockfile.hxx>
39 : :
40 : : #include <cstdio>
41 : :
42 : : using namespace com::sun::star::lang;
43 : : using namespace com::sun::star::uri;
44 : : using namespace com::sun::star::uno;
45 : :
46 : : using ::rtl::OUString;
47 : :
48 : : namespace desktop
49 : : {
50 : :
51 : : namespace {
52 : :
53 : 96 : OUString translateExternalUris(OUString const & input) {
54 : : OUString t(
55 : : com::sun::star::uri::ExternalUriReferenceTranslator::create(
56 [ + - ][ + - ]: 192 : comphelper::getProcessComponentContext())->
[ + - ]
57 [ + - ]: 96 : translateToInternal(input));
58 [ + - ]: 96 : return t.isEmpty() ? input : t;
59 : : }
60 : :
61 : 768 : std::vector< OUString > translateExternalUris(
62 : : std::vector< OUString > const & input)
63 : : {
64 : 768 : std::vector< OUString > t;
65 [ - + ][ + - ]: 1536 : for (std::vector< OUString >::const_iterator i(input.begin());
66 : 768 : i != input.end(); ++i)
67 : : {
68 [ # # ][ # # ]: 0 : t.push_back(translateExternalUris(*i));
69 : : }
70 : 768 : return t;
71 : : }
72 : :
73 : : class ExtCommandLineSupplier: public CommandLineArgs::Supplier {
74 : : public:
75 : 158 : explicit ExtCommandLineSupplier():
76 [ + - ]: 158 : m_count(rtl_getAppCommandArgCount()),
77 [ + - ]: 158 : m_index(0)
78 : : {
79 : 158 : rtl::OUString url;
80 [ + - ][ + - ]: 158 : if (tools::getProcessWorkingDir(url)) {
81 [ + - ]: 158 : m_cwdUrl.reset(url);
82 : 158 : }
83 : 158 : }
84 : :
85 [ + - ][ - + ]: 158 : virtual ~ExtCommandLineSupplier() {}
86 : :
87 : 158 : virtual boost::optional< rtl::OUString > getCwdUrl() { return m_cwdUrl; }
88 : :
89 : 1106 : virtual bool next(rtl::OUString * argument) {
90 : : OSL_ASSERT(argument != NULL);
91 [ + + ]: 1106 : if (m_index < m_count) {
92 : 948 : rtl_getAppCommandArg(m_index++, &argument->pData);
93 : 948 : return true;
94 : : } else {
95 : 1106 : return false;
96 : : }
97 : : }
98 : :
99 : : private:
100 : : boost::optional< rtl::OUString > m_cwdUrl;
101 : : sal_uInt32 m_count;
102 : : sal_uInt32 m_index;
103 : : };
104 : :
105 : : }
106 : :
107 : 0 : CommandLineArgs::Supplier::Exception::Exception() {}
108 : :
109 : 0 : CommandLineArgs::Supplier::Exception::Exception(Exception const &) {}
110 : :
111 [ # # ]: 0 : CommandLineArgs::Supplier::Exception::~Exception() {}
112 : :
113 : : CommandLineArgs::Supplier::Exception &
114 : 0 : CommandLineArgs::Supplier::Exception::operator =(Exception const &)
115 : 0 : { return *this; }
116 : :
117 [ - + ]: 158 : CommandLineArgs::Supplier::~Supplier() {}
118 : :
119 : : // intialize class with command line parameters from process environment
120 [ + - ][ + - ]: 158 : CommandLineArgs::CommandLineArgs()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
121 : : {
122 : 158 : InitParamValues();
123 [ + - ]: 158 : ExtCommandLineSupplier s;
124 [ + - ][ + - ]: 158 : ParseCommandLine_Impl( s );
125 : 158 : }
126 : :
127 [ # # ][ # # ]: 0 : CommandLineArgs::CommandLineArgs( Supplier& supplier )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
128 : : {
129 : 0 : InitParamValues();
130 [ # # ]: 0 : ParseCommandLine_Impl( supplier );
131 : 0 : }
132 : :
133 : : // ----------------------------------------------------------------------------
134 : :
135 : 158 : void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
136 : : {
137 [ + - ]: 158 : m_cwdUrl = supplier.getCwdUrl();
138 : :
139 : : // parse command line arguments
140 : 158 : bool bOpenEvent(true);
141 : 158 : bool bPrintEvent(false);
142 : 158 : bool bViewEvent(false);
143 : 158 : bool bStartEvent(false);
144 : 158 : bool bPrintToEvent(false);
145 : 158 : bool bPrinterName(false);
146 : 158 : bool bForceOpenEvent(false);
147 : 158 : bool bForceNewEvent(false);
148 : 158 : bool bDisplaySpec(false);
149 : 158 : bool bOpenDoc(false);
150 : 158 : bool bConversionEvent(false);
151 : 158 : bool bConversionParamsEvent(false);
152 : 158 : bool bBatchPrintEvent(false);
153 : 158 : bool bBatchPrinterNameEvent(false);
154 : 158 : bool bConversionOutEvent(false);
155 : :
156 : 948 : for (;;)
157 : : {
158 : 1106 : ::rtl::OUString aArg;
159 [ + + ][ + - ]: 1106 : if ( !supplier.next( &aArg ) )
160 : : {
161 : : break;
162 : : }
163 : :
164 [ + - ]: 948 : if ( !aArg.isEmpty() )
165 : : {
166 : 948 : m_bEmpty = false;
167 : 948 : ::rtl::OUString oArg;
168 [ - + ][ + - ]: 948 : if ( !InterpretCommandLineParameter( aArg, oArg ))
169 : : {
170 [ # # ]: 0 : if ( aArg.toChar() == '-' )
171 : : {
172 : : // handle this argument as an option
173 [ # # ]: 0 : if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("-n")))
174 : : {
175 : : // force new documents based on the following documents
176 : 0 : bForceNewEvent = true;
177 : 0 : bOpenEvent = false;
178 : 0 : bForceOpenEvent = false;
179 : 0 : bPrintToEvent = false;
180 : 0 : bPrintEvent = false;
181 : 0 : bViewEvent = false;
182 : 0 : bStartEvent = false;
183 : 0 : bDisplaySpec = false;
184 : : }
185 [ # # ]: 0 : else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM( "-o" )))
186 : : {
187 : : // force open documents regardless if they are templates or not
188 : 0 : bForceOpenEvent = true;
189 : 0 : bOpenEvent = false;
190 : 0 : bForceNewEvent = false;
191 : 0 : bPrintToEvent = false;
192 : 0 : bPrintEvent = false;
193 : 0 : bViewEvent = false;
194 : 0 : bStartEvent = false;
195 : 0 : bDisplaySpec = false;
196 : : }
197 [ # # ]: 0 : else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM( "-pt" )))
198 : : {
199 : : // Print to special printer
200 : 0 : bPrintToEvent = true;
201 : 0 : bPrinterName = true;
202 : 0 : bPrintEvent = false;
203 : 0 : bOpenEvent = false;
204 : 0 : bForceNewEvent = false;
205 : 0 : bViewEvent = false;
206 : 0 : bStartEvent = false;
207 : 0 : bDisplaySpec = false;
208 : 0 : bForceOpenEvent = false;
209 : : }
210 [ # # ]: 0 : else if ( aArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM( "-p" )))
211 : : {
212 : : // Print to default printer
213 : 0 : bPrintEvent = true;
214 : 0 : bPrintToEvent = false;
215 : 0 : bOpenEvent = false;
216 : 0 : bForceNewEvent = false;
217 : 0 : bForceOpenEvent = false;
218 : 0 : bViewEvent = false;
219 : 0 : bStartEvent = false;
220 : 0 : bDisplaySpec = false;
221 : : }
222 [ # # ]: 0 : else if ( oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM( "view" )))
223 : : {
224 : : // open in viewmode
225 : 0 : bOpenEvent = false;
226 : 0 : bPrintEvent = false;
227 : 0 : bPrintToEvent = false;
228 : 0 : bForceNewEvent = false;
229 : 0 : bForceOpenEvent = false;
230 : 0 : bViewEvent = true;
231 : 0 : bStartEvent = false;
232 : 0 : bDisplaySpec = false;
233 : : }
234 [ # # ]: 0 : else if ( oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM( "show" )))
235 : : {
236 : : // open in viewmode
237 : 0 : bOpenEvent = false;
238 : 0 : bViewEvent = false;
239 : 0 : bStartEvent = true;
240 : 0 : bPrintEvent = false;
241 : 0 : bPrintToEvent = false;
242 : 0 : bForceNewEvent = false;
243 : 0 : bForceOpenEvent = false;
244 : 0 : bDisplaySpec = false;
245 : : }
246 [ # # ]: 0 : else if ( oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("display")))
247 : : {
248 : : // set display
249 : 0 : bOpenEvent = false;
250 : 0 : bPrintEvent = false;
251 : 0 : bForceOpenEvent = false;
252 : 0 : bPrintToEvent = false;
253 : 0 : bForceNewEvent = false;
254 : 0 : bViewEvent = false;
255 : 0 : bStartEvent = false;
256 : 0 : bDisplaySpec = true;
257 : : }
258 [ # # ]: 0 : else if ( oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("language")))
259 : : {
260 : 0 : bOpenEvent = false;
261 : 0 : bPrintEvent = false;
262 : 0 : bForceOpenEvent = false;
263 : 0 : bPrintToEvent = false;
264 : 0 : bForceNewEvent = false;
265 : 0 : bViewEvent = false;
266 : 0 : bStartEvent = false;
267 : 0 : bDisplaySpec = false;
268 : : }
269 [ # # ]: 0 : else if ( oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("convert-to")))
270 : : {
271 : 0 : bOpenEvent = false;
272 : 0 : bConversionEvent = true;
273 : 0 : bConversionParamsEvent = true;
274 : : }
275 [ # # ]: 0 : else if ( oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("print-to-file")))
276 : : {
277 : 0 : bOpenEvent = false;
278 : 0 : bBatchPrintEvent = true;
279 : : }
280 [ # # ][ # # ]: 0 : else if ( oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("printer-name")) &&
[ # # ]
281 : : bBatchPrintEvent )
282 : : {
283 : 0 : bBatchPrinterNameEvent = true;
284 : : }
285 [ # # ][ # # ]: 0 : else if ( oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("outdir")) &&
[ # # ][ # # ]
286 : : (bConversionEvent || bBatchPrintEvent) )
287 : : {
288 : 0 : bConversionOutEvent = true;
289 : : }
290 : : #if defined UNX
291 : : else
292 : : // because it's impossible to filter these options that
293 : : // are handled in the soffice shell script with the
294 : : // primitive tools that /bin/sh offers, ignore them here
295 [ # # # # : 0 : if (!oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("backtrace")) &&
# # # # #
# ][ # # ]
296 : 0 : !oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("strace")) &&
297 : 0 : !oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("valgrind")) &&
298 : : // for X Session Management, handled in
299 : : // vcl/unx/generic/app/sm.cxx:
300 : 0 : !oArg.match("session=") &&
301 : : //ignore additional legacy options that don't do anything anymore
302 : 0 : !oArg.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("nocrashreport")))
303 : : {
304 : : fprintf(stderr, "Unknown option %s\n",
305 [ # # ][ # # ]: 0 : rtl::OUStringToOString(aArg, osl_getThreadTextEncoding()).getStr());
[ # # ]
306 [ # # ]: 0 : fprintf(stderr, "Run 'soffice --help' to see a full list of available command line options.\n");
307 : 0 : m_unknown = true;
308 : : }
309 : : #endif
310 : : }
311 : : else
312 : : {
313 [ # # ][ # # ]: 0 : if ( bPrinterName && bPrintToEvent )
314 : : {
315 : : // first argument after "-pt" this must be the printer name
316 : 0 : m_printername = aArg;
317 : 0 : bPrinterName = false;
318 : : }
319 [ # # ][ # # ]: 0 : else if ( bConversionParamsEvent && bConversionEvent )
320 : : {
321 : : // first argument must be the the params
322 : 0 : m_conversionparams = aArg;
323 : 0 : bConversionParamsEvent = false;
324 : : }
325 [ # # ][ # # ]: 0 : else if ( bBatchPrinterNameEvent && bBatchPrintEvent )
326 : : {
327 : : // first argument is the printer name
328 : 0 : m_printername = aArg;
329 : 0 : bBatchPrinterNameEvent = false;
330 : : }
331 [ # # ][ # # ]: 0 : else if ( (bConversionEvent || bBatchPrintEvent) && bConversionOutEvent )
[ # # ]
332 : : {
333 : 0 : m_conversionout = aArg;
334 : 0 : bConversionOutEvent = false;
335 : : }
336 : : else
337 : : {
338 [ # # ][ # # ]: 0 : if( bOpenEvent || bViewEvent || bForceNewEvent || bForceOpenEvent )
[ # # ][ # # ]
339 : : {
340 [ # # ]: 0 : if( aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("::ODMA")) )
341 : : {
342 : 0 : ::rtl::OUString sArg("vnd.sun.star.odma:/");
343 : 0 : sArg += aArg;
344 : 0 : aArg = sArg;
345 : : }
346 : : }
347 : : // handle this argument as a filename
348 [ # # ]: 0 : if ( bOpenEvent )
349 : : {
350 [ # # ]: 0 : m_openlist.push_back(aArg);
351 : 0 : bOpenDoc = true;
352 : : }
353 [ # # ]: 0 : else if ( bViewEvent )
354 : : {
355 [ # # ]: 0 : m_viewlist.push_back(aArg);
356 : 0 : bOpenDoc = true;
357 : : }
358 [ # # ]: 0 : else if ( bStartEvent )
359 : : {
360 [ # # ]: 0 : m_startlist.push_back(aArg);
361 : 0 : bOpenDoc = true;
362 : : }
363 [ # # ]: 0 : else if ( bPrintEvent )
364 : : {
365 [ # # ]: 0 : m_printlist.push_back(aArg);
366 : 0 : bOpenDoc = true;
367 : : }
368 [ # # ]: 0 : else if ( bPrintToEvent )
369 : : {
370 [ # # ]: 0 : m_printtolist.push_back(aArg);
371 : 0 : bOpenDoc = true;
372 : : }
373 [ # # ]: 0 : else if ( bForceNewEvent )
374 : : {
375 [ # # ]: 0 : m_forcenewlist.push_back(aArg);
376 : 0 : bOpenDoc = true;
377 : : }
378 [ # # ]: 0 : else if ( bForceOpenEvent )
379 : : {
380 [ # # ]: 0 : m_forceopenlist.push_back(aArg);
381 : 0 : bOpenDoc = true;
382 : : }
383 [ # # ]: 0 : else if ( bDisplaySpec )
384 : : {
385 : 0 : bDisplaySpec = false; // only one display, not a lsit
386 : 0 : bOpenEvent = true; // set back to standard
387 : : }
388 [ # # ][ # # ]: 0 : else if ( bConversionEvent || bBatchPrintEvent )
389 [ # # ]: 0 : m_conversionlist.push_back(aArg);
390 : : }
391 : : }
392 : 948 : }
393 : : }
394 [ + + ]: 1106 : }
395 : :
396 [ - + ]: 158 : if ( bOpenDoc )
397 : 0 : m_bDocumentArgs = true;
398 : 158 : }
399 : :
400 : 948 : bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& aArg, ::rtl::OUString& oArg )
401 : : {
402 : 948 : bool bDeprecated = false;
403 [ + - ]: 948 : if (aArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("--")))
404 : : {
405 : 948 : oArg = ::rtl::OUString(aArg.getStr()+2, aArg.getLength()-2);
406 : : }
407 [ # # ]: 0 : else if (aArg.toChar() == '-')
408 : : {
409 [ # # ]: 0 : if ( aArg.getLength() > 2 ) // -h, -o, -n, -? are still valid
410 : 0 : bDeprecated = true;
411 : 0 : oArg = ::rtl::OUString(aArg.getStr()+1, aArg.getLength()-1);
412 : : }
413 : : else
414 : : {
415 : 0 : return false;
416 : : }
417 : :
418 [ - + ]: 948 : if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "minimized" )) )
419 : : {
420 : 0 : m_minimized = true;
421 : : }
422 [ - + ]: 948 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "invisible" )) )
423 : : {
424 : 0 : m_invisible = true;
425 : : }
426 [ + + ]: 948 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "norestore" )) )
427 : : {
428 : 158 : m_norestore = true;
429 : : }
430 [ - + ]: 790 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nodefault" )) )
431 : : {
432 : 0 : m_nodefault = true;
433 : : }
434 [ + + ]: 790 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "headless" )) )
435 : : {
436 : : // Headless means also invisibile, so set this parameter to true!
437 : 158 : m_headless = true;
438 : 158 : m_invisible = true;
439 : : }
440 [ - + ]: 632 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "quickstart" )) )
441 : : {
442 : : #if defined(ENABLE_QUICKSTART_APPLET)
443 : 0 : m_quickstart = true;
444 : : #endif
445 : 0 : m_noquickstart = false;
446 : : }
447 [ + + ]: 632 : else if ( oArg == "quickstart=no" )
448 : : {
449 : 158 : m_noquickstart = true;
450 : 158 : m_quickstart = false;
451 : : }
452 [ - + ]: 474 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "terminate_after_init" )) )
453 : : {
454 : 0 : m_terminateafterinit = true;
455 : : }
456 [ + + ]: 474 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nofirststartwizard" )) )
457 : : {
458 : 158 : m_nofirststartwizard = true;
459 : : }
460 [ + + ]: 316 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nologo" )) )
461 : : {
462 : 158 : m_nologo = true;
463 : : }
464 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "nolockcheck" )) )
465 : : {
466 : 0 : m_nolockcheck = true;
467 : : // Workaround for automated testing
468 : 0 : ::svt::DocumentLockFile::AllowInteraction( false );
469 : : }
470 [ + - + - : 474 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "help" ))
- + ][ - + ]
471 : 158 : || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-h" ))
472 : 158 : || aArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "-?" )))
473 : : {
474 : 0 : m_help = true;
475 : : }
476 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpwriter" )) )
477 : : {
478 : 0 : m_helpwriter = true;
479 : : }
480 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpcalc" )) )
481 : : {
482 : 0 : m_helpcalc = true;
483 : : }
484 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpdraw" )) )
485 : : {
486 : 0 : m_helpdraw = true;
487 : : }
488 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpimpress" )) )
489 : : {
490 : 0 : m_helpimpress = true;
491 : : }
492 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpbase" )) )
493 : : {
494 : 0 : m_helpbase = true;
495 : : }
496 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpbasic" )) )
497 : : {
498 : 0 : m_helpbasic = true;
499 : : }
500 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "helpmath" )) )
501 : : {
502 : 0 : m_helpmath = true;
503 : : }
504 [ - + ]: 158 : else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "version" )) )
505 : : {
506 : 0 : m_version = true;
507 : : }
508 [ - + ]: 158 : else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("splash-pipe=")) )
509 : : {
510 : 0 : m_splashpipe = true;
511 : : }
512 : : #ifdef MACOSX
513 : : /* #i84053# ignore -psn on Mac
514 : : Platform dependent #ifdef here is ugly, however this is currently
515 : : the only platform dependent parameter. Should more appear
516 : : we should find a better solution
517 : : */
518 : : else if ( aArg.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("-psn")) )
519 : : {
520 : : m_psn = true;
521 : : return true;
522 : : }
523 : : #endif
524 [ - + ]: 158 : else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("infilter=")))
525 : : {
526 [ # # ]: 0 : m_infilter.push_back(oArg.copy(RTL_CONSTASCII_LENGTH("infilter=")));
527 : : }
528 [ + - ]: 158 : else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("accept=")))
529 : : {
530 [ + - ]: 158 : m_accept.push_back(oArg.copy(RTL_CONSTASCII_LENGTH("accept=")));
531 : : }
532 [ # # ]: 0 : else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("unaccept=")))
533 : : {
534 [ # # ]: 0 : m_unaccept.push_back(oArg.copy(RTL_CONSTASCII_LENGTH("unaccept=")));
535 : : }
536 [ # # ]: 0 : else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("language=")))
537 : : {
538 : 0 : m_language = oArg.copy(RTL_CONSTASCII_LENGTH("language="));
539 : : }
540 [ # # ]: 0 : else if ( oArg == "writer" )
541 : : {
542 : 0 : m_writer = true;
543 : 0 : m_bDocumentArgs = true;
544 : : }
545 [ # # ]: 0 : else if ( oArg == "calc" )
546 : : {
547 : 0 : m_calc = true;
548 : 0 : m_bDocumentArgs = true;
549 : : }
550 [ # # ]: 0 : else if ( oArg == "draw" )
551 : : {
552 : 0 : m_draw = true;
553 : 0 : m_bDocumentArgs = true;
554 : : }
555 [ # # ]: 0 : else if ( oArg == "impress" )
556 : : {
557 : 0 : m_impress = true;
558 : 0 : m_bDocumentArgs = true;
559 : : }
560 [ # # ]: 0 : else if ( oArg == "base" )
561 : : {
562 : 0 : m_base = true;
563 : 0 : m_bDocumentArgs = true;
564 : : }
565 [ # # ]: 0 : else if ( oArg == "global" )
566 : : {
567 : 0 : m_global = true;
568 : 0 : m_bDocumentArgs = true;
569 : : }
570 [ # # ]: 0 : else if ( oArg == "math" )
571 : : {
572 : 0 : m_math = true;
573 : 0 : m_bDocumentArgs = true;
574 : : }
575 [ # # ]: 0 : else if ( oArg == "web" )
576 : : {
577 : 0 : m_web = true;
578 : 0 : m_bDocumentArgs = true;
579 : : }
580 : : else
581 : 0 : return false;
582 : :
583 [ - + ]: 948 : if (bDeprecated)
584 : : {
585 [ # # ][ # # ]: 0 : rtl::OString sArg(rtl::OUStringToOString(aArg, osl_getThreadTextEncoding()));
586 [ # # ]: 0 : fprintf(stderr, "Warning: %s is deprecated. Use -%s instead.\n", sArg.getStr(), sArg.getStr());
587 : : }
588 : 948 : return true;
589 : : }
590 : :
591 : 158 : void CommandLineArgs::InitParamValues()
592 : : {
593 : 158 : m_minimized = false;
594 : 158 : m_invisible = false;
595 : 158 : m_norestore = false;
596 : : #ifdef LIBO_HEADLESS
597 : : m_headless = true;
598 : : #else
599 : 158 : m_headless = false;
600 : : #endif
601 : 158 : m_quickstart = false;
602 : 158 : m_noquickstart = false;
603 : 158 : m_terminateafterinit = false;
604 : 158 : m_nofirststartwizard = false;
605 : 158 : m_nologo = false;
606 : 158 : m_nolockcheck = false;
607 : 158 : m_nodefault = false;
608 : 158 : m_help = false;
609 : 158 : m_writer = false;
610 : 158 : m_calc = false;
611 : 158 : m_draw = false;
612 : 158 : m_impress = false;
613 : 158 : m_global = false;
614 : 158 : m_math = false;
615 : 158 : m_web = false;
616 : 158 : m_base = false;
617 : 158 : m_helpwriter = false;
618 : 158 : m_helpcalc = false;
619 : 158 : m_helpdraw = false;
620 : 158 : m_helpbasic = false;
621 : 158 : m_helpmath = false;
622 : 158 : m_helpimpress = false;
623 : 158 : m_helpbase = false;
624 : 158 : m_psn = false;
625 : 158 : m_version = false;
626 : 158 : m_unknown = false;
627 : 158 : m_splashpipe = false;
628 : 158 : m_bEmpty = true;
629 : 158 : m_bDocumentArgs = false;
630 : 158 : }
631 : :
632 : 0 : bool CommandLineArgs::IsMinimized() const
633 : : {
634 : 0 : return m_minimized;
635 : : }
636 : :
637 : 700 : bool CommandLineArgs::IsInvisible() const
638 : : {
639 : 700 : return m_invisible;
640 : : }
641 : :
642 : 96 : bool CommandLineArgs::IsNoRestore() const
643 : : {
644 : 96 : return m_norestore;
645 : : }
646 : :
647 : 0 : bool CommandLineArgs::IsNoDefault() const
648 : : {
649 : 0 : return m_nodefault;
650 : : }
651 : :
652 : 632 : bool CommandLineArgs::IsHeadless() const
653 : : {
654 : 632 : return m_headless;
655 : : }
656 : :
657 : 192 : bool CommandLineArgs::IsQuickstart() const
658 : : {
659 : 192 : return m_quickstart;
660 : : }
661 : :
662 : 0 : bool CommandLineArgs::IsNoQuickstart() const
663 : : {
664 : 0 : return m_noquickstart;
665 : : }
666 : :
667 : 158 : bool CommandLineArgs::IsTerminateAfterInit() const
668 : : {
669 : 158 : return m_terminateafterinit;
670 : : }
671 : :
672 : 0 : bool CommandLineArgs::IsNoLogo() const
673 : : {
674 : 0 : return m_nologo;
675 : : }
676 : :
677 : 0 : bool CommandLineArgs::IsNoLockcheck() const
678 : : {
679 : 0 : return m_nolockcheck;
680 : : }
681 : :
682 : 316 : bool CommandLineArgs::IsHelp() const
683 : : {
684 : 316 : return m_help;
685 : : }
686 : 96 : bool CommandLineArgs::IsHelpWriter() const
687 : : {
688 : 96 : return m_helpwriter;
689 : : }
690 : :
691 : 96 : bool CommandLineArgs::IsHelpCalc() const
692 : : {
693 : 96 : return m_helpcalc;
694 : : }
695 : :
696 : 96 : bool CommandLineArgs::IsHelpDraw() const
697 : : {
698 : 96 : return m_helpdraw;
699 : : }
700 : :
701 : 96 : bool CommandLineArgs::IsHelpImpress() const
702 : : {
703 : 96 : return m_helpimpress;
704 : : }
705 : :
706 : 96 : bool CommandLineArgs::IsHelpBase() const
707 : : {
708 : 96 : return m_helpbase;
709 : : }
710 : 96 : bool CommandLineArgs::IsHelpMath() const
711 : : {
712 : 96 : return m_helpmath;
713 : : }
714 : 96 : bool CommandLineArgs::IsHelpBasic() const
715 : : {
716 : 96 : return m_helpbasic;
717 : : }
718 : :
719 : 0 : bool CommandLineArgs::IsWriter() const
720 : : {
721 : 0 : return m_writer;
722 : : }
723 : :
724 : 0 : bool CommandLineArgs::IsCalc() const
725 : : {
726 : 0 : return m_calc;
727 : : }
728 : :
729 : 0 : bool CommandLineArgs::IsDraw() const
730 : : {
731 : 0 : return m_draw;
732 : : }
733 : :
734 : 0 : bool CommandLineArgs::IsImpress() const
735 : : {
736 : 0 : return m_impress;
737 : : }
738 : :
739 : 0 : bool CommandLineArgs::IsBase() const
740 : : {
741 : 0 : return m_base;
742 : : }
743 : :
744 : 0 : bool CommandLineArgs::IsGlobal() const
745 : : {
746 : 0 : return m_global;
747 : : }
748 : :
749 : 0 : bool CommandLineArgs::IsMath() const
750 : : {
751 : 0 : return m_math;
752 : : }
753 : :
754 : 0 : bool CommandLineArgs::IsWeb() const
755 : : {
756 : 0 : return m_web;
757 : : }
758 : :
759 : 158 : bool CommandLineArgs::IsVersion() const
760 : : {
761 : 158 : return m_version;
762 : : }
763 : :
764 : 158 : bool CommandLineArgs::HasUnknown() const
765 : : {
766 : 158 : return m_unknown;
767 : : }
768 : :
769 : 0 : bool CommandLineArgs::HasModuleParam() const
770 : : {
771 : : return m_writer || m_calc || m_draw || m_impress || m_global || m_math
772 [ # # ][ # # ]: 0 : || m_web || m_base;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
773 : : }
774 : :
775 : 0 : bool CommandLineArgs::HasSplashPipe() const
776 : : {
777 : 0 : return m_splashpipe;
778 : : }
779 : :
780 : 158 : std::vector< rtl::OUString > const & CommandLineArgs::GetAccept() const
781 : : {
782 : 158 : return m_accept;
783 : : }
784 : :
785 : 0 : std::vector< rtl::OUString > const & CommandLineArgs::GetUnaccept() const
786 : : {
787 : 0 : return m_unaccept;
788 : : }
789 : :
790 : 96 : std::vector< rtl::OUString > CommandLineArgs::GetOpenList() const
791 : : {
792 : 96 : return translateExternalUris(m_openlist);
793 : : }
794 : :
795 : 96 : std::vector< rtl::OUString > CommandLineArgs::GetViewList() const
796 : : {
797 : 96 : return translateExternalUris(m_viewlist);
798 : : }
799 : :
800 : 96 : std::vector< rtl::OUString > CommandLineArgs::GetStartList() const
801 : : {
802 : 96 : return translateExternalUris(m_startlist);
803 : : }
804 : :
805 : 96 : std::vector< rtl::OUString > CommandLineArgs::GetForceOpenList() const
806 : : {
807 : 96 : return translateExternalUris(m_forceopenlist);
808 : : }
809 : :
810 : 96 : std::vector< rtl::OUString > CommandLineArgs::GetForceNewList() const
811 : : {
812 : 96 : return translateExternalUris(m_forcenewlist);
813 : : }
814 : :
815 : 96 : std::vector< rtl::OUString > CommandLineArgs::GetPrintList() const
816 : : {
817 : 96 : return translateExternalUris(m_printlist);
818 : : }
819 : :
820 : 96 : std::vector< rtl::OUString > CommandLineArgs::GetPrintToList() const
821 : : {
822 : 96 : return translateExternalUris(m_printtolist);
823 : : }
824 : :
825 : 96 : rtl::OUString CommandLineArgs::GetPrinterName() const
826 : : {
827 : 96 : return m_printername;
828 : : }
829 : :
830 : 158 : rtl::OUString CommandLineArgs::GetLanguage() const
831 : : {
832 : 158 : return m_language;
833 : : }
834 : :
835 : 96 : std::vector< rtl::OUString > const & CommandLineArgs::GetInFilter() const
836 : : {
837 : 96 : return m_infilter;
838 : : }
839 : :
840 : 96 : std::vector< rtl::OUString > CommandLineArgs::GetConversionList() const
841 : : {
842 : 96 : return translateExternalUris(m_conversionlist);
843 : : }
844 : :
845 : 96 : rtl::OUString CommandLineArgs::GetConversionParams() const
846 : : {
847 : 96 : return m_conversionparams;
848 : : }
849 : 96 : rtl::OUString CommandLineArgs::GetConversionOut() const
850 : : {
851 : 96 : return translateExternalUris(m_conversionout);
852 : : }
853 : :
854 : 0 : bool CommandLineArgs::IsEmpty() const
855 : : {
856 : 0 : return m_bEmpty;
857 : : }
858 : :
859 : 96 : bool CommandLineArgs::WantsToLoadDocument() const
860 : : {
861 : 96 : return m_bDocumentArgs;
862 : : }
863 : :
864 : : } // namespace desktop
865 : :
866 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|