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