LCOV - code coverage report
Current view: top level - desktop/source/app - cmdlinehelp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 22 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 72 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <stdlib.h>
      31                 :            : #ifdef UNX
      32                 :            : #include <stdio.h>
      33                 :            : #endif
      34                 :            : #include <comphelper/string.hxx>
      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_version[] =
      57                 :            :         "%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION\n"\
      58                 :            :         "\n";
      59                 :            :     const char aCmdLineHelp_head[] =
      60                 :            :         "Usage: %CMDNAME [options] [documents...]\n"\
      61                 :            :         "\n"\
      62                 :            :         "Options:\n";
      63                 :            :     const char aCmdLineHelp_left[] =
      64                 :            :         "--minimized    \n"\
      65                 :            :         "--invisible    \n"\
      66                 :            :         "--norestore    \n"\
      67                 :            :         "--quickstart   \n"\
      68                 :            :         "--nologo       \n"\
      69                 :            :         "--nolockcheck  \n"\
      70                 :            :         "--nodefault    \n"\
      71                 :            :         "--headless     \n"\
      72                 :            :         "--help/-h/-?   \n"\
      73                 :            :         "--version      \n"\
      74                 :            :         "--writer       \n"\
      75                 :            :         "--calc         \n"\
      76                 :            :         "--draw         \n"\
      77                 :            :         "--impress      \n"\
      78                 :            :         "--base         \n"\
      79                 :            :         "--math         \n"\
      80                 :            :         "--global       \n"\
      81                 :            :         "--web          \n"\
      82                 :            :         "-o             \n"\
      83                 :            :         "-n             \n";
      84                 :            :     const char aCmdLineHelp_right[] =
      85                 :            :         "keep startup bitmap minimized.\n"\
      86                 :            :         "no startup screen, no default document and no UI.\n"\
      87                 :            :         "suppress restart/restore after fatal errors.\n"\
      88                 :            :         "starts the quickstart service\n"\
      89                 :            :         "don't show startup screen.\n"\
      90                 :            :         "don't check for remote instances using the installation\n"\
      91                 :            :         "don't start with an empty document\n"\
      92                 :            :         "like invisible but no userinteraction at all.\n"\
      93                 :            :         "show this message and exit.\n"\
      94                 :            :         "display the version information.\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                 :            :         "--infilter=<filter>\n"\
     123                 :            :         "      Force an input filter type if possible\n"\
     124                 :            :         "      Eg. --infilter=\"Calc Office Open XML\"\n"\
     125                 :            :         "--convert-to output_file_extension[:output_filter_name] [--outdir output_dir] files\n"\
     126                 :            :         "      Batch convert files.\n"\
     127                 :            :         "      If --outdir is not specified then current working dir is used as output_dir.\n"\
     128                 :            :         "      Eg. --convert-to pdf *.doc\n"\
     129                 :            :         "          --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc\n"\
     130                 :            :         "--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"\
     131                 :            :         "      Batch print files to file.\n"\
     132                 :            :         "      If --outdir is not specified then current working dir is used as output_dir.\n"\
     133                 :            :         "      Eg. --print-to-file *.doc\n"\
     134                 :            :         "          --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\n"\
     135                 :            :         "\nRemaining arguments will be treated as filenames or URLs of documents to open.\n\n";
     136                 :            : 
     137                 :            :     rtl::OUString ReplaceStringHookProc(const rtl::OUString& rStr);
     138                 :            : 
     139                 :          0 :     void displayCmdlineHelp()
     140                 :            :     {
     141                 :            :         // if you put variables in other chunks don't forget to call the replace routines
     142                 :            :         // for those chunks...
     143         [ #  # ]:          0 :         String aHelpMessage_version(aCmdLineHelp_version, RTL_TEXTENCODING_ASCII_US);
     144         [ #  # ]:          0 :         String aHelpMessage_head(aCmdLineHelp_head, RTL_TEXTENCODING_ASCII_US);
     145         [ #  # ]:          0 :         String aHelpMessage_left(aCmdLineHelp_left, RTL_TEXTENCODING_ASCII_US);
     146         [ #  # ]:          0 :         String aHelpMessage_right(aCmdLineHelp_right, RTL_TEXTENCODING_ASCII_US);
     147         [ #  # ]:          0 :         String aHelpMessage_bottom(aCmdLineHelp_bottom, RTL_TEXTENCODING_ASCII_US);
     148 [ #  # ][ #  # ]:          0 :         aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version);
                 [ #  # ]
     149 [ #  # ][ #  # ]:          0 :         aHelpMessage_head.SearchAndReplaceAscii( "%CMDNAME", String( "soffice", RTL_TEXTENCODING_ASCII_US) );
                 [ #  # ]
     150                 :            : #ifdef UNX
     151                 :            :         // on unix use console for output
     152                 :            :         fprintf(stdout, "%s%s",
     153                 :            :                 rtl::OUStringToOString(aHelpMessage_version, RTL_TEXTENCODING_ASCII_US).getStr(),
     154 [ #  # ][ #  # ]:          0 :                 rtl::OUStringToOString(aHelpMessage_head, RTL_TEXTENCODING_ASCII_US).getStr());
         [ #  # ][ #  # ]
                 [ #  # ]
     155                 :            :         // merge left and right column
     156 [ #  # ][ #  # ]:          0 :         sal_Int32 n = comphelper::string::getTokenCount(aHelpMessage_left, '\n');
     157                 :            :         rtl::OString bsLeft(rtl::OUStringToOString(aHelpMessage_left,
     158 [ #  # ][ #  # ]:          0 :             RTL_TEXTENCODING_ASCII_US));
     159                 :            :         rtl::OString bsRight(rtl::OUStringToOString(aHelpMessage_right,
     160 [ #  # ][ #  # ]:          0 :             RTL_TEXTENCODING_ASCII_US));
     161         [ #  # ]:          0 :         for ( sal_Int32 i = 0; i < n; ++i )
     162                 :            :         {
     163                 :            :             using comphelper::string::getToken;
     164         [ #  # ]:          0 :             fprintf(stdout, "%s", getToken(bsLeft, i, '\n').getStr());
     165         [ #  # ]:          0 :             fprintf(stdout, "%s\n", getToken(bsRight, i, '\n').getStr());
     166                 :            :         }
     167                 :            :         fprintf(stdout, "%s", rtl::OUStringToOString(aHelpMessage_bottom,
     168 [ #  # ][ #  # ]:          0 :                     RTL_TEXTENCODING_ASCII_US).getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     169                 :            : #else
     170                 :            :         // rest gets a dialog box
     171                 :            :         CmdlineHelpDialog aDlg;
     172                 :            :         String head = aHelpMessage_version;
     173                 :            :         head.Append(aHelpMessage_head);
     174                 :            :         aDlg.m_ftHead.SetText(head);
     175                 :            :         aDlg.m_ftLeft.SetText(aHelpMessage_left);
     176                 :            :         aDlg.m_ftRight.SetText(aHelpMessage_right);
     177                 :            :         aDlg.m_ftBottom.SetText(aHelpMessage_bottom);
     178                 :            :         aDlg.Execute();
     179                 :            : #endif
     180                 :          0 :     }
     181                 :            : 
     182                 :          0 :     void displayVersion()
     183                 :            :     {
     184                 :          0 :         rtl::OUString aVersionMsg(aCmdLineHelp_version);
     185         [ #  # ]:          0 :         aVersionMsg = ReplaceStringHookProc(aVersionMsg);
     186                 :            : #ifdef UNX
     187 [ #  # ][ #  # ]:          0 :         fprintf(stdout, "%s", rtl::OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
     188                 :            : #else
     189                 :            :         // Just re-use the help dialog for now.
     190                 :            :         CmdlineHelpDialog aDlg;
     191                 :            :         aDlg.m_ftHead.SetText(aVersionMsg);
     192                 :            :         aDlg.Execute();
     193                 :            : #endif
     194                 :          0 :     }
     195                 :            : 
     196                 :            : #ifndef UNX
     197                 :            :     CmdlineHelpDialog::CmdlineHelpDialog (void)
     198                 :            :     : ModalDialog( NULL, DesktopResId( DLG_CMDLINEHELP ) )
     199                 :            :     , m_ftHead( this, DesktopResId( TXT_DLG_CMDLINEHELP_HEADER ) )
     200                 :            :     , m_ftLeft( this, DesktopResId( TXT_DLG_CMDLINEHELP_LEFT ) )
     201                 :            :     , m_ftRight( this, DesktopResId( TXT_DLG_CMDLINEHELP_RIGHT ) )
     202                 :            :     , m_ftBottom( this, DesktopResId( TXT_DLG_CMDLINEHELP_BOTTOM ) )
     203                 :            :     , m_btOk( this, DesktopResId( BTN_DLG_CMDLINEHELP_OK ) )
     204                 :            :     {
     205                 :            :         FreeResource();
     206                 :            :     }
     207                 :            : #endif
     208                 :            : }
     209                 :            : 
     210                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10