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 <tools/string.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <rtl/bootstrap.hxx>
|
|
|
|
#include <app.hxx>
|
|
|
|
|
|
|
|
#include "desktopresid.hxx"
|
|
|
|
#include "desktop.hrc"
|
|
|
|
#include "cmdlinehelp.hxx"
|
|
|
|
|
|
|
|
namespace desktop
|
|
|
|
{
|
|
|
|
// to be able to display the help nicely in a dialog box with propotional font,
|
|
|
|
// 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"\
|
|
|
|
"--invisible \n"\
|
|
|
|
"--norestore \n"\
|
|
|
|
"--quickstart \n"\
|
|
|
|
"--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"\
|
|
|
|
"no startup screen, no default document and no UI.\n"\
|
|
|
|
"suppress restart/restore after fatal errors.\n"\
|
2010-10-11 16:47:39 +01:00
|
|
|
"starts the quickstart service\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"\
|
|
|
|
"like invisible but no userinteraction at all.\n"\
|
|
|
|
"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"\
|
2011-01-03 22:05:41 -05:00
|
|
|
"--infilter=<filter>\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"\
|
|
|
|
"--convert-to output_file_extension[:output_filter_name] [--outdir output_dir] files\n"\
|
2010-08-25 23:37:30 +02:00
|
|
|
" Batch convert files.\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"\
|
|
|
|
"--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"\
|
|
|
|
" --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\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-03-19 20:31:38 +00:00
|
|
|
rtl::OUString ReplaceStringHookProc(const rtl::OUString& rStr);
|
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...
|
2011-01-11 12:22:38 -05:00
|
|
|
String aHelpMessage_version(aCmdLineHelp_version, RTL_TEXTENCODING_ASCII_US);
|
2003-03-25 12:52:54 +00:00
|
|
|
String aHelpMessage_head(aCmdLineHelp_head, RTL_TEXTENCODING_ASCII_US);
|
|
|
|
String aHelpMessage_left(aCmdLineHelp_left, RTL_TEXTENCODING_ASCII_US);
|
|
|
|
String aHelpMessage_right(aCmdLineHelp_right, RTL_TEXTENCODING_ASCII_US);
|
|
|
|
String aHelpMessage_bottom(aCmdLineHelp_bottom, RTL_TEXTENCODING_ASCII_US);
|
2012-03-19 20:31:38 +00:00
|
|
|
aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version);
|
2003-03-25 12:52:54 +00:00
|
|
|
aHelpMessage_head.SearchAndReplaceAscii( "%CMDNAME", String( "soffice", RTL_TEXTENCODING_ASCII_US) );
|
2012-09-25 10:15:15 +02:00
|
|
|
if (!unknown.isEmpty())
|
|
|
|
{
|
|
|
|
aHelpMessage_head = "Unknown option: " + unknown + "\n\n"
|
|
|
|
+ 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",
|
2011-11-26 10:44:02 +00:00
|
|
|
rtl::OUStringToOString(aHelpMessage_version, RTL_TEXTENCODING_ASCII_US).getStr(),
|
|
|
|
rtl::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');
|
2011-11-26 10:44:02 +00:00
|
|
|
rtl::OString bsLeft(rtl::OUStringToOString(aHelpMessage_left,
|
|
|
|
RTL_TEXTENCODING_ASCII_US));
|
2012-01-12 23:45:08 +00:00
|
|
|
rtl::OString bsRight(rtl::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
|
|
|
{
|
2011-11-26 10:44:02 +00:00
|
|
|
using comphelper::string::getToken;
|
|
|
|
fprintf(stdout, "%s", getToken(bsLeft, i, '\n').getStr());
|
|
|
|
fprintf(stdout, "%s\n", getToken(bsRight, i, '\n').getStr());
|
2003-03-25 12:52:54 +00:00
|
|
|
}
|
2011-11-27 20:37:42 +00:00
|
|
|
fprintf(stdout, "%s", rtl::OUStringToOString(aHelpMessage_bottom,
|
|
|
|
RTL_TEXTENCODING_ASCII_US).getStr());
|
2003-03-25 12:52:54 +00:00
|
|
|
#else
|
|
|
|
// rest gets a dialog box
|
|
|
|
CmdlineHelpDialog aDlg;
|
2011-01-11 12:22:38 -05:00
|
|
|
String head = aHelpMessage_version;
|
|
|
|
head.Append(aHelpMessage_head);
|
|
|
|
aDlg.m_ftHead.SetText(head);
|
2003-03-25 12:52:54 +00:00
|
|
|
aDlg.m_ftLeft.SetText(aHelpMessage_left);
|
|
|
|
aDlg.m_ftRight.SetText(aHelpMessage_right);
|
|
|
|
aDlg.m_ftBottom.SetText(aHelpMessage_bottom);
|
|
|
|
aDlg.Execute();
|
|
|
|
#endif
|
|
|
|
}
|
2011-01-11 12:04:28 -05:00
|
|
|
|
|
|
|
void displayVersion()
|
|
|
|
{
|
2012-03-19 20:31:38 +00:00
|
|
|
rtl::OUString aVersionMsg(aCmdLineHelp_version);
|
|
|
|
aVersionMsg = ReplaceStringHookProc(aVersionMsg);
|
2011-01-11 12:33:18 -05:00
|
|
|
#ifdef UNX
|
2011-06-29 22:34:59 +01:00
|
|
|
fprintf(stdout, "%s", rtl::OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
|
2011-01-11 12:33:18 -05:00
|
|
|
#else
|
|
|
|
// Just re-use the help dialog for now.
|
|
|
|
CmdlineHelpDialog aDlg;
|
|
|
|
aDlg.m_ftHead.SetText(aVersionMsg);
|
|
|
|
aDlg.Execute();
|
|
|
|
#endif
|
2011-01-11 12:04:28 -05:00
|
|
|
}
|
|
|
|
|
2008-05-13 12:12:46 +00:00
|
|
|
#ifndef UNX
|
2003-03-25 12:52:54 +00:00
|
|
|
CmdlineHelpDialog::CmdlineHelpDialog (void)
|
|
|
|
: ModalDialog( NULL, DesktopResId( DLG_CMDLINEHELP ) )
|
|
|
|
, m_ftHead( this, DesktopResId( TXT_DLG_CMDLINEHELP_HEADER ) )
|
|
|
|
, m_ftLeft( this, DesktopResId( TXT_DLG_CMDLINEHELP_LEFT ) )
|
|
|
|
, m_ftRight( this, DesktopResId( TXT_DLG_CMDLINEHELP_RIGHT ) )
|
|
|
|
, m_ftBottom( this, DesktopResId( TXT_DLG_CMDLINEHELP_BOTTOM ) )
|
|
|
|
, m_btOk( this, DesktopResId( BTN_DLG_CMDLINEHELP_OK ) )
|
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
}
|
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: */
|