bump product version to 4.1.6.2
[LibreOffice.git] / desktop / source / app / cmdlinehelp.cxx
bloba9ed3df8b048c93df45d69659df662d1db39b27b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <stdlib.h>
22 #ifdef UNX
23 #include <stdio.h>
24 #endif
25 #include <comphelper/string.hxx>
26 #include <sal/types.h>
27 #include <tools/string.hxx>
28 #include <vcl/msgbox.hxx>
29 #include <rtl/bootstrap.hxx>
30 #include <app.hxx>
32 #include "desktopresid.hxx"
33 #include "desktop.hrc"
34 #include "cmdlinehelp.hxx"
36 namespace desktop
38 // to be able to display the help nicely in a dialog box with propotional font,
39 // we need to split it in chunks...
40 // ___HEAD___
41 // LEFT RIGHT
42 // LEFT RIGHT
43 // LEFT RIGHT
44 // __BOTTOM__
45 // [OK]
47 const char aCmdLineHelp_version[] =
48 "%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"\
49 "\n";
50 const char aCmdLineHelp_head[] =
51 "Usage: %CMDNAME [options] [documents...]\n"\
52 "\n"\
53 "Options:\n";
54 const char aCmdLineHelp_left[] =
55 "--minimized \n"\
56 "--invisible \n"\
57 "--norestore \n"\
58 "--quickstart \n"\
59 "--nologo \n"\
60 "--nolockcheck \n"\
61 "--nodefault \n"\
62 "--headless \n"\
63 "--help/-h/-? \n"\
64 "--version \n"\
65 "--writer \n"\
66 "--calc \n"\
67 "--draw \n"\
68 "--impress \n"\
69 "--base \n"\
70 "--math \n"\
71 "--global \n"\
72 "--web \n"\
73 "-o \n"\
74 "-n \n";
75 const char aCmdLineHelp_right[] =
76 "keep startup bitmap minimized.\n"\
77 "no startup screen, no default document and no UI.\n"\
78 "suppress restart/restore after fatal errors.\n"\
79 "starts the quickstart service\n"\
80 "don't show startup screen.\n"\
81 "don't check for remote instances using the installation\n"\
82 "don't start with an empty document\n"\
83 "like invisible but no userinteraction at all.\n"\
84 "show this message and exit.\n"\
85 "display the version information.\n"\
86 "create new text document.\n"\
87 "create new spreadsheet document.\n"\
88 "create new drawing.\n"\
89 "create new presentation.\n"\
90 "create new database.\n"\
91 "create new formula.\n"\
92 "create new global document.\n"\
93 "create new HTML document.\n"\
94 "open documents regardless whether they are templates or not.\n"\
95 "always open documents as new files (use as template).\n";
96 const char aCmdLineHelp_bottom[] =
97 "--display <display>\n"\
98 " Specify X-Display to use in Unix/X11 versions.\n"
99 "-p <documents...>\n"\
100 " print the specified documents on the default printer.\n"\
101 "--pt <printer> <documents...>\n"\
102 " print the specified documents on the specified printer.\n"\
103 "--view <documents...>\n"\
104 " open the specified documents in viewer-(readonly-)mode.\n"\
105 "--show <presentation>\n"\
106 " open the specified presentation and start it immediately\n"\
107 "--accept=<accept-string>\n"\
108 " Specify an UNO connect-string to create an UNO acceptor through which\n"\
109 " other programs can connect to access the API\n"\
110 "--unaccept=<accept-string>\n"\
111 " Close an acceptor that was created with --accept=<accept-string>\n"\
112 " Use --unnaccept=all to close all open acceptors\n"\
113 "--infilter=<filter>\n"\
114 " Force an input filter type if possible\n"\
115 " Eg. --infilter=\"Calc Office Open XML\"\n"\
116 "--convert-to output_file_extension[:output_filter_name] [--outdir output_dir] files\n"\
117 " Batch convert files.\n"\
118 " If --outdir is not specified then current working dir is used as output_dir.\n"\
119 " Eg. --convert-to pdf *.doc\n"\
120 " --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc\n"\
121 "--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"\
122 " Batch print files to file.\n"\
123 " If --outdir is not specified then current working dir is used as output_dir.\n"\
124 " Eg. --print-to-file *.doc\n"\
125 " --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\n"\
126 "--pidfile file\n"\
127 " Store soffice.bin pid to file.\n"\
128 "\nRemaining arguments will be treated as filenames or URLs of documents to open.\n\n";
130 OUString ReplaceStringHookProc(const OUString& rStr);
132 void displayCmdlineHelp(OUString const & unknown)
134 // if you put variables in other chunks don't forget to call the replace routines
135 // for those chunks...
136 String aHelpMessage_version(aCmdLineHelp_version, RTL_TEXTENCODING_ASCII_US);
137 String aHelpMessage_head(aCmdLineHelp_head, RTL_TEXTENCODING_ASCII_US);
138 String aHelpMessage_left(aCmdLineHelp_left, RTL_TEXTENCODING_ASCII_US);
139 String aHelpMessage_right(aCmdLineHelp_right, RTL_TEXTENCODING_ASCII_US);
140 String aHelpMessage_bottom(aCmdLineHelp_bottom, RTL_TEXTENCODING_ASCII_US);
141 aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version);
142 aHelpMessage_head.SearchAndReplaceAscii( "%CMDNAME", String( "soffice", RTL_TEXTENCODING_ASCII_US) );
143 if (!unknown.isEmpty())
145 aHelpMessage_head = "Unknown option: " + unknown + "\n\n"
146 + aHelpMessage_head;
148 #ifdef UNX
149 // on unix use console for output
150 fprintf(stdout, "%s%s",
151 OUStringToOString(aHelpMessage_version, RTL_TEXTENCODING_ASCII_US).getStr(),
152 OUStringToOString(aHelpMessage_head, RTL_TEXTENCODING_ASCII_US).getStr());
153 // merge left and right column
154 sal_Int32 n = comphelper::string::getTokenCount(aHelpMessage_left, '\n');
155 OString bsLeft(OUStringToOString(aHelpMessage_left,
156 RTL_TEXTENCODING_ASCII_US));
157 OString bsRight(OUStringToOString(aHelpMessage_right,
158 RTL_TEXTENCODING_ASCII_US));
159 for ( sal_Int32 i = 0; i < n; ++i )
161 using comphelper::string::getToken;
162 fprintf(stdout, "%s", getToken(bsLeft, i, '\n').getStr());
163 fprintf(stdout, "%s\n", getToken(bsRight, i, '\n').getStr());
165 fprintf(stdout, "%s", OUStringToOString(aHelpMessage_bottom,
166 RTL_TEXTENCODING_ASCII_US).getStr());
167 #else
168 // rest gets a dialog box
169 CmdlineHelpDialog aDlg;
170 String head = aHelpMessage_version;
171 head.Append(aHelpMessage_head);
172 aDlg.m_pftHead->SetText(head);
173 aDlg.m_pftLeft->SetText(aHelpMessage_left);
174 aDlg.m_pftRight->SetText(aHelpMessage_right);
175 aDlg.m_pftBottom->SetText(aHelpMessage_bottom);
176 aDlg.Execute();
177 #endif
180 void displayVersion()
182 OUString aVersionMsg(aCmdLineHelp_version);
183 aVersionMsg = ReplaceStringHookProc(aVersionMsg);
184 #ifdef UNX
185 fprintf(stdout, "%s", OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
186 #else
187 // Just re-use the help dialog for now.
188 CmdlineHelpDialog aDlg;
189 aDlg.m_pftHead->SetText(aVersionMsg);
190 aDlg.m_pftLeft->SetText("");
191 aDlg.m_pftRight->SetText("");
192 aDlg.m_pftBottom->SetText("");
193 aDlg.Execute();
194 #endif
197 #ifndef UNX
198 CmdlineHelpDialog::CmdlineHelpDialog (void)
199 : ModalDialog( NULL, "CmdLineHelp", "desktop/ui/cmdlinehelp.ui" )
201 get(m_pftHead, "header");
202 get(m_pftLeft, "left");
203 get(m_pftRight, "right");
204 get(m_pftBottom, "bottom");
206 #endif
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */