sdext/source/presenter/PresenterNotesView.cxx | 3 ++- sdext/source/presenter/PresenterSlideShowView.cxx | 4 ++++ sdext/source/presenter/PresenterSlideShowView.hxx | 8 +++++++- sdext/source/presenter/PresenterSlideSorter.cxx | 5 +++++ sdext/source/presenter/PresenterSlideSorter.hxx | 8 +++++++- sdext/source/presenter/PresenterToolBar.cxx | 5 +++++ sdext/source/presenter/PresenterToolBar.hxx | 8 +++++++- sdext/source/presenter/PresenterViewFactory.cxx | 16 +++++++++++++--- sdext/source/presenter/PresenterViewFactory.hxx | 5 ++++- vcl/inc/unx/gtk/gtkinst.hxx | 7 +++++++ vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx | 3 ++- vcl/unx/gtk3/gtkinst.cxx | 3 ++- 12 files changed, 65 insertions(+), 10 deletions(-)
New commits: commit 80099fdd51a69eaa6c36ca88ef772810e4a777fa Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Dec 14 18:50:30 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Dec 23 22:56:40 2022 +0000 loplugin:unocast (SalGtkXWindow) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I139c4006c385019d7332b1594ff24e2ab314e5ed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144766 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index a597e5be2436..6446122611e5 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -33,6 +33,7 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/awt/XWindow.hpp> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/compbase.hxx> #include <vcl/weld.hxx> #include <vcl/weldutils.hxx> @@ -343,6 +344,12 @@ public: { return m_pWeldWidget; } + + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const& aIdentifier) override + { + return comphelper::getSomethingImpl( + aIdentifier, this, comphelper::FallbackToGetSomethingOf<TransportAsXWindow>{}); + } }; GdkPixbuf* load_icon_by_name(const OUString& rIconName); diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx index 4068d57f2fa1..762f1338fe62 100644 --- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#include <comphelper/servicehelper.hxx> #include <osl/diagnose.h> #include <rtl/process.h> #include <sal/log.hxx> @@ -1631,7 +1632,7 @@ GtkWidget* SalGtkPicker::GetParentWidget(const uno::Sequence<uno::Any>& rArgumen if (xParentWindow.is()) { - if (SalGtkXWindow* pGtkXWindow = dynamic_cast<SalGtkXWindow*>(xParentWindow.get())) + if (SalGtkXWindow* pGtkXWindow = comphelper::getFromUnoTunnel<SalGtkXWindow>(xParentWindow)) pParentWidget = pGtkXWindow->getGtkWidget(); else { diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 0525f8118531..960aabe11a0b 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -65,6 +65,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/servicehelper.hxx> #include <comphelper/string.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/implbase.hxx> @@ -24483,7 +24484,7 @@ weld::MessageDialog* GtkInstance::CreateMessageDialog(weld::Widget* pParent, Vcl weld::Window* GtkInstance::GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) { - if (SalGtkXWindow* pGtkXWindow = dynamic_cast<SalGtkXWindow*>(rWindow.get())) + if (SalGtkXWindow* pGtkXWindow = comphelper::getFromUnoTunnel<SalGtkXWindow>(rWindow)) return pGtkXWindow->getFrameWeld(); return SalInstance::GetFrameWeld(rWindow); } commit cc147f576d8687fb79c77d47d41dc4ba1678a469 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Dec 14 18:18:39 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Dec 23 22:56:25 2022 +0000 loplugin:unocast (sdext::presenter::CachablePresenterView) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: Ib158190fe9059d1c6b0b002cd37f83593a494e63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144764 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sdext/source/presenter/PresenterNotesView.cxx b/sdext/source/presenter/PresenterNotesView.cxx index ca434f5fa8a8..7bfc1bfa2c06 100644 --- a/sdext/source/presenter/PresenterNotesView.cxx +++ b/sdext/source/presenter/PresenterNotesView.cxx @@ -378,7 +378,8 @@ 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); + return comphelper::getSomethingImpl( + aIdentifier, this, comphelper::FallbackToGetSomethingOf<CachablePresenterView>{}); } css::uno::Sequence<sal_Int8> const & PresenterNotesView::getUnoTunnelId() { diff --git a/sdext/source/presenter/PresenterSlideShowView.cxx b/sdext/source/presenter/PresenterSlideShowView.cxx index 132eaf35f85e..be4cc6a65d20 100644 --- a/sdext/source/presenter/PresenterSlideShowView.cxx +++ b/sdext/source/presenter/PresenterSlideShowView.cxx @@ -279,6 +279,10 @@ css::uno::Reference<css::drawing::XDrawPage> SAL_CALL PresenterSlideShowView::ge return mxCurrentSlide; } +sal_Int64 PresenterSlideShowView::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return CachablePresenterView::getSomething(aIdentifier); +} + //----- CachablePresenterView ------------------------------------------------- void PresenterSlideShowView::ReleaseView() diff --git a/sdext/source/presenter/PresenterSlideShowView.hxx b/sdext/source/presenter/PresenterSlideShowView.hxx index e4466522eddf..7f93e4b0e6e2 100644 --- a/sdext/source/presenter/PresenterSlideShowView.hxx +++ b/sdext/source/presenter/PresenterSlideShowView.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/drawing/framework/XResourceId.hpp> #include <com/sun/star/drawing/framework/XView.hpp> #include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/presentation/XSlideShowController.hpp> #include <com/sun/star/rendering/XPolyPolygon2D.hpp> #include <com/sun/star/uno/XComponentContext.hpp> @@ -47,7 +48,8 @@ typedef cppu::WeakComponentImplHelper< css::awt::XMouseMotionListener, css::awt::XWindowListener, css::drawing::framework::XView, - css::drawing::XDrawView + css::drawing::XDrawView, + css::lang::XUnoTunnel > PresenterSlideShowViewInterfaceBase; /** Life view in a secondary window of a full screen slide show. @@ -166,6 +168,10 @@ public: virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage() override; + // XUnoTunnel + + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override; + // CachablePresenterView virtual void ActivatePresenterView() override; diff --git a/sdext/source/presenter/PresenterSlideSorter.cxx b/sdext/source/presenter/PresenterSlideSorter.cxx index ef33a4dde634..1b3fb0a1d753 100644 --- a/sdext/source/presenter/PresenterSlideSorter.cxx +++ b/sdext/source/presenter/PresenterSlideSorter.cxx @@ -612,6 +612,11 @@ Reference<drawing::XDrawPage> SAL_CALL PresenterSlideSorter::getCurrentPage() } +sal_Int64 PresenterSlideSorter::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return CachablePresenterView::getSomething(aIdentifier); +} + + void PresenterSlideSorter::UpdateLayout() { if ( ! mxWindow.is()) diff --git a/sdext/source/presenter/PresenterSlideSorter.hxx b/sdext/source/presenter/PresenterSlideSorter.hxx index 807bc439929e..7f1f3ac845d8 100644 --- a/sdext/source/presenter/PresenterSlideSorter.hxx +++ b/sdext/source/presenter/PresenterSlideSorter.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/drawing/framework/XResourceId.hpp> #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/geometry/RealRectangle2D.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/rendering/XPolyPolygon2D.hpp> namespace sdext::presenter { @@ -50,7 +51,8 @@ typedef cppu::WeakComponentImplHelper< css::drawing::XSlidePreviewCacheListener, css::awt::XMouseListener, css::awt::XMouseMotionListener, - css::drawing::XDrawView + css::drawing::XDrawView, + css::lang::XUnoTunnel > PresenterSlideSorterInterfaceBase; /** A simple slide sorter for the presenter screen. It uses a preview cache @@ -129,6 +131,10 @@ public: virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage() override; + // XUnoTunnel + + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override; + private: css::uno::Reference<css::uno::XComponentContext> mxComponentContext; css::uno::Reference<css::drawing::framework::XResourceId> mxViewId; diff --git a/sdext/source/presenter/PresenterToolBar.cxx b/sdext/source/presenter/PresenterToolBar.cxx index 867459423d8e..b095975680e4 100644 --- a/sdext/source/presenter/PresenterToolBar.cxx +++ b/sdext/source/presenter/PresenterToolBar.cxx @@ -575,6 +575,11 @@ Reference<drawing::XDrawPage> SAL_CALL PresenterToolBar::getCurrentPage() } +sal_Int64 PresenterToolBar::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return CachablePresenterView::getSomething(aIdentifier); +} + + void PresenterToolBar::CreateControls ( const OUString& rsConfigurationPath) { diff --git a/sdext/source/presenter/PresenterToolBar.hxx b/sdext/source/presenter/PresenterToolBar.hxx index 1b789955689c..50937ea8d3bd 100644 --- a/sdext/source/presenter/PresenterToolBar.hxx +++ b/sdext/source/presenter/PresenterToolBar.hxx @@ -34,6 +34,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 <functional> @@ -44,7 +45,8 @@ typedef cppu::WeakComponentImplHelper< css::awt::XPaintListener, css::awt::XMouseListener, css::awt::XMouseMotionListener, - css::drawing::XDrawView + css::drawing::XDrawView, + css::lang::XUnoTunnel > PresenterToolBarInterfaceBase; typedef cppu::WeakComponentImplHelper< @@ -134,6 +136,10 @@ public: virtual css::uno::Reference<css::drawing::XDrawPage> SAL_CALL getCurrentPage() override; + // XUnoTunnel + + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override; + class Context; private: diff --git a/sdext/source/presenter/PresenterViewFactory.cxx b/sdext/source/presenter/PresenterViewFactory.cxx index 06eff32f7d3f..2768edf763ab 100644 --- a/sdext/source/presenter/PresenterViewFactory.cxx +++ b/sdext/source/presenter/PresenterViewFactory.cxx @@ -26,6 +26,7 @@ #include "PresenterSlideSorter.hxx" #include "PresenterToolBar.hxx" #include <com/sun/star/drawing/framework/XControllerManager.hpp> +#include <comphelper/servicehelper.hxx> #include <utility> using namespace ::com::sun::star; @@ -215,7 +216,7 @@ void SAL_CALL PresenterViewFactory::releaseResource (const Reference<XResource>& pDescriptor->SetActivationState(false); // Dispose only views that we can not put into the cache. - CachablePresenterView* pView = dynamic_cast<CachablePresenterView*>(rxView.get()); + CachablePresenterView* pView = comphelper::getFromUnoTunnel<CachablePresenterView>(rxView); if (pView == nullptr || mpResourceCache == nullptr) { try @@ -271,7 +272,7 @@ Reference<XResource> PresenterViewFactory::GetViewFromCache( if (iView->second.second == rxAnchorPane) { CachablePresenterView* pView - = dynamic_cast<CachablePresenterView*>(iView->second.first.get()); + = comphelper::getFromUnoTunnel<CachablePresenterView>(iView->second.first); if (pView != nullptr) pView->ActivatePresenterView(); return iView->second.first; @@ -322,7 +323,7 @@ Reference<XResource> PresenterViewFactory::CreateView( } // Activate it. - CachablePresenterView* pView = dynamic_cast<CachablePresenterView*>(xView.get()); + CachablePresenterView* pView = comphelper::getFromUnoTunnel<CachablePresenterView>(xView); if (pView != nullptr) pView->ActivatePresenterView(); } @@ -480,6 +481,15 @@ void PresenterViewFactory::ThrowIfDisposed() const //===== CachablePresenterView ================================================= +sal_Int64 CachablePresenterView::getSomething(css::uno::Sequence<sal_Int8> const & id) { + return comphelper::getSomethingImpl(id, this); +} + +css::uno::Sequence<sal_Int8> const & CachablePresenterView::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + CachablePresenterView::CachablePresenterView() : mbIsPresenterViewActive(true) { diff --git a/sdext/source/presenter/PresenterViewFactory.hxx b/sdext/source/presenter/PresenterViewFactory.hxx index 7f3468d4e57a..32429c790cff 100644 --- a/sdext/source/presenter/PresenterViewFactory.hxx +++ b/sdext/source/presenter/PresenterViewFactory.hxx @@ -39,7 +39,7 @@ typedef ::cppu::WeakComponentImplHelper < /** Base class for presenter views that allows the view factory to store them in a cache and reuse deactivated views. */ -class SAL_LOPLUGIN_ANNOTATE("crosscast") CachablePresenterView +class CachablePresenterView { public: virtual void ActivatePresenterView(); @@ -55,6 +55,9 @@ public: */ virtual void ReleaseView(); + sal_Int64 getSomething(css::uno::Sequence<sal_Int8> const & id); + static css::uno::Sequence<sal_Int8> const & getUnoTunnelId(); + protected: bool mbIsPresenterViewActive;