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