xref: /aoo42x/main/desktop/source/app/cmdlinehelp.cxx (revision 2722cedd)
1*2722ceddSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2722ceddSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2722ceddSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2722ceddSAndrew Rist  * distributed with this work for additional information
6*2722ceddSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2722ceddSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2722ceddSAndrew Rist  * "License"); you may not use this file except in compliance
9*2722ceddSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2722ceddSAndrew Rist  *
11*2722ceddSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2722ceddSAndrew Rist  *
13*2722ceddSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2722ceddSAndrew Rist  * software distributed under the License is distributed on an
15*2722ceddSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2722ceddSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2722ceddSAndrew Rist  * specific language governing permissions and limitations
18*2722ceddSAndrew Rist  * under the License.
19*2722ceddSAndrew Rist  *
20*2722ceddSAndrew Rist  *************************************************************/
21*2722ceddSAndrew Rist 
22*2722ceddSAndrew 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 {
43cdf0e10cSrcweir 	// to be able to display the help nicely in a dialog box with propotional 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 =
59cdf0e10cSrcweir 		"-minimized    \n"\
60cdf0e10cSrcweir 		"-invisible    \n"\
61cdf0e10cSrcweir 		"-norestore    \n"\
62cdf0e10cSrcweir 		"-quickstart   \n"\
63cdf0e10cSrcweir 		"-nologo       \n"\
64cdf0e10cSrcweir 		"-nolockcheck  \n"\
65cdf0e10cSrcweir 		"-nodefault    \n"\
66cdf0e10cSrcweir 		"-headless     \n"\
67cdf0e10cSrcweir 		"-help/-h/-?   \n"\
68cdf0e10cSrcweir 		"-writer       \n"\
69cdf0e10cSrcweir 		"-calc         \n"\
70cdf0e10cSrcweir 		"-draw         \n"\
71cdf0e10cSrcweir 		"-impress      \n"\
72cdf0e10cSrcweir 		"-base         \n"\
73cdf0e10cSrcweir 		"-math         \n"\
74cdf0e10cSrcweir 		"-global       \n"\
75cdf0e10cSrcweir 		"-web          \n"\
76cdf0e10cSrcweir 		"-o            \n"\
77cdf0e10cSrcweir 		"-n            \n";
78cdf0e10cSrcweir 	const char *aCmdLineHelp_right =
79cdf0e10cSrcweir 		"keep startup bitmap minimized.\n"\
80cdf0e10cSrcweir 		"no startup screen, no default document and no UI.\n"\
81cdf0e10cSrcweir 		"suppress restart/restore after fatal errors.\n"\
82cdf0e10cSrcweir 		"starts the quickstart service (only available on windows and OS/2 platform)\n"\
83cdf0e10cSrcweir 		"don't show startup screen.\n"\
84cdf0e10cSrcweir 		"don't check for remote instances using the installation\n"\
85cdf0e10cSrcweir 		"don't start with an empty document\n"\
86cdf0e10cSrcweir 		"like invisible but no userinteraction at all.\n"\
87cdf0e10cSrcweir 		"show this message and exit.\n"\
88cdf0e10cSrcweir 		"create new text document.\n"\
89cdf0e10cSrcweir 		"create new spreadsheet document.\n"\
90cdf0e10cSrcweir 		"create new drawing.\n"\
91cdf0e10cSrcweir 		"create new presentation.\n"\
92cdf0e10cSrcweir 		"create new database.\n"\
93cdf0e10cSrcweir 		"create new formula.\n"\
94cdf0e10cSrcweir 		"create new global document.\n"\
95cdf0e10cSrcweir 		"create new HTML document.\n"\
96cdf0e10cSrcweir 		"open documents regardless whether they are templates or not.\n"\
97cdf0e10cSrcweir 		"always open documents as new files (use as template).\n";
98cdf0e10cSrcweir 	const char *aCmdLineHelp_bottom =
99cdf0e10cSrcweir 		"-display <display>\n"\
100cdf0e10cSrcweir 		"      Specify X-Display to use in Unix/X11 versions.\n"
101cdf0e10cSrcweir 		"-p <documents...>\n"\
102cdf0e10cSrcweir 		"      print the specified documents on the default printer.\n"\
103cdf0e10cSrcweir 		"-pt <printer> <documents...>\n"\
104cdf0e10cSrcweir 		"      print the specified documents on the specified printer.\n"\
105cdf0e10cSrcweir 		"-view <documents...>\n"\
106cdf0e10cSrcweir 		"      open the specified documents in viewer-(readonly-)mode.\n"\
107cdf0e10cSrcweir 		"-show <presentation>\n"\
108cdf0e10cSrcweir 		"      open the specified presentation and start it immediately\n"\
109cdf0e10cSrcweir 		"-accept=<accept-string>\n"\
110cdf0e10cSrcweir         "      Specify an UNO connect-string to create an UNO acceptor through which\n"\
111cdf0e10cSrcweir 		"      other programs can connect to access the API\n"\
112cdf0e10cSrcweir 		"-unaccept=<accept-string>\n"\
113cdf0e10cSrcweir 		"      Close an acceptor that was created with -accept=<accept-string>\n"\
114cdf0e10cSrcweir 		"      Use -unnaccept=all to close all open acceptors\n"\
115cdf0e10cSrcweir 		"Remaining arguments will be treated as filenames or URLs of documents to open.\n";
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	void ReplaceStringHookProc( UniString& rStr );
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 	void displayCmdlineHelp()
120cdf0e10cSrcweir 	{
121cdf0e10cSrcweir 		// if you put variables in other chunks don't forget to call the replace routines
122cdf0e10cSrcweir 		// for those chunks...
123cdf0e10cSrcweir 		String aHelpMessage_head(aCmdLineHelp_head, RTL_TEXTENCODING_ASCII_US);
124cdf0e10cSrcweir 		String aHelpMessage_left(aCmdLineHelp_left, RTL_TEXTENCODING_ASCII_US);
125cdf0e10cSrcweir 		String aHelpMessage_right(aCmdLineHelp_right, RTL_TEXTENCODING_ASCII_US);
126cdf0e10cSrcweir 		String aHelpMessage_bottom(aCmdLineHelp_bottom, RTL_TEXTENCODING_ASCII_US);
127cdf0e10cSrcweir 		ReplaceStringHookProc(aHelpMessage_head);
128cdf0e10cSrcweir 		::rtl::OUString aDefault;
129cdf0e10cSrcweir 		String aVerId( ::utl::Bootstrap::getBuildIdData( aDefault ));
130cdf0e10cSrcweir 		aHelpMessage_head.SearchAndReplaceAscii( "%BUILDID", aVerId );
131cdf0e10cSrcweir 		aHelpMessage_head.SearchAndReplaceAscii( "%CMDNAME", String( "soffice", RTL_TEXTENCODING_ASCII_US) );
132cdf0e10cSrcweir #ifdef UNX
133cdf0e10cSrcweir 		// on unix use console for output
134cdf0e10cSrcweir 		fprintf(stderr, "%s\n", ByteString(aHelpMessage_head,
135cdf0e10cSrcweir 					RTL_TEXTENCODING_ASCII_US).GetBuffer());
136cdf0e10cSrcweir 		// merge left and right column
137cdf0e10cSrcweir 		int n = aHelpMessage_left.GetTokenCount ('\n');
138cdf0e10cSrcweir 		ByteString bsLeft(aHelpMessage_left, RTL_TEXTENCODING_ASCII_US);
139cdf0e10cSrcweir 		ByteString bsRight(aHelpMessage_right, RTL_TEXTENCODING_ASCII_US);
140cdf0e10cSrcweir 		for ( int i = 0; i < n; i++ )
141cdf0e10cSrcweir 		{
142cdf0e10cSrcweir 			fprintf(stderr, "%s", bsLeft.GetToken(i, '\n').GetBuffer());
143cdf0e10cSrcweir 			fprintf(stderr, "%s\n", bsRight.GetToken(i, '\n').GetBuffer());
144cdf0e10cSrcweir 		}
145cdf0e10cSrcweir 		fprintf(stderr, "%s", ByteString(aHelpMessage_bottom,
146cdf0e10cSrcweir                     RTL_TEXTENCODING_ASCII_US).GetBuffer());
147cdf0e10cSrcweir #else
148cdf0e10cSrcweir 		// rest gets 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
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