1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #include <com/sun/star/accessibility/XAccessibleText.hpp>
23 #include <com/sun/star/beans/PropertyValue.hdl>
24 #include <com/sun/star/uno/Sequence.hxx>
25 #include <o3tl/typed_flags_set.hxx>
26 #include <rtl/ustring.hxx>
27 #include <vcl/dllapi.h>
28 
29 /**
30  * According to the IAccessible2 specification, some of the attributes that LibreOffice
31  * handles as text attributes are mapped to IAccessible2 text attributes as well,
32  * but others should be reported as object attributes (e.g. text alignment is reported
33  * via the "text-align" object attribute on the paragraph object).
34  *
35  * https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes
36  * https://wiki.linuxfoundation.org/accessibility/iaccessible2/objectattributes
37  *
38  * This enum class is used to specify the type(s) of attributes of interest.
39  */
40 enum class IA2AttributeType
41 {
42     None = 0x0000,
43     ObjectAttributes = 0x0001,
44     TextAttributes = 0x0002
45 };
46 
47 template <> struct o3tl::typed_flags<IA2AttributeType> : is_typed_flags<IA2AttributeType, 0x003>
48 {
49 };
50 
51 namespace AccessibleTextAttributeHelper
52 {
53 /**
54      * Get the IAccessible2 text attributes and the span of the attributes at the given index.
55      * @param xText The interface to query for the information.
56      * @param eAttributeType: The type(s) of attributes of interest.
57      * @param nOffset Character offset for which to retrieve the information.
58      * @param rStartOffset Out param that is set to the start index of the attribute run.
59      * @param rEndOffset Out param that is set to the end index of the attribute run.
60      * @return IAccessible2 text attributes at the given character offset.
61      */
62 OUString VCL_DLLPUBLIC
63 GetIAccessible2TextAttributes(const css::uno::Reference<css::accessibility::XAccessibleText>& xText,
64                               IA2AttributeType eAttributeType, sal_Int32 nOffset,
65                               sal_Int32& rStartOffset, sal_Int32& rEndOffset);
66 };
67 
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
69