Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / svx / source / inc / svxrectctaccessiblecontext.hxx
blobde479bf8717443ecc11fa26ed68f8236f759de14
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #ifndef INCLUDED_SVX_SOURCE_INC_SVXRECTCTACCESSIBLECONTEXT_HXX
22 #define INCLUDED_SVX_SOURCE_INC_SVXRECTCTACCESSIBLECONTEXT_HXX
24 #include <com/sun/star/accessibility/XAccessible.hpp>
25 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
26 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
27 #include <com/sun/star/accessibility/XAccessibleValue.hpp>
28 #include <com/sun/star/uno/Reference.hxx>
29 #include <cppuhelper/implbase3.hxx>
30 #include <comphelper/accessibleselectionhelper.hxx>
31 #include <rtl/ref.hxx>
32 #include <svx/rectenum.hxx>
33 #include <tools/gen.hxx>
34 #include <vector>
36 namespace com::sun::star::awt {
37 struct Point;
38 struct Rectangle;
39 struct Size;
40 class XFocusListener;
42 namespace tools { class Rectangle; }
43 class SvxRectCtl;
44 class SvxRectCtlChildAccessibleContext;
45 namespace vcl { class Window; }
47 typedef ::cppu::ImplHelper1<css::accessibility::XAccessible> OAccessibleHelper_Base;
49 class SvxRectCtlAccessibleContext final : public ::comphelper::OAccessibleSelectionHelper,
50 public OAccessibleHelper_Base
52 public:
53 // internal
54 SvxRectCtlAccessibleContext(SvxRectCtl* pRepresentation);
56 DECLARE_XINTERFACE( )
57 DECLARE_XTYPEPROVIDER( )
59 // XAccessibleComponent
60 virtual void SAL_CALL grabFocus() override;
61 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point& rPoint) override;
63 // XAccessible
64 // XAccessibleContext
65 virtual sal_Int32 SAL_CALL getAccessibleChildCount() override;
66 virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleChild(sal_Int32 nIndex) override;
67 virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override;
68 virtual sal_Int16 SAL_CALL getAccessibleRole() override;
69 virtual OUString SAL_CALL getAccessibleDescription() override;
70 virtual OUString SAL_CALL getAccessibleName() override;
71 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override;
72 virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override;
74 virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext() override { return this; }
75 virtual sal_Int32 SAL_CALL getForeground() override;
76 virtual sal_Int32 SAL_CALL getBackground() override;
78 /** Selects a new child by point.
80 <p>If the child was not selected before, the state of the child will
81 be updated. If the point is not invalid, the index will internally set to NOCHILDSELECTED</p>
83 @param eButton
84 Button which belongs to the child which should be selected.
86 void selectChild( RectPoint ePoint );
87 void FireChildFocus( RectPoint eButton );
89 private:
90 virtual ~SvxRectCtlAccessibleContext() override;
92 // OCommonAccessibleSelection
93 // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
94 virtual bool implIsSelected(sal_Int32 nAccessibleChildIndex) override;
96 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
97 virtual void implSelect(sal_Int32 nAccessibleChildIndex, bool bSelect) override;
99 // OCommonAccessibleComponent
100 virtual css::awt::Rectangle implGetBounds() override;
102 virtual void SAL_CALL disposing() override;
104 void checkChildIndex(tools::Long nIndex);
106 /** Selects a new child by index.
108 <p>If the child was not selected before, the state of the child will
109 be updated. If the index is invalid, the index will internally set to NOCHILDSELECTED</p>
111 @param nIndexOfChild
112 Index of the new child which should be selected.
114 void selectChild( tools::Long nIndexOfChild );
116 /** Description of this object. This is not a constant because it can
117 be set from the outside.
119 OUString msDescription;
121 /** Name of this object.
123 OUString msName;
125 /// pointer to internal representation
126 SvxRectCtl* mpRepr;
128 /// array for all possible children
129 std::vector<rtl::Reference<SvxRectCtlChildAccessibleContext>> mvChildren;
131 /// actual selected child
132 tools::Long mnSelectedChild;
135 typedef ::cppu::ImplHelper3 < css::accessibility::XAccessible,
136 css::accessibility::XAccessibleValue,
137 css::accessibility::XAccessibleAction
138 > OAccessibleHelper_Base_3;
140 class SvxRectCtlChildAccessibleContext final : public ::comphelper::OAccessibleComponentHelper,
141 public OAccessibleHelper_Base_3
143 public:
144 SvxRectCtlChildAccessibleContext(
145 const css::uno::Reference< css::accessibility::XAccessible>& rxParent,
146 const OUString& rName, const OUString& rDescription,
147 const tools::Rectangle& rBoundingBox,
148 tools::Long nIndexInParent );
150 DECLARE_XINTERFACE( )
151 DECLARE_XTYPEPROVIDER( )
153 // XAccessibleComponent
154 virtual void SAL_CALL grabFocus() override;
155 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& rPoint ) override;
157 // XAccessibleContext
158 virtual sal_Int32 SAL_CALL getAccessibleChildCount() override;
159 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 nIndex ) override;
160 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override;
161 virtual sal_Int16 SAL_CALL getAccessibleRole() override;
162 virtual OUString SAL_CALL getAccessibleDescription() override;
163 virtual OUString SAL_CALL getAccessibleName() override;
164 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override;
165 virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override;
167 virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext() override { return this; }
169 virtual sal_Int32 SAL_CALL getForeground() override;
170 virtual sal_Int32 SAL_CALL getBackground() override;
172 // XAccessibleValue
173 virtual css::uno::Any SAL_CALL
174 getCurrentValue() override;
176 virtual sal_Bool SAL_CALL
177 setCurrentValue( const css::uno::Any& aNumber ) override;
179 virtual css::uno::Any SAL_CALL
180 getMaximumValue() override;
182 virtual css::uno::Any SAL_CALL
183 getMinimumValue() override;
185 // XAccessibleAction
186 virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override;
187 virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override;
188 virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override;
189 virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override;
191 // internal
192 /// Sets the checked status
193 void setStateChecked(bool bChecked);
194 void FireFocusEvent();
196 private:
197 virtual ~SvxRectCtlChildAccessibleContext() override;
199 virtual void SAL_CALL disposing() override;
201 // OCommonAccessibleComponent
202 /// implements the calculation of the bounding rectangle
203 virtual css::awt::Rectangle implGetBounds( ) override;
205 /** Description of this object. This is not a constant because it can
206 be set from the outside. Furthermore, it changes according to the
207 draw page's display mode.
209 OUString msDescription;
211 /** Name of this object. It changes according the draw page's
212 display mode.
214 OUString msName;
216 /// Reference to the parent object.
217 css::uno::Reference< css::accessibility::XAccessible >
218 mxParent;
220 /// Bounding box
221 tools::Rectangle maBoundingBox;
223 /// index of child in parent
224 tools::Long mnIndexInParent;
226 /// Indicates, if object is checked
227 bool mbIsChecked;
231 #endif
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */