From 810b8a14f6d555eb9be0da8c69d67c9a390dcca6 Mon Sep 17 00:00:00 2001 From: Vasily Melenchuk Date: Fri, 2 Nov 2018 11:20:14 +0100 Subject: presentation minimizer: use standard error reporting Insead of custom error dialogs try to use standard LO error reporting & localization Change-Id: I199c7770dd884a6c5d9b22075d22ab9a9f2037a8 Reviewed-on: https://gerrit.libreoffice.org/62779 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- .../openoffice/Office/PresentationMinimizer.xcu | 3 - .../openoffice/Office/PresentationMinimizer.xcs | 4 - sdext/Library_PresentationMinimizer.mk | 4 +- sdext/source/minimizer/errordialog.cxx | 96 ---------------------- sdext/source/minimizer/errordialog.hxx | 56 ------------- sdext/source/minimizer/optimizerdialog.cxx | 31 +++++-- sdext/source/minimizer/pppoptimizertoken.cxx | 1 - sdext/source/minimizer/pppoptimizertoken.hxx | 1 - 8 files changed, 28 insertions(+), 168 deletions(-) delete mode 100644 sdext/source/minimizer/errordialog.cxx delete mode 100644 sdext/source/minimizer/errordialog.hxx diff --git a/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu b/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu index 5e0b723cf53d..1a2bbe315267 100644 --- a/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu +++ b/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu @@ -196,9 +196,6 @@ The current presentation contains no OLE objects. . - - Writing output file failed. - diff --git a/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs b/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs index b74cf38d883e..5a9758139b1f 100644 --- a/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs @@ -361,10 +361,6 @@ The current presentation contains no OLE objects. String STR_FILESIZESEPARATOR. . - - String STR_ERROR_IO. - Writing output file failed. - diff --git a/sdext/Library_PresentationMinimizer.mk b/sdext/Library_PresentationMinimizer.mk index 884d4ee7310e..c1f2a00a49b5 100644 --- a/sdext/Library_PresentationMinimizer.mk +++ b/sdext/Library_PresentationMinimizer.mk @@ -33,6 +33,9 @@ $(eval $(call gb_Library_use_libraries,PresentationMinimizer,\ cppu \ cppuhelper \ sal \ + sfx \ + svt \ + vcl \ tl \ )) @@ -51,7 +54,6 @@ $(eval $(call gb_Library_add_exception_objects,PresentationMinimizer,\ sdext/source/minimizer/pppoptimizertoken \ sdext/source/minimizer/pppoptimizeruno \ sdext/source/minimizer/unodialog \ - sdext/source/minimizer/errordialog \ )) # vim:set noet sw=4 ts=4: diff --git a/sdext/source/minimizer/errordialog.cxx b/sdext/source/minimizer/errordialog.cxx deleted file mode 100644 index d4b67675069b..000000000000 --- a/sdext/source/minimizer/errordialog.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "errordialog.hxx" -#include "informationdialog.hxx" -#include "optimizationstats.hxx" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DIALOG_WIDTH 240 -#define DIALOG_HEIGHT 60 -#define PAGE_POS_X 35 -#define PAGE_WIDTH (DIALOG_WIDTH - PAGE_POS_X) - 6 - -using namespace ::com::sun::star; -using namespace ::com::sun::star::io; -using namespace ::com::sun::star::ui; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; - -void ErrorDialog::InitDialog() -{ - // setting the dialog properties - OUString pNames[] - = { OUString("Closeable"), OUString("Height"), OUString("Moveable"), OUString("PositionX"), - OUString("PositionY"), OUString("Title"), OUString("Width") }; - - Any pValues[] = { Any(true), - Any(sal_Int32(DIALOG_HEIGHT)), - Any(true), - Any(sal_Int32(245)), - Any(sal_Int32(115)), - Any(getString(STR_SUN_OPTIMIZATION_WIZARD2)), - Any(sal_Int32(DIALOG_WIDTH)) }; - - sal_Int32 nCount = SAL_N_ELEMENTS(pNames); - - Sequence aNames(pNames, nCount); - Sequence aValues(pValues, nCount); - - mxDialogModelMultiPropertySet->setPropertyValues(aNames, aValues); - - css::uno::Reference xItemListener; - InsertImage(*this, "aboutimage", "private:standardimage/error", 5, 5, 25, 25, false); - InsertFixedText(*this, "fixedtext", maText, PAGE_POS_X, 6, PAGE_WIDTH, 24, true, 0); - InsertButton(*this, "button", mxActionListener, DIALOG_WIDTH / 2 - 25, DIALOG_HEIGHT - 20, 50, - 2, getString(STR_OK)); -} - -ErrorDialog::ErrorDialog(const Reference& rxContext, - Reference const& rxFrame, const OUString& rText) - : UnoDialog(rxContext, rxFrame) - , ConfigurationAccess(rxContext) - , mxActionListener(new OKActionListener(*this)) - , maText(rText) -{ - Reference xFrame(mxController->getFrame()); - Reference xContainerWindow(xFrame->getContainerWindow()); - Reference xWindowPeer(xContainerWindow, UNO_QUERY_THROW); - createWindowPeer(xWindowPeer); - - InitDialog(); -} - -ErrorDialog::~ErrorDialog() {} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sdext/source/minimizer/errordialog.hxx b/sdext/source/minimizer/errordialog.hxx deleted file mode 100644 index cc2eecb34d43..000000000000 --- a/sdext/source/minimizer/errordialog.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SDEXT_SOURCE_MINIMIZER_ERRORDIALOG_HXX -#define INCLUDED_SDEXT_SOURCE_MINIMIZER_ERRORDIALOG_HXX - -#include "unodialog.hxx" -#include "configurationaccess.hxx" -#include "pppoptimizertoken.hxx" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class ErrorDialog : public UnoDialog, public ConfigurationAccess -{ -public: - ErrorDialog(const css::uno::Reference& rxContext, - css::uno::Reference const& rxFrame, const OUString& rText); - ~ErrorDialog(); - -private: - css::uno::Reference mxActionListener; - - void InitDialog(); - - const OUString& maText; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx index 62b364345674..17eb90630715 100644 --- a/sdext/source/minimizer/optimizerdialog.cxx +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -21,7 +21,6 @@ #include "optimizerdialog.hxx" #include "impoptimizer.hxx" #include "fileopendialog.hxx" -#include "errordialog.hxx" #include #include #include @@ -30,6 +29,9 @@ #include #include #include +#include +#include +#include #include #include @@ -568,6 +570,8 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent ) lArguments[ 2 ].Name = "InformationDialog"; lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame(); + + ErrCode errorCode; try { ImpOptimizer aOptimizer( @@ -577,15 +581,30 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent ) } catch (css::io::IOException&) { - mrOptimizerDialog.maStats.SetStatusValue(TK_Progress, Any(static_cast(0))); + // We always receive just ERRCODE_IO_CANTWRITE in case of problems, so no need to bother + // about extracting error code from exception text + errorCode = ERRCODE_IO_CANTWRITE; + } + catch (css::uno::Exception&) + { + // Other general exception + errorCode = ERRCODE_IO_GENERAL; + } + + if (errorCode != ERRCODE_NONE) + { + // Restore wizard controls + mrOptimizerDialog.maStats.SetStatusValue(TK_Progress, + Any(static_cast(0))); mrOptimizerDialog.setControlProperty("btnNavBack", "Enabled", Any(true)); mrOptimizerDialog.setControlProperty("btnNavNext", "Enabled", Any(false)); mrOptimizerDialog.setControlProperty("btnNavFinish", "Enabled", Any(true)); mrOptimizerDialog.setControlProperty("btnNavCancel", "Enabled", Any(true)); - ErrorDialog aInformationDialog( - mrOptimizerDialog.UnoDialog::mxContext, mrOptimizerDialog.GetFrame(), - mrOptimizerDialog.getString(STR_ERROR_IO)); - aInformationDialog.execute(); + + OUString aFileName; + mrOptimizerDialog.GetConfigProperty(TK_SaveAsURL) >>= aFileName; + SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, aFileName); + ErrorHandler::HandleError(errorCode); break; } diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx index 08784c34460d..8ad7bba53ce1 100644 --- a/sdext/source/minimizer/pppoptimizertoken.cxx +++ b/sdext/source/minimizer/pppoptimizertoken.cxx @@ -152,7 +152,6 @@ static const TokenTable pTokenTableArray[] = { "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS }, { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS }, { "STR_FileSizeSeparator", STR_FILESIZESEPARATOR }, - { "STR_ERROR_IO", STR_ERROR_IO }, { "NotFound", TK_NotFound } }; diff --git a/sdext/source/minimizer/pppoptimizertoken.hxx b/sdext/source/minimizer/pppoptimizertoken.hxx index 3562e8b0ca89..e458da0d3181 100644 --- a/sdext/source/minimizer/pppoptimizertoken.hxx +++ b/sdext/source/minimizer/pppoptimizertoken.hxx @@ -135,7 +135,6 @@ enum PPPOptimizerTokenEnum STR_OPTIMIZING_GRAPHICS, STR_CREATING_OLE_REPLACEMENTS, STR_FILESIZESEPARATOR, - STR_ERROR_IO, TK_NotFound }; -- cgit