summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2016-11-22 02:59:29 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2016-11-23 16:47:39 +0000
commit24a24e65cafffe137d76de0a6eb5270ea88ebffd (patch)
treecf8c2745ae0fd2555c5ae7c4489c7043fff9d2f2 /desktop
parent4be1a9f9797fece0de236d26d10246853b4df850 (diff)
tdf#100826: use console for -h and --version also on Windows
This removes the dialog used to show version information and command line help on Windows. Now, selecting and scrolling becomes possible, code is simplified and unified under all platforms. Change-Id: Ia749bbb62d697eff655b3a646859c1986a023ec0 Reviewed-on: https://gerrit.libreoffice.org/31059 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/UIConfig_deployment.mk1
-rw-r--r--desktop/qa/unit/data/desktop-dialogs-test.txt1
-rw-r--r--desktop/source/app/cmdlinehelp.cxx310
-rw-r--r--desktop/source/app/cmdlinehelp.hxx21
-rw-r--r--desktop/uiconfig/ui/cmdlinehelp.ui137
5 files changed, 133 insertions, 337 deletions
diff --git a/desktop/UIConfig_deployment.mk b/desktop/UIConfig_deployment.mk
index d5cb72c10910..a1e08c8b599b 100644
--- a/desktop/UIConfig_deployment.mk
+++ b/desktop/UIConfig_deployment.mk
@@ -10,7 +10,6 @@
$(eval $(call gb_UIConfig_UIConfig,desktop))
$(eval $(call gb_UIConfig_add_uifiles,desktop,\
- desktop/uiconfig/ui/cmdlinehelp \
desktop/uiconfig/ui/dependenciesdialog \
desktop/uiconfig/ui/extensionmanager \
desktop/uiconfig/ui/installforalldialog \
diff --git a/desktop/qa/unit/data/desktop-dialogs-test.txt b/desktop/qa/unit/data/desktop-dialogs-test.txt
index b07bff10578e..cdcf9227fc5a 100644
--- a/desktop/qa/unit/data/desktop-dialogs-test.txt
+++ b/desktop/qa/unit/data/desktop-dialogs-test.txt
@@ -35,7 +35,6 @@
# test case since they need some document and model data to work
# desktop/ui/extensionmanager.ui
-desktop/ui/cmdlinehelp.ui
desktop/ui/dependenciesdialog.ui
desktop/ui/updaterequireddialog.ui
desktop/ui/showlicensedialog.ui
diff --git a/desktop/source/app/cmdlinehelp.cxx b/desktop/source/app/cmdlinehelp.cxx
index aaa6af9830b9..122238c9ef81 100644
--- a/desktop/source/app/cmdlinehelp.cxx
+++ b/desktop/source/app/cmdlinehelp.cxx
@@ -19,213 +19,167 @@
#include <stdlib.h>
-#ifdef UNX
#include <stdio.h>
-#endif
#include <comphelper/string.hxx>
#include <sal/types.h>
-#include <vcl/msgbox.hxx>
-#include <rtl/bootstrap.hxx>
#include <app.hxx>
-#include "desktopresid.hxx"
-#include "desktop.hrc"
#include "cmdlinehelp.hxx"
+#ifdef _WIN32
+#include "windows.h"
+#include "io.h"
+#include "Fcntl.h"
+#endif
+
namespace desktop
{
- // to be able to display the help nicely in a dialog box with proportional font,
- // we need to split it in chunks...
- // ___HEAD___
- // LEFT RIGHT
- // LEFT RIGHT
- // LEFT RIGHT
- // __BOTTOM__
- // [OK]
-
const char aCmdLineHelp_version[] =
- "%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"\
+ "%PRODUCTNAME %PRODUCTVERSION%PRODUCTEXTENSION %BUILDID\n"
"\n";
- const char aCmdLineHelp_head[] =
- "Usage: %CMDNAME [options] [documents...]\n"\
- "\n"\
- "Options:\n";
- const char aCmdLineHelp_left[] =
- "--minimized \n"\
- "--invisible \n"\
- "--norestore \n"\
- "--quickstart \n"\
- "--safe-mode \n"\
- "--nologo \n"\
- "--nolockcheck \n"\
- "--nodefault \n"\
- "--headless \n"\
- "--help/-h/-? \n"\
- "--version \n"\
- "--writer \n"\
- "--calc \n"\
- "--draw \n"\
- "--impress \n"\
- "--base \n"\
- "--math \n"\
- "--global \n"\
- "--web \n"\
- "-o \n"\
- "-n \n";
- const char aCmdLineHelp_right[] =
- "keep startup bitmap minimized.\n"\
- "no startup screen, no default document and no UI.\n"\
- "suppress restart/restore after fatal errors.\n"\
- "starts the quickstart service\n"\
- "starts the safe mode\n"\
- "don't show startup screen.\n"\
- "don't check for remote instances using the installation\n"\
- "don't start with an empty document\n"\
- "like invisible but no user interaction at all.\n"\
- "show this message and exit.\n"\
- "display the version information.\n"\
- "create new text document.\n"\
- "create new spreadsheet document.\n"\
- "create new drawing.\n"\
- "create new presentation.\n"\
- "create new database.\n"\
- "create new formula.\n"\
- "create new global document.\n"\
- "create new HTML document.\n"\
- "open documents regardless whether they are templates or not.\n"\
- "always open documents as new files (use as template).\n";
- const char aCmdLineHelp_bottom[] =
- "--display <display>\n"\
+ const char aCmdLineHelp[] =
+ "Usage: %CMDNAME [options] [documents...]\n"
+ "\n"
+ "Options:\n"
+ "--minimized keep startup bitmap minimized.\n"
+ "--invisible no startup screen, no default document and no UI.\n"
+ "--norestore suppress restart/restore after fatal errors.\n"
+ "--quickstart starts the quickstart service\n"
+ "--safe-mode starts the safe mode\n"
+ "--nologo don't show startup screen.\n"
+ "--nolockcheck don't check for remote instances using the installation\n"
+ "--nodefault don't start with an empty document\n"
+ "--headless like invisible but no user interaction at all.\n"
+ "--help/-h/-? show this message and exit.\n"
+ "--version display the version information.\n"
+ "--writer create new text document.\n"
+ "--calc create new spreadsheet document.\n"
+ "--draw create new drawing.\n"
+ "--impress create new presentation.\n"
+ "--base create new database.\n"
+ "--math create new formula.\n"
+ "--global create new global document.\n"
+ "--web create new HTML document.\n"
+ "-o open documents regardless whether they are templates or not.\n"
+ "-n always open documents as new files (use as template).\n"
+ "--display <display>\n"
" Specify X-Display to use in Unix/X11 versions.\n"
- "-p <documents...>\n"\
- " print the specified documents on the default printer.\n"\
- "--pt <printer> <documents...>\n"\
- " print the specified documents on the specified printer.\n"\
- "--view <documents...>\n"\
- " open the specified documents in viewer-(readonly-)mode.\n"\
- "--show <presentation>\n"\
- " open the specified presentation and start it immediately\n"\
- "--language=<language_tag>\n"\
- " Override the UI language with the given locale\n"\
- " Eg. --language=fr\n"\
- "--accept=<accept-string>\n"\
- " Specify an UNO connect-string to create an UNO acceptor through which\n"\
- " other programs can connect to access the API\n"\
- "--unaccept=<accept-string>\n"\
- " Close an acceptor that was created with --accept=<accept-string>\n"\
- " Use --unnaccept=all to close all open acceptors\n"\
- "--infilter=<filter>[:filter_options]\n"\
- " Force an input filter type if possible\n"\
- " Eg. --infilter=\"Calc Office Open XML\"\n"\
- " --infilter=\"Text (encoded):UTF8,LF,,,\"\n"\
- "--convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files\n"\
- " Batch convert files (implies --headless).\n"\
- " If --outdir is not specified then current working dir is used as output_dir.\n"\
- " Eg. --convert-to pdf *.doc\n"\
- " --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc\n"\
- " --convert-to \"html:XHTML Writer File:UTF8\" *.doc\n"\
- " --convert-to \"txt:Text (encoded):UTF8\" *.doc\n"\
- "--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"\
- " Batch print files to file.\n"\
- " If --outdir is not specified then current working dir is used as output_dir.\n"\
- " Eg. --print-to-file *.doc\n"\
- " --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\n" \
- "--cat files\n"\
- " Dump text content of the files to console\n"\
- " Eg. --cat *.odt\n"\
- "--pidfile=file\n"\
- " Store soffice.bin pid to file.\n"\
- "-env:<VAR>[=<VALUE>]\n"\
- " Set a bootstrap variable.\n"\
- " Eg. -env:UserInstallation=file:///tmp/test to set a non-default user profile path.\n"\
+ "-p <documents...>\n"
+ " print the specified documents on the default printer.\n"
+ "--pt <printer> <documents...>\n"
+ " print the specified documents on the specified printer.\n"
+ "--view <documents...>\n"
+ " open the specified documents in viewer-(readonly-)mode.\n"
+ "--show <presentation>\n"
+ " open the specified presentation and start it immediately\n"
+ "--language=<language_tag>\n"
+ " Override the UI language with the given locale\n"
+ " Eg. --language=fr\n"
+ "--accept=<accept-string>\n"
+ " Specify an UNO connect-string to create an UNO acceptor through which\n"
+ " other programs can connect to access the API\n"
+ "--unaccept=<accept-string>\n"
+ " Close an acceptor that was created with --accept=<accept-string>\n"
+ " Use --unnaccept=all to close all open acceptors\n"
+ "--infilter=<filter>[:filter_options]\n"
+ " Force an input filter type if possible\n"
+ " Eg. --infilter=\"Calc Office Open XML\"\n"
+ " --infilter=\"Text (encoded):UTF8,LF,,,\"\n"
+ "--convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files\n"
+ " Batch convert files (implies --headless).\n"
+ " If --outdir is not specified then current working dir is used as output_dir.\n"
+ " Eg. --convert-to pdf *.doc\n"
+ " --convert-to pdf:writer_pdf_Export --outdir /home/user *.doc\n"
+ " --convert-to \"html:XHTML Writer File:UTF8\" *.doc\n"
+ " --convert-to \"txt:Text (encoded):UTF8\" *.doc\n"
+ "--print-to-file [-printer-name printer_name] [--outdir output_dir] files\n"
+ " Batch print files to file.\n"
+ " If --outdir is not specified then current working dir is used as output_dir.\n"
+ " Eg. --print-to-file *.doc\n"
+ " --print-to-file --printer-name nasty_lowres_printer --outdir /home/user *.doc\n"
+ "--cat files\n"
+ " Dump text content of the files to console\n"
+ " Eg. --cat *.odt\n"
+ "--pidfile=file\n"
+ " Store soffice.bin pid to file.\n"
+ "-env:<VAR>[=<VALUE>]\n"
+ " Set a bootstrap variable.\n"
+ " Eg. -env:UserInstallation=file:///tmp/test to set a non-default user profile path.\n"
"\nRemaining arguments will be treated as filenames or URLs of documents to open.\n\n";
+#ifdef _WIN32
+ namespace{
+ class lcl_Console {
+ public:
+ explicit lcl_Console(short nBufHeight)
+ {
+ bFreeConsole = AllocConsole() != FALSE;
+ CONSOLE_SCREEN_BUFFER_INFO cinfo;
+ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cinfo);
+ cinfo.dwSize.Y = nBufHeight;
+ SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), cinfo.dwSize);
+ // stdin
+ intptr_t stdHandle = reinterpret_cast<intptr_t>(GetStdHandle(STD_INPUT_HANDLE));
+ int fileHandle = _open_osfhandle(stdHandle, _O_TEXT);
+ FILE *fp = _fdopen(fileHandle, "r");
+ *stdin = *fp;
+ setvbuf(stdin, NULL, _IONBF, 0);
+ // stdout
+ stdHandle = reinterpret_cast<intptr_t>(GetStdHandle(STD_OUTPUT_HANDLE));
+ fileHandle = _open_osfhandle(stdHandle, _O_TEXT);
+ fp = _fdopen(fileHandle, "w");
+ *stdout = *fp;
+ setvbuf(stdout, NULL, _IONBF, 0);
+ // stderr
+ stdHandle = reinterpret_cast<intptr_t>(GetStdHandle(STD_ERROR_HANDLE));
+ fileHandle = _open_osfhandle(stdHandle, _O_TEXT);
+ fp = _fdopen(fileHandle, "w");
+ *stderr = *fp;
+ setvbuf(stderr, NULL, _IONBF, 0);
+ }
+
+ ~lcl_Console()
+ {
+ if (bFreeConsole)
+ {
+ fprintf(stdout, "Press Enter to close this console...");
+ fgetc(stdin);
+ FreeConsole();
+ }
+ }
+ private:
+ bool bFreeConsole;
+ };
+ }
+#endif
+
void displayCmdlineHelp(OUString const & unknown)
{
- // if you put variables in other chunks don't forget to call the replace routines
- // for those chunks...
- OUString aHelpMessage_version(aCmdLineHelp_version);
- OUString aHelpMessage_head(aCmdLineHelp_head);
- OUString aHelpMessage_left(aCmdLineHelp_left);
- OUString aHelpMessage_right(aCmdLineHelp_right);
- OUString aHelpMessage_bottom(aCmdLineHelp_bottom);
- aHelpMessage_version = ReplaceStringHookProc(aHelpMessage_version);
- aHelpMessage_head = aHelpMessage_head.replaceFirst( "%CMDNAME", "soffice" );
+ OUString aHelpMessage_version = ReplaceStringHookProc(aCmdLineHelp_version);
+ OUString aHelpMessage(OUString(aCmdLineHelp).replaceFirst("%CMDNAME", "soffice"));
if (!unknown.isEmpty())
{
- aHelpMessage_head = "Error in option: " + unknown + "\n\n"
- + aHelpMessage_head;
+ aHelpMessage = "Error in option: " + unknown + "\n\n"
+ + aHelpMessage;
}
-#ifdef UNX
- // on unix use console for output
+#ifdef _WIN32
+ sal_Int32 n = comphelper::string::getTokenCount(aHelpMessage, '\n');
+ lcl_Console aConsole(short(n*2));
+#endif
fprintf(stdout, "%s%s",
OUStringToOString(aHelpMessage_version, RTL_TEXTENCODING_ASCII_US).getStr(),
- OUStringToOString(aHelpMessage_head, RTL_TEXTENCODING_ASCII_US).getStr());
- // merge left and right column
- sal_Int32 n = comphelper::string::getTokenCount(aHelpMessage_left, '\n');
- OString bsLeft(OUStringToOString(aHelpMessage_left,
- RTL_TEXTENCODING_ASCII_US));
- OString bsRight(OUStringToOString(aHelpMessage_right,
- RTL_TEXTENCODING_ASCII_US));
- for ( sal_Int32 i = 0; i < n; ++i )
- {
- fprintf(stdout, "%s", bsLeft.getToken(i, '\n').getStr());
- fprintf(stdout, "%s\n", bsRight.getToken(i, '\n').getStr());
- }
- fprintf(stdout, "%s", OUStringToOString(aHelpMessage_bottom,
- RTL_TEXTENCODING_ASCII_US).getStr());
-#else
- // rest gets a dialog box
- ScopedVclPtrInstance<CmdlineHelpDialog> aDlg;
- aDlg->m_pftHead->SetText(aHelpMessage_version + aHelpMessage_head);
- aDlg->m_pftLeft->SetText(aHelpMessage_left);
- aDlg->m_pftRight->SetText(aHelpMessage_right);
- aDlg->m_pftBottom->SetText(aHelpMessage_bottom);
- aDlg->Execute();
-#endif
+ OUStringToOString(aHelpMessage, RTL_TEXTENCODING_ASCII_US).getStr());
}
void displayVersion()
{
OUString aVersionMsg(aCmdLineHelp_version);
aVersionMsg = ReplaceStringHookProc(aVersionMsg);
-#ifdef UNX
- fprintf(stdout, "%s", OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
-#else
- // Just re-use the help dialog for now.
- ScopedVclPtrInstance<CmdlineHelpDialog> aDlg;
- aDlg->m_pftHead->SetText(aVersionMsg);
- aDlg->m_pftLeft->SetText("");
- aDlg->m_pftRight->SetText("");
- aDlg->m_pftBottom->SetText("");
- aDlg->Execute();
+#ifdef _WIN32
+ lcl_Console aConsole(short(10));
#endif
+ fprintf(stdout, "%s", OUStringToOString(aVersionMsg, RTL_TEXTENCODING_ASCII_US).getStr());
}
-
-#ifndef UNX
- CmdlineHelpDialog::CmdlineHelpDialog()
- : ModalDialog( nullptr, "CmdLineHelp", "desktop/ui/cmdlinehelp.ui" )
- {
- get(m_pftHead, "header");
- get(m_pftLeft, "left");
- get(m_pftRight, "right");
- get(m_pftBottom, "bottom");
- }
-
- CmdlineHelpDialog::~CmdlineHelpDialog()
- {
- disposeOnce();
- }
-
- void CmdlineHelpDialog::dispose()
- {
- m_pftHead.disposeAndClear();
- m_pftLeft.disposeAndClear();
- m_pftRight.disposeAndClear();
- m_pftBottom.disposeAndClear();
- ModalDialog::dispose();
- }
-#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/source/app/cmdlinehelp.hxx b/desktop/source/app/cmdlinehelp.hxx
index cbf1da41c35a..e1a15360545a 100644
--- a/desktop/source/app/cmdlinehelp.hxx
+++ b/desktop/source/app/cmdlinehelp.hxx
@@ -20,31 +20,12 @@
#ifndef INCLUDED_DESKTOP_SOURCE_APP_CMDLINEHELP_HXX
#define INCLUDED_DESKTOP_SOURCE_APP_CMDLINEHELP_HXX
-#include <vcl/dialog.hxx>
-#include <vcl/fixed.hxx>
-#include <vcl/button.hxx>
+#include <rtl/ustring.hxx>
namespace desktop
{
void displayCmdlineHelp( OUString const & unknown );
void displayVersion();
-#ifndef UNX
- class CmdlineHelpDialog : public ModalDialog
- {
- public:
- CmdlineHelpDialog();
-
- ~CmdlineHelpDialog() override;
-
- VclPtr<FixedText> m_pftHead;
- VclPtr<FixedText> m_pftLeft;
- VclPtr<FixedText> m_pftRight;
- VclPtr<FixedText> m_pftBottom;
-
- private:
- void dispose() override;
- };
-#endif
}
#endif
diff --git a/desktop/uiconfig/ui/cmdlinehelp.ui b/desktop/uiconfig/ui/cmdlinehelp.ui
deleted file mode 100644
index 62c61ac47c23..000000000000
--- a/desktop/uiconfig/ui/cmdlinehelp.ui
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<interface>
- <!-- interface-requires gtk+ 3.0 -->
- <object class="GtkDialog" id="CmdLineHelp">
- <property name="can_focus">False</property>
- <property name="border_width">6</property>
- <property name="title" translatable="yes">Help Message</property>
- <property name="destroy_with_parent">True</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkBox" id="box1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel" id="header">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <property name="xpad">10</property>
- <property name="label" translatable="no">HEADER</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="grid1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <child>
- <object class="GtkLabel" id="left">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <property name="xpad">10</property>
- <property name="label" translatable="no">LEFT</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="right">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <property name="xpad">10</property>
- <property name="label" translatable="no">RIGHT</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="bottom">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="xalign">0</property>
- <property name="xpad">10</property>
- <property name="label" translatable="no">BOTTOM</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="layout_style">center</property>
- <child>
- <object class="GtkButton" id="button1">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="halign">center</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="0">button1</action-widget>
- </action-widgets>
- </object>
-</interface>