1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/implbase.hxx>
30 #include <comphelper/accessibleselectionhelper.hxx>
31 #include <rtl/ref.hxx>
32 #include <svx/rectenum.hxx>
33 #include <tools/gen.hxx>
36 namespace com::sun::star::awt
{
42 namespace tools
{ class Rectangle
; }
44 class SvxRectCtlChildAccessibleContext
;
46 class SvxRectCtlAccessibleContext final
: public cppu::ImplInheritanceHelper
<
47 ::comphelper::OAccessibleSelectionHelper
,
48 css::accessibility::XAccessible
>
52 SvxRectCtlAccessibleContext(SvxRectCtl
* pRepresentation
);
54 // XAccessibleComponent
55 virtual void SAL_CALL
grabFocus() override
;
56 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint(const css::awt::Point
& rPoint
) override
;
60 virtual sal_Int64 SAL_CALL
getAccessibleChildCount() override
;
61 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild(sal_Int64 nIndex
) override
;
62 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleParent() override
;
63 virtual sal_Int16 SAL_CALL
getAccessibleRole() override
;
64 virtual OUString SAL_CALL
getAccessibleDescription() override
;
65 virtual OUString SAL_CALL
getAccessibleName() override
;
66 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet() override
;
67 virtual sal_Int64 SAL_CALL
getAccessibleStateSet() override
;
69 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext() override
{ return this; }
70 virtual sal_Int32 SAL_CALL
getForeground() override
;
71 virtual sal_Int32 SAL_CALL
getBackground() override
;
73 /** Selects a new child by point.
75 <p>If the child was not selected before, the state of the child will
76 be updated. If the point is not invalid, the index will internally set to NOCHILDSELECTED</p>
79 Button which belongs to the child which should be selected.
81 void selectChild( RectPoint ePoint
);
82 void FireChildFocus( RectPoint eButton
);
85 virtual ~SvxRectCtlAccessibleContext() override
;
87 // OCommonAccessibleSelection
88 // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
89 virtual bool implIsSelected(sal_Int64 nAccessibleChildIndex
) override
;
91 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
92 virtual void implSelect(sal_Int64 nAccessibleChildIndex
, bool bSelect
) override
;
94 // OCommonAccessibleComponent
95 virtual css::awt::Rectangle
implGetBounds() override
;
97 virtual void SAL_CALL
disposing() override
;
99 void checkChildIndex(sal_Int64 nIndex
);
101 /** Selects a new child by index.
103 <p>If the child was not selected before, the state of the child will
104 be updated. If the index is invalid, the index will internally set to NOCHILDSELECTED</p>
107 Index of the new child which should be selected.
109 void selectChild( tools::Long nIndexOfChild
);
111 /** Description of this object. This is not a constant because it can
112 be set from the outside.
114 OUString msDescription
;
116 /** Name of this object.
120 /// pointer to internal representation
123 /// array for all possible children
124 std::vector
<rtl::Reference
<SvxRectCtlChildAccessibleContext
>> mvChildren
;
126 /// actual selected child
127 tools::Long mnSelectedChild
;
130 class SvxRectCtlChildAccessibleContext final
: public cppu::ImplInheritanceHelper
<
131 ::comphelper::OAccessibleComponentHelper
,
132 css::accessibility::XAccessible
,
133 css::accessibility::XAccessibleValue
,
134 css::accessibility::XAccessibleAction
>
137 SvxRectCtlChildAccessibleContext(
138 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
139 OUString aName
, OUString aDescription
,
140 const tools::Rectangle
& rBoundingBox
,
141 tools::Long nIndexInParent
);
143 // XAccessibleComponent
144 virtual void SAL_CALL
grabFocus() override
;
145 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const css::awt::Point
& rPoint
) override
;
147 // XAccessibleContext
148 virtual sal_Int64 SAL_CALL
getAccessibleChildCount() override
;
149 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int64 nIndex
) override
;
150 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleParent() override
;
151 virtual sal_Int16 SAL_CALL
getAccessibleRole() override
;
152 virtual OUString SAL_CALL
getAccessibleDescription() override
;
153 virtual OUString SAL_CALL
getAccessibleName() override
;
154 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet() override
;
155 virtual sal_Int64 SAL_CALL
getAccessibleStateSet() override
;
157 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext() override
{ return this; }
159 virtual sal_Int32 SAL_CALL
getForeground() override
;
160 virtual sal_Int32 SAL_CALL
getBackground() override
;
163 virtual css::uno::Any SAL_CALL
164 getCurrentValue() override
;
166 virtual sal_Bool SAL_CALL
167 setCurrentValue( const css::uno::Any
& aNumber
) override
;
169 virtual css::uno::Any SAL_CALL
170 getMaximumValue() override
;
172 virtual css::uno::Any SAL_CALL
173 getMinimumValue() override
;
175 virtual css::uno::Any SAL_CALL
176 getMinimumIncrement() override
;
179 virtual sal_Int32 SAL_CALL
getAccessibleActionCount( ) override
;
180 virtual sal_Bool SAL_CALL
doAccessibleAction ( sal_Int32 nIndex
) override
;
181 virtual OUString SAL_CALL
getAccessibleActionDescription ( sal_Int32 nIndex
) override
;
182 virtual css::uno::Reference
< css::accessibility::XAccessibleKeyBinding
> SAL_CALL
getAccessibleActionKeyBinding( sal_Int32 nIndex
) override
;
185 /// Sets the checked status
186 void setStateChecked(bool bChecked
);
187 void FireFocusEvent();
190 virtual ~SvxRectCtlChildAccessibleContext() override
;
192 virtual void SAL_CALL
disposing() override
;
194 // OCommonAccessibleComponent
195 /// implements the calculation of the bounding rectangle
196 virtual css::awt::Rectangle
implGetBounds( ) override
;
198 /** Description of this object. This is not a constant because it can
199 be set from the outside. Furthermore, it changes according to the
200 draw page's display mode.
202 OUString msDescription
;
204 /** Name of this object. It changes according the draw page's
209 /// Reference to the parent object.
210 css::uno::Reference
< css::accessibility::XAccessible
>
214 tools::Rectangle maBoundingBox
;
216 /// index of child in parent
217 tools::Long mnIndexInParent
;
219 /// Indicates, if object is checked
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */