Kaydet (Commit) 810b8a14 authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Thorsten Behrens

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: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst d3b505c3
...@@ -196,9 +196,6 @@ The current presentation contains no OLE objects.</value> ...@@ -196,9 +196,6 @@ The current presentation contains no OLE objects.</value>
<prop oor:name="STR_FILESIZESEPARATOR"> <prop oor:name="STR_FILESIZESEPARATOR">
<value xml:lang="en-US">.</value> <value xml:lang="en-US">.</value>
</prop> </prop>
<prop oor:name="STR_ERROR_IO">
<value xml:lang="en-US">Writing output file failed.</value>
</prop>
</node> </node>
<node oor:name="LastUsedSettings"> <node oor:name="LastUsedSettings">
<prop oor:name="Name"> <prop oor:name="Name">
......
...@@ -361,10 +361,6 @@ The current presentation contains no OLE objects.</value> ...@@ -361,10 +361,6 @@ The current presentation contains no OLE objects.</value>
<info><desc>String STR_FILESIZESEPARATOR.</desc></info> <info><desc>String STR_FILESIZESEPARATOR.</desc></info>
<value>.</value> <value>.</value>
</prop> </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> </group>
<node-ref oor:name="LastUsedSettings" oor:node-type="OptimizerSettings"> <node-ref oor:name="LastUsedSettings" oor:node-type="OptimizerSettings">
<info> <info>
......
...@@ -33,6 +33,9 @@ $(eval $(call gb_Library_use_libraries,PresentationMinimizer,\ ...@@ -33,6 +33,9 @@ $(eval $(call gb_Library_use_libraries,PresentationMinimizer,\
cppu \ cppu \
cppuhelper \ cppuhelper \
sal \ sal \
sfx \
svt \
vcl \
tl \ tl \
)) ))
...@@ -51,7 +54,6 @@ $(eval $(call gb_Library_add_exception_objects,PresentationMinimizer,\ ...@@ -51,7 +54,6 @@ $(eval $(call gb_Library_add_exception_objects,PresentationMinimizer,\
sdext/source/minimizer/pppoptimizertoken \ sdext/source/minimizer/pppoptimizertoken \
sdext/source/minimizer/pppoptimizeruno \ sdext/source/minimizer/pppoptimizeruno \
sdext/source/minimizer/unodialog \ sdext/source/minimizer/unodialog \
sdext/source/minimizer/errordialog \
)) ))
# vim:set noet sw=4 ts=4: # vim:set noet sw=4 ts=4:
/* -*- 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: */
/* -*- 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: */
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "optimizerdialog.hxx" #include "optimizerdialog.hxx"
#include "impoptimizer.hxx" #include "impoptimizer.hxx"
#include "fileopendialog.hxx" #include "fileopendialog.hxx"
#include "errordialog.hxx"
#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
...@@ -30,6 +29,9 @@ ...@@ -30,6 +29,9 @@
#include <com/sun/star/util/XCloseBroadcaster.hpp> #include <com/sun/star/util/XCloseBroadcaster.hpp>
#include <sal/macros.h> #include <sal/macros.h>
#include <osl/time.h> #include <osl/time.h>
#include <vcl/errinf.hxx>
#include <svtools/sfxecode.hxx>
#include <svtools/ehdl.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <bitmaps.hlst> #include <bitmaps.hlst>
...@@ -568,6 +570,8 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent ) ...@@ -568,6 +570,8 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent )
lArguments[ 2 ].Name = "InformationDialog"; lArguments[ 2 ].Name = "InformationDialog";
lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame(); lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame();
ErrCode errorCode;
try try
{ {
ImpOptimizer aOptimizer( ImpOptimizer aOptimizer(
...@@ -577,15 +581,30 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent ) ...@@ -577,15 +581,30 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent )
} }
catch (css::io::IOException&) 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("btnNavBack", "Enabled", Any(true));
mrOptimizerDialog.setControlProperty("btnNavNext", "Enabled", Any(false)); mrOptimizerDialog.setControlProperty("btnNavNext", "Enabled", Any(false));
mrOptimizerDialog.setControlProperty("btnNavFinish", "Enabled", Any(true)); mrOptimizerDialog.setControlProperty("btnNavFinish", "Enabled", Any(true));
mrOptimizerDialog.setControlProperty("btnNavCancel", "Enabled", Any(true)); mrOptimizerDialog.setControlProperty("btnNavCancel", "Enabled", Any(true));
ErrorDialog aInformationDialog(
mrOptimizerDialog.UnoDialog::mxContext, mrOptimizerDialog.GetFrame(), OUString aFileName;
mrOptimizerDialog.getString(STR_ERROR_IO)); mrOptimizerDialog.GetConfigProperty(TK_SaveAsURL) >>= aFileName;
aInformationDialog.execute(); SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, aFileName);
ErrorHandler::HandleError(errorCode);
break; break;
} }
......
...@@ -152,7 +152,6 @@ static const TokenTable pTokenTableArray[] = ...@@ -152,7 +152,6 @@ static const TokenTable pTokenTableArray[] =
{ "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS }, { "STR_OPTIMIZING_GRAPHICS", STR_OPTIMIZING_GRAPHICS },
{ "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS }, { "STR_CREATING_OLE_REPLACEMENTS",STR_CREATING_OLE_REPLACEMENTS },
{ "STR_FileSizeSeparator", STR_FILESIZESEPARATOR }, { "STR_FileSizeSeparator", STR_FILESIZESEPARATOR },
{ "STR_ERROR_IO", STR_ERROR_IO },
{ "NotFound", TK_NotFound } { "NotFound", TK_NotFound }
}; };
......
...@@ -135,7 +135,6 @@ enum PPPOptimizerTokenEnum ...@@ -135,7 +135,6 @@ enum PPPOptimizerTokenEnum
STR_OPTIMIZING_GRAPHICS, STR_OPTIMIZING_GRAPHICS,
STR_CREATING_OLE_REPLACEMENTS, STR_CREATING_OLE_REPLACEMENTS,
STR_FILESIZESEPARATOR, STR_FILESIZESEPARATOR,
STR_ERROR_IO,
TK_NotFound TK_NotFound
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment