2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-15 17:28:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2003-04-04 16:22:42 +00:00
|
|
|
|
2006-09-17 08:35:24 +00:00
|
|
|
|
2003-03-25 12:52:54 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#ifdef UNX
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
2011-11-26 10:44:02 +00:00
|
|
|
#include <comphelper/string.hxx>
|
2003-03-25 12:52:54 +00:00
|
|
|
#include <sal/types.h>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <rtl/bootstrap.hxx>
|
|
|
|
#include <app.hxx>
|
|
|
|
|
|
|
|
#include "desktopresid.hxx"
|
|
|
|
#include "desktop.hrc"
|
|
|
|
#include "cmdlinehelp.hxx"
|
|
|
|
|
|
|
|
namespace desktop
|
|
|
|
{
|
2016-01-09 22:55:28 +01:00
|
|
|
// to be able to display the help nicely in a dialog box with proportional font,
|
2003-03-25 12:52:54 +00:00
|
|
|
// we need to split it in chunks...
|
|
|
|
// ___HEAD___
|
|
|
|
// LEFT RIGHT
|
|
|
|
// LEFT RIGHT
|
|
|
|
// LEFT RIGHT
|
|
|
|
// __BOTTOM__
|
|
|
|
// [OK]
|
|
|
|
|
2012-03-19 20:31:38 +00:00
|
|
|
const char aCmdLineHelp_version[] =
|
2013-02-14 23:48:31 -05:00
|
|
|
"%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"\
|
2011-01-11 12:22:38 -05:00
|
|
|
"\n";
|
2012-03-19 20:31:38 +00:00
|
|
|
const char aCmdLineHelp_head[] =
|
2003-03-25 12:52:54 +00:00
|
|
|
"Usage: %CMDNAME [options] [documents...]\n"\
|
|
|
|
"\n"\
|
|
|
|
"Options:\n";
|
2012-03-19 20:31:38 +00:00
|
|
|
const char aCmdLineHelp_left[] =
|
2011-01-03 22:05:41 -05:00
|
|
|
"--minimized \n"\
|
2015-03-30 18:55:10 +03:00
|
|
|
"--invisible \n"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--norestore \n"\
|
|
|
|
"--quickstart \n"\
|
2016-10-07 18:19:03 +02:00
|
|
|
"--safe-mode \n"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--nologo \n"\
|
|
|
|
"--nolockcheck \n"\
|
|
|
|
"--nodefault \n"\
|
|
|
|
"--headless \n"\
|
|
|
|
"--help/-h/-? \n"\
|
2011-01-11 12:27:51 -05:00
|
|
|
"--version \n"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--writer \n"\
|
|
|
|
"--calc \n"\
|
|
|
|
"--draw \n"\
|
|
|
|
"--impress \n"\
|
|
|
|
"--base \n"\
|
|
|
|
"--math \n"\
|
|
|
|
"--global \n"\
|
|
|
|
"--web \n"\
|
2012-01-09 16:36:02 +01:00
|
|
|
"-o \n"\
|
|
|
|
"-n \n";
|
2012-03-19 20:31:38 +00:00
|
|
|
const char aCmdLineHelp_right[] =
|
2003-03-25 12:52:54 +00:00
|
|
|
"keep startup bitmap minimized.\n"\
|
2015-03-30 18:55:10 +03:00
|
|
|
"no startup screen, no default document and no UI.\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
"suppress restart/restore after fatal errors.\n"\
|
2010-10-11 16:47:39 +01:00
|
|
|
"starts the quickstart service\n"\
|
2016-10-07 18:19:03 +02:00
|
|
|
"starts the safe mode\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
"don't show startup screen.\n"\
|
|
|
|
"don't check for remote instances using the installation\n"\
|
|
|
|
"don't start with an empty document\n"\
|
2015-03-30 18:55:10 +03:00
|
|
|
"like invisible but no user interaction at all.\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
"show this message and exit.\n"\
|
2011-01-11 12:27:51 -05:00
|
|
|
"display the version information.\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
"create new text document.\n"\
|
|
|
|
"create new spreadsheet document.\n"\
|
|
|
|
"create new drawing.\n"\
|
|
|
|
"create new presentation.\n"\
|
2004-08-02 13:39:38 +00:00
|
|
|
"create new database.\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
"create new formula.\n"\
|
|
|
|
"create new global document.\n"\
|
|
|
|
"create new HTML document.\n"\
|
|
|
|
"open documents regardless whether they are templates or not.\n"\
|
|
|
|
"always open documents as new files (use as template).\n";
|
2012-03-19 20:31:38 +00:00
|
|
|
const char aCmdLineHelp_bottom[] =
|
2011-01-03 22:05:41 -05:00
|
|
|
"--display <display>\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
" Specify X-Display to use in Unix/X11 versions.\n"
|
|
|
|
"-p <documents...>\n"\
|
|
|
|
" print the specified documents on the default printer.\n"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--pt <printer> <documents...>\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
" print the specified documents on the specified printer.\n"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--view <documents...>\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
" open the specified documents in viewer-(readonly-)mode.\n"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--show <presentation>\n"\
|
2003-05-28 12:26:13 +00:00
|
|
|
" open the specified presentation and start it immediately\n"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--accept=<accept-string>\n"\
|
2003-03-25 12:52:54 +00:00
|
|
|
" Specify an UNO connect-string to create an UNO acceptor through which\n"\
|
|
|
|
" other programs can connect to access the API\n"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--unaccept=<accept-string>\n"\
|
2012-01-09 16:36:02 +01:00
|
|
|
" Close an acceptor that was created with --accept=<accept-string>\n"\
|
|
|
|
" Use --unnaccept=all to close all open acceptors\n"\
|
2014-06-03 12:42:47 +02:00
|
|
|
"--infilter=<filter>[:filter_options]\n"\
|
2010-08-25 23:38:54 +02:00
|
|
|
" Force an input filter type if possible\n"\
|
2012-01-09 16:36:02 +01:00
|
|
|
" Eg. --infilter=\"Calc Office Open XML\"\n"\
|
2014-06-03 12:42:47 +02:00
|
|
|
" --infilter=\"Text (encoded):UTF8,LF,,,\"\n"\
|
|
|
|
"--convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files\n"\
|
2015-01-02 12:32:31 +01:00
|
|
|
" Batch convert files (implies --headless).\n"\
|
2012-01-09 16:36:02 +01:00
|
|
|
" If --outdir is not specified then current working dir is used as output_dir.\n"\
|
|
|
|
" Eg. --convert-to pdf *.doc\n"\
|
|
|
|
" --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc\n"\
|
2014-06-03 12:42:47 +02:00
|
|
|
" --convert-to \"html:XHTML Writer File:UTF8\" *.doc\n"\
|
|
|
|
" --convert-to \"txt:Text (encoded):UTF8\" *.doc\n"\
|
2012-01-09 16:36:02 +01:00
|
|
|
"--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"\
|
2010-08-25 23:37:30 +02:00
|
|
|
" Batch print files to file.\n"\
|
2012-01-09 16:36:02 +01:00
|
|
|
" If --outdir is not specified then current working dir is used as output_dir.\n"\
|
|
|
|
" Eg. --print-to-file *.doc\n"\
|
2014-07-30 01:16:34 +05:30
|
|
|
" --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\n" \
|
|
|
|
"--cat files\n"\
|
|
|
|
" Dump text content of the files to console\n"\
|
|
|
|
" Eg. --cat *.odt\n"\
|
2015-11-20 16:19:04 +01:00
|
|
|
"--pidfile=file\n"\
|
2013-03-23 13:32:26 +01:00
|
|
|
" Store soffice.bin pid to file.\n"\
|
2013-12-11 09:58:22 +01:00
|
|
|
"-env:<VAR>[=<VALUE>]\n"\
|
|
|
|
" Set a bootstrap variable.\n"\
|
|
|
|
" Eg. -env:UserInstallation=file:///tmp/test to set a non-default user profile path.\n"\
|
2011-01-11 12:33:18 -05:00
|
|
|
"\nRemaining arguments will be treated as filenames or URLs of documents to open.\n\n";
|
2003-03-25 12:52:54 +00:00
|
|
|
|
2012-09-25 10:15:15 +02:00
|
|
|
void displayCmdlineHelp(OUString const & unknown)
|
2003-03-25 12:52:54 +00:00
|
|
|
{
|
|
|
|
// if you put variables in other chunks don't forget to call the replace routines
|
|
|
|
// for those chunks...
|
2014-12-12 17:51:36 +01:00
|
|
|
OUString aHelpMessage_version(aCmdLineHelp_version);
|
|
|
|
OUString aHelpMessage_head(aCmdLineHelp_head);
|
|
|
|
OUString aHelpMessage_left(aCmdLineHelp_left);
|
|
|
|
OUString aHelpMessage_right(aCmdLineHelp_right);
|
|
|
|
OUString aHelpMessage_bottom(aCmdLineHelp_bottom);
|
2012-03-19 20:31:38 +00:00
|
|
|
aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version);
|
2013-09-16 08:33:10 +02:00
|
|
|
aHelpMessage_head = aHelpMessage_head.replaceFirst( "%CMDNAME", "soffice" );
|
2012-09-25 10:15:15 +02:00
|
|
|
if (!unknown.isEmpty())
|
|
|
|
{
|
2016-07-19 20:03:01 +10:00
|
|
|
aHelpMessage_head = "Error in option: " + unknown + "\n\n"
|
2012-09-25 10:15:15 +02:00
|
|
|
+ aHelpMessage_head;
|
|
|
|
}
|
2003-03-25 12:52:54 +00:00
|
|
|
#ifdef UNX
|
|
|
|
// on unix use console for output
|
2011-01-11 12:22:38 -05:00
|
|
|
fprintf(stdout, "%s%s",
|
2013-04-07 12:06:47 +02:00
|
|
|
OUStringToOString(aHelpMessage_version, RTL_TEXTENCODING_ASCII_US).getStr(),
|
|
|
|
OUStringToOString(aHelpMessage_head, RTL_TEXTENCODING_ASCII_US).getStr());
|
2003-03-25 12:52:54 +00:00
|
|
|
// merge left and right column
|
2012-01-02 10:55:27 +00:00
|
|
|
sal_Int32 n = comphelper::string::getTokenCount(aHelpMessage_left, '\n');
|
2013-04-07 12:06:47 +02:00
|
|
|
OString bsLeft(OUStringToOString(aHelpMessage_left,
|
2011-11-26 10:44:02 +00:00
|
|
|
RTL_TEXTENCODING_ASCII_US));
|
2013-04-07 12:06:47 +02:00
|
|
|
OString bsRight(OUStringToOString(aHelpMessage_right,
|
2011-11-26 10:44:02 +00:00
|
|
|
RTL_TEXTENCODING_ASCII_US));
|
|
|
|
for ( sal_Int32 i = 0; i < n; ++i )
|
2003-03-25 12:52:54 +00:00
|
|
|
{
|
2015-01-02 13:21:32 +01:00
|
|
|
fprintf(stdout, "%s", bsLeft.getToken(i, '\n').getStr());
|
|
|
|
fprintf(stdout, "%s\n", bsRight.getToken(i, '\n').getStr());
|
2003-03-25 12:52:54 +00:00
|
|
|
}
|
2013-04-07 12:06:47 +02:00
|
|
|
fprintf(stdout, "%s", OUStringToOString(aHelpMessage_bottom,
|
2011-11-27 20:37:42 +00:00
|
|
|
RTL_TEXTENCODING_ASCII_US).getStr());
|
2003-03-25 12:52:54 +00:00
|
|
|
#else
|
|
|
|
// rest gets a dialog box
|
2016-10-14 16:57:24 +02:00
|
|
|
ScopedVclPtrInstance<CmdlineHelpDialog> aDlg;
|
|
|
|
aDlg->m_pftHead->SetText(aHelpMessage_version + aHelpMessage_head);
|
|
|
|
aDlg->m_pftLeft->SetText(aHelpMessage_left);
|
|
|
|
aDlg->m_pftRight->SetText(aHelpMessage_right);
|
|
|
|
aDlg->m_pftBottom->SetText(aHelpMessage_bottom);
|
|
|
|
aDlg->Execute();
|
2003-03-25 12:52:54 +00:00
|
|
|
#endif
|
|
|
|
}
|
2011-01-11 12:04:28 -05:00
|
|
|
|
|
|
|
void displayVersion()
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aVersionMsg(aCmdLineHelp_version);
|
2012-03-19 20:31:38 +00:00
|
|
|
aVersionMsg = ReplaceStringHookProc(aVersionMsg);
|
2011-01-11 12:33:18 -05:00
|
|
|
#ifdef UNX
|
2013-04-07 12:06:47 +02:00
|
|
|
fprintf(stdout, "%s", OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
|
2011-01-11 12:33:18 -05:00
|
|
|
#else
|
|
|
|
// Just re-use the help dialog for now.
|
2016-10-14 16:57:24 +02:00
|
|
|
ScopedVclPtrInstance<CmdlineHelpDialog> aDlg;
|
|
|
|
aDlg->m_pftHead->SetText(aVersionMsg);
|
|
|
|
aDlg->m_pftLeft->SetText("");
|
|
|
|
aDlg->m_pftRight->SetText("");
|
|
|
|
aDlg->m_pftBottom->SetText("");
|
|
|
|
aDlg->Execute();
|
2011-01-11 12:33:18 -05:00
|
|
|
#endif
|
2011-01-11 12:04:28 -05:00
|
|
|
}
|
|
|
|
|
2008-05-13 12:12:46 +00:00
|
|
|
#ifndef UNX
|
2015-04-14 12:44:47 +02:00
|
|
|
CmdlineHelpDialog::CmdlineHelpDialog()
|
2016-10-14 16:57:24 +02:00
|
|
|
: ModalDialog( nullptr, "CmdLineHelp", "desktop/ui/cmdlinehelp.ui" )
|
2003-03-25 12:52:54 +00:00
|
|
|
{
|
2013-03-07 21:31:46 +01:00
|
|
|
get(m_pftHead, "header");
|
|
|
|
get(m_pftLeft, "left");
|
|
|
|
get(m_pftRight, "right");
|
|
|
|
get(m_pftBottom, "bottom");
|
2003-03-25 12:52:54 +00:00
|
|
|
}
|
2016-10-14 16:57:24 +02:00
|
|
|
|
|
|
|
CmdlineHelpDialog::~CmdlineHelpDialog()
|
|
|
|
{
|
|
|
|
disposeOnce();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdlineHelpDialog::dispose()
|
|
|
|
{
|
|
|
|
m_pftHead.disposeAndClear();
|
|
|
|
m_pftLeft.disposeAndClear();
|
|
|
|
m_pftRight.disposeAndClear();
|
|
|
|
m_pftBottom.disposeAndClear();
|
|
|
|
ModalDialog::dispose();
|
|
|
|
}
|
2008-05-13 12:12:46 +00:00
|
|
|
#endif
|
2003-03-25 12:52:54 +00:00
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|