1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #pragma once
20 
21 #include <extended/accessiblebrowseboxcell.hxx>
22 #include <comphelper/accessibletexthelper.hxx>
23 #include <cppuhelper/implbase2.hxx>
24 #include <com/sun/star/accessibility/AccessibleScrollType.hpp>
25 
26 namespace accessibility
27 {
28     typedef ::cppu::ImplHelper2 <   css::accessibility::XAccessibleText
29                                 ,   css::accessibility::XAccessible
30                                 >   AccessibleTextHelper_BASE;
31 
32     // implementation of a table cell of BrowseBox
33     class AccessibleBrowseBoxTableCell final : public AccessibleBrowseBoxCell
34                                         ,public AccessibleTextHelper_BASE
35                                         ,public ::comphelper::OCommonAccessibleText
36     {
37     private:
38         sal_Int32   m_nOffset;
39 
40         // OCommonAccessibleText
41         virtual OUString                        implGetText() final override;
42         virtual css::lang::Locale               implGetLocale() override;
43         virtual void                            implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override;
44 
45     public:
46         AccessibleBrowseBoxTableCell( const css::uno::Reference< css::accessibility::XAccessible >& _rxParent,
47                                     ::vcl::IAccessibleTableProvider& _rBrowseBox,
48                                     const css::uno::Reference< css::awt::XWindow >& _xFocusWindow,
49                                     sal_Int32 _nRowId,
50                                     sal_uInt16 _nColId,
51                                     sal_Int32 _nOffset );
52 
53         // XInterface -------------------------------------------------------------
54 
55         /** Queries for a new interface. */
56         css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override;
57 
58         /** Acquires the object (calls acquire() on base class). */
59         virtual void SAL_CALL acquire() noexcept override;
60 
61         /** Releases the object (calls release() on base class). */
62         virtual void SAL_CALL release() noexcept override;
63 
64         // XEventListener
65         using AccessibleBrowseBoxBase::disposing;
66         virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
67 
68         /** @return  The index of this object among the parent's children. */
69         virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override;
70 
71         /** @return
72                 The name of this class.
73         */
74         virtual OUString SAL_CALL getImplementationName() override;
75 
76         /** @return
77                 The count of visible children.
78         */
79         virtual sal_Int32 SAL_CALL getAccessibleChildCount() override;
80 
81         /** @return
82                 The XAccessible interface of the specified child.
83         */
84         virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
85             getAccessibleChild( sal_Int32 nChildIndex ) override;
86 
87         /** Creates a new AccessibleStateSetHelper and fills it with states of the
88             current object.
89             @return
90                 A filled AccessibleStateSetHelper.
91         */
92         rtl::Reference<::utl::AccessibleStateSetHelper> implCreateStateSetHelper() override;
93 
94         // XAccessible ------------------------------------------------------------
95 
96         /** @return  The XAccessibleContext interface of this object. */
97         virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL
98         getAccessibleContext() override;
99 
100         // XAccessibleText
101         virtual sal_Int32 SAL_CALL getCaretPosition() override;
102         virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override;
103         virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override;
104         virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override;
105         virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override;
106         virtual sal_Int32 SAL_CALL getCharacterCount() override;
107         virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override;
108         virtual OUString SAL_CALL getSelectedText() override;
109         virtual sal_Int32 SAL_CALL getSelectionStart() override;
110         virtual sal_Int32 SAL_CALL getSelectionEnd() override;
111         virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
112         virtual OUString SAL_CALL getText() final override;
113         virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
114         virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
115         virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
116         virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override;
117         virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override;
118         virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override;
119     };
120 }
121 
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
123