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 <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann 2022-12-14 18:50:30 +01:00
parent cc147f576d
commit 80099fdd51
3 changed files with 11 additions and 2 deletions

View File

@ -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);

View File

@ -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
{

View File

@ -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);
}