LCOV - code coverage report
Current view: top level - libreoffice/desktop/source/app - cmdlinehelp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 25 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <stdlib.h>
      22             : #ifdef UNX
      23             : #include <stdio.h>
      24             : #endif
      25             : #include <comphelper/string.hxx>
      26             : #include <sal/types.h>
      27             : #include <tools/string.hxx>
      28             : #include <vcl/msgbox.hxx>
      29             : #include <rtl/bootstrap.hxx>
      30             : #include <app.hxx>
      31             : 
      32             : #include "desktopresid.hxx"
      33             : #include "desktop.hrc"
      34             : #include "cmdlinehelp.hxx"
      35             : 
      36             : namespace desktop
      37             : {
      38             :     // to be able to display the help nicely in a dialog box with propotional font,
      39             :     // we need to split it in chunks...
      40             :     //  ___HEAD___
      41             :     //  LEFT RIGHT
      42             :     //  LEFT RIGHT
      43             :     //  LEFT RIGHT
      44             :     //  __BOTTOM__
      45             :     //     [OK]
      46             : 
      47             :     const char aCmdLineHelp_version[] =
      48             :         "%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION\n"\
      49             :         "\n";
      50             :     const char aCmdLineHelp_head[] =
      51             :         "Usage: %CMDNAME [options] [documents...]\n"\
      52             :         "\n"\
      53             :         "Options:\n";
      54             :     const char aCmdLineHelp_left[] =
      55             :         "--minimized    \n"\
      56             :         "--invisible    \n"\
      57             :         "--norestore    \n"\
      58             :         "--quickstart   \n"\
      59             :         "--nologo       \n"\
      60             :         "--nolockcheck  \n"\
      61             :         "--nodefault    \n"\
      62             :         "--headless     \n"\
      63             :         "--help/-h/-?   \n"\
      64             :         "--version      \n"\
      65             :         "--writer       \n"\
      66             :         "--calc         \n"\
      67             :         "--draw         \n"\
      68             :         "--impress      \n"\
      69             :         "--base         \n"\
      70             :         "--math         \n"\
      71             :         "--global       \n"\
      72             :         "--web          \n"\
      73             :         "-o             \n"\
      74             :         "-n             \n";
      75             :     const char aCmdLineHelp_right[] =
      76             :         "keep startup bitmap minimized.\n"\
      77             :         "no startup screen, no default document and no UI.\n"\
      78             :         "suppress restart/restore after fatal errors.\n"\
      79             :         "starts the quickstart service\n"\
      80             :         "don't show startup screen.\n"\
      81             :         "don't check for remote instances using the installation\n"\
      82             :         "don't start with an empty document\n"\
      83             :         "like invisible but no userinteraction at all.\n"\
      84             :         "show this message and exit.\n"\
      85             :         "display the version information.\n"\
      86             :         "create new text document.\n"\
      87             :         "create new spreadsheet document.\n"\
      88             :         "create new drawing.\n"\
      89             :         "create new presentation.\n"\
      90             :         "create new database.\n"\
      91             :         "create new formula.\n"\
      92             :         "create new global document.\n"\
      93             :         "create new HTML document.\n"\
      94             :         "open documents regardless whether they are templates or not.\n"\
      95             :         "always open documents as new files (use as template).\n";
      96             :     const char aCmdLineHelp_bottom[] =
      97             :         "--display <display>\n"\
      98             :         "      Specify X-Display to use in Unix/X11 versions.\n"
      99             :         "-p <documents...>\n"\
     100             :         "      print the specified documents on the default printer.\n"\
     101             :         "--pt <printer> <documents...>\n"\
     102             :         "      print the specified documents on the specified printer.\n"\
     103             :         "--view <documents...>\n"\
     104             :         "      open the specified documents in viewer-(readonly-)mode.\n"\
     105             :         "--show <presentation>\n"\
     106             :         "      open the specified presentation and start it immediately\n"\
     107             :         "--accept=<accept-string>\n"\
     108             :         "      Specify an UNO connect-string to create an UNO acceptor through which\n"\
     109             :         "      other programs can connect to access the API\n"\
     110             :         "--unaccept=<accept-string>\n"\
     111             :         "      Close an acceptor that was created with --accept=<accept-string>\n"\
     112             :         "      Use --unnaccept=all to close all open acceptors\n"\
     113             :         "--infilter=<filter>\n"\
     114             :         "      Force an input filter type if possible\n"\
     115             :         "      Eg. --infilter=\"Calc Office Open XML\"\n"\
     116             :         "--convert-to output_file_extension[:output_filter_name] [--outdir output_dir] files\n"\
     117             :         "      Batch convert files.\n"\
     118             :         "      If --outdir is not specified then current working dir is used as output_dir.\n"\
     119             :         "      Eg. --convert-to pdf *.doc\n"\
     120             :         "          --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc\n"\
     121             :         "--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"\
     122             :         "      Batch print files to file.\n"\
     123             :         "      If --outdir is not specified then current working dir is used as output_dir.\n"\
     124             :         "      Eg. --print-to-file *.doc\n"\
     125             :         "          --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\n"\
     126             :         "\nRemaining arguments will be treated as filenames or URLs of documents to open.\n\n";
     127             : 
     128             :     rtl::OUString ReplaceStringHookProc(const rtl::OUString& rStr);
     129             : 
     130           0 :     void displayCmdlineHelp(OUString const & unknown)
     131             :     {
     132             :         // if you put variables in other chunks don't forget to call the replace routines
     133             :         // for those chunks...
     134           0 :         String aHelpMessage_version(aCmdLineHelp_version, RTL_TEXTENCODING_ASCII_US);
     135           0 :         String aHelpMessage_head(aCmdLineHelp_head, RTL_TEXTENCODING_ASCII_US);
     136           0 :         String aHelpMessage_left(aCmdLineHelp_left, RTL_TEXTENCODING_ASCII_US);
     137           0 :         String aHelpMessage_right(aCmdLineHelp_right, RTL_TEXTENCODING_ASCII_US);
     138           0 :         String aHelpMessage_bottom(aCmdLineHelp_bottom, RTL_TEXTENCODING_ASCII_US);
     139           0 :         aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version);
     140           0 :         aHelpMessage_head.SearchAndReplaceAscii( "%CMDNAME", String( "soffice", RTL_TEXTENCODING_ASCII_US) );
     141           0 :         if (!unknown.isEmpty())
     142             :         {
     143           0 :             aHelpMessage_head = "Unknown option: " + unknown + "\n\n"
     144           0 :                 + aHelpMessage_head;
     145             :         }
     146             : #ifdef UNX
     147             :         // on unix use console for output
     148             :         fprintf(stdout, "%s%s",
     149             :                 rtl::OUStringToOString(aHelpMessage_version, RTL_TEXTENCODING_ASCII_US).getStr(),
     150           0 :                 rtl::OUStringToOString(aHelpMessage_head, RTL_TEXTENCODING_ASCII_US).getStr());
     151             :         // merge left and right column
     152           0 :         sal_Int32 n = comphelper::string::getTokenCount(aHelpMessage_left, '\n');
     153             :         rtl::OString bsLeft(rtl::OUStringToOString(aHelpMessage_left,
     154           0 :             RTL_TEXTENCODING_ASCII_US));
     155             :         rtl::OString bsRight(rtl::OUStringToOString(aHelpMessage_right,
     156           0 :             RTL_TEXTENCODING_ASCII_US));
     157           0 :         for ( sal_Int32 i = 0; i < n; ++i )
     158             :         {
     159             :             using comphelper::string::getToken;
     160           0 :             fprintf(stdout, "%s", getToken(bsLeft, i, '\n').getStr());
     161           0 :             fprintf(stdout, "%s\n", getToken(bsRight, i, '\n').getStr());
     162             :         }
     163             :         fprintf(stdout, "%s", rtl::OUStringToOString(aHelpMessage_bottom,
     164           0 :                     RTL_TEXTENCODING_ASCII_US).getStr());
     165             : #else
     166             :         // rest gets a dialog box
     167             :         CmdlineHelpDialog aDlg;
     168             :         String head = aHelpMessage_version;
     169             :         head.Append(aHelpMessage_head);
     170             :         aDlg.m_ftHead.SetText(head);
     171             :         aDlg.m_ftLeft.SetText(aHelpMessage_left);
     172             :         aDlg.m_ftRight.SetText(aHelpMessage_right);
     173             :         aDlg.m_ftBottom.SetText(aHelpMessage_bottom);
     174             :         aDlg.Execute();
     175             : #endif
     176           0 :     }
     177             : 
     178           0 :     void displayVersion()
     179             :     {
     180           0 :         rtl::OUString aVersionMsg(aCmdLineHelp_version);
     181           0 :         aVersionMsg = ReplaceStringHookProc(aVersionMsg);
     182             : #ifdef UNX
     183           0 :         fprintf(stdout, "%s", rtl::OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
     184             : #else
     185             :         // Just re-use the help dialog for now.
     186             :         CmdlineHelpDialog aDlg;
     187             :         aDlg.m_ftHead.SetText(aVersionMsg);
     188             :         aDlg.Execute();
     189             : #endif
     190           0 :     }
     191             : 
     192             : #ifndef UNX
     193             :     CmdlineHelpDialog::CmdlineHelpDialog (void)
     194             :     : ModalDialog( NULL, DesktopResId( DLG_CMDLINEHELP ) )
     195             :     , m_ftHead( this, DesktopResId( TXT_DLG_CMDLINEHELP_HEADER ) )
     196             :     , m_ftLeft( this, DesktopResId( TXT_DLG_CMDLINEHELP_LEFT ) )
     197             :     , m_ftRight( this, DesktopResId( TXT_DLG_CMDLINEHELP_RIGHT ) )
     198             :     , m_ftBottom( this, DesktopResId( TXT_DLG_CMDLINEHELP_BOTTOM ) )
     199             :     , m_btOk( this, DesktopResId( BTN_DLG_CMDLINEHELP_OK ) )
     200             :     {
     201             :         FreeResource();
     202             :     }
     203             : #endif
     204             : }
     205             : 
     206             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10