diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 2aa818b87dcf..fea0a5da3559 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -2376,7 +2376,6 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/drawing/framework,\ AnchorBindingMode \ XResource \ XResourceId \ - XView \ )) $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/embed,\ Actions \ diff --git a/sd/IwyuFilter_sd.yaml b/sd/IwyuFilter_sd.yaml index eed4179b8ba0..a58cf54c3468 100644 --- a/sd/IwyuFilter_sd.yaml +++ b/sd/IwyuFilter_sd.yaml @@ -225,7 +225,7 @@ excludelist: sd/source/ui/inc/framework/ViewShellWrapper.hxx: # base class has to be a complete type - com/sun/star/awt/XWindowListener.hpp - - com/sun/star/drawing/framework/XView.hpp + - framework/XView.hxx - com/sun/star/lang/XUnoTunnel.hpp - com/sun/star/view/XSelectionSupplier.hpp sd/source/ui/inc/tools/SlotStateListener.hxx: diff --git a/sd/inc/pch/precompiled_sd.hxx b/sd/inc/pch/precompiled_sd.hxx index af6f76f449df..0461da901224 100644 --- a/sd/inc/pch/precompiled_sd.hxx +++ b/sd/inc/pch/precompiled_sd.hxx @@ -204,7 +204,6 @@ #include #include #include -#include #include #include #include diff --git a/sd/source/console/PresenterAccessibility.cxx b/sd/source/console/PresenterAccessibility.cxx index a30e3192bd9a..e98b251dd320 100644 --- a/sd/source/console/PresenterAccessibility.cxx +++ b/sd/source/console/PresenterAccessibility.cxx @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -146,7 +146,7 @@ void PresenterAccessible::UpdateAccessibilityHierarchy() pPaneContainer->FindPaneURL(PresenterPaneFactory::msNotesPaneURL)); // Get the notes view. - Reference xNotesView; + rtl::Reference xNotesView; if (pNotesPane) xNotesView = pNotesPane->mxView; rtl::Reference pNotesView ( diff --git a/sd/source/console/PresenterController.cxx b/sd/source/console/PresenterController.cxx index d7eeb71f9904..c9b224279a4f 100644 --- a/sd/source/console/PresenterController.cxx +++ b/sd/source/console/PresenterController.cxx @@ -376,7 +376,7 @@ void PresenterController::UpdateViews() // Tell all views about the slides they should display. for (const auto& rxPane : mpPaneContainer->maPanes) { - Reference xDrawView (rxPane->mxView, UNO_QUERY); + Reference xDrawView (cppu::getXWeak(rxPane->mxView.get()), UNO_QUERY); if (xDrawView.is()) xDrawView->setCurrentPage(mxCurrentSlide); } @@ -690,7 +690,7 @@ void PresenterController::notifyConfigurationChange ( { // A view bound to one of the panes has been created and is // stored in the pane container along with its pane. - Reference xView (rEvent.ResourceObject,UNO_QUERY); + rtl::Reference xView = dynamic_cast(rEvent.ResourceObject.get()); if (xView.is()) { mpPaneContainer->StoreView(xView); @@ -704,7 +704,7 @@ void PresenterController::notifyConfigurationChange ( if (rEvent.ResourceId->isBoundTo(mxMainPaneId,AnchorBindingMode_INDIRECT)) { // If this is a view then remove it from the pane container. - Reference xView (rEvent.ResourceObject,UNO_QUERY); + rtl::Reference xView = dynamic_cast(rEvent.ResourceObject.get()); if (xView.is()) { PresenterPaneContainer::SharedPaneDescriptor pDescriptor( @@ -769,7 +769,7 @@ void SAL_CALL PresenterController::keyPressed (const awt::KeyEvent& rEvent) if ( ! rxPane->mbIsActive) continue; - Reference xKeyListener (rxPane->mxView, UNO_QUERY); + Reference xKeyListener (cppu::getXWeak(rxPane->mxView.get()), UNO_QUERY); if (xKeyListener.is()) xKeyListener->keyPressed(rEvent); } @@ -947,7 +947,7 @@ void SAL_CALL PresenterController::keyReleased (const awt::KeyEvent& rEvent) if ( ! rxPane->mbIsActive) continue; - Reference xKeyListener (rxPane->mxView, UNO_QUERY); + Reference xKeyListener (cppu::getXWeak(rxPane->mxView.get()), UNO_QUERY); if (xKeyListener.is()) xKeyListener->keyReleased(rEvent); } diff --git a/sd/source/console/PresenterHelpView.cxx b/sd/source/console/PresenterHelpView.cxx index cf9fa4655752..06b4d9b9b828 100644 --- a/sd/source/console/PresenterHelpView.cxx +++ b/sd/source/console/PresenterHelpView.cxx @@ -123,8 +123,7 @@ PresenterHelpView::PresenterHelpView ( const Reference& rxViewId, const rtl::Reference<::sd::DrawController>& rxController, ::rtl::Reference xPresenterController) - : PresenterHelpViewInterfaceBase(m_aMutex), - mxComponentContext(rxContext), + : mxComponentContext(rxContext), mxViewId(rxViewId), mpPresenterController(std::move(xPresenterController)), mnSeparatorY(0), @@ -180,7 +179,7 @@ PresenterHelpView::~PresenterHelpView() { } -void SAL_CALL PresenterHelpView::disposing() +void PresenterHelpView::disposing(std::unique_lock&) { mxViewId = nullptr; @@ -217,24 +216,32 @@ void SAL_CALL PresenterHelpView::disposing (const lang::EventObject& rEventObjec void SAL_CALL PresenterHelpView::windowResized (const awt::WindowEvent&) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } Resize(); } void SAL_CALL PresenterHelpView::windowMoved (const awt::WindowEvent&) { - ThrowIfDisposed(); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); } void SAL_CALL PresenterHelpView::windowShown (const lang::EventObject&) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } Resize(); } void SAL_CALL PresenterHelpView::windowHidden (const lang::EventObject&) { - ThrowIfDisposed(); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); } //----- XPaintListener -------------------------------------------------------- @@ -429,7 +436,10 @@ void PresenterHelpView::CheckFontSize() Reference SAL_CALL PresenterHelpView::getResourceId() { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } return mxViewId; } @@ -474,16 +484,6 @@ void PresenterHelpView::Resize() CheckFontSize(); } -void PresenterHelpView::ThrowIfDisposed() -{ - if (rBHelper.bDisposed || rBHelper.bInDispose) - { - throw lang::DisposedException ( - u"PresenterHelpView has been already disposed"_ustr, - static_cast(this)); - } -} - //===== LineDescriptor ========================================================= namespace { diff --git a/sd/source/console/PresenterHelpView.hxx b/sd/source/console/PresenterHelpView.hxx index 2829771f83eb..40c858b9fe7e 100644 --- a/sd/source/console/PresenterHelpView.hxx +++ b/sd/source/console/PresenterHelpView.hxx @@ -21,11 +21,10 @@ #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERHELPVIEW_HXX #include "PresenterController.hxx" -#include #include #include #include -#include +#include #include #include #include @@ -34,8 +33,8 @@ namespace sdext::presenter { class PresenterButton; -typedef cppu::WeakComponentImplHelper< - css::drawing::framework::XView, +typedef cppu::ImplInheritanceHelper< + sd::framework::AbstractView, css::awt::XWindowListener, css::awt::XPaintListener > PresenterHelpViewInterfaceBase; @@ -43,8 +42,7 @@ typedef cppu::WeakComponentImplHelper< /** Show help text that describes the defined keys. */ class PresenterHelpView - : private ::cppu::BaseMutex, - public PresenterHelpViewInterfaceBase + : public PresenterHelpViewInterfaceBase { public: explicit PresenterHelpView ( @@ -54,10 +52,11 @@ public: ::rtl::Reference xPresenterController); virtual ~PresenterHelpView() override; - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock&) override; // lang::XEventListener + using WeakComponentImplHelperBase::disposing; virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) override; @@ -107,11 +106,6 @@ private: time. */ void CheckFontSize(); - - /** @throws css::lang::DisposedException when the object has already been - disposed. - */ - void ThrowIfDisposed(); }; } // end of namespace ::sdext::presenter diff --git a/sd/source/console/PresenterNotesView.cxx b/sd/source/console/PresenterNotesView.cxx index 825cd765cb0b..305568306837 100644 --- a/sd/source/console/PresenterNotesView.cxx +++ b/sd/source/console/PresenterNotesView.cxx @@ -55,8 +55,7 @@ PresenterNotesView::PresenterNotesView ( const Reference& rxViewId, const ::rtl::Reference<::sd::DrawController>& rxController, const ::rtl::Reference& rpPresenterController) - : PresenterNotesViewInterfaceBase(m_aMutex), - mxViewId(rxViewId), + : mxViewId(rxViewId), mpPresenterController(rpPresenterController), maSeparatorColor(0xffffff), mnSeparatorYLocation(0), @@ -112,7 +111,10 @@ PresenterNotesView::PresenterNotesView ( } catch (RuntimeException&) { - PresenterNotesView::disposing(); + { + std::unique_lock l(m_aMutex); + PresenterNotesView::disposing(l); + } throw; } } @@ -121,7 +123,7 @@ PresenterNotesView::~PresenterNotesView() { } -void SAL_CALL PresenterNotesView::disposing() +void PresenterNotesView::disposing(std::unique_lock&) { if (mxParentWindow.is()) { @@ -270,11 +272,9 @@ void SAL_CALL PresenterNotesView::windowHidden (const lang::EventObject&) {} void SAL_CALL PresenterNotesView::windowPaint (const awt::PaintEvent& rEvent) { - if (rBHelper.bDisposed || rBHelper.bInDispose) { - throw lang::DisposedException ( - u"PresenterNotesView object has already been disposed"_ustr, - static_cast(this)); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); } if ( ! mbIsPresenterViewActive) diff --git a/sd/source/console/PresenterNotesView.hxx b/sd/source/console/PresenterNotesView.hxx index e2f3139f4bda..c7371024522c 100644 --- a/sd/source/console/PresenterNotesView.hxx +++ b/sd/source/console/PresenterNotesView.hxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,10 +42,10 @@ class PresenterButton; class PresenterScrollBar; class PresenterTextView; -typedef cppu::WeakComponentImplHelper< +typedef cppu::ImplInheritanceHelper< + sd::framework::AbstractView, css::awt::XWindowListener, css::awt::XPaintListener, - css::drawing::framework::XView, css::drawing::XDrawView, css::awt::XKeyListener > PresenterNotesViewInterfaceBase; @@ -55,8 +55,7 @@ typedef cppu::WeakComponentImplHelper< notes text. */ class PresenterNotesView - : private ::cppu::BaseMutex, - public PresenterNotesViewInterfaceBase, + : public PresenterNotesViewInterfaceBase, public CachablePresenterView { public: @@ -67,7 +66,7 @@ public: const ::rtl::Reference& rpPresenterController); virtual ~PresenterNotesView() override; - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock&) override; /** Typically called from setCurrentSlide() with the notes page that is associated with the slide given to setCurrentSlide(). @@ -84,6 +83,7 @@ public: // lang::XEventListener + using WeakComponentImplHelperBase::disposing; virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) override; diff --git a/sd/source/console/PresenterPaneContainer.cxx b/sd/source/console/PresenterPaneContainer.cxx index 9b71efc7349d..85c219d2251b 100644 --- a/sd/source/console/PresenterPaneContainer.cxx +++ b/sd/source/console/PresenterPaneContainer.cxx @@ -137,7 +137,7 @@ PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::SharedPaneDescriptor PresenterPaneContainer::StoreView ( - const Reference& rxView) + const rtl::Reference& rxView) { SharedPaneDescriptor pDescriptor; @@ -189,7 +189,7 @@ PresenterPaneContainer::SharedPaneDescriptor } PresenterPaneContainer::SharedPaneDescriptor - PresenterPaneContainer::RemoveView (const Reference& rxView) + PresenterPaneContainer::RemoveView (const rtl::Reference& rxView) { SharedPaneDescriptor pDescriptor; diff --git a/sd/source/console/PresenterPaneContainer.hxx b/sd/source/console/PresenterPaneContainer.hxx index f2de216a15f1..dc9217ca936c 100644 --- a/sd/source/console/PresenterPaneContainer.hxx +++ b/sd/source/console/PresenterPaneContainer.hxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -56,7 +56,7 @@ public: virtual void SAL_CALL disposing() override; - typedef ::std::function&)> + typedef ::std::function&)> ViewInitializationFunction; /** Each pane descriptor holds references to one pane and the view @@ -73,7 +73,7 @@ public: css::uno::Reference mxPaneId; OUString msViewURL; ::rtl::Reference mxPane; - css::uno::Reference mxView; + rtl::Reference mxView; css::uno::Reference mxContentWindow; css::uno::Reference mxBorderWindow; OUString msTitleTemplate; @@ -107,13 +107,13 @@ public: const css::uno::Reference& rxBorderWindow); SharedPaneDescriptor StoreView ( - const css::uno::Reference& rxView); + const rtl::Reference& rxView); SharedPaneDescriptor RemovePane ( const css::uno::Reference& rxPaneId); SharedPaneDescriptor RemoveView ( - const css::uno::Reference& rxView); + const rtl::Reference& rxView); /** Find the pane whose border window is identical to the given border window. diff --git a/sd/source/console/PresenterSlidePreview.cxx b/sd/source/console/PresenterSlidePreview.cxx index df1e285c0f97..d65e3f3a6345 100644 --- a/sd/source/console/PresenterSlidePreview.cxx +++ b/sd/source/console/PresenterSlidePreview.cxx @@ -45,8 +45,7 @@ PresenterSlidePreview::PresenterSlidePreview ( const Reference& rxViewId, const rtl::Reference& rxAnchorPane, const ::rtl::Reference& rpPresenterController) - : PresenterSlidePreviewInterfaceBase(m_aMutex), - mpPresenterController(rpPresenterController), + : mpPresenterController(rpPresenterController), mxViewId(rxViewId), mnSlideAspectRatio(28.0 / 21.0) { @@ -93,7 +92,7 @@ PresenterSlidePreview::~PresenterSlidePreview() { } -void SAL_CALL PresenterSlidePreview::disposing() +void PresenterSlidePreview::disposing(std::unique_lock&) { if (mxWindow.is()) { @@ -123,7 +122,10 @@ sal_Bool SAL_CALL PresenterSlidePreview::isAnchorOnly() void SAL_CALL PresenterSlidePreview::windowResized (const awt::WindowEvent&) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); Resize(); } @@ -132,7 +134,10 @@ void SAL_CALL PresenterSlidePreview::windowMoved (const awt::WindowEvent&) {} void SAL_CALL PresenterSlidePreview::windowShown (const lang::EventObject&) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); Resize(); } @@ -143,7 +148,10 @@ void SAL_CALL PresenterSlidePreview::windowHidden (const lang::EventObject&) {} void SAL_CALL PresenterSlidePreview::windowPaint (const awt::PaintEvent& rEvent) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); if (mxWindow.is()) @@ -170,14 +178,20 @@ void SAL_CALL PresenterSlidePreview::disposing (const lang::EventObject& rEvent) void SAL_CALL PresenterSlidePreview::setCurrentPage (const Reference& rxSlide) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); SetSlide(rxSlide); } Reference SAL_CALL PresenterSlidePreview::getCurrentPage() { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } return nullptr; } @@ -332,16 +346,6 @@ void PresenterSlidePreview::Resize() SetSlide(mxCurrentSlide); } -void PresenterSlidePreview::ThrowIfDisposed() -{ - if (PresenterSlidePreviewInterfaceBase::rBHelper.bDisposed || PresenterSlidePreviewInterfaceBase::rBHelper.bInDispose) - { - throw lang::DisposedException ( - u"PresenterSlidePreview object has already been disposed"_ustr, - static_cast(this)); - } -} - } // end of namespace ::sdext::presenter /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/console/PresenterSlidePreview.hxx b/sd/source/console/PresenterSlidePreview.hxx index 6d6221c65d07..f03e1a1d5c87 100644 --- a/sd/source/console/PresenterSlidePreview.hxx +++ b/sd/source/console/PresenterSlidePreview.hxx @@ -28,16 +28,15 @@ #include #include #include -#include +#include #include -#include #include #include namespace sdext::presenter { -typedef ::cppu::WeakComponentImplHelper < - css::drawing::framework::XView, +typedef ::cppu::ImplInheritanceHelper < + sd::framework::AbstractView, css::drawing::XDrawView, css::awt::XPaintListener, css::awt::XWindowListener @@ -50,8 +49,7 @@ typedef ::cppu::WeakComponentImplHelper < uses a derived class that overrides the setCurrentSlide() method. */ class PresenterSlidePreview - : private ::cppu::BaseMutex, - public PresenterSlidePreviewInterfaceBase + : public PresenterSlidePreviewInterfaceBase { public: PresenterSlidePreview ( @@ -60,9 +58,11 @@ public: const rtl::Reference& rxAnchorPane, const ::rtl::Reference& rpPresenterController); virtual ~PresenterSlidePreview() override; + PresenterSlidePreview(const PresenterSlidePreview&) = delete; PresenterSlidePreview& operator=(const PresenterSlidePreview&) = delete; - virtual void SAL_CALL disposing() override; + + virtual void disposing(std::unique_lock&) override; // XResourceId @@ -131,11 +131,6 @@ private: /** React to a resize of the anchor pane. */ void Resize(); - - /** @throws css::lang::DisposedException when the object has already been - disposed. - */ - void ThrowIfDisposed(); }; } // end of namespace ::sd::presenter diff --git a/sd/source/console/PresenterSlideShowView.cxx b/sd/source/console/PresenterSlideShowView.cxx index 82e01f8a0270..897bd7abc9eb 100644 --- a/sd/source/console/PresenterSlideShowView.cxx +++ b/sd/source/console/PresenterSlideShowView.cxx @@ -80,15 +80,13 @@ PresenterSlideShowView::PresenterSlideShowView ( css::uno::Reference xViewId, const rtl::Reference<::sd::DrawController>& rxController, ::rtl::Reference xPresenterController) - : PresenterSlideShowViewInterfaceBase(m_aMutex), - mxComponentContext(std::move(xContext)), + : mxComponentContext(std::move(xContext)), mpPresenterController(std::move(xPresenterController)), mxViewId(std::move(xViewId)), mxController(rxController), mxSlideShowController(lcl_GetSlideShowController(rxController)), mbIsViewAdded(false), mnPageAspectRatio(28.0/21.0), - maBroadcaster(m_aMutex), mbIsForcedPaintPending(false), mbIsPaintPending(true), mbIsEndSlideVisible(false) @@ -178,16 +176,19 @@ PresenterSlideShowView::~PresenterSlideShowView() { } -void PresenterSlideShowView::disposing() +void PresenterSlideShowView::disposing(std::unique_lock&) { // Tell all listeners that we are disposed. lang::EventObject aEvent; aEvent.Source = static_cast(this); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) - pIterator->disposeAndClear(aEvent); + { + std::unique_lock l(m_aMutex); + maMouseListeners.disposeAndClear(l, aEvent); + maMouseMotionListeners.disposeAndClear(l, aEvent); + maPaintListeners.disposeAndClear(l, aEvent); + maModifyListeners.disposeAndClear(l, aEvent); + } // Do this for // XPaintListener, XModifyListener,XMouseListener,XMouseMotionListener,XWindowListener? @@ -314,14 +315,20 @@ void PresenterSlideShowView::ReleaseView() Reference SAL_CALL PresenterSlideShowView::getCanvas() { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } return Reference(mxViewCanvas, UNO_QUERY); } void SAL_CALL PresenterSlideShowView::clear() { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } mbIsForcedPaintPending = false; mbIsPaintPending = false; @@ -348,7 +355,10 @@ void SAL_CALL PresenterSlideShowView::clear() geometry::AffineMatrix2D SAL_CALL PresenterSlideShowView::getTransformation() { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } if (mxViewWindow.is()) { @@ -374,85 +384,83 @@ geometry::AffineMatrix2D SAL_CALL PresenterSlideShowView::getTransformation() geometry::IntegerSize2D SAL_CALL PresenterSlideShowView::getTranslationOffset() { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } return geometry::IntegerSize2D(0,0); } void SAL_CALL PresenterSlideShowView::addTransformationChangedListener( const Reference& rxListener) { - ThrowIfDisposed(); - maBroadcaster.addListener( - cppu::UnoType::get(), - rxListener); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + maModifyListeners.addInterface(l, rxListener); } void SAL_CALL PresenterSlideShowView::removeTransformationChangedListener( const Reference& rxListener) { - ThrowIfDisposed(); - maBroadcaster.removeListener( - cppu::UnoType::get(), - rxListener); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + maModifyListeners.removeInterface(l, rxListener); } void SAL_CALL PresenterSlideShowView::addPaintListener( const Reference& rxListener) { - ThrowIfDisposed(); - maBroadcaster.addListener( - cppu::UnoType::get(), - rxListener); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + maPaintListeners.addInterface(l, rxListener); } void SAL_CALL PresenterSlideShowView::removePaintListener( const Reference& rxListener) { - ThrowIfDisposed(); - maBroadcaster.removeListener( - cppu::UnoType::get(), - rxListener); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + maPaintListeners.removeInterface(l, rxListener); } void SAL_CALL PresenterSlideShowView::addMouseListener( const Reference& rxListener) { - ThrowIfDisposed(); - maBroadcaster.addListener( - cppu::UnoType::get(), - rxListener); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + maMouseListeners.addInterface(l, rxListener); } void SAL_CALL PresenterSlideShowView::removeMouseListener( const Reference& rxListener) { - ThrowIfDisposed(); - maBroadcaster.removeListener( - cppu::UnoType::get(), - rxListener); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + maMouseListeners.removeInterface(l, rxListener); } void SAL_CALL PresenterSlideShowView::addMouseMotionListener( const Reference& rxListener) { - ThrowIfDisposed(); - maBroadcaster.addListener( - cppu::UnoType::get(), - rxListener); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + maMouseMotionListeners.addInterface(l, rxListener); } void SAL_CALL PresenterSlideShowView::removeMouseMotionListener( const Reference& rxListener) { - ThrowIfDisposed(); - maBroadcaster.removeListener( - cppu::UnoType::get(), - rxListener); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + maMouseMotionListeners.removeInterface(l, rxListener); } void SAL_CALL PresenterSlideShowView::setMouseCursor(::sal_Int16 nPointerShape) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } // Create a pointer when it does not yet exist. if ( ! mxPointer.is()) @@ -518,11 +526,9 @@ void SAL_CALL PresenterSlideShowView::mousePressed (const awt::MouseEvent& rEven { awt::MouseEvent aEvent (rEvent); aEvent.Source = static_cast(this); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) { - pIterator->notifyEach(&awt::XMouseListener::mousePressed, aEvent); + std::unique_lock l(m_aMutex); + maMouseListeners.notifyEach(l, &awt::XMouseListener::mousePressed, aEvent); } // Only when the end slide is displayed we forward the mouse event to @@ -537,11 +543,9 @@ void SAL_CALL PresenterSlideShowView::mouseReleased (const awt::MouseEvent& rEve { awt::MouseEvent aEvent (rEvent); aEvent.Source = static_cast(this); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) { - pIterator->notifyEach(&awt::XMouseListener::mouseReleased, aEvent); + std::unique_lock l(m_aMutex); + maMouseListeners.notifyEach(l, &awt::XMouseListener::mouseReleased, aEvent); } } @@ -549,11 +553,9 @@ void SAL_CALL PresenterSlideShowView::mouseEntered (const awt::MouseEvent& rEven { awt::MouseEvent aEvent (rEvent); aEvent.Source = static_cast(this); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) { - pIterator->notifyEach(&awt::XMouseListener::mouseEntered, aEvent); + std::unique_lock l(m_aMutex); + maMouseListeners.notifyEach(l, &awt::XMouseListener::mouseEntered, aEvent); } } @@ -561,11 +563,9 @@ void SAL_CALL PresenterSlideShowView::mouseExited (const awt::MouseEvent& rEvent { awt::MouseEvent aEvent (rEvent); aEvent.Source = static_cast(this); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) { - pIterator->notifyEach(&awt::XMouseListener::mouseExited, aEvent); + std::unique_lock l(m_aMutex); + maMouseListeners.notifyEach(l, &awt::XMouseListener::mouseExited, aEvent); } } @@ -575,11 +575,9 @@ void SAL_CALL PresenterSlideShowView::mouseDragged (const awt::MouseEvent& rEven { awt::MouseEvent aEvent (rEvent); aEvent.Source = static_cast(this); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) { - pIterator->notifyEach(&awt::XMouseMotionListener::mouseDragged, aEvent); + std::unique_lock l(m_aMutex); + maMouseMotionListeners.notifyEach(l, &awt::XMouseMotionListener::mouseDragged, aEvent); } } @@ -587,11 +585,9 @@ void SAL_CALL PresenterSlideShowView::mouseMoved (const awt::MouseEvent& rEvent) { awt::MouseEvent aEvent (rEvent); aEvent.Source = static_cast(this); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) { - pIterator->notifyEach(&awt::XMouseMotionListener::mouseMoved, aEvent); + std::unique_lock l(m_aMutex); + maMouseMotionListeners.notifyEach(l, &awt::XMouseMotionListener::mouseMoved, aEvent); } } @@ -599,7 +595,10 @@ void SAL_CALL PresenterSlideShowView::mouseMoved (const awt::MouseEvent& rEvent) void SAL_CALL PresenterSlideShowView::windowResized (const awt::WindowEvent&) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); Resize(); @@ -773,11 +772,9 @@ void PresenterSlideShowView::PaintInnerWindow (const awt::PaintEvent& rEvent) // Forward window paint to listeners. awt::PaintEvent aEvent (rEvent); aEvent.Source = static_cast(this); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) { - pIterator->notifyEach(&awt::XPaintListener::windowPaint, aEvent); + std::unique_lock l(m_aMutex); + maPaintListeners.notifyEach(l, &awt::XPaintListener::windowPaint, aEvent); } /** The slide show relies on the back buffer of the canvas not being @@ -885,11 +882,9 @@ void PresenterSlideShowView::Resize() // Notify listeners that the transformation that maps the view into the // window has changed. lang::EventObject aEvent (static_cast(this)); - ::cppu::OInterfaceContainerHelper* pIterator - = maBroadcaster.getContainer(cppu::UnoType::get()); - if (pIterator != nullptr) { - pIterator->notifyEach(&util::XModifyListener::modified, aEvent); + std::unique_lock l(m_aMutex); + maModifyListeners.notifyEach(l, &util::XModifyListener::modified, aEvent); } // Due to constant aspect ratio resizing may lead a preview that changes @@ -946,16 +941,6 @@ void PresenterSlideShowView::CreateBackgroundPolygons() } } -void PresenterSlideShowView::ThrowIfDisposed() -{ - if (rBHelper.bDisposed || rBHelper.bInDispose) - { - throw lang::DisposedException ( - u"PresenterSlideShowView object has already been disposed"_ustr, - static_cast(this)); - } -} - void PresenterSlideShowView::impl_addAndConfigureView() { Reference xView (this); diff --git a/sd/source/console/PresenterSlideShowView.hxx b/sd/source/console/PresenterSlideShowView.hxx index 632bb243630c..6bcd6fd745a2 100644 --- a/sd/source/console/PresenterSlideShowView.hxx +++ b/sd/source/console/PresenterSlideShowView.hxx @@ -30,31 +30,30 @@ #include #include #include -#include +#include #include #include #include #include #include -#include +#include namespace sdext::presenter { -typedef cppu::WeakComponentImplHelper< +typedef cppu::ImplInheritanceHelper< + sd::framework::AbstractView, css::presentation::XSlideShowView, css::awt::XPaintListener, css::awt::XMouseListener, css::awt::XMouseMotionListener, css::awt::XWindowListener, - css::drawing::framework::XView, css::drawing::XDrawView > PresenterSlideShowViewInterfaceBase; /** Life view in a secondary window of a full screen slide show. */ class PresenterSlideShowView - : protected ::cppu::BaseMutex, - public PresenterSlideShowViewInterfaceBase, + : public PresenterSlideShowViewInterfaceBase, public CachablePresenterView { public: @@ -68,7 +67,7 @@ public: PresenterSlideShowView& operator=(const PresenterSlideShowView&) = delete; void LateInit(); - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock&) override; // CachablePresenterView @@ -196,7 +195,10 @@ private: /** This broadcast helper is used to notify listeners registered to a SlideShowView object. */ - ::cppu::OBroadcastHelper maBroadcaster; + comphelper::OInterfaceContainerHelper4 maMouseListeners; + comphelper::OInterfaceContainerHelper4 maMouseMotionListeners; + comphelper::OInterfaceContainerHelper4 maPaintListeners; + comphelper::OInterfaceContainerHelper4 maModifyListeners; SharedBitmapDescriptor mpBackground; @@ -225,11 +227,6 @@ private: void CreateBackgroundPolygons(); - /** @throws css::lang::DisposedException when the object has already been - disposed. - */ - void ThrowIfDisposed(); - void impl_addAndConfigureView(); }; diff --git a/sd/source/console/PresenterSlideSorter.cxx b/sd/source/console/PresenterSlideSorter.cxx index 7cd70cc9a2fe..d43fbe075c30 100644 --- a/sd/source/console/PresenterSlideSorter.cxx +++ b/sd/source/console/PresenterSlideSorter.cxx @@ -230,8 +230,7 @@ PresenterSlideSorter::PresenterSlideSorter ( const Reference& rxViewId, const rtl::Reference<::sd::DrawController>& rxController, const ::rtl::Reference& rpPresenterController) - : PresenterSlideSorterInterfaceBase(m_aMutex), - mxComponentContext(rxContext), + : mxComponentContext(rxContext), mxViewId(rxViewId), mpPresenterController(rpPresenterController), mxSlideShowController(mpPresenterController->GetSlideShowController()), @@ -328,7 +327,10 @@ PresenterSlideSorter::PresenterSlideSorter ( } catch (RuntimeException&) { - disposing(); + { + std::unique_lock l(m_aMutex); + disposing(l); + } throw; } } @@ -337,7 +339,7 @@ PresenterSlideSorter::~PresenterSlideSorter() { } -void SAL_CALL PresenterSlideSorter::disposing() +void PresenterSlideSorter::disposing(std::unique_lock&) { mxComponentContext = nullptr; mxViewId = nullptr; @@ -412,26 +414,34 @@ void SAL_CALL PresenterSlideSorter::disposing (const lang::EventObject& rEventOb void SAL_CALL PresenterSlideSorter::windowResized (const awt::WindowEvent&) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } mbIsLayoutPending = true; mpPresenterController->GetPaintManager()->Invalidate(mxWindow); } void SAL_CALL PresenterSlideSorter::windowMoved (const awt::WindowEvent&) { - ThrowIfDisposed(); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); } void SAL_CALL PresenterSlideSorter::windowShown (const lang::EventObject&) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } mbIsLayoutPending = true; mpPresenterController->GetPaintManager()->Invalidate(mxWindow); } void SAL_CALL PresenterSlideSorter::windowHidden (const lang::EventObject&) { - ThrowIfDisposed(); + std::unique_lock l(m_aMutex); + throwIfDisposed(l); } //----- XPaintListener -------------------------------------------------------- @@ -537,7 +547,10 @@ void SAL_CALL PresenterSlideSorter::mouseDragged (const css::awt::MouseEvent&) { Reference SAL_CALL PresenterSlideSorter::getResourceId() { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } return mxViewId; } @@ -567,7 +580,10 @@ void SAL_CALL PresenterSlideSorter::notifyPreviewCreation ( void SAL_CALL PresenterSlideSorter::setCurrentPage (const Reference&) { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex()); if (!mxSlideShowController.is()) @@ -598,7 +614,10 @@ void SAL_CALL PresenterSlideSorter::setCurrentPage (const Reference SAL_CALL PresenterSlideSorter::getCurrentPage() { - ThrowIfDisposed(); + { + std::unique_lock l(m_aMutex); + throwIfDisposed(l); + } return nullptr; } @@ -1042,16 +1061,6 @@ bool PresenterSlideSorter::ProvideCanvas() return mxCanvas.is(); } -void PresenterSlideSorter::ThrowIfDisposed() -{ - if (rBHelper.bDisposed || rBHelper.bInDispose) - { - throw lang::DisposedException ( - u"PresenterSlideSorter has been already disposed"_ustr, - static_cast(this)); - } -} - //===== PresenterSlideSorter::Layout ========================================== PresenterSlideSorter::Layout::Layout ( diff --git a/sd/source/console/PresenterSlideSorter.hxx b/sd/source/console/PresenterSlideSorter.hxx index cb2fa7ce507a..404a2899b744 100644 --- a/sd/source/console/PresenterSlideSorter.hxx +++ b/sd/source/console/PresenterSlideSorter.hxx @@ -25,13 +25,12 @@ #include "PresenterPaneContainer.hxx" #include "PresenterViewFactory.hxx" #include -#include #include #include #include #include #include -#include +#include #include #include #include @@ -42,8 +41,8 @@ namespace sdext::presenter { class PresenterButton; class PresenterScrollBar; -typedef cppu::WeakComponentImplHelper< - css::drawing::framework::XView, +typedef cppu::ImplInheritanceHelper< + sd::framework::AbstractView, css::awt::XWindowListener, css::awt::XPaintListener, css::beans::XPropertyChangeListener, @@ -57,8 +56,7 @@ typedef cppu::WeakComponentImplHelper< to create the slide previews. Painting is done via a canvas. */ class PresenterSlideSorter - : private ::cppu::BaseMutex, - public PresenterSlideSorterInterfaceBase, + : public PresenterSlideSorterInterfaceBase, public CachablePresenterView { public: @@ -69,10 +67,11 @@ public: const ::rtl::Reference& rpPresenterController); virtual ~PresenterSlideSorter() override; - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock&) override; // lang::XEventListener + using WeakComponentImplHelperBase::disposing; virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) override; @@ -176,11 +175,6 @@ private: void GotoSlide (const sal_Int32 nSlideIndex); void ScrollSlideIntoView(sal_Int32 nSlideIndex); bool ProvideCanvas(); - - /** @throws css::lang::DisposedException when the object has already been - disposed. - */ - void ThrowIfDisposed(); }; } // end of namespace ::sdext::presenter diff --git a/sd/source/console/PresenterToolBar.cxx b/sd/source/console/PresenterToolBar.cxx index a0a2d218ded6..79f8aab3a839 100644 --- a/sd/source/console/PresenterToolBar.cxx +++ b/sd/source/console/PresenterToolBar.cxx @@ -926,8 +926,7 @@ PresenterToolBarView::PresenterToolBarView ( const Reference& rxViewId, const rtl::Reference<::sd::DrawController>& rxController, const ::rtl::Reference& rpPresenterController) - : PresenterToolBarViewInterfaceBase(m_aMutex), - mxViewId(rxViewId), + : mxViewId(rxViewId), mpPresenterController(rpPresenterController) { try @@ -968,7 +967,7 @@ PresenterToolBarView::~PresenterToolBarView() { } -void SAL_CALL PresenterToolBarView::disposing() +void PresenterToolBarView::disposing(std::unique_lock&) { rtl::Reference xComponent = std::move(mpToolBar); if (xComponent.is()) diff --git a/sd/source/console/PresenterToolBar.hxx b/sd/source/console/PresenterToolBar.hxx index fb415f324a7b..6d37a2dc3888 100644 --- a/sd/source/console/PresenterToolBar.hxx +++ b/sd/source/console/PresenterToolBar.hxx @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -47,9 +47,9 @@ typedef cppu::WeakComponentImplHelper< css::drawing::XDrawView > PresenterToolBarInterfaceBase; -typedef cppu::WeakComponentImplHelper< +typedef cppu::ImplInheritanceHelper< + sd::framework::AbstractView, css::awt::XPaintListener, - css::drawing::framework::XView, css::drawing::XDrawView > PresenterToolBarViewInterfaceBase; @@ -188,8 +188,7 @@ private: /** View for the PresenterToolBar. */ class PresenterToolBarView - : private ::cppu::BaseMutex, - public PresenterToolBarViewInterfaceBase + : public PresenterToolBarViewInterfaceBase { public: explicit PresenterToolBarView ( @@ -201,7 +200,7 @@ public: PresenterToolBarView(const PresenterToolBarView&) = delete; PresenterToolBarView& operator=(const PresenterToolBarView&) = delete; - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock&) override; const ::rtl::Reference& GetPresenterToolBar() const; @@ -211,6 +210,7 @@ public: // lang::XEventListener + using WeakComponentImplHelperBase::disposing; virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) override; diff --git a/sd/source/console/PresenterViewFactory.cxx b/sd/source/console/PresenterViewFactory.cxx index a27fd674d9fc..59c4b40afb7d 100644 --- a/sd/source/console/PresenterViewFactory.cxx +++ b/sd/source/console/PresenterViewFactory.cxx @@ -160,9 +160,8 @@ void PresenterViewFactory::disposing(std::unique_lock&) { try { - Reference xComponent (rView.second.first, UNO_QUERY); - if (xComponent.is()) - xComponent->dispose(); + if (rView.second.first.is()) + rView.second.first->dispose(); } catch (lang::DisposedException&) { @@ -246,7 +245,7 @@ void PresenterViewFactory::releaseResource (const Reference& rxView) rtl::Reference xAnchorPane = dynamic_cast( mxConfigurationController->getResource(xViewId->getAnchor()).get()); (*mpResourceCache)[xViewId->getResourceURL()] - = ViewResourceDescriptor(Reference(rxView, UNO_QUERY), xAnchorPane); + = ViewResourceDescriptor(dynamic_cast(rxView.get()), xAnchorPane); pView->DeactivatePresenterView(); } } @@ -293,7 +292,7 @@ Reference PresenterViewFactory::CreateView( const Reference& rxViewId, const rtl::Reference& rxAnchorPane) { - Reference xView; + rtl::Reference xView; try { @@ -337,7 +336,7 @@ Reference PresenterViewFactory::CreateView( return xView; } -Reference PresenterViewFactory::CreateSlideShowView( +rtl::Reference PresenterViewFactory::CreateSlideShowView( const Reference& rxViewId) const { if ( ! mxConfigurationController.is()) @@ -363,11 +362,11 @@ Reference PresenterViewFactory::CreateSlideShowView( } } -Reference PresenterViewFactory::CreateSlidePreviewView( +rtl::Reference PresenterViewFactory::CreateSlidePreviewView( const Reference& rxViewId, const rtl::Reference& rxAnchorPane) const { - Reference xView; + rtl::Reference xView; if ( ! mxConfigurationController.is()) return xView; @@ -376,13 +375,12 @@ Reference PresenterViewFactory::CreateSlidePreviewView( try { - xView.set( - static_cast(new NextSlidePreview( + xView = + new NextSlidePreview( mxComponentContext, rxViewId, rxAnchorPane, - mpPresenterController)), - UNO_QUERY_THROW); + mpPresenterController); } catch (RuntimeException&) { @@ -392,7 +390,7 @@ Reference PresenterViewFactory::CreateSlidePreviewView( return xView; } -Reference PresenterViewFactory::CreateToolBarView( +rtl::Reference PresenterViewFactory::CreateToolBarView( const Reference& rxViewId) const { return new PresenterToolBarView( @@ -402,10 +400,10 @@ Reference PresenterViewFactory::CreateToolBarView( mpPresenterController); } -Reference PresenterViewFactory::CreateNotesView( +rtl::Reference PresenterViewFactory::CreateNotesView( const Reference& rxViewId) const { - Reference xView; + rtl::Reference xView; if ( ! mxConfigurationController.is()) return xView; @@ -414,13 +412,12 @@ Reference PresenterViewFactory::CreateNotesView( try { - xView.set(static_cast( + xView = new PresenterNotesView( mxComponentContext, rxViewId, mxControllerWeak.get(), - mpPresenterController)), - UNO_QUERY_THROW); + mpPresenterController); } catch (RuntimeException&) { @@ -430,10 +427,10 @@ Reference PresenterViewFactory::CreateNotesView( return xView; } -Reference PresenterViewFactory::CreateSlideSorterView( +rtl::Reference PresenterViewFactory::CreateSlideSorterView( const Reference& rxViewId) const { - Reference xView; + rtl::Reference xView; if ( ! mxConfigurationController.is()) return xView; @@ -458,14 +455,14 @@ Reference PresenterViewFactory::CreateSlideSorterView( return xView; } -Reference PresenterViewFactory::CreateHelpView( +rtl::Reference PresenterViewFactory::CreateHelpView( const Reference& rxViewId) const { - return Reference(new PresenterHelpView( + return new PresenterHelpView( mxComponentContext, rxViewId, mxControllerWeak.get(), - mpPresenterController)); + mpPresenterController); } //===== CachablePresenterView ================================================= diff --git a/sd/source/console/PresenterViewFactory.hxx b/sd/source/console/PresenterViewFactory.hxx index 2a31442b2183..ecba1db68cca 100644 --- a/sd/source/console/PresenterViewFactory.hxx +++ b/sd/source/console/PresenterViewFactory.hxx @@ -22,7 +22,7 @@ #include "PresenterController.hxx" #include -#include +#include #include #include #include @@ -108,7 +108,7 @@ private: rtl::Reference mxConfigurationController; unotools::WeakReference<::sd::DrawController> mxControllerWeak; ::rtl::Reference mpPresenterController; - typedef ::std::pair, + typedef ::std::pair, rtl::Reference > ViewResourceDescriptor; typedef ::std::map ResourceContainer; std::unique_ptr mpResourceCache; @@ -120,23 +120,23 @@ private: void Register (const ::rtl::Reference<::sd::DrawController>& rxController); - css::uno::Reference CreateSlideShowView( + rtl::Reference CreateSlideShowView( const css::uno::Reference& rxViewId) const; - css::uno::Reference CreateSlidePreviewView( + rtl::Reference CreateSlidePreviewView( const css::uno::Reference& rxViewId, const rtl::Reference& rxPane) const; - css::uno::Reference CreateToolBarView( + rtl::Reference CreateToolBarView( const css::uno::Reference& rxViewId) const; - css::uno::Reference CreateNotesView( + rtl::Reference CreateNotesView( const css::uno::Reference& rxViewId) const; - css::uno::Reference CreateSlideSorterView( + rtl::Reference CreateSlideSorterView( const css::uno::Reference& rxViewId) const; - css::uno::Reference CreateHelpView( + rtl::Reference CreateHelpView( const css::uno::Reference& rxViewId) const; css::uno::Reference GetViewFromCache ( diff --git a/sd/source/console/PresenterWindowManager.cxx b/sd/source/console/PresenterWindowManager.cxx index c55381c9671a..08222efb8415 100644 --- a/sd/source/console/PresenterWindowManager.cxx +++ b/sd/source/console/PresenterWindowManager.cxx @@ -141,7 +141,7 @@ void PresenterWindowManager::SetTheme (const std::shared_ptr& rp } } -void PresenterWindowManager::NotifyViewCreation (const Reference& rxView) +void PresenterWindowManager::NotifyViewCreation (const rtl::Reference& rxView) { PresenterPaneContainer::SharedPaneDescriptor pDescriptor ( mpPaneContainer->FindPaneId(rxView->getResourceId()->getAnchor())); diff --git a/sd/source/console/PresenterWindowManager.hxx b/sd/source/console/PresenterWindowManager.hxx index 673e86ddb8f1..f75d6c02de94 100644 --- a/sd/source/console/PresenterWindowManager.hxx +++ b/sd/source/console/PresenterWindowManager.hxx @@ -70,7 +70,7 @@ public: void SetParentPane (const rtl::Reference& rxPane); void SetTheme (const std::shared_ptr& rpTheme); - void NotifyViewCreation (const css::uno::Reference& rxView); + void NotifyViewCreation (const rtl::Reference& rxView); void SetPanePosSizeAbsolute ( const OUString& rsPaneURL, const double nX, diff --git a/sd/source/ui/framework/configuration/Configuration.cxx b/sd/source/ui/framework/configuration/Configuration.cxx index 3b08c9689119..837059d21904 100644 --- a/sd/source/ui/framework/configuration/Configuration.cxx +++ b/sd/source/ui/framework/configuration/Configuration.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -283,6 +284,8 @@ ConfigurationChangeRequest::~ConfigurationChangeRequest() {} AbstractPane::~AbstractPane() {} +AbstractView::~AbstractView() {} + } // end of namespace sd::framework diff --git a/sd/source/ui/framework/factories/PresentationFactory.cxx b/sd/source/ui/framework/factories/PresentationFactory.cxx index 227c1cf09bae..2740bbd99acf 100644 --- a/sd/source/ui/framework/factories/PresentationFactory.cxx +++ b/sd/source/ui/framework/factories/PresentationFactory.cxx @@ -21,9 +21,8 @@ #include #include -#include +#include #include -#include #include #include @@ -39,14 +38,11 @@ namespace sd::framework { namespace { -typedef comphelper::WeakComponentImplHelper PresentationViewInterfaceBase; - /** The PresentationView is not an actual view, it is a marker whose existence in a configuration indicates that a slideshow is running (in another application window). */ -class PresentationView - : public PresentationViewInterfaceBase +class PresentationView : public AbstractView { public: explicit PresentationView (const Reference& rxViewId) diff --git a/sd/source/ui/framework/module/CenterViewFocusModule.cxx b/sd/source/ui/framework/module/CenterViewFocusModule.cxx index 422852030050..a97408c4dda6 100644 --- a/sd/source/ui/framework/module/CenterViewFocusModule.cxx +++ b/sd/source/ui/framework/module/CenterViewFocusModule.cxx @@ -117,9 +117,9 @@ void CenterViewFocusModule::HandleNewView ( FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL), FrameworkHelper::msViewURLPrefix, AnchorBindingMode_DIRECT)); - Reference xView; + rtl::Reference xView; if (xViewIds.hasElements()) - xView.set( mxConfigurationController->getResource(xViewIds[0]),UNO_QUERY); + xView = dynamic_cast( mxConfigurationController->getResource(xViewIds[0]).get() ); if (mpBase!=nullptr) { auto pViewShellWrapper = dynamic_cast(xView.get()); diff --git a/sd/source/ui/framework/module/NotesPaneModule.cxx b/sd/source/ui/framework/module/NotesPaneModule.cxx index f4ff256db10d..c523f940df7a 100644 --- a/sd/source/ui/framework/module/NotesPaneModule.cxx +++ b/sd/source/ui/framework/module/NotesPaneModule.cxx @@ -222,7 +222,7 @@ void NotesPaneModule::onMainViewSwitch(const OUString& rsViewURL, const bool bIs } } -bool NotesPaneModule::IsMasterView(const Reference& xView) +bool NotesPaneModule::IsMasterView(const rtl::Reference& xView) { if (mpViewShellBase != nullptr) { @@ -250,7 +250,8 @@ void NotesPaneModule::onResourceRequest( return; // do not record the state of bottom pane when in master edit modes - if (!IsMasterView({ mxConfigurationController->getResource(aCenterViews[0]), UNO_QUERY })) + if (!IsMasterView(dynamic_cast( + mxConfigurationController->getResource(aCenterViews[0]).get()))) { if (bActivation) { diff --git a/sd/source/ui/framework/module/NotesPaneModule.hxx b/sd/source/ui/framework/module/NotesPaneModule.hxx index 37d44c085f62..58410867baaf 100644 --- a/sd/source/ui/framework/module/NotesPaneModule.hxx +++ b/sd/source/ui/framework/module/NotesPaneModule.hxx @@ -15,10 +15,6 @@ #include #include -namespace com::sun::star::drawing::framework -{ -class XView; -} namespace sd { class DrawController; @@ -33,6 +29,7 @@ namespace sd::framework { class ConfigurationController; class Configuration; +class AbstractView; /** This module is responsible for handling visibility of NotesPane across modes */ @@ -77,7 +74,7 @@ private: void onMainViewSwitch(const OUString& rsViewURL, const bool bIsActivated); void onResourceRequest(bool bActivation, const rtl::Reference& rxConfiguration); - bool IsMasterView(const css::uno::Reference& xView); + bool IsMasterView(const rtl::Reference& xView); DECL_LINK(EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent&, void); }; diff --git a/sd/source/ui/framework/module/ToolBarModule.cxx b/sd/source/ui/framework/module/ToolBarModule.cxx index f7b8235168f5..0099127f734d 100644 --- a/sd/source/ui/framework/module/ToolBarModule.cxx +++ b/sd/source/ui/framework/module/ToolBarModule.cxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/sd/source/ui/framework/tools/FrameworkHelper.cxx b/sd/source/ui/framework/tools/FrameworkHelper.cxx index 7bf19952133a..ddbeb4cae30b 100644 --- a/sd/source/ui/framework/tools/FrameworkHelper.cxx +++ b/sd/source/ui/framework/tools/FrameworkHelper.cxx @@ -354,14 +354,14 @@ bool FrameworkHelper::IsValid() const return lcl_getViewShell( lcl_getFirstViewInPane( mxConfigurationController, xPaneId ) ); } -::std::shared_ptr FrameworkHelper::GetViewShell (const Reference& rxView) +::std::shared_ptr FrameworkHelper::GetViewShell (const rtl::Reference& rxView) { return lcl_getViewShell( rxView ); } -Reference FrameworkHelper::GetView (const Reference& rxPaneOrViewId) +rtl::Reference FrameworkHelper::GetView (const Reference& rxPaneOrViewId) { - Reference xView; + rtl::Reference xView; if ( ! rxPaneOrViewId.is() || ! mxConfigurationController.is()) return nullptr; @@ -370,11 +370,11 @@ Reference FrameworkHelper::GetView (const Reference& rxPaneO { if (rxPaneOrViewId->getResourceURL().match(msViewURLPrefix)) { - xView.set( mxConfigurationController->getResource( rxPaneOrViewId ), UNO_QUERY ); + xView = dynamic_cast(mxConfigurationController->getResource( rxPaneOrViewId ).get()); } else { - xView.set( lcl_getFirstViewInPane( mxConfigurationController, rxPaneOrViewId ), UNO_QUERY ); + xView = dynamic_cast(lcl_getFirstViewInPane( mxConfigurationController, rxPaneOrViewId ).get()); } } catch (lang::DisposedException&) @@ -462,7 +462,7 @@ const OUString & FrameworkHelper::GetViewURL (ViewShell::ShellType eType) namespace { -void updateEditMode(const Reference &xView, const EditMode eEMode, bool updateFrameView) +void updateEditMode(const rtl::Reference &xView, const EditMode eEMode, bool updateFrameView) { // Ensure we have the expected edit mode // The check is only for DrawViewShell as OutlineViewShell @@ -488,7 +488,7 @@ void asyncUpdateEditMode(FrameworkHelper* const pHelper, const EditMode eEMode) { Reference xPaneId ( FrameworkHelper::CreateResourceId(framework::FrameworkHelper::msCenterPaneURL)); - Reference xView (pHelper->GetView(xPaneId)); + rtl::Reference xView (pHelper->GetView(xPaneId)); updateEditMode(xView, eEMode, true); } @@ -527,7 +527,7 @@ void FrameworkHelper::HandleModeChangeSlot ( Reference xPaneId ( CreateResourceId(framework::FrameworkHelper::msCenterPaneURL)); - Reference xView (GetView(xPaneId)); + rtl::Reference xView (GetView(xPaneId)); // Compute requested view OUString sRequestedView; diff --git a/offapi/com/sun/star/drawing/framework/XView.idl b/sd/source/ui/inc/framework/AbstractView.hxx similarity index 74% rename from offapi/com/sun/star/drawing/framework/XView.idl rename to sd/source/ui/inc/framework/AbstractView.hxx index 49f3b814d43f..6e2ac6c903fb 100644 --- a/offapi/com/sun/star/drawing/framework/XView.idl +++ b/sd/source/ui/inc/framework/AbstractView.hxx @@ -17,7 +17,18 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -module com { module sun { module star { module drawing { module framework { +#pragma once + +#include +#include +#include +#include +#include + +namespace sd::framework +{ +typedef comphelper::WeakComponentImplHelper + AbstractViewInterfaceBase; /** A view in the drawing framework is any object that paints into a pane.

Typical examples are the Impress views that show a graphical @@ -28,11 +39,12 @@ module com { module sun { module star { module drawing { module framework { reference them.

The URL prefix of views is private:resource/view

*/ -interface XView +class SD_DLLPUBLIC AbstractView : public AbstractViewInterfaceBase { - interface XResource; +public: + virtual ~AbstractView() override; }; -}; }; }; }; }; // ::com::sun::star::drawing::framework +} // end of namespace sd::framework /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/inc/framework/FrameworkHelper.hxx b/sd/source/ui/inc/framework/FrameworkHelper.hxx index 78bdaf2cf219..2d29332e7ce4 100644 --- a/sd/source/ui/inc/framework/FrameworkHelper.hxx +++ b/sd/source/ui/inc/framework/FrameworkHelper.hxx @@ -29,7 +29,6 @@ #include namespace com::sun::star::drawing::framework { class XResourceId; } -namespace com::sun::star::drawing::framework { class XView; } namespace sd::framework { struct ConfigurationChangeEvent; } namespace sd { @@ -39,6 +38,7 @@ class ViewShellBase; namespace sd::framework { class ConfigurationController; +class AbstractView; /** The FrameworkHelper is a convenience class that simplifies the access to the drawing framework. @@ -131,7 +131,7 @@ public: reference then an empty pointer is returned. */ static ::std::shared_ptr GetViewShell ( - const css::uno::Reference& rxView); + const rtl::Reference& rxView); typedef ::std::function ConfigurationChangeEventFilter; @@ -172,7 +172,7 @@ public: of the involved objects does not support XTunnel (where necessary). */ - css::uno::Reference GetView ( + rtl::Reference GetView ( const css::uno::Reference& rxPaneOrViewId); /** Request the specified view to be displayed in the specified pane. diff --git a/sd/source/ui/inc/framework/ViewShellWrapper.hxx b/sd/source/ui/inc/framework/ViewShellWrapper.hxx index c91e97d19b29..949a1ddfaadf 100644 --- a/sd/source/ui/inc/framework/ViewShellWrapper.hxx +++ b/sd/source/ui/inc/framework/ViewShellWrapper.hxx @@ -19,7 +19,7 @@ #pragma once -#include +#include #include #include #include @@ -32,10 +32,11 @@ namespace com::sun::star::awt { class XWindow; } namespace sd::framework { -typedef comphelper::WeakComponentImplHelper < css::awt::XWindowListener - , css::view::XSelectionSupplier - , css::drawing::framework::XView - > ViewShellWrapperInterfaceBase; +typedef cppu::ImplInheritanceHelper< + sd::framework::AbstractView + , css::awt::XWindowListener + , css::view::XSelectionSupplier + > ViewShellWrapperInterfaceBase; /** This class wraps ViewShell objects and makes them look like an XView. Most importantly it provides access to the ViewShell implementation. diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx index ca762720fe0b..123a2afe85fa 100644 --- a/sd/source/ui/sidebar/LayoutMenu.cxx +++ b/sd/source/ui/sidebar/LayoutMenu.cxx @@ -56,7 +56,7 @@ #include #include -#include +#include #include #include @@ -476,7 +476,7 @@ void LayoutMenu::Fill() { Reference xPaneId (new sd::framework::ResourceId( FrameworkHelper::msCenterPaneURL)); - Reference xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId)); + rtl::Reference xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId)); if (xView.is()) sCenterPaneViewName = xView->getResourceId()->getResourceURL(); } diff --git a/sd/source/ui/tools/EventMultiplexer.cxx b/sd/source/ui/tools/EventMultiplexer.cxx index 3c0f03739bbf..ba11d5c35e94 100644 --- a/sd/source/ui/tools/EventMultiplexer.cxx +++ b/sd/source/ui/tools/EventMultiplexer.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -515,10 +515,10 @@ void EventMultiplexer::Implementation::notifyConfigurationChange ( // Add selection change listener at slide sorter. if (rEvent.ResourceId->getResourceURL() == FrameworkHelper::msSlideSorterURL) { + auto pView = dynamic_cast(rEvent.ResourceObject.get()); slidesorter::SlideSorterViewShell* pViewShell = dynamic_cast( - FrameworkHelper::GetViewShell( - Reference(rEvent.ResourceObject,UNO_QUERY)).get()); + FrameworkHelper::GetViewShell(pView).get()); if (pViewShell != nullptr) pViewShell->AddSelectionChangeListener ( LINK(this, @@ -541,10 +541,10 @@ void EventMultiplexer::Implementation::notifyConfigurationChange ( // selection change listener at slide sorter. if (rEvent.ResourceId->getResourceURL() == FrameworkHelper::msSlideSorterURL) { + auto pView = dynamic_cast(rEvent.ResourceObject.get()); slidesorter::SlideSorterViewShell* pViewShell = dynamic_cast( - FrameworkHelper::GetViewShell( - Reference(rEvent.ResourceObject, UNO_QUERY)).get()); + FrameworkHelper::GetViewShell(pView).get()); if (pViewShell != nullptr) pViewShell->RemoveSelectionChangeListener ( LINK(this, diff --git a/sd/source/ui/view/ViewTabBar.cxx b/sd/source/ui/view/ViewTabBar.cxx index 0f5859ed469d..3e911d583efe 100644 --- a/sd/source/ui/view/ViewTabBar.cxx +++ b/sd/source/ui/view/ViewTabBar.cxx @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -258,13 +258,12 @@ bool ViewTabBar::ActivatePage(size_t nIndex) mxController->getConfigurationController()); if ( ! xConfigurationController.is()) throw RuntimeException(); - Reference xView; + rtl::Reference xView; try { - xView.set(xConfigurationController->getResource( + xView = dynamic_cast(xConfigurationController->getResource( new sd::framework::ResourceId( - FrameworkHelper::msCenterPaneURL)), - UNO_QUERY); + FrameworkHelper::msCenterPaneURL)).get()); } catch (const DeploymentException&) { @@ -415,7 +414,7 @@ const std::vector& ViewTabBar::getTabBarButtons() const void ViewTabBar::UpdateActiveButton() { - Reference xView; + rtl::Reference xView; if (mpViewShellBase != nullptr) xView = FrameworkHelper::Instance(*mpViewShellBase)->GetView( mxViewTabBarId->getAnchor()); diff --git a/sd/source/ui/view/frmview.cxx b/sd/source/ui/view/frmview.cxx index 6800dec6f4a6..7def456f4468 100644 --- a/sd/source/ui/view/frmview.cxx +++ b/sd/source/ui/view/frmview.cxx @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include @@ -89,7 +89,7 @@ FrameView::FrameView(SdDrawDocument* pDrawDoc, FrameView* pFrameView /* = NULL * nSdViewShellCount++; OUString sViewURL; - Reference xView ( + rtl::Reference xView ( framework::FrameworkHelper::Instance(*pBase)->GetView( new sd::framework::ResourceId( framework::FrameworkHelper::msCenterPaneURL))); diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 1d3ff4437d20..d26fbfcd1c84 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -95,7 +95,7 @@ #include #include -#include +#include #include using namespace ::com::sun::star; @@ -428,10 +428,10 @@ void ViewShell::BroadcastContextForActivation(const bool bIsActivated) { auto pFrameworkHelper = framework::FrameworkHelper::Instance(GetViewShellBase()); - uno::Reference xView; + rtl::Reference xView; if (rResId->getResourceURL().match(framework::FrameworkHelper::msViewURLPrefix)) { - xView.set(xConfigurationController->getResource(rResId), UNO_QUERY); + xView = dynamic_cast(xConfigurationController->getResource(rResId).get()); if (xView.is()) { diff --git a/sd/workben/custompanel/ctp_panel.hxx b/sd/workben/custompanel/ctp_panel.hxx index 03e844e31645..56f529bda382 100644 --- a/sd/workben/custompanel/ctp_panel.hxx +++ b/sd/workben/custompanel/ctp_panel.hxx @@ -19,7 +19,7 @@ #pragma once -#include +#include #include #include #include