LCOV - code coverage report
Current view: top level - desktop/source/app - cmdlinehelp.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 26 3.8 %
Date: 2015-06-13 12:38:46 Functions: 2 4 50.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 <vcl/msgbox.hxx>
      28             : #include <rtl/bootstrap.hxx>
      29             : #include <app.hxx>
      30             : 
      31             : #include "desktopresid.hxx"
      32             : #include "desktop.hrc"
      33             : #include "cmdlinehelp.hxx"
      34             : 
      35             : namespace desktop
      36             : {
      37             :     // to be able to display the help nicely in a dialog box with propotional font,
      38             :     // we need to split it in chunks...
      39             :     //  ___HEAD___
      40             :     //  LEFT RIGHT
      41             :     //  LEFT RIGHT
      42             :     //  LEFT RIGHT
      43             :     //  __BOTTOM__
      44             :     //     [OK]
      45             : 
      46             :     const char aCmdLineHelp_version[] =
      47             :         "%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"\
      48             :         "\n";
      49             :     const char aCmdLineHelp_head[] =
      50             :         "Usage: %CMDNAME [options] [documents...]\n"\
      51             :         "\n"\
      52             :         "Options:\n";
      53             :     const char aCmdLineHelp_left[] =
      54             :         "--minimized    \n"\
      55             :         "--invisible    \n"\
      56             :         "--norestore    \n"\
      57             :         "--quickstart   \n"\
      58             :         "--nologo       \n"\
      59             :         "--nolockcheck  \n"\
      60             :         "--nodefault    \n"\
      61             :         "--headless     \n"\
      62             :         "--help/-h/-?   \n"\
      63             :         "--version      \n"\
      64             :         "--writer       \n"\
      65             :         "--calc         \n"\
      66             :         "--draw         \n"\
      67             :         "--impress      \n"\
      68             :         "--base         \n"\
      69             :         "--math         \n"\
      70             :         "--global       \n"\
      71             :         "--web          \n"\
      72             :         "-o             \n"\
      73             :         "-n             \n";
      74             :     const char aCmdLineHelp_right[] =
      75             :         "keep startup bitmap minimized.\n"\
      76             :         "no startup screen, no default document and no UI.\n"\
      77             :         "suppress restart/restore after fatal errors.\n"\
      78             :         "starts the quickstart service\n"\
      79             :         "don't show startup screen.\n"\
      80             :         "don't check for remote instances using the installation\n"\
      81             :         "don't start with an empty document\n"\
      82             :         "like invisible but no user interaction at all.\n"\
      83             :         "show this message and exit.\n"\
      84             :         "display the version information.\n"\
      85             :         "create new text document.\n"\
      86             :         "create new spreadsheet document.\n"\
      87             :         "create new drawing.\n"\
      88             :         "create new presentation.\n"\
      89             :         "create new database.\n"\
      90             :         "create new formula.\n"\
      91             :         "create new global document.\n"\
      92             :         "create new HTML document.\n"\
      93             :         "open documents regardless whether they are templates or not.\n"\
      94             :         "always open documents as new files (use as template).\n";
      95             :     const char aCmdLineHelp_bottom[] =
      96             :         "--display <display>\n"\
      97             :         "      Specify X-Display to use in Unix/X11 versions.\n"
      98             :         "-p <documents...>\n"\
      99             :         "      print the specified documents on the default printer.\n"\
     100             :         "--pt <printer> <documents...>\n"\
     101             :         "      print the specified documents on the specified printer.\n"\
     102             :         "--view <documents...>\n"\
     103             :         "      open the specified documents in viewer-(readonly-)mode.\n"\
     104             :         "--show <presentation>\n"\
     105             :         "      open the specified presentation and start it immediately\n"\
     106             :         "--accept=<accept-string>\n"\
     107             :         "      Specify an UNO connect-string to create an UNO acceptor through which\n"\
     108             :         "      other programs can connect to access the API\n"\
     109             :         "--unaccept=<accept-string>\n"\
     110             :         "      Close an acceptor that was created with --accept=<accept-string>\n"\
     111             :         "      Use --unnaccept=all to close all open acceptors\n"\
     112             :         "--infilter=<filter>[:filter_options]\n"\
     113             :         "      Force an input filter type if possible\n"\
     114             :         "      Eg. --infilter=\"Calc Office Open XML\"\n"\
     115             :         "          --infilter=\"Text (encoded):UTF8,LF,,,\"\n"\
     116             :         "--convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files\n"\
     117             :         "      Batch convert files (implies --headless).\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             :         "          --convert-to \"html:XHTML Writer File:UTF8\" *.doc\n"\
     122             :         "          --convert-to \"txt:Text (encoded):UTF8\" *.doc\n"\
     123             :         "--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"\
     124             :         "      Batch print files to file.\n"\
     125             :         "      If --outdir is not specified then current working dir is used as output_dir.\n"\
     126             :         "      Eg. --print-to-file *.doc\n"\
     127             :         "          --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\n" \
     128             :         "--cat files\n"\
     129             :         "      Dump text content of the files to console\n"\
     130             :         "      Eg. --cat *.odt\n"\
     131             :         "--pidfile file\n"\
     132             :         "      Store soffice.bin pid to file.\n"\
     133             :         "-env:<VAR>[=<VALUE>]\n"\
     134             :         "      Set a bootstrap variable.\n"\
     135             :         "      Eg. -env:UserInstallation=file:///tmp/test to set a non-default user profile path.\n"\
     136             :         "\nRemaining arguments will be treated as filenames or URLs of documents to open.\n\n";
     137             : 
     138           0 :     void displayCmdlineHelp(OUString const & unknown)
     139             :     {
     140             :         // if you put variables in other chunks don't forget to call the replace routines
     141             :         // for those chunks...
     142           0 :         OUString aHelpMessage_version(aCmdLineHelp_version);
     143           0 :         OUString aHelpMessage_head(aCmdLineHelp_head);
     144           0 :         OUString aHelpMessage_left(aCmdLineHelp_left);
     145           0 :         OUString aHelpMessage_right(aCmdLineHelp_right);
     146           0 :         OUString aHelpMessage_bottom(aCmdLineHelp_bottom);
     147           0 :         aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version);
     148           0 :         aHelpMessage_head = aHelpMessage_head.replaceFirst( "%CMDNAME", "soffice" );
     149           0 :         if (!unknown.isEmpty())
     150             :         {
     151           0 :             aHelpMessage_head = "Unknown option: " + unknown + "\n\n"
     152           0 :                 + aHelpMessage_head;
     153             :         }
     154             : #ifdef UNX
     155             :         // on unix use console for output
     156             :         fprintf(stdout, "%s%s",
     157             :                 OUStringToOString(aHelpMessage_version, RTL_TEXTENCODING_ASCII_US).getStr(),
     158           0 :                 OUStringToOString(aHelpMessage_head, RTL_TEXTENCODING_ASCII_US).getStr());
     159             :         // merge left and right column
     160           0 :         sal_Int32 n = comphelper::string::getTokenCount(aHelpMessage_left, '\n');
     161             :         OString bsLeft(OUStringToOString(aHelpMessage_left,
     162           0 :             RTL_TEXTENCODING_ASCII_US));
     163             :         OString bsRight(OUStringToOString(aHelpMessage_right,
     164           0 :             RTL_TEXTENCODING_ASCII_US));
     165           0 :         for ( sal_Int32 i = 0; i < n; ++i )
     166             :         {
     167           0 :             fprintf(stdout, "%s", bsLeft.getToken(i, '\n').getStr());
     168           0 :             fprintf(stdout, "%s\n", bsRight.getToken(i, '\n').getStr());
     169             :         }
     170             :         fprintf(stdout, "%s", OUStringToOString(aHelpMessage_bottom,
     171           0 :                     RTL_TEXTENCODING_ASCII_US).getStr());
     172             : #else
     173             :         // rest gets a dialog box
     174             :         CmdlineHelpDialog aDlg;
     175             :         aDlg.m_pftHead->SetText(aHelpMessage_version + aHelpMessage_head);
     176             :         aDlg.m_pftLeft->SetText(aHelpMessage_left);
     177             :         aDlg.m_pftRight->SetText(aHelpMessage_right);
     178             :         aDlg.m_pftBottom->SetText(aHelpMessage_bottom);
     179             :         aDlg.Execute();
     180             : #endif
     181           0 :     }
     182             : 
     183           0 :     void displayVersion()
     184             :     {
     185           0 :         OUString aVersionMsg(aCmdLineHelp_version);
     186           0 :         aVersionMsg = ReplaceStringHookProc(aVersionMsg);
     187             : #ifdef UNX
     188           0 :         fprintf(stdout, "%s", OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
     189             : #else
     190             :         // Just re-use the help dialog for now.
     191             :         CmdlineHelpDialog aDlg;
     192             :         aDlg.m_pftHead->SetText(aVersionMsg);
     193             :         aDlg.m_pftLeft->SetText("");
     194             :         aDlg.m_pftRight->SetText("");
     195             :         aDlg.m_pftBottom->SetText("");
     196             :         aDlg.Execute();
     197             : #endif
     198           0 :     }
     199             : 
     200             : #ifndef UNX
     201             :     CmdlineHelpDialog::CmdlineHelpDialog()
     202             :     : ModalDialog( NULL, "CmdLineHelp", "desktop/ui/cmdlinehelp.ui" )
     203             :     {
     204             :         get(m_pftHead, "header");
     205             :         get(m_pftLeft, "left");
     206             :         get(m_pftRight, "right");
     207             :         get(m_pftBottom, "bottom");
     208             :     }
     209             : #endif
     210         348 : }
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11