summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2018-08-09 15:37:00 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-08-31 13:03:47 +0200
commiteb199c1b5e8d6039a1969cc6ddb3d627bedf5bd8 (patch)
tree64d652b9d0103ac53e7f096e36d09a7c9dab10ae
parente2e47898180e547cad7ccde1e5890385d573e551 (diff)
presentation minimizer: report possible errors
In process bunch of different problems can occur, but they are not reported to user. IO errors are now shown with message dialog, other exceptions (if any) are passed to upper level. Change-Id: Idc15cb5b7f97de296e095d71ae1f3b2700fc0fa7 Reviewed-on: https://gerrit.libreoffice.org/58765 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.mk1
-rw-r--r--sdext/source/minimizer/errordialog.cxx96
-rw-r--r--sdext/source/minimizer/errordialog.hxx56
-rw-r--r--sdext/source/minimizer/informationdialog.cxx16
-rw-r--r--sdext/source/minimizer/informationdialog.hxx17
-rw-r--r--sdext/source/minimizer/optimizerdialog.cxx31
-rw-r--r--sdext/source/minimizer/pppoptimizertoken.cxx1
-rw-r--r--sdext/source/minimizer/pppoptimizertoken.hxx1
10 files changed, 208 insertions, 18 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu b/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu
index 1a2bbe315267..82b0307791ce 100644
--- a/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/PresentationMinimizer.xcu
@@ -196,6 +196,9 @@ 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 5a9758139b1f..24266c087b88 100644
--- a/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/PresentationMinimizer.xcs
@@ -361,6 +361,10 @@ 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 77a1e5a27c40..884d4ee7310e 100644
--- a/sdext/Library_PresentationMinimizer.mk
+++ b/sdext/Library_PresentationMinimizer.mk
@@ -51,6 +51,7 @@ $(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
new file mode 100644
index 000000000000..d4b67675069b
--- /dev/null
+++ b/sdext/source/minimizer/errordialog.cxx
@@ -0,0 +1,96 @@
+/* -*- 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
new file mode 100644
index 000000000000..cc2eecb34d43
--- /dev/null
+++ b/sdext/source/minimizer/errordialog.hxx
@@ -0,0 +1,56 @@
+/* -*- 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/informationdialog.cxx b/sdext/source/minimizer/informationdialog.cxx
index 45551141e275..4f3de61a2075 100644
--- a/sdext/source/minimizer/informationdialog.cxx
+++ b/sdext/source/minimizer/informationdialog.cxx
@@ -49,7 +49,7 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
-OUString InsertFixedText( InformationDialog& rInformationDialog, const OUString& rControlName, const OUString& rLabel,
+OUString InsertFixedText( UnoDialog& rInformationDialog, const OUString& rControlName, const OUString& rLabel,
sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, bool bMultiLine, sal_Int16 nTabIndex )
{
OUString pNames[] = {
@@ -82,7 +82,7 @@ OUString InsertFixedText( InformationDialog& rInformationDialog, const OUString&
}
OUString InsertImage(
- InformationDialog& rInformationDialog,
+ UnoDialog& rInformationDialog,
const OUString& rControlName,
const OUString& rURL,
sal_Int32 nPosX,
@@ -117,7 +117,7 @@ OUString InsertImage(
return rControlName;
}
-OUString InsertCheckBox( InformationDialog& rInformationDialog, const OUString& rControlName,
+OUString InsertCheckBox( UnoDialog& rInformationDialog, const OUString& rControlName,
const Reference< XItemListener >& rItemListener, const OUString& rLabel,
sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int16 nTabIndex )
{
@@ -153,8 +153,8 @@ OUString InsertCheckBox( InformationDialog& rInformationDialog, const OUString&
return rControlName;
}
-OUString InsertButton( InformationDialog& rInformationDialog, const OUString& rControlName, Reference< XActionListener > const & xActionListener,
- sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int16 nTabIndex, PPPOptimizerTokenEnum nResID )
+OUString InsertButton( UnoDialog& rInformationDialog, const OUString& rControlName, Reference< XActionListener > const & xActionListener,
+ sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int16 nTabIndex, const OUString& rText )
{
sal_Int32 nHeight = 14;
OUString pNames[] = {
@@ -171,7 +171,7 @@ OUString InsertButton( InformationDialog& rInformationDialog, const OUString& rC
Any pValues[] = {
Any( true ),
Any( nHeight ),
- Any( rInformationDialog.getString( nResID ) ),
+ Any( rText ),
Any( nXPos ),
Any( nYPos ),
Any( static_cast< sal_Int16 >( PushButtonType_OK ) ),
@@ -298,7 +298,7 @@ void InformationDialog::InitDialog()
InsertFixedText( *this, "fixedtext", aInfoString, PAGE_POS_X, 6, PAGE_WIDTH, 24, true, 0 );
if ( !maSaveAsURL.isEmpty() )
InsertCheckBox( *this, "OpenNewDocument", xItemListener, getString( STR_AUTOMATICALLY_OPEN ), PAGE_POS_X, 42, PAGE_WIDTH, 1 );
- InsertButton( *this, "button", mxActionListener, DIALOG_WIDTH / 2 - 25, nDialogHeight - 20, 50, 2, STR_OK );
+ InsertButton( *this, "button", mxActionListener, DIALOG_WIDTH / 2 - 25, nDialogHeight - 20, 50, 2, getString( STR_OK ) );
bool bOpenNewDocument = mrbOpenNewDocument;
setControlProperty( "OpenNewDocument", "State", Any( static_cast<sal_Int16>(bOpenNewDocument) ) );
@@ -350,7 +350,7 @@ void OKActionListener::actionPerformed( const ActionEvent& rEvent )
{
if ( rEvent.ActionCommand == "button" )
{
- mrInformationDialog.endExecute( true );
+ mrDialog.endExecute( true );
}
}
void OKActionListener::disposing( const css::lang::EventObject& /* Source */ )
diff --git a/sdext/source/minimizer/informationdialog.hxx b/sdext/source/minimizer/informationdialog.hxx
index f70a60c51281..9d0405b36531 100644
--- a/sdext/source/minimizer/informationdialog.hxx
+++ b/sdext/source/minimizer/informationdialog.hxx
@@ -36,6 +36,19 @@
#include <com/sun/star/io/XStream.hpp>
#include <cppuhelper/implbase.hxx>
+OUString InsertFixedText( UnoDialog& rInformationDialog, const OUString& rControlName, const OUString& rLabel,
+ sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, bool bMultiLine, sal_Int16 nTabIndex );
+
+OUString InsertImage( UnoDialog& rInformationDialog, const OUString& rControlName, const OUString& rURL,
+ sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight, bool bScale );
+
+OUString InsertCheckBox( UnoDialog& rInformationDialog, const OUString& rControlName,
+ const css::uno::Reference< css::awt::XItemListener >& rItemListener, const OUString& rLabel,
+ sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int16 nTabIndex );
+
+OUString InsertButton( UnoDialog& rInformationDialog, const OUString& rControlName,
+ css::uno::Reference< css::awt::XActionListener > const & xActionListener, sal_Int32 nXPos, sal_Int32 nYPos,
+ sal_Int32 nWidth, sal_Int16 nTabIndex, const OUString& rText );
class InformationDialog : public UnoDialog, public ConfigurationAccess
{
@@ -64,13 +77,13 @@ private:
class OKActionListener : public ::cppu::WeakImplHelper< css::awt::XActionListener >
{
public:
- explicit OKActionListener( InformationDialog& rInformationDialog ) : mrInformationDialog( rInformationDialog ){}
+ explicit OKActionListener( UnoDialog& rDialog ) : mrDialog( rDialog ){}
virtual void SAL_CALL actionPerformed( const css::awt::ActionEvent& Event ) override;
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
private:
- InformationDialog& mrInformationDialog;
+ UnoDialog& mrDialog;
};
#endif
diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx
index bf2f30f78c70..62b364345674 100644
--- a/sdext/source/minimizer/optimizerdialog.cxx
+++ b/sdext/source/minimizer/optimizerdialog.cxx
@@ -19,12 +19,14 @@
#include "optimizerdialog.hxx"
-#include "pppoptimizer.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>
#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/util/XCloseBroadcaster.hpp>
#include <sal/macros.h>
#include <osl/time.h>
@@ -472,7 +474,6 @@ void ItemListener::disposing( const css::lang::EventObject& /* Source */ )
{
}
-
void ActionListener::actionPerformed( const ActionEvent& rEvent )
{
switch( TKGet( rEvent.ActionCommand ) )
@@ -555,11 +556,6 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent )
}
if ( bSuccessfullyExecuted )
{
- Reference < XDispatch > xDispatch(
- new PPPOptimizer(
- mrOptimizerDialog.GetComponentContext(),
- mrOptimizerDialog.GetFrame()));
-
URL aURL;
aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:";
aURL.Path = "optimize";
@@ -572,7 +568,26 @@ void ActionListener::actionPerformed( const ActionEvent& rEvent )
lArguments[ 2 ].Name = "InformationDialog";
lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame();
- xDispatch->dispatch( aURL, lArguments );
+ try
+ {
+ ImpOptimizer aOptimizer(
+ mrOptimizerDialog.GetComponentContext(),
+ mrOptimizerDialog.GetFrame()->getController()->getModel());
+ aOptimizer.Optimize(lArguments);
+ }
+ catch (css::io::IOException&)
+ {
+ 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();
+ break;
+ }
mrOptimizerDialog.endExecute( bSuccessfullyExecuted );
}
diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx
index 79303918e775..0551ba294a25 100644
--- a/sdext/source/minimizer/pppoptimizertoken.cxx
+++ b/sdext/source/minimizer/pppoptimizertoken.cxx
@@ -152,6 +152,7 @@ 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 e458da0d3181..3562e8b0ca89 100644
--- a/sdext/source/minimizer/pppoptimizertoken.hxx
+++ b/sdext/source/minimizer/pppoptimizertoken.hxx
@@ -135,6 +135,7 @@ enum PPPOptimizerTokenEnum
STR_OPTIMIZING_GRAPHICS,
STR_CREATING_OLE_REPLACEMENTS,
STR_FILESIZESEPARATOR,
+ STR_ERROR_IO,
TK_NotFound
};