xref: /trunk/main/desktop/source/app/cmdlinehelp.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_desktop.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <stdlib.h>
32*cdf0e10cSrcweir #ifdef UNX
33*cdf0e10cSrcweir #include <stdio.h>
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir #include <sal/types.h>
36*cdf0e10cSrcweir #include <tools/string.hxx>
37*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
38*cdf0e10cSrcweir #include <rtl/bootstrap.hxx>
39*cdf0e10cSrcweir #include <app.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include "desktopresid.hxx"
42*cdf0e10cSrcweir #include "desktop.hrc"
43*cdf0e10cSrcweir #include "cmdlinehelp.hxx"
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace desktop
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir 	// to be able to display the help nicely in a dialog box with propotional font,
48*cdf0e10cSrcweir 	// we need to split it in chunks...
49*cdf0e10cSrcweir 	//  ___HEAD___
50*cdf0e10cSrcweir 	//  LEFT RIGHT
51*cdf0e10cSrcweir 	//  LEFT RIGHT
52*cdf0e10cSrcweir 	//  LEFT RIGHT
53*cdf0e10cSrcweir 	//  __BOTTOM__
54*cdf0e10cSrcweir 	//     [OK]
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 	const char *aCmdLineHelp_head =
57*cdf0e10cSrcweir 		"%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION %BUILDID\n"\
58*cdf0e10cSrcweir 		"\n"\
59*cdf0e10cSrcweir 		"Usage: %CMDNAME [options] [documents...]\n"\
60*cdf0e10cSrcweir 		"\n"\
61*cdf0e10cSrcweir 		"Options:\n";
62*cdf0e10cSrcweir 	const char *aCmdLineHelp_left =
63*cdf0e10cSrcweir 		"-minimized    \n"\
64*cdf0e10cSrcweir 		"-invisible    \n"\
65*cdf0e10cSrcweir 		"-norestore    \n"\
66*cdf0e10cSrcweir 		"-quickstart   \n"\
67*cdf0e10cSrcweir 		"-nologo       \n"\
68*cdf0e10cSrcweir 		"-nolockcheck  \n"\
69*cdf0e10cSrcweir 		"-nodefault    \n"\
70*cdf0e10cSrcweir 		"-headless     \n"\
71*cdf0e10cSrcweir 		"-help/-h/-?   \n"\
72*cdf0e10cSrcweir 		"-writer       \n"\
73*cdf0e10cSrcweir 		"-calc         \n"\
74*cdf0e10cSrcweir 		"-draw         \n"\
75*cdf0e10cSrcweir 		"-impress      \n"\
76*cdf0e10cSrcweir 		"-base         \n"\
77*cdf0e10cSrcweir 		"-math         \n"\
78*cdf0e10cSrcweir 		"-global       \n"\
79*cdf0e10cSrcweir 		"-web          \n"\
80*cdf0e10cSrcweir 		"-o            \n"\
81*cdf0e10cSrcweir 		"-n            \n";
82*cdf0e10cSrcweir 	const char *aCmdLineHelp_right =
83*cdf0e10cSrcweir 		"keep startup bitmap minimized.\n"\
84*cdf0e10cSrcweir 		"no startup screen, no default document and no UI.\n"\
85*cdf0e10cSrcweir 		"suppress restart/restore after fatal errors.\n"\
86*cdf0e10cSrcweir 		"starts the quickstart service (only available on windows and OS/2 platform)\n"\
87*cdf0e10cSrcweir 		"don't show startup screen.\n"\
88*cdf0e10cSrcweir 		"don't check for remote instances using the installation\n"\
89*cdf0e10cSrcweir 		"don't start with an empty document\n"\
90*cdf0e10cSrcweir 		"like invisible but no userinteraction at all.\n"\
91*cdf0e10cSrcweir 		"show this message and exit.\n"\
92*cdf0e10cSrcweir 		"create new text document.\n"\
93*cdf0e10cSrcweir 		"create new spreadsheet document.\n"\
94*cdf0e10cSrcweir 		"create new drawing.\n"\
95*cdf0e10cSrcweir 		"create new presentation.\n"\
96*cdf0e10cSrcweir 		"create new database.\n"\
97*cdf0e10cSrcweir 		"create new formula.\n"\
98*cdf0e10cSrcweir 		"create new global document.\n"\
99*cdf0e10cSrcweir 		"create new HTML document.\n"\
100*cdf0e10cSrcweir 		"open documents regardless whether they are templates or not.\n"\
101*cdf0e10cSrcweir 		"always open documents as new files (use as template).\n";
102*cdf0e10cSrcweir 	const char *aCmdLineHelp_bottom =
103*cdf0e10cSrcweir 		"-display <display>\n"\
104*cdf0e10cSrcweir 		"      Specify X-Display to use in Unix/X11 versions.\n"
105*cdf0e10cSrcweir 		"-p <documents...>\n"\
106*cdf0e10cSrcweir 		"      print the specified documents on the default printer.\n"\
107*cdf0e10cSrcweir 		"-pt <printer> <documents...>\n"\
108*cdf0e10cSrcweir 		"      print the specified documents on the specified printer.\n"\
109*cdf0e10cSrcweir 		"-view <documents...>\n"\
110*cdf0e10cSrcweir 		"      open the specified documents in viewer-(readonly-)mode.\n"\
111*cdf0e10cSrcweir 		"-show <presentation>\n"\
112*cdf0e10cSrcweir 		"      open the specified presentation and start it immediately\n"\
113*cdf0e10cSrcweir 		"-accept=<accept-string>\n"\
114*cdf0e10cSrcweir         "      Specify an UNO connect-string to create an UNO acceptor through which\n"\
115*cdf0e10cSrcweir 		"      other programs can connect to access the API\n"\
116*cdf0e10cSrcweir 		"-unaccept=<accept-string>\n"\
117*cdf0e10cSrcweir 		"      Close an acceptor that was created with -accept=<accept-string>\n"\
118*cdf0e10cSrcweir 		"      Use -unnaccept=all to close all open acceptors\n"\
119*cdf0e10cSrcweir 		"Remaining arguments will be treated as filenames or URLs of documents to open.\n";
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 	void ReplaceStringHookProc( UniString& rStr );
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 	void displayCmdlineHelp()
124*cdf0e10cSrcweir 	{
125*cdf0e10cSrcweir 		// if you put variables in other chunks don't forget to call the replace routines
126*cdf0e10cSrcweir 		// for those chunks...
127*cdf0e10cSrcweir 		String aHelpMessage_head(aCmdLineHelp_head, RTL_TEXTENCODING_ASCII_US);
128*cdf0e10cSrcweir 		String aHelpMessage_left(aCmdLineHelp_left, RTL_TEXTENCODING_ASCII_US);
129*cdf0e10cSrcweir 		String aHelpMessage_right(aCmdLineHelp_right, RTL_TEXTENCODING_ASCII_US);
130*cdf0e10cSrcweir 		String aHelpMessage_bottom(aCmdLineHelp_bottom, RTL_TEXTENCODING_ASCII_US);
131*cdf0e10cSrcweir 		ReplaceStringHookProc(aHelpMessage_head);
132*cdf0e10cSrcweir 		::rtl::OUString aDefault;
133*cdf0e10cSrcweir 		String aVerId( ::utl::Bootstrap::getBuildIdData( aDefault ));
134*cdf0e10cSrcweir 		aHelpMessage_head.SearchAndReplaceAscii( "%BUILDID", aVerId );
135*cdf0e10cSrcweir 		aHelpMessage_head.SearchAndReplaceAscii( "%CMDNAME", String( "soffice", RTL_TEXTENCODING_ASCII_US) );
136*cdf0e10cSrcweir #ifdef UNX
137*cdf0e10cSrcweir 		// on unix use console for output
138*cdf0e10cSrcweir 		fprintf(stderr, "%s\n", ByteString(aHelpMessage_head,
139*cdf0e10cSrcweir 					RTL_TEXTENCODING_ASCII_US).GetBuffer());
140*cdf0e10cSrcweir 		// merge left and right column
141*cdf0e10cSrcweir 		int n = aHelpMessage_left.GetTokenCount ('\n');
142*cdf0e10cSrcweir 		ByteString bsLeft(aHelpMessage_left, RTL_TEXTENCODING_ASCII_US);
143*cdf0e10cSrcweir 		ByteString bsRight(aHelpMessage_right, RTL_TEXTENCODING_ASCII_US);
144*cdf0e10cSrcweir 		for ( int i = 0; i < n; i++ )
145*cdf0e10cSrcweir 		{
146*cdf0e10cSrcweir 			fprintf(stderr, "%s", bsLeft.GetToken(i, '\n').GetBuffer());
147*cdf0e10cSrcweir 			fprintf(stderr, "%s\n", bsRight.GetToken(i, '\n').GetBuffer());
148*cdf0e10cSrcweir 		}
149*cdf0e10cSrcweir 		fprintf(stderr, "%s", ByteString(aHelpMessage_bottom,
150*cdf0e10cSrcweir                     RTL_TEXTENCODING_ASCII_US).GetBuffer());
151*cdf0e10cSrcweir #else
152*cdf0e10cSrcweir 		// rest gets a dialog box
153*cdf0e10cSrcweir 		CmdlineHelpDialog aDlg;
154*cdf0e10cSrcweir 		aDlg.m_ftHead.SetText(aHelpMessage_head);
155*cdf0e10cSrcweir 		aDlg.m_ftLeft.SetText(aHelpMessage_left);
156*cdf0e10cSrcweir 		aDlg.m_ftRight.SetText(aHelpMessage_right);
157*cdf0e10cSrcweir 		aDlg.m_ftBottom.SetText(aHelpMessage_bottom);
158*cdf0e10cSrcweir 		aDlg.Execute();
159*cdf0e10cSrcweir #endif
160*cdf0e10cSrcweir 	}
161*cdf0e10cSrcweir #ifndef UNX
162*cdf0e10cSrcweir 	CmdlineHelpDialog::CmdlineHelpDialog (void)
163*cdf0e10cSrcweir 	: ModalDialog( NULL, DesktopResId( DLG_CMDLINEHELP ) )
164*cdf0e10cSrcweir 	, m_ftHead( this, DesktopResId( TXT_DLG_CMDLINEHELP_HEADER ) )
165*cdf0e10cSrcweir 	, m_ftLeft( this, DesktopResId( TXT_DLG_CMDLINEHELP_LEFT ) )
166*cdf0e10cSrcweir 	, m_ftRight( this, DesktopResId( TXT_DLG_CMDLINEHELP_RIGHT ) )
167*cdf0e10cSrcweir 	, m_ftBottom( this, DesktopResId( TXT_DLG_CMDLINEHELP_BOTTOM ) )
168*cdf0e10cSrcweir 	, m_btOk( this, DesktopResId( BTN_DLG_CMDLINEHELP_OK ) )
169*cdf0e10cSrcweir 	{
170*cdf0e10cSrcweir 		FreeResource();
171*cdf0e10cSrcweir 	}
172*cdf0e10cSrcweir #endif
173*cdf0e10cSrcweir }
174