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
52Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext( )
53{
54 return this;
55}
56
58{
59 SolarMutexGuard aGuard;
60 IsValid();
62}
63
64Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int64 i )
65{
66 SolarMutexGuard aGuard;
67 IsValid();
68
69 if (i < 0 || i >= getAccessibleChildCount())
70 throw IndexOutOfBoundsException();
71
72 Reference< XAccessible > xRet = mpFrameSel->GetChildAccessible( i );
73 if( !xRet.is() )
74 throw RuntimeException();
75 return xRet;
76}
77
78Reference< XAccessible > AccFrameSelector::getAccessibleParent( )
79{
80 SolarMutexGuard aGuard;
81 IsValid();
82 Reference< XAccessible > xRet = mpFrameSel->getAccessibleParent();
83 return xRet;
84}
85
87{
88 return AccessibleRole::OPTION_PANE;
89}
90
92{
93 SolarMutexGuard aGuard;
94 IsValid();
95 return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[0].first);
96}
97
99{
100 SolarMutexGuard aGuard;
101 IsValid();
102 return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[0].first);
103}
104
105Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet( )
106{
107 SolarMutexGuard aGuard;
108 IsValid();
110}
111
113{
114 SolarMutexGuard aGuard;
115 sal_Int64 nStateSet = 0;
116
117 if(!mpFrameSel)
118 nStateSet |= AccessibleStateType::DEFUNC;
119 else
120 {
121 // add standard states
122 nStateSet |=
123 AccessibleStateType::EDITABLE |
124 AccessibleStateType::FOCUSABLE |
125 AccessibleStateType::MULTI_SELECTABLE |
126 AccessibleStateType::SELECTABLE |
127 AccessibleStateType::SHOWING |
128 AccessibleStateType::VISIBLE |
129 AccessibleStateType::OPAQUE;
130 if(mpFrameSel->IsEnabled())
131 {
132 nStateSet |= AccessibleStateType::ENABLED;
133 nStateSet |= AccessibleStateType::SENSITIVE;
134 }
135
136 if (mpFrameSel->HasFocus())
137 {
138 nStateSet |= AccessibleStateType::ACTIVE;
139 nStateSet |= AccessibleStateType::FOCUSED;
140 nStateSet |= AccessibleStateType::SELECTED;
141 }
142 }
143 return nStateSet;
144}
145
147 const css::awt::Point& aPt )
148{
149 SolarMutexGuard aGuard;
150 IsValid();
151 //aPt is relative to the frame selector
152 return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
153}
154
156{
157 SolarMutexGuard aGuard;
158 IsValid();
160}
161
163{
164 SolarMutexGuard aGuard;
165
166 //see FrameSelector::Paint
168 return sal_Int32(rStyles.GetLabelTextColor());
169}
170
172{
173 SolarMutexGuard aGuard;
174
175 //see FrameSelector::Paint
177 return sal_Int32(rStyles.GetDialogColor());
178}
179
181{
182 SolarMutexGuard aGuard;
183 IsValid();
184
185 css::awt::Rectangle aRet;
186
187 const Point aOutPos;
189
190 aRet.X = aOutPos.X();
191 aRet.Y = aOutPos.Y();
192 aRet.Width = aOutSize.Width();
193 aRet.Height = aOutSize.Height();
194
195 return aRet;
196}
197
199{
200 SolarMutexGuard aGuard;
201 IsValid();
202
203 css::awt::Point aScreenLoc(0, 0);
204
205 if (weld::DrawingArea* pDrawingArea = mpFrameSel->GetDrawingArea())
206 {
207 Point aPos = pDrawingArea->get_accessible_location_on_screen();
208 aScreenLoc.X = aPos.X();
209 aScreenLoc.Y = aPos.Y();
210 }
211
212 return aScreenLoc;
213}
214
216{
217 if(!mpFrameSel)
218 throw RuntimeException();
219}
220
222{
223 mpFrameSel = nullptr;
224}
225
227 : mpFrameSel(&rFrameSel)
228 , meBorder(eBorder)
229{
230}
231
233{
234}
235
236Reference< XAccessibleContext > AccFrameSelectorChild::getAccessibleContext( )
237{
238 return this;
239}
240
242{
243 SolarMutexGuard aGuard;
244 IsValid();
245 return 0;
246}
247
248Reference< XAccessible > AccFrameSelectorChild::getAccessibleChild( sal_Int64 )
249{
250 throw RuntimeException();
251}
252
254{
255 SolarMutexGuard aGuard;
256 IsValid();
257 Reference< XAccessible > xRet = mpFrameSel->CreateAccessible();
258 return xRet;
259}
260
262{
263 return AccessibleRole::CHECK_BOX;
264}
265
267{
268 SolarMutexGuard aGuard;
269 IsValid();
270 return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[static_cast<sal_uInt32>(meBorder)].first);
271}
272
274{
275 SolarMutexGuard aGuard;
276 IsValid();
277 return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[static_cast<sal_uInt32>(meBorder)].first);
278}
279
280Reference< XAccessibleRelationSet > AccFrameSelectorChild::getAccessibleRelationSet( )
281{
282 SolarMutexGuard aGuard;
283 IsValid();
284 Reference< XAccessibleRelationSet > xRet = new utl::AccessibleRelationSetHelper;
285 return xRet;
286}
287
289{
290 SolarMutexGuard aGuard;
291 sal_Int64 nStateSet = 0;
292
293 if(!mpFrameSel)
294 nStateSet |= AccessibleStateType::DEFUNC;
295 else
296 {
297 nStateSet |=
298 AccessibleStateType::EDITABLE |
299 AccessibleStateType::FOCUSABLE |
300 AccessibleStateType::MULTI_SELECTABLE |
301 AccessibleStateType::SELECTABLE |
302 AccessibleStateType::SHOWING |
303 AccessibleStateType::VISIBLE |
304 AccessibleStateType::OPAQUE;
305 if(mpFrameSel->IsEnabled())
306 {
307 nStateSet |= AccessibleStateType::ENABLED;
308 nStateSet |= AccessibleStateType::SENSITIVE;
309 }
310
312 {
313 nStateSet |= AccessibleStateType::ACTIVE;
314 nStateSet |= AccessibleStateType::FOCUSED;
315 nStateSet |= AccessibleStateType::SELECTED;
316 }
317 }
318 return nStateSet;
319}
320
322 const css::awt::Point& aPt )
323{
324 SolarMutexGuard aGuard;
325 IsValid();
326 //aPt is relative to the frame selector
327 return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
328}
329
331{
332 SolarMutexGuard aGuard;
333 IsValid();
335 Point aPos = aSpot.TopLeft();
336 Size aSz = aSpot.GetSize();
337 css::awt::Rectangle aRet;
338 aRet.X = aPos.X();
339 aRet.Y = aPos.Y();
340 aRet.Width = aSz.Width();
341 aRet.Height = aSz.Height();
342 return aRet;
343}
344
346{
347 SolarMutexGuard aGuard;
348 IsValid();
350}
351
353{
354 SolarMutexGuard aGuard;
355
356 //see FrameSelector::Paint
358 return sal_Int32(rStyles.GetLabelTextColor());
359}
360
362{
363 SolarMutexGuard aGuard;
364
365 //see FrameSelector::Paint
367 return sal_Int32(rStyles.GetDialogColor());
368}
369
371{
372 if(!mpFrameSel)
373 throw RuntimeException();
374}
375
377{
378 mpFrameSel = nullptr;
379}
380
381}
382
383/* 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 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.