summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-12-22 20:06:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-24 08:21:00 +0100
commit252dd254b5b29298457b889623783152e9bed534 (patch)
tree07583e1f12bacc6ab8e40b35f4832c27076b84da /include
parent54115790926a5964534472dff7e4661ea34acb28 (diff)
new comphelper::WeakImplComponentHelper
to replace the cppu:: equivalent with a lightweight version that uses std::mutex instead of osl::Mutex Change-Id: I1b7873a0c2d9cda21f529e43a4ac2fa7574c91a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127335 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/comphelper/compbase.hxx106
-rw-r--r--include/drawinglayer/primitive2d/baseprimitive2d.hxx40
-rw-r--r--include/editeng/AccessibleEditableTextPara.hxx7
-rw-r--r--include/vcl/weldutils.hxx42
4 files changed, 135 insertions, 60 deletions
diff --git a/include/comphelper/compbase.hxx b/include/comphelper/compbase.hxx
new file mode 100644
index 000000000000..6143fbb411ac
--- /dev/null
+++ b/include/comphelper/compbase.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#pragma once
+
+#include <sal/config.h>
+
+#include <comphelper/comphelperdllapi.h>
+#include <comphelper/interfacecontainer4.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <mutex>
+
+namespace comphelper
+{
+/**
+ Serves two purposes
+ (1) extracts code that doesn't need to be templated
+ (2) helps to handle the custom where we have conflicting interfaces
+ e.g. multiple UNO interfaces that extend css::lang::XComponent
+*/
+class COMPHELPER_DLLPUBLIC WeakComponentImplHelperBase : public cppu::OWeakObject,
+ public css::lang::XComponent
+{
+public:
+ virtual ~WeakComponentImplHelperBase() override;
+
+ // css::lang::XComponent
+ virtual void SAL_CALL dispose() override;
+ virtual void SAL_CALL
+ addEventListener(css::uno::Reference<css::lang::XEventListener> const& rxListener) override;
+ virtual void SAL_CALL
+ removeEventListener(css::uno::Reference<css::lang::XEventListener> const& rxListener) override;
+
+ /** called by dispose for subclasses to do dispose() work */
+ virtual void disposing();
+
+protected:
+ comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> maEventListeners;
+ mutable std::mutex m_aMutex;
+ bool m_bDisposed;
+};
+
+template <typename... Ifc>
+class SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper : public WeakComponentImplHelperBase,
+ public css::lang::XTypeProvider,
+ public Ifc...
+{
+public:
+ virtual void SAL_CALL acquire() noexcept final override { OWeakObject::acquire(); }
+
+ virtual void SAL_CALL release() noexcept final override { OWeakObject::release(); }
+
+ // css::lang::XComponent
+ virtual void SAL_CALL dispose() noexcept final override
+ {
+ WeakComponentImplHelperBase::dispose();
+ }
+ virtual void SAL_CALL addEventListener(
+ css::uno::Reference<css::lang::XEventListener> const& rxListener) final override
+ {
+ WeakComponentImplHelperBase::addEventListener(rxListener);
+ }
+ virtual void SAL_CALL removeEventListener(
+ css::uno::Reference<css::lang::XEventListener> const& rxListener) final override
+ {
+ WeakComponentImplHelperBase::removeEventListener(rxListener);
+ }
+
+ virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const& rType) override
+ {
+ css::uno::Any aReturn = ::cppu::queryInterface(
+ rType, static_cast<css::uno::XWeak*>(this),
+ static_cast<css::lang::XComponent*>(static_cast<WeakComponentImplHelperBase*>(this)),
+ static_cast<css::lang::XTypeProvider*>(this), static_cast<Ifc*>(this)...);
+ if (aReturn.hasValue())
+ return aReturn;
+ return OWeakObject::queryInterface(rType);
+ }
+
+ // css::lang::XTypeProvider
+ virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override
+ {
+ static const css::uno::Sequence<css::uno::Type> aTypeList{
+ cppu::UnoType<css::uno::XWeak>::get(), cppu::UnoType<css::lang::XComponent>::get(),
+ cppu::UnoType<css::lang::XTypeProvider>::get(), cppu::UnoType<Ifc>::get()...
+ };
+ return aTypeList;
+ }
+ virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override
+ {
+ return css::uno::Sequence<sal_Int8>();
+ }
+};
+
+} // namespace comphelper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
index 5fbcafc655db..c264912941aa 100644
--- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx
@@ -25,55 +25,21 @@
#include <drawinglayer/primitive2d/Primitive2DVisitor.hxx>
#include <drawinglayer/geometry/viewinformation2d.hxx>
-#include <cppuhelper/weak.hxx>
-#include <com/sun/star/lang/XComponent.hpp>
-#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/util/XAccounting.hpp>
#include <basegfx/range/b2drange.hxx>
#include <com/sun/star/graphic/XPrimitive2D.hpp>
+#include <comphelper/compbase.hxx>
#include <salhelper/simplereferenceobject.hxx>
#include <rtl/ref.hxx>
#include <deque>
-#include <mutex>
namespace drawinglayer::geometry
{
class ViewInformation2D;
}
-/** This is a custom re-implementation of cppu::WeakComponentImplHelper which uses
- std::mutex and skips parts of the XComponent stuff.
-*/
-class DRAWINGLAYERCORE_DLLPUBLIC BasePrimitive2DImplBase : public cppu::OWeakObject,
- public css::lang::XComponent,
- public css::lang::XTypeProvider,
- public css::graphic::XPrimitive2D,
- public css::util::XAccounting
-{
-public:
- virtual ~BasePrimitive2DImplBase() override;
-
- virtual void SAL_CALL acquire() noexcept override;
- virtual void SAL_CALL release() noexcept override;
- virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const& aType) override;
-
- // css::lang::XComponent
- virtual void SAL_CALL dispose() override;
- virtual void SAL_CALL
- addEventListener(css::uno::Reference<css::lang::XEventListener> const& xListener) override;
- virtual void SAL_CALL
- removeEventListener(css::uno::Reference<css::lang::XEventListener> const& xListener) override;
-
- // css::lang::XTypeProvider
- virtual css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
- virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId() override
- {
- return css::uno::Sequence<sal_Int8>();
- }
-
-protected:
- mutable std::mutex m_aMutex;
-};
+typedef comphelper::WeakComponentImplHelper<css::graphic::XPrimitive2D, css::util::XAccounting>
+ BasePrimitive2DImplBase;
namespace drawinglayer::primitive2d
{
diff --git a/include/editeng/AccessibleEditableTextPara.hxx b/include/editeng/AccessibleEditableTextPara.hxx
index 34fab512fbcb..02f907704bdb 100644
--- a/include/editeng/AccessibleEditableTextPara.hxx
+++ b/include/editeng/AccessibleEditableTextPara.hxx
@@ -23,8 +23,7 @@
#include <config_options.h>
#include <rtl/ustring.hxx>
#include <tools/gen.hxx>
-#include <cppuhelper/compbase.hxx>
-#include <cppuhelper/basemutex.hxx>
+#include <comphelper/compbase.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -51,7 +50,7 @@ namespace accessibility { class AccessibleImageBullet; }
namespace accessibility
{
- typedef ::cppu::WeakComponentImplHelper< css::accessibility::XAccessible,
+ typedef ::comphelper::WeakComponentImplHelper< css::accessibility::XAccessible,
css::accessibility::XAccessibleContext,
css::accessibility::XAccessibleComponent,
css::accessibility::XAccessibleEditableText,
@@ -63,7 +62,7 @@ namespace accessibility
/** This class implements the actual text paragraphs for the EditEngine/Outliner UAA
*/
- class UNLESS_MERGELIBS(EDITENG_DLLPUBLIC) AccessibleEditableTextPara final : public ::cppu::BaseMutex, public AccessibleTextParaInterfaceBase, private ::comphelper::OCommonAccessibleText
+ class UNLESS_MERGELIBS(EDITENG_DLLPUBLIC) AccessibleEditableTextPara final : public AccessibleTextParaInterfaceBase, private ::comphelper::OCommonAccessibleText
{
// override OCommonAccessibleText methods
diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx
index a11ab6c9f283..a8c2e1eac11d 100644
--- a/include/vcl/weldutils.hxx
+++ b/include/vcl/weldutils.hxx
@@ -15,9 +15,8 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
#include <com/sun/star/uno/Reference.hxx>
-#include <comphelper/interfacecontainer2.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
+#include <comphelper/interfacecontainer4.hxx>
+#include <comphelper/compbase.hxx>
#include <tools/time.hxx>
#include <vcl/dllapi.h>
#include <vcl/formatter.hxx>
@@ -34,32 +33,25 @@ class Window;
namespace weld
{
-typedef cppu::WeakComponentImplHelper<css::awt::XWindow> TransportAsXWindow_Base;
+typedef comphelper::WeakComponentImplHelper<css::awt::XWindow> TransportAsXWindow_Base;
-class VCL_DLLPUBLIC TransportAsXWindow : public cppu::BaseMutex, public TransportAsXWindow_Base
+class VCL_DLLPUBLIC TransportAsXWindow : public TransportAsXWindow_Base
{
private:
weld::Widget* m_pWeldWidget;
weld::Builder* m_pWeldWidgetBuilder;
- comphelper::OInterfaceContainerHelper2 m_aWindowListeners;
- comphelper::OInterfaceContainerHelper2 m_aKeyListeners;
- comphelper::OInterfaceContainerHelper2 m_aFocusListeners;
- comphelper::OInterfaceContainerHelper2 m_aMouseListeners;
- comphelper::OInterfaceContainerHelper2 m_aMotionListeners;
- comphelper::OInterfaceContainerHelper2 m_aPaintListeners;
+ comphelper::OInterfaceContainerHelper4<css::awt::XWindowListener> m_aWindowListeners;
+ comphelper::OInterfaceContainerHelper4<css::awt::XKeyListener> m_aKeyListeners;
+ comphelper::OInterfaceContainerHelper4<css::awt::XFocusListener> m_aFocusListeners;
+ comphelper::OInterfaceContainerHelper4<css::awt::XMouseListener> m_aMouseListeners;
+ comphelper::OInterfaceContainerHelper4<css::awt::XMouseMotionListener> m_aMotionListeners;
+ comphelper::OInterfaceContainerHelper4<css::awt::XPaintListener> m_aPaintListeners;
public:
TransportAsXWindow(weld::Widget* pWeldWidget, weld::Builder* pWeldWidgetBuilder = nullptr)
- : TransportAsXWindow_Base(m_aMutex)
- , m_pWeldWidget(pWeldWidget)
+ : m_pWeldWidget(pWeldWidget)
, m_pWeldWidgetBuilder(pWeldWidgetBuilder)
- , m_aWindowListeners(m_aMutex)
- , m_aKeyListeners(m_aMutex)
- , m_aFocusListeners(m_aMutex)
- , m_aMouseListeners(m_aMutex)
- , m_aMotionListeners(m_aMutex)
- , m_aPaintListeners(m_aMutex)
{
}
@@ -96,72 +88,84 @@ public:
void SAL_CALL
addWindowListener(const css::uno::Reference<css::awt::XWindowListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aWindowListeners.addInterface(rListener);
}
void SAL_CALL
removeWindowListener(const css::uno::Reference<css::awt::XWindowListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aWindowListeners.removeInterface(rListener);
}
void SAL_CALL
addFocusListener(const css::uno::Reference<css::awt::XFocusListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aFocusListeners.addInterface(rListener);
}
void SAL_CALL
removeFocusListener(const css::uno::Reference<css::awt::XFocusListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aFocusListeners.removeInterface(rListener);
}
void SAL_CALL
addKeyListener(const css::uno::Reference<css::awt::XKeyListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aKeyListeners.addInterface(rListener);
}
void SAL_CALL
removeKeyListener(const css::uno::Reference<css::awt::XKeyListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aKeyListeners.removeInterface(rListener);
}
void SAL_CALL
addMouseListener(const css::uno::Reference<css::awt::XMouseListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aMouseListeners.addInterface(rListener);
}
void SAL_CALL
removeMouseListener(const css::uno::Reference<css::awt::XMouseListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aMouseListeners.removeInterface(rListener);
}
void SAL_CALL addMouseMotionListener(
const css::uno::Reference<css::awt::XMouseMotionListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aMotionListeners.addInterface(rListener);
}
void SAL_CALL removeMouseMotionListener(
const css::uno::Reference<css::awt::XMouseMotionListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aMotionListeners.removeInterface(rListener);
}
void SAL_CALL
addPaintListener(const css::uno::Reference<css::awt::XPaintListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aPaintListeners.addInterface(rListener);
}
void SAL_CALL
removePaintListener(const css::uno::Reference<css::awt::XPaintListener>& rListener) override
{
+ std::unique_lock g(m_aMutex);
m_aPaintListeners.removeInterface(rListener);
}
};