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