summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chart2/source/controller/sidebar/Chart2PanelFactory.cxx3
-rw-r--r--extensions/source/propctrlr/browserline.cxx3
-rw-r--r--extensions/source/propctrlr/handlerhelper.cxx6
-rw-r--r--extensions/source/propctrlr/propcontroller.cxx5
-rw-r--r--framework/source/uielement/toolbarwrapper.cxx3
-rw-r--r--include/vcl/weldutils.hxx12
-rw-r--r--sc/source/ui/sidebar/ScPanelFactory.cxx3
-rw-r--r--sd/source/ui/sidebar/PanelFactory.cxx2
-rw-r--r--starmath/source/SmPanelFactory.cxx3
-rw-r--r--svtools/source/uno/toolboxcontroller.cxx3
-rw-r--r--svx/source/sidebar/PanelFactory.cxx3
-rw-r--r--sw/source/uibase/sidebar/SwPanelFactory.cxx3
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/source/window/weldutils.cxx21
14 files changed, 57 insertions, 14 deletions
diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
index 081322b09408..4d0208fbc450 100644
--- a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
+++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <vcl/weldutils.hxx>
@@ -61,7 +62,7 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
Reference<css::frame::XController> xController (aArguments.getOrDefault("Controller", Reference<css::frame::XController>()));
weld::Widget* pParent(nullptr);
- if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+ if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xParentWindow))
pParent = pTunnel->getWidget();
if (!pParent)
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)
diff --git a/framework/source/uielement/toolbarwrapper.cxx b/framework/source/uielement/toolbarwrapper.cxx
index 8f3937ef094f..33bf896b6f5a 100644
--- a/framework/source/uielement/toolbarwrapper.cxx
+++ b/framework/source/uielement/toolbarwrapper.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/ui/UIElementType.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/servicehelper.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/svapp.hxx>
@@ -153,7 +154,7 @@ void SAL_CALL ToolBarWrapper::initialize( const Sequence< Any >& aArguments )
m_xToolBarManager = pToolBarManager;
pToolBar->WillUsePopupMode( bPopupMode );
}
- else if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+ else if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xParentWindow))
{
m_xBuilder = Application::CreateBuilder(pTunnel->getWidget(), "svt/ui/managedtoolbar.ui");
m_xTopLevel = m_xBuilder->weld_container("toolbarcontainer");
diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx
index 8a4c128515a0..24f1a1cc1ef7 100644
--- a/include/vcl/weldutils.hxx
+++ b/include/vcl/weldutils.hxx
@@ -14,9 +14,11 @@
#include <com/sun/star/frame/XDispatch.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <comphelper/interfacecontainer4.hxx>
#include <comphelper/compbase.hxx>
+#include <comphelper/servicehelper.hxx>
#include <tools/time.hxx>
#include <vcl/dllapi.h>
#include <vcl/formatter.hxx>
@@ -33,7 +35,8 @@ class Window;
namespace weld
{
-typedef comphelper::WeakComponentImplHelper<css::awt::XWindow> TransportAsXWindow_Base;
+typedef comphelper::WeakComponentImplHelper<css::awt::XWindow, css::lang::XUnoTunnel>
+ TransportAsXWindow_Base;
class VCL_DLLPUBLIC TransportAsXWindow : public TransportAsXWindow_Base
{
@@ -168,6 +171,13 @@ public:
std::unique_lock g(m_aMutex);
m_aPaintListeners.removeInterface(g, rListener);
}
+
+ 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();
};
// don't export to avoid duplicate WeakImplHelper definitions with MSVC
diff --git a/sc/source/ui/sidebar/ScPanelFactory.cxx b/sc/source/ui/sidebar/ScPanelFactory.cxx
index bbcff315c289..f9534fec548e 100644
--- a/sc/source/ui/sidebar/ScPanelFactory.cxx
+++ b/sc/source/ui/sidebar/ScPanelFactory.cxx
@@ -29,6 +29,7 @@
#include <vcl/weldutils.hxx>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -60,7 +61,7 @@ Reference<ui::XUIElement> SAL_CALL ScPanelFactory::createUIElement (
SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
weld::Widget* pParent(nullptr);
- if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+ if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xParentWindow))
pParent = pTunnel->getWidget();
if (!pParent)
diff --git a/sd/source/ui/sidebar/PanelFactory.cxx b/sd/source/ui/sidebar/PanelFactory.cxx
index c7ca8c25c4c8..a8e5add252c5 100644
--- a/sd/source/ui/sidebar/PanelFactory.cxx
+++ b/sd/source/ui/sidebar/PanelFactory.cxx
@@ -67,7 +67,7 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
// Throw exceptions when the arguments are not as expected.
weld::Widget* pParent(nullptr);
- if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+ if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xParentWindow))
pParent = pTunnel->getWidget();
if (!pParent)
diff --git a/starmath/source/SmPanelFactory.cxx b/starmath/source/SmPanelFactory.cxx
index df35dcadffbc..682e13295092 100644
--- a/starmath/source/SmPanelFactory.cxx
+++ b/starmath/source/SmPanelFactory.cxx
@@ -26,6 +26,7 @@
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/servicehelper.hxx>
#include <sfx2/sidebar/SidebarPanelBase.hxx>
#include <vcl/weldutils.hxx>
@@ -69,7 +70,7 @@ css::uno::Reference<css::ui::XUIElement> SAL_CALL SmPanelFactory::createUIElemen
SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
weld::Widget* pParent(nullptr);
- if (auto pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+ if (auto pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xParentWindow))
pParent = pTunnel->getWidget();
if (!pParent)
diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx
index 8fe4eb37c621..734fbe285623 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -34,6 +34,7 @@
#include <vcl/weldutils.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <comphelper/servicehelper.hxx>
const int TOOLBARCONTROLLER_PROPHANDLE_SUPPORTSVISIBLE = 1;
constexpr OUStringLiteral TOOLBARCONTROLLER_PROPNAME_SUPPORTSVISIBLE = u"SupportsVisible";
@@ -222,7 +223,7 @@ void SAL_CALL ToolboxController::initialize( const Sequence< Any >& aArguments )
if ( !m_aCommandURL.isEmpty() )
m_aListenerMap.emplace( m_aCommandURL, Reference< XDispatch >() );
- if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(getParent().get()))
+ if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(getParent()))
{
m_pToolbar = dynamic_cast<weld::Toolbar*>(pTunnel->getWidget());
assert(m_pToolbar && "must be a toolbar");
diff --git a/svx/source/sidebar/PanelFactory.cxx b/svx/source/sidebar/PanelFactory.cxx
index f55575d1ab97..468dd998a32a 100644
--- a/svx/source/sidebar/PanelFactory.cxx
+++ b/svx/source/sidebar/PanelFactory.cxx
@@ -42,6 +42,7 @@
#include <vcl/weldutils.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/compbase.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ui/XSidebar.hpp>
@@ -102,7 +103,7 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement (
SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
weld::Widget* pParent(nullptr);
- if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+ if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xParentWindow))
pParent = pTunnel->getWidget();
if (!pParent)
diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx
index 5dcd0f389216..3f307bbf7cdf 100644
--- a/sw/source/uibase/sidebar/SwPanelFactory.cxx
+++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx
@@ -37,6 +37,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <comphelper/namedvaluecollection.hxx>
#include <comphelper/compbase.hxx>
+#include <comphelper/servicehelper.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -90,7 +91,7 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue);
weld::Widget* pParent(nullptr);
- if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get()))
+ if (weld::TransportAsXWindow* pTunnel = comphelper::getFromUnoTunnel<weld::TransportAsXWindow>(xParentWindow))
pParent = pTunnel->getWidget();
if (!pParent)
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 74e8ff66d4aa..f3a165b830ca 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -162,6 +162,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/window/taskpanelist \
vcl/source/window/toolbox2 \
vcl/source/window/toolbox \
+ vcl/source/window/weldutils \
vcl/source/window/window2 \
vcl/source/window/window3 \
vcl/source/window/window \
diff --git a/vcl/source/window/weldutils.cxx b/vcl/source/window/weldutils.cxx
new file mode 100644
index 000000000000..9a36f23b92d5
--- /dev/null
+++ b/vcl/source/window/weldutils.cxx
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/config.h>
+
+#include <comphelper/servicehelper.hxx>
+#include <vcl/weldutils.hxx>
+
+css::uno::Sequence<sal_Int8> const& weld::TransportAsXWindow::getUnoTunnelId()
+{
+ static comphelper::UnoIdInit const id;
+ return id.getSeq();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */