LCOV - code coverage report
Current view: top level - desktop/source/app - cmdlinehelp.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 25 0.0 %
Date: 2014-04-14 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 <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 userinteraction 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>\n"\
     113             :         "      Force an input filter type if possible\n"\
     114             :         "      Eg. --infilter=\"Calc Office Open XML\"\n"\
     115             :         "--convert-to output_file_extension[:output_filter_name] [--outdir output_dir] files\n"\
     116             :         "      Batch convert files.\n"\
     117             :         "      If --outdir is not specified then current working dir is used as output_dir.\n"\
     118             :         "      Eg. --convert-to pdf *.doc\n"\
     119             :         "          --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc\n"\
     120             :         "--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"\
     121             :         "      Batch print files to file.\n"\
     122             :         "      If --outdir is not specified then current working dir is used as output_dir.\n"\
     123             :         "      Eg. --print-to-file *.doc\n"\
     124             :         "          --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\n"\
     125             :         "--pidfile file\n"\
     126             :         "      Store soffice.bin pid to file.\n"\
     127             :         "-env:<VAR>[=<VALUE>]\n"\
     128             :         "      Set a bootstrap variable.\n"\
     129             :         "      Eg. -env:UserInstallation=file:///tmp/test to set a non-default user profile path.\n"\
     130             :         "\nRemaining arguments will be treated as filenames or URLs of documents to open.\n\n";
     131             : 
     132             :     OUString ReplaceStringHookProc(const OUString& rStr);
     133             : 
     134           0 :     void displayCmdlineHelp(OUString const & unknown)
     135             :     {
     136             :         // if you put variables in other chunks don't forget to call the replace routines
     137             :         // for those chunks...
     138           0 :         OUString aHelpMessage_version = OUString::createFromAscii(aCmdLineHelp_version);
     139           0 :         OUString aHelpMessage_head = OUString::createFromAscii(aCmdLineHelp_head);
     140           0 :         OUString aHelpMessage_left = OUString::createFromAscii(aCmdLineHelp_left);
     141           0 :         OUString aHelpMessage_right = OUString::createFromAscii(aCmdLineHelp_right);
     142           0 :         OUString aHelpMessage_bottom = OUString::createFromAscii(aCmdLineHelp_bottom);
     143           0 :         aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version);
     144           0 :         aHelpMessage_head = aHelpMessage_head.replaceFirst( "%CMDNAME", "soffice" );
     145           0 :         if (!unknown.isEmpty())
     146             :         {
     147           0 :             aHelpMessage_head = "Unknown option: " + unknown + "\n\n"
     148           0 :                 + aHelpMessage_head;
     149             :         }
     150             : #ifdef UNX
     151             :         // on unix use console for output
     152             :         fprintf(stdout, "%s%s",
     153             :                 OUStringToOString(aHelpMessage_version, RTL_TEXTENCODING_ASCII_US).getStr(),
     154           0 :                 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             :         OString bsLeft(OUStringToOString(aHelpMessage_left,
     158           0 :             RTL_TEXTENCODING_ASCII_US));
     159             :         OString bsRight(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", OUStringToOString(aHelpMessage_bottom,
     168           0 :                     RTL_TEXTENCODING_ASCII_US).getStr());
     169             : #else
     170             :         // rest gets a dialog box
     171             :         CmdlineHelpDialog aDlg;
     172             :         aDlg.m_pftHead->SetText(aHelpMessage_version + aHelpMessage_head);
     173             :         aDlg.m_pftLeft->SetText(aHelpMessage_left);
     174             :         aDlg.m_pftRight->SetText(aHelpMessage_right);
     175             :         aDlg.m_pftBottom->SetText(aHelpMessage_bottom);
     176             :         aDlg.Execute();
     177             : #endif
     178           0 :     }
     179             : 
     180           0 :     void displayVersion()
     181             :     {
     182           0 :         OUString aVersionMsg(aCmdLineHelp_version);
     183           0 :         aVersionMsg = ReplaceStringHookProc(aVersionMsg);
     184             : #ifdef UNX
     185           0 :         fprintf(stdout, "%s", OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
     186             : #else
     187             :         // Just re-use the help dialog for now.
     188             :         CmdlineHelpDialog aDlg;
     189             :         aDlg.m_pftHead->SetText(aVersionMsg);
     190             :         aDlg.m_pftLeft->SetText("");
     191             :         aDlg.m_pftRight->SetText("");
     192             :         aDlg.m_pftBottom->SetText("");
     193             :         aDlg.Execute();
     194             : #endif
     195           0 :     }
     196             : 
     197             : #ifndef UNX
     198             :     CmdlineHelpDialog::CmdlineHelpDialog (void)
     199             :     : ModalDialog( NULL, "CmdLineHelp", "desktop/ui/cmdlinehelp.ui" )
     200             :     {
     201             :         get(m_pftHead, "header");
     202             :         get(m_pftLeft, "left");
     203             :         get(m_pftRight, "right");
     204             :         get(m_pftBottom, "bottom");
     205             :     }
     206             : #endif
     207             : }
     208             : 
     209             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10