summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2018-11-02 11:20:14 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-11-05 22:27:18 +0100
commit810b8a14f6d555eb9be0da8c69d67c9a390dcca6 (patch)
treeb0ea1bd3ad9edcf4ba90b1b7e740aea3d01f3097
parentd3b505c388537cc9a923da74b85aeeab79f3803a (diff)
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 <Thorsten.Behrens@CIB.de>
-rw-r--r--officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu3
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs4
-rw-r--r--sdext/Library_PresentationMinimizer.mk4
-rw-r--r--sdext/source/minimizer/errordialog.cxx96
-rw-r--r--sdext/source/minimizer/errordialog.hxx56
-rw-r--r--sdext/source/minimizer/optimizerdialog.cxx31
-rw-r--r--sdext/source/minimizer/pppoptimizertoken.cxx1
-rw-r--r--sdext/source/minimizer/pppoptimizertoken.hxx1
8 files changed, 28 insertions, 168 deletions
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.</value>
<prop oor:name="STR_FILESIZESEPARATOR">
<value xml:lang="en-US">.</value>
</prop>
- <prop oor:name="STR_ERROR_IO">
- <value xml:lang="en-US">Writing output file failed.</value>
- </prop>
</node>
<node oor:name="LastUsedSettings">
<prop oor:name="Name">
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.</value>
<info><desc>String STR_FILESIZESEPARATOR.</desc></info>
<value>.</value>
</prop>
- <prop oor:name="STR_ERROR_IO" oor:type="xs:string" oor:localized="true">
- <info><desc>String STR_ERROR_IO.</desc></info>
- <value>Writing output file failed.</value>
- </prop>
</group>
<node-ref oor:name="LastUsedSettings" oor:node-type="OptimizerSettings">
<info>
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 <com/sun/star/graphic/GraphicProvider.hpp>
-#include <com/sun/star/graphic/XGraphicProvider.hpp>
-#include <com/sun/star/graphic/XGraphic.hpp>
-#include <com/sun/star/io/TempFile.hpp>
-#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
-#include <com/sun/star/util/URL.hpp>
-#include <com/sun/star/util/URLTransformer.hpp>
-#include <com/sun/star/util/XURLTransformer.hpp>
-#include <rtl/ustrbuf.hxx>
-#include <sal/macros.h>
-
-#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<OUString> aNames(pNames, nCount);
- Sequence<Any> aValues(pValues, nCount);
-
- mxDialogModelMultiPropertySet->setPropertyValues(aNames, aValues);
-
- css::uno::Reference<css::awt::XItemListener> 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<XComponentContext>& rxContext,
- Reference<XFrame> const& rxFrame, const OUString& rText)
- : UnoDialog(rxContext, rxFrame)
- , ConfigurationAccess(rxContext)
- , mxActionListener(new OKActionListener(*this))
- , maText(rText)
-{
- Reference<XFrame> xFrame(mxController->getFrame());
- Reference<XWindow> xContainerWindow(xFrame->getContainerWindow());
- Reference<XWindowPeer> 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 <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/awt/XItemListener.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/text/XTextRange.hpp>
-#include <com/sun/star/drawing/XShapes.hpp>
-#include <com/sun/star/container/XIndexAccess.hpp>
-#include <com/sun/star/view/XSelectionSupplier.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/awt/XItemEventBroadcaster.hpp>
-#include <com/sun/star/awt/PushButtonType.hpp>
-#include <com/sun/star/io/XStream.hpp>
-#include <cppuhelper/implbase.hxx>
-
-class ErrorDialog : public UnoDialog, public ConfigurationAccess
-{
-public:
- ErrorDialog(const css::uno::Reference<css::uno::XComponentContext>& rxContext,
- css::uno::Reference<css::frame::XFrame> const& rxFrame, const OUString& rText);
- ~ErrorDialog();
-
-private:
- css::uno::Reference<css::awt::XActionListener> 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 <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
@@ -30,6 +29,9 @@
#include <com/sun/star/util/XCloseBroadcaster.hpp>
#include <sal/macros.h>
#include <osl/time.h>
+#include <vcl/errinf.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svtools/ehdl.hxx>
#include <tools/urlobj.hxx>
#include <bitmaps.hlst>
@@ -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<sal_Int32>(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<sal_Int32>(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
};