xref: /aoo41x/main/desktop/source/app/cmdlinehelp.cxx (revision b8ac9833)
12722ceddSAndrew Rist /**************************************************************
2467d16d0SMatthias Seidel  *
32722ceddSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42722ceddSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52722ceddSAndrew Rist  * distributed with this work for additional information
62722ceddSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72722ceddSAndrew Rist  * to you under the Apache License, Version 2.0 (the
82722ceddSAndrew Rist  * "License"); you may not use this file except in compliance
92722ceddSAndrew Rist  * with the License.  You may obtain a copy of the License at
10467d16d0SMatthias Seidel  *
112722ceddSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12467d16d0SMatthias Seidel  *
132722ceddSAndrew Rist  * Unless required by applicable law or agreed to in writing,
142722ceddSAndrew Rist  * software distributed under the License is distributed on an
152722ceddSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162722ceddSAndrew Rist  * KIND, either express or implied.  See the License for the
172722ceddSAndrew Rist  * specific language governing permissions and limitations
182722ceddSAndrew Rist  * under the License.
19467d16d0SMatthias Seidel  *
202722ceddSAndrew Rist  *************************************************************/
212722ceddSAndrew Rist 
222722ceddSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_desktop.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <stdlib.h>
28cdf0e10cSrcweir #ifdef UNX
29cdf0e10cSrcweir #include <stdio.h>
30cdf0e10cSrcweir #endif
31cdf0e10cSrcweir #include <sal/types.h>
32cdf0e10cSrcweir #include <tools/string.hxx>
33cdf0e10cSrcweir #include <vcl/msgbox.hxx>
34cdf0e10cSrcweir #include <rtl/bootstrap.hxx>
35cdf0e10cSrcweir #include <app.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #include "desktopresid.hxx"
38cdf0e10cSrcweir #include "desktop.hrc"
39cdf0e10cSrcweir #include "cmdlinehelp.hxx"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace desktop
42cdf0e10cSrcweir {
43467d16d0SMatthias Seidel 	// To be able to display the help nicely in a dialog box with proportional font,
44cdf0e10cSrcweir 	// we need to split it in chunks...
45cdf0e10cSrcweir 	//  ___HEAD___
46cdf0e10cSrcweir 	//  LEFT RIGHT
47cdf0e10cSrcweir 	//  LEFT RIGHT
48cdf0e10cSrcweir 	//  LEFT RIGHT
49cdf0e10cSrcweir 	//  __BOTTOM__
50cdf0e10cSrcweir 	//     [OK]
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	const char *aCmdLineHelp_head =
53cdf0e10cSrcweir 		"%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION %BUILDID\n"\
54cdf0e10cSrcweir 		"\n"\
55cdf0e10cSrcweir 		"Usage: %CMDNAME [options] [documents...]\n"\
56cdf0e10cSrcweir 		"\n"\
57cdf0e10cSrcweir 		"Options:\n";
58cdf0e10cSrcweir 	const char *aCmdLineHelp_left =
5985c309d6SJürgen Schmidt 		"-minimized      \n"\
6085c309d6SJürgen Schmidt 		"-invisible      \n"\
6185c309d6SJürgen Schmidt 		"-norestore      \n"\
6285c309d6SJürgen Schmidt 		"-quickstart     \n"\
6385c309d6SJürgen Schmidt 		"-nologo         \n"\
6485c309d6SJürgen Schmidt 		"-nolockcheck    \n"\
6585c309d6SJürgen Schmidt 		"-nodefault      \n"\
6685c309d6SJürgen Schmidt 		"-headless       \n"\
6785c309d6SJürgen Schmidt 		"-conversionmode \n"\
6885c309d6SJürgen Schmidt 		"-help/-h/-?     \n"\
6985c309d6SJürgen Schmidt 		"-writer         \n"\
7085c309d6SJürgen Schmidt 		"-calc           \n"\
7185c309d6SJürgen Schmidt 		"-draw           \n"\
7285c309d6SJürgen Schmidt 		"-impress        \n"\
7385c309d6SJürgen Schmidt 		"-base           \n"\
7485c309d6SJürgen Schmidt 		"-math           \n"\
7585c309d6SJürgen Schmidt 		"-global         \n"\
7685c309d6SJürgen Schmidt 		"-web            \n"\
7785c309d6SJürgen Schmidt 		"-o              \n"\
7885c309d6SJürgen Schmidt 		"-n              \n";
79cdf0e10cSrcweir 	const char *aCmdLineHelp_right =
80*b8ac9833SMatthias Seidel 		"Keep startup screen minimized.\n"\
81*b8ac9833SMatthias Seidel 		"No startup screen, no default document and no UI.\n"\
82*b8ac9833SMatthias Seidel 		"Suppress restart/restore after fatal errors.\n"\
83*b8ac9833SMatthias Seidel 		"Start the quickstart service (only available on Windows and OS/2).\n"\
84*b8ac9833SMatthias Seidel 		"Don't show startup screen.\n"\
85*b8ac9833SMatthias Seidel 		"Don't check for remote instances using the installation.\n"\
86*b8ac9833SMatthias Seidel 		"Don't start with an empty document.\n"\
87*b8ac9833SMatthias Seidel 		"Like invisible but no user interaction at all.\n"\
88*b8ac9833SMatthias Seidel 		"Enable further optimization for document conversion, incl. headless mode.\n"\
89*b8ac9833SMatthias Seidel 		"Show this message.\n"\
90*b8ac9833SMatthias Seidel 		"Create new text document.\n"\
91*b8ac9833SMatthias Seidel 		"Create new spreadsheet document.\n"\
92*b8ac9833SMatthias Seidel 		"Create new drawing.\n"\
93*b8ac9833SMatthias Seidel 		"Create new presentation.\n"\
94*b8ac9833SMatthias Seidel 		"Create new database.\n"\
95*b8ac9833SMatthias Seidel 		"Create new formula.\n"\
96*b8ac9833SMatthias Seidel 		"Create new global document.\n"\
97*b8ac9833SMatthias Seidel 		"Create new HTML document.\n"\
98*b8ac9833SMatthias Seidel 		"Open documents regardless whether they are templates or not.\n"\
99*b8ac9833SMatthias Seidel 		"Always open documents as new files (use as template).\n";
100cdf0e10cSrcweir 	const char *aCmdLineHelp_bottom =
101cdf0e10cSrcweir 		"-display <display>\n"\
102cdf0e10cSrcweir 		"      Specify X-Display to use in Unix/X11 versions.\n"
103cdf0e10cSrcweir 		"-p <documents...>\n"\
104*b8ac9833SMatthias Seidel 		"      Print the specified documents on the default printer.\n"\
105cdf0e10cSrcweir 		"-pt <printer> <documents...>\n"\
106*b8ac9833SMatthias Seidel 		"      Print the specified documents on the specified printer.\n"\
107cdf0e10cSrcweir 		"-view <documents...>\n"\
108*b8ac9833SMatthias Seidel 		"      Open the specified documents in viewer-(readonly-)mode.\n"\
109cdf0e10cSrcweir 		"-show <presentation>\n"\
110*b8ac9833SMatthias Seidel 		"      Open the specified presentation and start it immediately.\n"\
111cdf0e10cSrcweir 		"-accept=<accept-string>\n"\
112467d16d0SMatthias Seidel 		"      Specify an UNO connect-string to create an UNO acceptor through which\n"\
113*b8ac9833SMatthias Seidel 		"      other programs can connect to access the API.\n"\
114cdf0e10cSrcweir 		"-unaccept=<accept-string>\n"\
115cdf0e10cSrcweir 		"      Close an acceptor that was created with -accept=<accept-string>\n"\
116*b8ac9833SMatthias Seidel 		"      Use -unnaccept=all to close all open acceptors.\n"\
117cdf0e10cSrcweir 		"Remaining arguments will be treated as filenames or URLs of documents to open.\n";
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	void ReplaceStringHookProc( UniString& rStr );
120cdf0e10cSrcweir 
displayCmdlineHelp()121cdf0e10cSrcweir 	void displayCmdlineHelp()
122cdf0e10cSrcweir 	{
123*b8ac9833SMatthias Seidel 		// If you put variables in other chunks don't forget to call the replace routines
124cdf0e10cSrcweir 		// for those chunks...
125cdf0e10cSrcweir 		String aHelpMessage_head(aCmdLineHelp_head, RTL_TEXTENCODING_ASCII_US);
126cdf0e10cSrcweir 		String aHelpMessage_left(aCmdLineHelp_left, RTL_TEXTENCODING_ASCII_US);
127cdf0e10cSrcweir 		String aHelpMessage_right(aCmdLineHelp_right, RTL_TEXTENCODING_ASCII_US);
128cdf0e10cSrcweir 		String aHelpMessage_bottom(aCmdLineHelp_bottom, RTL_TEXTENCODING_ASCII_US);
129cdf0e10cSrcweir 		ReplaceStringHookProc(aHelpMessage_head);
130cdf0e10cSrcweir 		::rtl::OUString aDefault;
131cdf0e10cSrcweir 		String aVerId( ::utl::Bootstrap::getBuildIdData( aDefault ));
132cdf0e10cSrcweir 		aHelpMessage_head.SearchAndReplaceAscii( "%BUILDID", aVerId );
133cdf0e10cSrcweir 		aHelpMessage_head.SearchAndReplaceAscii( "%CMDNAME", String( "soffice", RTL_TEXTENCODING_ASCII_US) );
134cdf0e10cSrcweir #ifdef UNX
135*b8ac9833SMatthias Seidel 		// On Unix use console for output
136*b8ac9833SMatthias Seidel 		fprintf(stderr, "%s\n", ByteString(aHelpMessage_head, RTL_TEXTENCODING_ASCII_US).GetBuffer());
137*b8ac9833SMatthias Seidel 		// Merge left and right column
138cdf0e10cSrcweir 		int n = aHelpMessage_left.GetTokenCount ('\n');
139cdf0e10cSrcweir 		ByteString bsLeft(aHelpMessage_left, RTL_TEXTENCODING_ASCII_US);
140cdf0e10cSrcweir 		ByteString bsRight(aHelpMessage_right, RTL_TEXTENCODING_ASCII_US);
141cdf0e10cSrcweir 		for ( int i = 0; i < n; i++ )
142cdf0e10cSrcweir 		{
143cdf0e10cSrcweir 			fprintf(stderr, "%s", bsLeft.GetToken(i, '\n').GetBuffer());
144cdf0e10cSrcweir 			fprintf(stderr, "%s\n", bsRight.GetToken(i, '\n').GetBuffer());
145cdf0e10cSrcweir 		}
146*b8ac9833SMatthias Seidel 		fprintf(stderr, "%s", ByteString(aHelpMessage_bottom, RTL_TEXTENCODING_ASCII_US).GetBuffer());
147cdf0e10cSrcweir #else
148*b8ac9833SMatthias Seidel 		// All other get a dialog box
149cdf0e10cSrcweir 		CmdlineHelpDialog aDlg;
150cdf0e10cSrcweir 		aDlg.m_ftHead.SetText(aHelpMessage_head);
151cdf0e10cSrcweir 		aDlg.m_ftLeft.SetText(aHelpMessage_left);
152cdf0e10cSrcweir 		aDlg.m_ftRight.SetText(aHelpMessage_right);
153cdf0e10cSrcweir 		aDlg.m_ftBottom.SetText(aHelpMessage_bottom);
154cdf0e10cSrcweir 		aDlg.Execute();
155cdf0e10cSrcweir #endif
156cdf0e10cSrcweir 	}
157cdf0e10cSrcweir #ifndef UNX
CmdlineHelpDialog(void)158cdf0e10cSrcweir 	CmdlineHelpDialog::CmdlineHelpDialog (void)
159cdf0e10cSrcweir 	: ModalDialog( NULL, DesktopResId( DLG_CMDLINEHELP ) )
160cdf0e10cSrcweir 	, m_ftHead( this, DesktopResId( TXT_DLG_CMDLINEHELP_HEADER ) )
161cdf0e10cSrcweir 	, m_ftLeft( this, DesktopResId( TXT_DLG_CMDLINEHELP_LEFT ) )
162cdf0e10cSrcweir 	, m_ftRight( this, DesktopResId( TXT_DLG_CMDLINEHELP_RIGHT ) )
163cdf0e10cSrcweir 	, m_ftBottom( this, DesktopResId( TXT_DLG_CMDLINEHELP_BOTTOM ) )
164cdf0e10cSrcweir 	, m_btOk( this, DesktopResId( BTN_DLG_CMDLINEHELP_OK ) )
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir 		FreeResource();
167cdf0e10cSrcweir 	}
168cdf0e10cSrcweir #endif
169cdf0e10cSrcweir }
170