vcl/source/uitest/toolboxitemuiobject.cxx |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 7ab67418792a2c1f12bad741f3d6740eb9108f7a
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Sep 24 18:37:11 2025 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 18 12:48:50 2025 +0100

    tdf#168409 uitest: Report toolbox item rect
    
    Also report the rectangle (via its x and y
    coordinates and width and height) of toolbox
    items via the UITest API.
    
    Besides making it accessible to actual UI tests,
    this can also be used by ScriptForge to implement
    logic previously depending on the unpublished
    a11y UNO API that is subject to change.
    
    While the UITest API is also not designed for
    external use and can change at any point in time,
    it's likely to keep working for now at least, at
    least when using the vcl/SalInstance*  weld
    implementation.
    
    See discussion in tdf#168409 for more background.
    
    Change-Id: Id9cefd4f0011a56751221e84eeaa8266614a0697
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191456
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/source/uitest/toolboxitemuiobject.cxx 
b/vcl/source/uitest/toolboxitemuiobject.cxx
index e976050cb85d..3758aefe93f5 100644
--- a/vcl/source/uitest/toolboxitemuiobject.cxx
+++ b/vcl/source/uitest/toolboxitemuiobject.cxx
@@ -19,8 +19,15 @@ ToolBoxItemUIObject::~ToolBoxItemUIObject() {}
 
 StringMap ToolBoxItemUIObject::get_state()
 {
-    StringMap aMap{ { u"Enabled"_ustr, 
OUString::boolean(m_pToolBox->IsItemEnabled(m_nId)) },
-                    { u"Text"_ustr, m_pToolBox->GetItemText(m_nId) } };
+    const tools::Rectangle aRect = m_pToolBox->GetItemRect(m_nId);
+    StringMap aMap{
+        { u"Enabled"_ustr, OUString::boolean(m_pToolBox->IsItemEnabled(m_nId)) 
},
+        { u"Text"_ustr, m_pToolBox->GetItemText(m_nId) },
+        { u"X"_ustr, OUString::number(aRect.getX()) },
+        { u"Y"_ustr, OUString::number(aRect.getY()) },
+        { u"Width"_ustr, OUString::number(aRect.GetWidth()) },
+        { u"Height"_ustr, OUString::number(aRect.GetHeight()) },
+    };
 
     return aMap;
 }

Reply via email to