sdext/source/presenter/PresenterAccessibility.cxx | 3 ++- sdext/source/presenter/PresenterNotesView.cxx | 10 ++++++++++ sdext/source/presenter/PresenterNotesView.hxx | 7 ++++++- sdext/source/presenter/PresenterProtocolHandler.cxx | 3 ++- sfx2/source/devtools/DevelopmentToolDockingWindow.cxx | 3 ++- sfx2/source/devtools/SelectionChangeHandler.hxx | 16 +++++++++++++++- 6 files changed, 37 insertions(+), 5 deletions(-)
New commits: commit 9e73ff9fce12e102bb3c3cea8d8bb96c88f2c9ad Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Dec 13 10:28:31 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Dec 14 08:55:32 2022 +0000 loplugin:unocast (sdext::presenter::PresenterNotesView) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: Iee184c75fb5d4a8f00b932c001df023de795c469 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144144 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sdext/source/presenter/PresenterAccessibility.cxx b/sdext/source/presenter/PresenterAccessibility.cxx index 4f2fa33f3866..7040da4a3c51 100644 --- a/sdext/source/presenter/PresenterAccessibility.cxx +++ b/sdext/source/presenter/PresenterAccessibility.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/drawing/framework/XPane.hpp> #include <com/sun/star/drawing/framework/XView.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/implbase.hxx> #include <o3tl/safeint.hxx> @@ -513,7 +514,7 @@ void PresenterAccessible::UpdateAccessibilityHierarchy() if (pNotesPane) xNotesView = pNotesPane->mxView; rtl::Reference<PresenterNotesView> pNotesView ( - dynamic_cast<PresenterNotesView*>(xNotesView.get())); + comphelper::getFromUnoTunnel<PresenterNotesView>(xNotesView)); UpdateAccessibilityHierarchy( pPreviewPane ? pPreviewPane->mxContentWindow : Reference<awt::XWindow>(), diff --git a/sdext/source/presenter/PresenterNotesView.cxx b/sdext/source/presenter/PresenterNotesView.cxx index 457be1f612b7..ca434f5fa8a8 100644 --- a/sdext/source/presenter/PresenterNotesView.cxx +++ b/sdext/source/presenter/PresenterNotesView.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/rendering/CompositeOperation.hpp> #include <com/sun/star/rendering/XSpriteCanvas.hpp> #include <com/sun/star/text/XTextRange.hpp> +#include <comphelper/servicehelper.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -376,6 +377,15 @@ void SAL_CALL PresenterNotesView::keyPressed (const awt::KeyEvent& rEvent) void SAL_CALL PresenterNotesView::keyReleased (const awt::KeyEvent&) {} +sal_Int64 PresenterNotesView::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence<sal_Int8> const & PresenterNotesView::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + void PresenterNotesView::Layout() { diff --git a/sdext/source/presenter/PresenterNotesView.hxx b/sdext/source/presenter/PresenterNotesView.hxx index 1af3f241f004..05368a7151c6 100644 --- a/sdext/source/presenter/PresenterNotesView.hxx +++ b/sdext/source/presenter/PresenterNotesView.hxx @@ -31,6 +31,7 @@ #include <com/sun/star/drawing/framework/XView.hpp> #include <com/sun/star/drawing/framework/XResourceId.hpp> #include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <rtl/ref.hxx> #include <memory> @@ -45,7 +46,8 @@ typedef cppu::WeakComponentImplHelper< css::awt::XPaintListener, css::drawing::framework::XView, css::drawing::XDrawView, - css::awt::XKeyListener + css::awt::XKeyListener, + css::lang::XUnoTunnel > PresenterNotesViewInterfaceBase; /** A drawing framework view of the notes of a slide. At the moment this is @@ -117,6 +119,9 @@ public: virtual void SAL_CALL keyPressed (const css::awt::KeyEvent& rEvent) override; virtual void SAL_CALL keyReleased (const css::awt::KeyEvent& rEvent) override; + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override; + static css::uno::Sequence<sal_Int8> const & getUnoTunnelId(); + private: css::uno::Reference<css::drawing::framework::XResourceId> mxViewId; ::rtl::Reference<PresenterController> mpPresenterController; diff --git a/sdext/source/presenter/PresenterProtocolHandler.cxx b/sdext/source/presenter/PresenterProtocolHandler.cxx index a32a73b6180e..bda104ce37d8 100644 --- a/sdext/source/presenter/PresenterProtocolHandler.cxx +++ b/sdext/source/presenter/PresenterProtocolHandler.cxx @@ -24,6 +24,7 @@ #include "PresenterPaneContainer.hxx" #include "PresenterViewFactory.hxx" #include "PresenterWindowManager.hxx" +#include <comphelper/servicehelper.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <algorithm> @@ -792,7 +793,7 @@ NotesFontSizeCommand::NotesFontSizeCommand( if (!pDescriptor) return nullptr; - return dynamic_cast<PresenterNotesView*>(pDescriptor->mxView.get()); + return comphelper::getFromUnoTunnel<PresenterNotesView>(pDescriptor->mxView); } void NotesFontSizeCommand::Execute() commit a98acca8fbc38d3fd5600ae5056a8e42b6d8a40d Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Dec 13 11:28:31 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Dec 14 08:55:19 2022 +0000 loplugin:unocast (SelectionChangeHandler) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: Ibc2511c8521923c854e4b450649ea616581af2fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144141 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx b/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx index de0950a7edaf..736343310bd5 100644 --- a/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx +++ b/sfx2/source/devtools/DevelopmentToolDockingWindow.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <comphelper/servicehelper.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/objsh.hxx> #include <sfx2/viewfrm.hxx> @@ -87,7 +88,7 @@ void DevelopmentToolDockingWindow::dispose() { // Stop and remove the listener auto* pSelectionChangeHandler - = dynamic_cast<SelectionChangeHandler*>(mxSelectionListener.get()); + = comphelper::getFromUnoTunnel<SelectionChangeHandler>(mxSelectionListener); if (pSelectionChangeHandler) pSelectionChangeHandler->stopListening(); diff --git a/sfx2/source/devtools/SelectionChangeHandler.hxx b/sfx2/source/devtools/SelectionChangeHandler.hxx index 57224e056a52..f919a2fe1400 100644 --- a/sfx2/source/devtools/SelectionChangeHandler.hxx +++ b/sfx2/source/devtools/SelectionChangeHandler.hxx @@ -13,12 +13,15 @@ #include <sfx2/devtools/DevelopmentToolDockingWindow.hxx> #include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> #include <comphelper/compbase.hxx> +#include <comphelper/servicehelper.hxx> #include <utility> -typedef comphelper::WeakComponentImplHelper<css::view::XSelectionChangeListener> +typedef comphelper::WeakComponentImplHelper<css::view::XSelectionChangeListener, + css::lang::XUnoTunnel> SelectionChangeHandlerInterfaceBase; /** Selection change handler to listen to document selection changes. @@ -67,6 +70,17 @@ public: virtual void SAL_CALL disposing(const css::lang::EventObject& /*rEvent*/) override {} using comphelper::WeakComponentImplHelperBase::disposing; + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const& aIdentifier) override + { + return comphelper::getSomethingImpl(aIdentifier, this); + } + + static css::uno::Sequence<sal_Int8> const& getUnoTunnelId() + { + static comphelper::UnoIdInit const id; + return id.getSeq(); + } + private: SelectionChangeHandler(const SelectionChangeHandler&) = delete; SelectionChangeHandler& operator=(const SelectionChangeHandler&) = delete;