diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-12-13 09:30:25 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-12-20 08:34:38 +0000 |
commit | feba0ddb1521d1142560fe54b7d7696ee910237f (patch) | |
tree | b13dbee741b4a4708b74613be33feda3d1a75c30 /extensions | |
parent | f6b4c3fb68f9b36e1e64fc4a4c680ab1bb7fb013 (diff) |
loplugin:unocast (weld::TransportAsXWindow)
(See the upcoming commit introducing that loplugin:unocast on why such
dynamic_casts from UNO types are dangerous.)
On macOS, where we implicitly use -fvisibility-inlines-hidden-static-local-var
since
<https://github.com/llvm/llvm-project/commit/d46f2c51e4c849683434bb5a0fb6164957474b8f>
"Make -fvisibility-inlines-hidden apply to static local variables in inline
functions on Darwin", the static id local var in
weld::TransportAsXWindow::getUnoTunnelId cannot be in an inline function
implicitly hidden via -fvisibility-inlines-hidden. Explicitly marking the
function as VCL_DLLPUBLIC would help, but would in turn cause MSVC error 2487
("member of a dll interface class may not be declared with dll interface"). So
just make the function non-inline in a new vcl/source/window/weldutils.cxx
(which would arguably be the best approach for the whole class, anyway).
Change-Id: Ib5615f6aae19346ea05b8b85ff77c0e5ea860994
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144331
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/propctrlr/browserline.cxx | 3 | ||||
-rw-r--r-- | extensions/source/propctrlr/handlerhelper.cxx | 6 | ||||
-rw-r--r-- | extensions/source/propctrlr/propcontroller.cxx | 5 |
3 files changed, 9 insertions, 5 deletions
diff --git a/extensions/source/propctrlr/browserline.cxx b/extensions/source/propctrlr/browserline.cxx index 53a58966e25d..c77d211314a0 100644 --- a/extensions/source/propctrlr/browserline.cxx +++ b/extensions/source/propctrlr/browserline.cxx @@ -26,6 +26,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> +#include <comphelper/servicehelper.hxx> #include <comphelper/string.hxx> #include <tools/debug.hxx> #include <comphelper/diagnose_ex.hxx> @@ -110,7 +111,7 @@ namespace pcr { m_xControl = rxControl; auto xWindow = m_xControl->getControlWindow(); - if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xWindow.get())) + if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xWindow)) m_pControlWindow = pTunnel->getWidget(); else m_pControlWindow = nullptr; diff --git a/extensions/source/propctrlr/handlerhelper.cxx b/extensions/source/propctrlr/handlerhelper.cxx index 77743c622ad7..55ffb9182f48 100644 --- a/extensions/source/propctrlr/handlerhelper.cxx +++ b/extensions/source/propctrlr/handlerhelper.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/inspection/XStringListControl.hpp> #include <com/sun/star/inspection/XNumericControl.hpp> #include <comphelper/diagnose_ex.hxx> +#include <comphelper/servicehelper.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <vcl/weldutils.hxx> @@ -291,8 +292,9 @@ namespace pcr std::unique_ptr<weld::Builder> PropertyHandlerHelper::makeBuilder(const OUString& rUIFile, const Reference<XComponentContext>& rContext) { Reference<XWindow> xWindow(rContext->getValueByName("BuilderParent"), UNO_QUERY_THROW); - weld::TransportAsXWindow& rTunnel = dynamic_cast<weld::TransportAsXWindow&>(*xWindow); - return Application::CreateBuilder(rTunnel.getWidget(), rUIFile); + weld::TransportAsXWindow* rTunnel + = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xWindow); + return Application::CreateBuilder(rTunnel->getWidget(), rUIFile); } void PropertyHandlerHelper::setBuilderParent(const css::uno::Reference<css::uno::XComponentContext>& rContext, weld::Widget* pParent) diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx index b0516fd90903..92556e1c05ad 100644 --- a/extensions/source/propctrlr/propcontroller.cxx +++ b/extensions/source/propctrlr/propcontroller.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/util/VetoException.hpp> #include <tools/debug.hxx> #include <comphelper/diagnose_ex.hxx> +#include <comphelper/servicehelper.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -338,7 +339,7 @@ namespace pcr OUString sUIFile("modules/spropctrlr/ui/formproperties.ui"); std::unique_ptr<weld::Builder> xBuilder; - if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xContainerWindow.get())) + if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xContainerWindow)) { xBuilder = Application::CreateBuilder(pTunnel->getWidget(), sUIFile); } @@ -1107,7 +1108,7 @@ namespace pcr // for ui-testing try and distinguish different instances of the controls auto xWindow = _rDescriptor.Control->getControlWindow(); - if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xWindow.get())) + if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xWindow)) { weld::Widget* m_pControlWindow = pTunnel->getWidget(); if (m_pControlWindow) |