LibreOffice Module svx (master) 1
AccessibleFrameSelector.cxx
Go to the documentation of this file.
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
21#include <com/sun/star/accessibility/AccessibleStateType.hpp>
22#include <com/sun/star/accessibility/AccessibleRole.hpp>
23#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25#include <vcl/svapp.hxx>
26#include <vcl/settings.hxx>
27#include <svx/frmsel.hxx>
28#include <svx/dialmgr.hxx>
29
30#include <frmsel.hrc>
31
32namespace svx::a11y {
33
34using ::com::sun::star::uno::Any;
35using ::com::sun::star::lang::IndexOutOfBoundsException;
36using ::com::sun::star::uno::Reference;
37using ::com::sun::star::uno::Sequence;
38using ::com::sun::star::uno::RuntimeException;
39
40using namespace ::com::sun::star::accessibility;
41
42
44 : mpFrameSel(&rFrameSel)
45{
46}
47
49{
50}
51
54
55Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext( )
56{
57 return this;
58}
59
61{
62 SolarMutexGuard aGuard;
63 IsValid();
65}
66
67Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int64 i )
68{
69 SolarMutexGuard aGuard;
70 IsValid();
71
72 if (i < 0 || i >= getAccessibleChildCount())
73 throw IndexOutOfBoundsException();
74
75 Reference< XAccessible > xRet = mpFrameSel->GetChildAccessible( i );
76 if( !xRet.is() )
77 throw RuntimeException();
78 return xRet;
79}
80
81Reference< XAccessible > AccFrameSelector::getAccessibleParent( )
82{
83 SolarMutexGuard aGuard;
84 IsValid();
85 Reference< XAccessible > xRet = mpFrameSel->getAccessibleParent();
86 return xRet;
87}
88
90{
91 return AccessibleRole::OPTION_PANE;
92}
93
95{
96 SolarMutexGuard aGuard;
97 IsValid();
98 return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[0].first);
99}
100
102{
103 SolarMutexGuard aGuard;
104 IsValid();
105 return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[0].first);
106}
107
108Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet( )
109{
110 SolarMutexGuard aGuard;
111 IsValid();
113}
114
116{
117 SolarMutexGuard aGuard;
118 sal_Int64 nStateSet = 0;
119
120 if(!mpFrameSel)
121 nStateSet |= AccessibleStateType::DEFUNC;
122 else
123 {
124 // add standard states
125 nStateSet |=
126 AccessibleStateType::EDITABLE |
127 AccessibleStateType::FOCUSABLE |
128 AccessibleStateType::MULTI_SELECTABLE |
129 AccessibleStateType::SELECTABLE |
130 AccessibleStateType::SHOWING |
131 AccessibleStateType::VISIBLE |
132 AccessibleStateType::OPAQUE;
133 if(mpFrameSel->IsEnabled())
134 {
135 nStateSet |= AccessibleStateType::ENABLED;
136 nStateSet |= AccessibleStateType::SENSITIVE;
137 }
138
139 if (mpFrameSel->HasFocus())
140 {
141 nStateSet |= AccessibleStateType::ACTIVE;
142 nStateSet |= AccessibleStateType::FOCUSED;
143 nStateSet |= AccessibleStateType::SELECTED;
144 }
145 }
146 return nStateSet;
147}
148
150 const css::awt::Point& aPt )
151{
152 SolarMutexGuard aGuard;
153 IsValid();
154 //aPt is relative to the frame selector
155 return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
156}
157
159{
160 SolarMutexGuard aGuard;
161 IsValid();
163}
164
166{
167 SolarMutexGuard aGuard;
168
169 //see FrameSelector::Paint
171 return sal_Int32(rStyles.GetLabelTextColor());
172}
173
175{
176 SolarMutexGuard aGuard;
177
178 //see FrameSelector::Paint
180 return sal_Int32(rStyles.GetDialogColor());
181}
182
184{
185 SolarMutexGuard aGuard;
186 IsValid();
187
188 css::awt::Rectangle aRet;
189
190 const Point aOutPos;
192
193 aRet.X = aOutPos.X();
194 aRet.Y = aOutPos.Y();
195 aRet.Width = aOutSize.Width();
196 aRet.Height = aOutSize.Height();
197
198 return aRet;
199}
200
202{
203 SolarMutexGuard aGuard;
204 IsValid();
205
206 css::awt::Point aScreenLoc(0, 0);
207
208 if (weld::DrawingArea* pDrawingArea = mpFrameSel->GetDrawingArea())
209 {
210 Point aPos = pDrawingArea->get_accessible_location_on_screen();
211 aScreenLoc.X = aPos.X();
212 aScreenLoc.Y = aPos.Y();
213 }
214
215 return aScreenLoc;
216}
217
219{
220 if(!mpFrameSel)
221 throw RuntimeException();
222}
223
225{
226 mpFrameSel = nullptr;
227}
228
230 : mpFrameSel(&rFrameSel)
231 , meBorder(eBorder)
232{
233}
234
236{
237}
238
241
242Reference< XAccessibleContext > AccFrameSelectorChild::getAccessibleContext( )
243{
244 return this;
245}
246
248{
249 SolarMutexGuard aGuard;
250 IsValid();
251 return 0;
252}
253
254Reference< XAccessible > AccFrameSelectorChild::getAccessibleChild( sal_Int64 )
255{
256 throw RuntimeException();
257}
258
260{
261 SolarMutexGuard aGuard;
262 IsValid();
263 Reference< XAccessible > xRet = mpFrameSel->CreateAccessible();
264 return xRet;
265}
266
268{
269 return AccessibleRole::CHECK_BOX;
270}
271
273{
274 SolarMutexGuard aGuard;
275 IsValid();
276 return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[static_cast<sal_uInt32>(meBorder)].first);
277}
278
280{
281 SolarMutexGuard aGuard;
282 IsValid();
283 return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[static_cast<sal_uInt32>(meBorder)].first);
284}
285
286Reference< XAccessibleRelationSet > AccFrameSelectorChild::getAccessibleRelationSet( )
287{
288 SolarMutexGuard aGuard;
289 IsValid();
290 Reference< XAccessibleRelationSet > xRet = new utl::AccessibleRelationSetHelper;
291 return xRet;
292}
293
295{
296 SolarMutexGuard aGuard;
297 sal_Int64 nStateSet = 0;
298
299 if(!mpFrameSel)
300 nStateSet |= AccessibleStateType::DEFUNC;
301 else
302 {
303 nStateSet |=
304 AccessibleStateType::EDITABLE |
305 AccessibleStateType::FOCUSABLE |
306 AccessibleStateType::MULTI_SELECTABLE |
307 AccessibleStateType::SELECTABLE |
308 AccessibleStateType::SHOWING |
309 AccessibleStateType::VISIBLE |
310 AccessibleStateType::OPAQUE;
311 if(mpFrameSel->IsEnabled())
312 {
313 nStateSet |= AccessibleStateType::ENABLED;
314 nStateSet |= AccessibleStateType::SENSITIVE;
315 }
316
318 {
319 nStateSet |= AccessibleStateType::ACTIVE;
320 nStateSet |= AccessibleStateType::FOCUSED;
321 nStateSet |= AccessibleStateType::SELECTED;
322 }
323 }
324 return nStateSet;
325}
326
328 const css::awt::Point& aPt )
329{
330 SolarMutexGuard aGuard;
331 IsValid();
332 //aPt is relative to the frame selector
333 return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
334}
335
337{
338 SolarMutexGuard aGuard;
339 IsValid();
341 Point aPos = aSpot.TopLeft();
342 Size aSz = aSpot.GetSize();
343 css::awt::Rectangle aRet;
344 aRet.X = aPos.X();
345 aRet.Y = aPos.Y();
346 aRet.Width = aSz.Width();
347 aRet.Height = aSz.Height();
348 return aRet;
349}
350
352{
353 SolarMutexGuard aGuard;
354 IsValid();
356}
357
359{
360 SolarMutexGuard aGuard;
361
362 //see FrameSelector::Paint
364 return sal_Int32(rStyles.GetLabelTextColor());
365}
366
368{
369 SolarMutexGuard aGuard;
370
371 //see FrameSelector::Paint
373 return sal_Int32(rStyles.GetDialogColor());
374}
375
377{
378 if(!mpFrameSel)
379 throw RuntimeException();
380}
381
383{
384 mpFrameSel = nullptr;
385}
386
387}
388
389/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetLabelTextColor() const
const Color & GetDialogColor() const
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: frmsel.cxx:1041
bool IsBorderSelected(FrameBorderType eBorder) const
Returns true, if the specified frame border is selected.
Definition: frmsel.cxx:979
tools::Rectangle GetClickBoundRect(FrameBorderType eBorder) const
Returns the bounding rectangle of the specified frame border (if enabled).
Definition: frmsel.cxx:1078
a11yrelationset get_accessible_relation_set() const
Definition: frmsel.hxx:162
sal_Int32 GetEnabledBorderCount() const
Returns the number of enabled frame borders.
Definition: frmsel.cxx:869
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: frmsel.hxx:160
rtl::Reference< a11y::AccFrameSelectorChild > GetChildAccessible(FrameBorderType eBorder)
Returns the accessibility child object of the specified frame border (if enabled).
Definition: frmsel.cxx:1050
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual OUString SAL_CALL getAccessibleName() override
virtual css::awt::Rectangle implGetBounds() override
implements the calculation of the bounding rectangle
virtual void SAL_CALL grabFocus() override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual OUString SAL_CALL getAccessibleDescription() override
AccFrameSelectorChild(FrameSelector &rFrameSel, FrameBorderType eBorder)
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual sal_Int32 SAL_CALL getForeground() override
virtual sal_Int32 SAL_CALL getBackground() override
virtual sal_Int32 SAL_CALL getBackground() override
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
virtual sal_Int64 SAL_CALL getAccessibleStateSet() override
virtual void SAL_CALL grabFocus() override
AccFrameSelector(FrameSelector &rFrameSel)
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 i) override
virtual css::awt::Rectangle implGetBounds() override
implements the calculation of the bounding rectangle
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
virtual OUString SAL_CALL getAccessibleName() override
virtual sal_Int32 SAL_CALL getForeground() override
virtual OUString SAL_CALL getAccessibleDescription() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual css::awt::Point SAL_CALL getLocationOnScreen() override
constexpr Point TopLeft() const
constexpr Size GetSize() const
weld::DrawingArea * GetDrawingArea() const
Size const & GetOutputSizePixel() const
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
int i
constexpr OUStringLiteral first
IMPLEMENT_FORWARD_XTYPEPROVIDER2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
FrameBorderType
Enumerates all borders a frame selection control can contain.