include/o3tl/make_unique.hxx | 34 ++++++++++++++++++++++++++++ sfx2/source/control/unoctitm.cxx | 40 ++++++++++++++++++++++----------- sfx2/source/safemode/safemode.cxx | 3 -- sw/source/filter/ww8/docxsdrexport.cxx | 2 - sw/source/filter/ww8/docxsdrexport.hxx | 3 +- 5 files changed, 65 insertions(+), 17 deletions(-)
New commits: commit b420c0052039a82e651f4556ad153d277b6a5c77 Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> Date: Mon Jan 23 14:28:21 2017 +0100 Remove useless call Change-Id: Ifab0bd0961fa0bbad41b0b4b5e44575a85f0aeb3 diff --git a/sfx2/source/safemode/safemode.cxx b/sfx2/source/safemode/safemode.cxx index 6d8dcf9..3a02f24 100644 --- a/sfx2/source/safemode/safemode.cxx +++ b/sfx2/source/safemode/safemode.cxx @@ -74,7 +74,6 @@ OUString SafeMode::getFilePath(const OUString& sFilename) rtl::Bootstrap::expandMacros(url); OUString aProfilePath; - FileBase::getSystemPathFromFileURL(url, aProfilePath); FileBase::getAbsoluteFileURL(url, sFilename, aProfilePath); return aProfilePath; } commit dc6139c97752232e45fd11d450823f6a6adf9be3 Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> Date: Mon Jan 23 14:26:44 2017 +0100 Fix mis-merge in safemode.cxx Change-Id: I78eef089759dc5053dd8e91c9994d9cec8dd1432 diff --git a/sfx2/source/safemode/safemode.cxx b/sfx2/source/safemode/safemode.cxx index 609ebbd..6d8dcf9 100644 --- a/sfx2/source/safemode/safemode.cxx +++ b/sfx2/source/safemode/safemode.cxx @@ -70,7 +70,7 @@ bool SafeMode::removeRestartFlag() OUString SafeMode::getFilePath(const OUString& sFilename) { - OUString url("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/safemode"); + OUString url("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/"); rtl::Bootstrap::expandMacros(url); OUString aProfilePath; commit 11cf1ca50d9bdee790d9082e51566864fbd23885 Author: Mike Kaganski <mike.kagan...@collabora.com> Date: Thu Nov 3 15:53:09 2016 +0300 tdf#88023: Only warn about unavailable JRE once The underlying design is that there's a single JavaInteractionHandler instance owned by a JavaContext, and that JavaContext installed in Desktop::Main (desktop/source/app/app.cxx). This patch ensures that no additional JavaContext is created in SfxOfficeDispatch::dispatch*() functions unless they are used without preinstalled JavaContext. Thanks to Stephan Bergmann for guidance! Change-Id: I2569df221067a5b9bf1f6cd5d8f69b561316a170 Reviewed-on: https://gerrit.libreoffice.org/30529 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index bba52c6..a720f18 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -26,6 +26,7 @@ #include <svl/itemset.hxx> #include <svl/visitem.hxx> #include <svtools/javacontext.hxx> +#include <svtools/javainteractionhandler.hxx> #include <svl/itempool.hxx> #include <tools/urlobj.hxx> #include <com/sun/star/util/URLTransformer.hpp> @@ -63,6 +64,7 @@ #include <sfx2/msgpool.hxx> #include <sfx2/objsh.hxx> +#include <o3tl/make_unique.hxx> #include <boost/scoped_ptr.hpp> #include <iostream> @@ -339,6 +341,29 @@ const ::com::sun::star::uno::Sequence< sal_Int8 >& SfxOfficeDispatch::impl_getSt return seqID ; } +#if HAVE_FEATURE_JAVA +// The JavaContext contains an interaction handler which is used when +// the creation of a Java Virtual Machine fails. There shall only be one +// user notification (message box) even if the same error (interaction) +// reoccurs. The effect is, that if a user selects a menu entry than they +// may get only one notification that a JRE is not selected. +// This function checks if a JavaContext is already available (typically +// created by Desktop::Main() in app.cxx), and creates new one if not. +namespace { +std::unique_ptr< css::uno::ContextLayer > EnsureJavaContext() +{ + css::uno::Reference< css::uno::XCurrentContext > xContext(css::uno::getCurrentContext()); + if (xContext.is()) + { + css::uno::Reference< css::task::XInteractionHandler > xHandler; + xContext->getValueByName(JAVA_INTERACTION_HANDLER_NAME) >>= xHandler; + if (xHandler.is()) + return nullptr; // No need to add new layer: JavaContext already present + } + return o3tl::make_unique< css::uno::ContextLayer >(new svt::JavaContext(xContext)); +} +} +#endif void SAL_CALL SfxOfficeDispatch::dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) throw ( ::com::sun::star::uno::RuntimeException, std::exception ) { @@ -346,15 +371,7 @@ void SAL_CALL SfxOfficeDispatch::dispatch( const ::com::sun::star::util::URL& aU if ( pControllerItem ) { #if HAVE_FEATURE_JAVA - // The JavaContext contains an interaction handler which is used when - // the creation of a Java Virtual Machine fails. The second parameter - // indicates, that there shall only be one user notification (message box) - // even if the same error (interaction) reoccurs. The effect is, that if a - // user selects a menu entry than they may get only one notification that - // a JRE is not selected. - com::sun::star::uno::ContextLayer layer( - new svt::JavaContext( com::sun::star::uno::getCurrentContext(), - true) ); + std::unique_ptr< css::uno::ContextLayer > layer(EnsureJavaContext()); #endif pControllerItem->dispatch( aURL, aArgs, ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchResultListener >() ); } @@ -368,10 +385,7 @@ void SAL_CALL SfxOfficeDispatch::dispatchWithNotification( const ::com::sun::sta if ( pControllerItem ) { #if HAVE_FEATURE_JAVA - // see comment for SfxOfficeDispatch::dispatch - com::sun::star::uno::ContextLayer layer( - new svt::JavaContext( com::sun::star::uno::getCurrentContext(), - true) ); + std::unique_ptr< css::uno::ContextLayer > layer(EnsureJavaContext()); #endif pControllerItem->dispatch( aURL, aArgs, rListener ); } commit c3a9ad0d96bdd8c67b1755189162aafa1877417c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 21 16:37:16 2015 +0100 o3tl: add make_unique template till we can't use std::make_unique Change-Id: I48b26f0199e339badf7a0e2bed322ca701689d13 Reviewed-on: https://gerrit.libreoffice.org/15846 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> diff --git a/include/o3tl/make_unique.hxx b/include/o3tl/make_unique.hxx new file mode 100644 index 0000000..2be03e9 --- /dev/null +++ b/include/o3tl/make_unique.hxx @@ -0,0 +1,34 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_O3TL_MAKE_UNIQUE_HXX +#define INCLUDED_O3TL_MAKE_UNIQUE_HXX + +#include <memory> +#include <utility> + +namespace o3tl +{ + +/** + * Constructs an object of type T and wraps it in a std::unique_ptr. + * + * Can be replaced by std::make_unique when we allow C++14. + */ +template<typename T, typename... Args> +typename std::unique_ptr<T> make_unique(Args&& ... args) +{ + return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); +} + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index ff9d5d5..6ddd224 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -184,7 +184,7 @@ struct DocxSdrExport::Impl }; DocxSdrExport::DocxSdrExport(DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML) - : m_pImpl(std::make_shared<Impl>(*this, rExport, pSerializer, pDrawingML)) + : m_pImpl(o3tl::make_unique<Impl>(*this, rExport, pSerializer, pDrawingML)) { } diff --git a/sw/source/filter/ww8/docxsdrexport.hxx b/sw/source/filter/ww8/docxsdrexport.hxx index dd98d71..0a32f20 100644 --- a/sw/source/filter/ww8/docxsdrexport.hxx +++ b/sw/source/filter/ww8/docxsdrexport.hxx @@ -11,6 +11,7 @@ #define INCLUDED_SW_SOURCE_FILTER_WW8_DOCXSDREXPORT_HXX #include <memory> +#include <o3tl/make_unique.hxx> #include <com/sun/star/xml/dom/XDocument.hpp> #include <rtl/strbuf.hxx> @@ -52,7 +53,7 @@ public: class DocxSdrExport { struct Impl; - std::shared_ptr<Impl> m_pImpl; + std::unique_ptr<Impl> m_pImpl; public: DocxSdrExport(DocxExport& rExport, sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML); ~DocxSdrExport(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits