From 80099fdd51a69eaa6c36ca88ef772810e4a777fa Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 14 Dec 2022 18:50:30 +0100 Subject: [PATCH] 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 --- vcl/inc/unx/gtk/gtkinst.hxx | 7 +++++++ vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx | 3 ++- vcl/unx/gtk3/gtkinst.cxx | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) 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 #include #include +#include #include #include #include @@ -343,6 +344,12 @@ public: { return m_pWeldWidget; } + + sal_Int64 SAL_CALL getSomething(css::uno::Sequence const& aIdentifier) override + { + return comphelper::getSomethingImpl( + aIdentifier, this, comphelper::FallbackToGetSomethingOf{}); + } }; 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 #include #include +#include #include #include #include @@ -1631,7 +1632,7 @@ GtkWidget* SalGtkPicker::GetParentWidget(const uno::Sequence& rArgumen if (xParentWindow.is()) { - if (SalGtkXWindow* pGtkXWindow = dynamic_cast(xParentWindow.get())) + if (SalGtkXWindow* pGtkXWindow = comphelper::getFromUnoTunnel(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 #include #include +#include #include #include #include @@ -24483,7 +24484,7 @@ weld::MessageDialog* GtkInstance::CreateMessageDialog(weld::Widget* pParent, Vcl weld::Window* GtkInstance::GetFrameWeld(const css::uno::Reference& rWindow) { - if (SalGtkXWindow* pGtkXWindow = dynamic_cast(rWindow.get())) + if (SalGtkXWindow* pGtkXWindow = comphelper::getFromUnoTunnel(rWindow)) return pGtkXWindow->getFrameWeld(); return SalInstance::GetFrameWeld(rWindow); }