diff --git a/offapi/com/sun/star/ui/test/XUITest.idl b/offapi/com/sun/star/ui/test/XUITest.idl index 201791d88df4..e4fd1d30aa19 100644 --- a/offapi/com/sun/star/ui/test/XUITest.idl +++ b/offapi/com/sun/star/ui/test/XUITest.idl @@ -21,6 +21,12 @@ interface XUITest XUIObject getTopFocusWindow(); XUIObject getFloatWindow(); + + /** Get the XUIObject for the given window. + + @since LibreOffice 25.8 + */ + XUIObject getWindow([in] ::com::sun::star::awt::XWindow xWindow); }; }; }; }; }; }; diff --git a/vcl/source/uitest/uno/uitest_uno.cxx b/vcl/source/uitest/uno/uitest_uno.cxx index a96371daba38..c49422877e8a 100644 --- a/vcl/source/uitest/uno/uitest_uno.cxx +++ b/vcl/source/uitest/uno/uitest_uno.cxx @@ -17,6 +17,7 @@ #include #include +#include #include #include "uiobject_uno.hxx" @@ -44,6 +45,9 @@ public: css::uno::Reference SAL_CALL getFloatWindow() override; + css::uno::Reference + SAL_CALL getWindow(const css::uno::Reference& xWindow) override; + OUString SAL_CALL getImplementationName() override; sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; @@ -94,6 +98,20 @@ css::uno::Reference SAL_CALL UITestUnoObj::getFloatWin return new UIObjectUnoObj(std::move(pObj)); } +css::uno::Reference + SAL_CALL UITestUnoObj::getWindow(const css::uno::Reference<::css::awt::XWindow>& xWindow) +{ + if (!xWindow.is()) + return {}; + + UnoWrapperBase* pWrapper = UnoWrapperBase::GetUnoWrapper(); + assert(pWrapper); + VclPtr pWindow = pWrapper->GetWindow(xWindow); + assert(pWindow); + + return new UIObjectUnoObj(pWindow->GetUITestFactory()(pWindow)); +} + OUString SAL_CALL UITestUnoObj::getImplementationName() { return u"org.libreoffice.uitest.UITest"_ustr;