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::lang::IndexOutOfBoundsException;
35using ::com::sun::star::uno::Reference;
36using ::com::sun::star::uno::RuntimeException;
37
38using namespace ::com::sun::star::accessibility;
39
40
42 : mpFrameSel(&rFrameSel)
43{
44}
45
47{
48}
49
50Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext( )
51{
52 return this;
53}
54
56{
57 SolarMutexGuard aGuard;
58 IsValid();
60}
61
62Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int64 i )
63{
64 SolarMutexGuard aGuard;
65 IsValid();
66
67 if (i < 0 || i >= getAccessibleChildCount())
68 throw IndexOutOfBoundsException();
69
70 Reference< XAccessible > xRet = mpFrameSel->GetChildAccessible( i );
71 if( !xRet.is() )
72 throw RuntimeException();
73 return xRet;
74}
75
76Reference< XAccessible > AccFrameSelector::getAccessibleParent( )
77{
78 SolarMutexGuard aGuard;
79 IsValid();
80 Reference< XAccessible > xRet = mpFrameSel->getAccessibleParent();
81 return xRet;
82}
83
85{
86 return AccessibleRole::OPTION_PANE;
87}
88
90{
91 SolarMutexGuard aGuard;
92 IsValid();
93 return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[0].first);
94}
95
97{
98 SolarMutexGuard aGuard;
99 IsValid();
100 return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[0].first);
101}
102
103Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet( )
104{
105 SolarMutexGuard aGuard;
106 IsValid();
108}
109
111{
112 SolarMutexGuard aGuard;
113 sal_Int64 nStateSet = 0;
114
115 if(!mpFrameSel)
116 nStateSet |= AccessibleStateType::DEFUNC;
117 else
118 {
119 // add standard states
120 nStateSet |=
121 AccessibleStateType::EDITABLE |
122 AccessibleStateType::FOCUSABLE |
123 AccessibleStateType::MULTI_SELECTABLE |
124 AccessibleStateType::SELECTABLE |
125 AccessibleStateType::SHOWING |
126 AccessibleStateType::VISIBLE |
127 AccessibleStateType::OPAQUE;
128 if(mpFrameSel->IsEnabled())
129 {
130 nStateSet |= AccessibleStateType::ENABLED;
131 nStateSet |= AccessibleStateType::SENSITIVE;
132 }
133
134 if (mpFrameSel->HasFocus())
135 {
136 nStateSet |= AccessibleStateType::ACTIVE;
137 nStateSet |= AccessibleStateType::FOCUSED;
138 nStateSet |= AccessibleStateType::SELECTED;
139 }
140 }
141 return nStateSet;
142}
143
145 const css::awt::Point& aPt )
146{
147 SolarMutexGuard aGuard;
148 IsValid();
149 //aPt is relative to the frame selector
150 return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
151}
152
154{
155 SolarMutexGuard aGuard;
156 IsValid();
158}
159
161{
162 SolarMutexGuard aGuard;
163
164 //see FrameSelector::Paint
166 return sal_Int32(rStyles.GetLabelTextColor());
167}
168
170{
171 SolarMutexGuard aGuard;
172
173 //see FrameSelector::Paint
175 return sal_Int32(rStyles.GetDialogColor());
176}
177
179{
180 SolarMutexGuard aGuard;
181 IsValid();
182
183 css::awt::Rectangle aRet;
184
185 const Point aOutPos;
187
188 aRet.X = aOutPos.X();
189 aRet.Y = aOutPos.Y();
190 aRet.Width = aOutSize.Width();
191 aRet.Height = aOutSize.Height();
192
193 return aRet;
194}
195
197{
198 SolarMutexGuard aGuard;
199 IsValid();
200
201 css::awt::Point aScreenLoc(0, 0);
202
203 if (weld::DrawingArea* pDrawingArea = mpFrameSel->GetDrawingArea())
204 {
205 Point aPos = pDrawingArea->get_accessible_location_on_screen();
206 aScreenLoc.X = aPos.X();
207 aScreenLoc.Y = aPos.Y();
208 }
209
210 return aScreenLoc;
211}
212
214{
215 if(!mpFrameSel)
216 throw RuntimeException();
217}
218
220{
221 mpFrameSel = nullptr;
222}
223
225 : mpFrameSel(&rFrameSel)
226 , meBorder(eBorder)
227{
228}
229
231{
232}
233
234Reference< XAccessibleContext > AccFrameSelectorChild::getAccessibleContext( )
235{
236 return this;
237}
238
240{
241 SolarMutexGuard aGuard;
242 IsValid();
243 return 0;
244}
245
246Reference< XAccessible > AccFrameSelectorChild::getAccessibleChild( sal_Int64 )
247{
248 throw RuntimeException();
249}
250
252{
253 SolarMutexGuard aGuard;
254 IsValid();
255 Reference< XAccessible > xRet = mpFrameSel->CreateAccessible();
256 return xRet;
257}
258
260{
261 return AccessibleRole::CHECK_BOX;
262}
263
265{
266 SolarMutexGuard aGuard;
267 IsValid();
268 return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[static_cast<sal_uInt32>(meBorder)].first);
269}
270
272{
273 SolarMutexGuard aGuard;
274 IsValid();
275 return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[static_cast<sal_uInt32>(meBorder)].first);
276}
277
278Reference< XAccessibleRelationSet > AccFrameSelectorChild::getAccessibleRelationSet( )
279{
280 SolarMutexGuard aGuard;
281 IsValid();
282 Reference< XAccessibleRelationSet > xRet = new utl::AccessibleRelationSetHelper;
283 return xRet;
284}
285
287{
288 SolarMutexGuard aGuard;
289 sal_Int64 nStateSet = 0;
290
291 if(!mpFrameSel)
292 nStateSet |= AccessibleStateType::DEFUNC;
293 else
294 {
295 nStateSet |=
296 AccessibleStateType::EDITABLE |
297 AccessibleStateType::FOCUSABLE |
298 AccessibleStateType::MULTI_SELECTABLE |
299 AccessibleStateType::SELECTABLE |
300 AccessibleStateType::SHOWING |
301 AccessibleStateType::VISIBLE |
302 AccessibleStateType::OPAQUE;
303 if(mpFrameSel->IsEnabled())
304 {
305 nStateSet |= AccessibleStateType::ENABLED;
306 nStateSet |= AccessibleStateType::SENSITIVE;
307 }
308
310 {
311 nStateSet |= AccessibleStateType::ACTIVE;
312 nStateSet |= AccessibleStateType::FOCUSED;
313 nStateSet |= AccessibleStateType::SELECTED;
314 }
315 }
316 return nStateSet;
317}
318
320 const css::awt::Point& aPt )
321{
322 SolarMutexGuard aGuard;
323 IsValid();
324 //aPt is relative to the frame selector
325 return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
326}
327
329{
330 SolarMutexGuard aGuard;
331 IsValid();
333 Point aPos = aSpot.TopLeft();
334 Size aSz = aSpot.GetSize();
335 css::awt::Rectangle aRet;
336 aRet.X = aPos.X();
337 aRet.Y = aPos.Y();
338 aRet.Width = aSz.Width();
339 aRet.Height = aSz.Height();
340 return aRet;
341}
342
344{
345 SolarMutexGuard aGuard;
346 IsValid();
348}
349
351{
352 SolarMutexGuard aGuard;
353
354 //see FrameSelector::Paint
356 return sal_Int32(rStyles.GetLabelTextColor());
357}
358
360{
361 SolarMutexGuard aGuard;
362
363 //see FrameSelector::Paint
365 return sal_Int32(rStyles.GetDialogColor());
366}
367
369{
370 if(!mpFrameSel)
371 throw RuntimeException();
372}
373
375{
376 mpFrameSel = nullptr;
377}
378
379}
380
381/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
constexpr tools::Long Y() const
constexpr tools::Long X() const
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:1043
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:1080
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:1052
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 css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() 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
FrameBorderType
Enumerates all borders a frame selection control can contain.