comphelper/source/misc/OAccessible.cxx |   14 +++++++++++++-
 include/comphelper/OAccessible.hxx     |    3 +++
 2 files changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 99ff2618e6b65dc8d9eb2eeb49a1b49e92ff6291
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Mar 5 12:12:45 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Mar 6 07:14:57 2026 +0100

    a11y: Introduce helper to implement XAccessibleExtendedAttributes logic
    
    In OAccessible, which is used as the base class for most a11y
    implementations, introduce a new virtual
    OAccessible::implGetExtendedAttributes that returns a
    std::unordered_map for the key/value pairs for extended attributes
    and use that in OAccessible::getExtendedAttributes to build the
    string mandated by the XAccessibleAttributes UNO interface.
    (The order of attributes in the resulting string shouldn't
    matter.)
    
    The default implementation still results in an empty map/string
    being returned. But this will allow switching subclasses to
    override the new helper method in upcoming commits instead of
    having to implement the string concatenation logic in each of them.
    
    Also let OAccessible::getExtendedAttributes use
    OExternalLockGuard like other UNO API methods in the class do,
    which locks the SolarMutex and checks that the object hasn't been
    disposed yet. (Both are reasonable when a11y UNO API methods
    are called.)
    
    If the latter results in any issues when switching subclasses
    to the new logic, those are probably preexisting issues that
    are surfacing then.
    
    Change-Id: Ie66f135fbf6cdc98c7cdca27fa3f5fe7db7f9a74
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201035
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/comphelper/source/misc/OAccessible.cxx 
b/comphelper/source/misc/OAccessible.cxx
index 84cb5f1d6fc1..0d7867ea6c87 100644
--- a/comphelper/source/misc/OAccessible.cxx
+++ b/comphelper/source/misc/OAccessible.cxx
@@ -194,7 +194,19 @@ Locale SAL_CALL OAccessible::getLocale()
     return xParentContext->getLocale();
 }
 
-OUString SAL_CALL OAccessible::getExtendedAttributes() { return OUString(); }
+std::unordered_map<OUString, OUString> 
OAccessible::implGetExtendedAttributes() { return {}; }
+
+OUString SAL_CALL OAccessible::getExtendedAttributes()
+{
+    OExternalLockGuard aGuard(this);
+
+    OUString sAttrs;
+    const std::unordered_map<OUString, OUString> aAttributes = 
implGetExtendedAttributes();
+    for (const auto& rAttribute : aAttributes)
+        sAttrs += rAttribute.first + u":" + rAttribute.second + u";";
+
+    return sAttrs;
+}
 
 Reference<XAccessibleContext> OAccessible::implGetParentContext()
 {
diff --git a/include/comphelper/OAccessible.hxx 
b/include/comphelper/OAccessible.hxx
index 7d58c77abde7..c0af14fa6e1c 100644
--- a/include/comphelper/OAccessible.hxx
+++ b/include/comphelper/OAccessible.hxx
@@ -28,6 +28,7 @@
 #include <cppuhelper/compbase.hxx>
 #include <comphelper/comphelperdllapi.h>
 
+#include <unordered_map>
 
 namespace comphelper
 {
@@ -147,6 +148,8 @@ protected:
     /// @throws css::uno::RuntimeException
     virtual css::awt::Rectangle implGetBounds(  ) = 0;
 
+    // Helper for implementing 
XAccessibleExtendedAttributes::getExtendedAttributes
+    virtual std::unordered_map<OUString, OUString> implGetExtendedAttributes();
 
 public:
     // XAccessibleComponent - default implementations which can be implemented 
using <method>implGetBounds</method>

Reply via email to