summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-10-20 12:41:15 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2023-10-21 13:48:22 +0200
commit9362766b94a4627db0d8adfac4285388970d1fba (patch)
treee130ba7f750ca4da01e22921005936b5c1132466 /include
parent8b327dd75caf3fd3374ad92f84a70c276678a046 (diff)
tdf#135922 a11y: Prepare reporting text attrs as IA2 obj attrs
According to the IAccessible2 specification, some of the attributes that LibreOffice handles as text attributes are mapped to IAccessible2 text attributes as well [1], but others should be reported as object attributes [2], e.g. text alignment is reported via the "text-align" object attribute on the paragraph object. So far, `AccessibleTextAttributeHelper` was only handling attributes that are mapped to IAccessible2 text attributes. Prepare for reporting object attributes as well, which will be required to report text alignment on Windows in a compliant way (s. tdf#135922). On the other hand, Qt also expects `QAccessibleTextInterface::attributes` to return text formatting using the attributes specified in the IAccessible2 attribute specifications and maps that to the platform-specific attributes (AT-SPI text attributes on Linux), but currently does not provide any way to report object attributes in addition to text attributes. It however supports e.g. the "text-align" attribute mentioned in the IAccessible2 object attribute specification when it's reported as a text attribute [3]. Therefore, add a new `IA2AttributeType` enum that can be used to specify what kind of IAccessible2 attributes (text attributes, object attributes) to report. Only request IA2 text attributes on Windows when text attributes are requested, but both types for Qt. So far, support for none of the object attributes has been implemented, but an upcoming change will do that. [1] https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes [2] https://wiki.linuxfoundation.org/accessibility/iaccessible2/objectattributes [3] https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/accessible/linux/atspiadaptor.cpp?id=546208f0ff23819d216cbb5bf0b5daded79b454e#n2193 Change-Id: Ief7c840d3c5274714a914ca0e56df0c5eaffb06d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158255 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'include')
-rw-r--r--include/vcl/accessibility/AccessibleTextAttributeHelper.hxx32
1 files changed, 29 insertions, 3 deletions
diff --git a/include/vcl/accessibility/AccessibleTextAttributeHelper.hxx b/include/vcl/accessibility/AccessibleTextAttributeHelper.hxx
index c5e02a04e85c..d0d49c3209b3 100644
--- a/include/vcl/accessibility/AccessibleTextAttributeHelper.hxx
+++ b/include/vcl/accessibility/AccessibleTextAttributeHelper.hxx
@@ -22,23 +22,49 @@
#include <com/sun/star/accessibility/XAccessibleText.hpp>
#include <com/sun/star/beans/PropertyValue.hdl>
#include <com/sun/star/uno/Sequence.hxx>
+#include <o3tl/typed_flags_set.hxx>
#include <rtl/ustring.hxx>
#include <vcl/dllapi.h>
+/**
+ * According to the IAccessible2 specification, some of the attributes that LibreOffice
+ * handles as text attributes are mapped to IAccessible2 text attributes as well,
+ * but others should be reported as object attributes (e.g. text alignment is reported
+ * via the "text-align" object attribute on the paragraph object).
+ *
+ * https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes
+ * https://wiki.linuxfoundation.org/accessibility/iaccessible2/objectattributes
+ *
+ * This enum class is used to specify the type(s) of attributes of interest.
+ */
+enum class IA2AttributeType
+{
+ None = 0x0000,
+ ObjectAttributes = 0x0001,
+ TextAttributes = 0x0002
+};
+
+template <> struct o3tl::typed_flags<IA2AttributeType> : is_typed_flags<IA2AttributeType, 0x003>
+{
+};
+
class VCL_DLLPUBLIC AccessibleTextAttributeHelper
{
public:
/** Converts UNO text attribute properties to a string holding
* the corresponding IAccessible2 text attributes.
* @param rUnoAttributes A sequence holding the UNO text attributes.
+ * @param eAttributeType: Thy type(s) of attributes of interest.
* @returns String holding the corresponding IAccessible2 text properties.
*/
static OUString ConvertUnoToIAccessible2TextAttributes(
- const css::uno::Sequence<css::beans::PropertyValue>& rUnoAttributes);
+ const css::uno::Sequence<css::beans::PropertyValue>& rUnoAttributes,
+ IA2AttributeType eAttributeType);
/**
* Get the IAccessible2 text attributes and the span of the attributes at the given index.
* @param xText The interface to query for the information.
+ * @param eAttributeType: Thy type(s) of attributes of interest.
* @param nOffset Character offset for which to retrieve the information.
* @param rStartOffset Out param that is set to the start index of the attribute run.
* @param rEndOffset Out param that is set to the end index of the attribute run.
@@ -46,8 +72,8 @@ public:
*/
static OUString
GetIAccessible2TextAttributes(css::uno::Reference<css::accessibility::XAccessibleText> xText,
- sal_Int32 nOffset, sal_Int32& rStartOffset,
- sal_Int32& rEndOffset);
+ IA2AttributeType eAttributeType, sal_Int32 nOffset,
+ sal_Int32& rStartOffset, sal_Int32& rEndOffset);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */