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>
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 
32 namespace svx::a11y {
33 
34 using ::com::sun::star::uno::Any;
35 using ::com::sun::star::uno::Reference;
36 using ::com::sun::star::uno::Sequence;
37 using ::com::sun::star::uno::RuntimeException;
38 
39 using namespace ::com::sun::star::accessibility;
40 
41 
43  : mpFrameSel(&rFrameSel)
44 {
45 }
46 
48 {
49 }
50 
52 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccFrameSelector, OAccessibleComponentHelper, OAccessibleHelper_Base )
53 
54 Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext( )
55 {
56  return this;
57 }
58 
60 {
61  SolarMutexGuard aGuard;
62  IsValid();
64 }
65 
66 Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int32 i )
67 {
68  SolarMutexGuard aGuard;
69  IsValid();
70  Reference< XAccessible > xRet = mpFrameSel->GetChildAccessible( i );
71  if( !xRet.is() )
72  throw RuntimeException();
73  return xRet;
74 }
75 
76 Reference< 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 
103 Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet( )
104 {
105  SolarMutexGuard aGuard;
106  IsValid();
108 }
109 
110 Reference< XAccessibleStateSet > AccFrameSelector::getAccessibleStateSet( )
111 {
112  SolarMutexGuard aGuard;
114 
115  if(!mpFrameSel)
116  pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
117  else
118  {
119  const sal_Int16 aStandardStates[] =
120  {
121  AccessibleStateType::EDITABLE,
122  AccessibleStateType::FOCUSABLE,
123  AccessibleStateType::MULTI_SELECTABLE,
124  AccessibleStateType::SELECTABLE,
125  AccessibleStateType::SHOWING,
126  AccessibleStateType::VISIBLE,
127  AccessibleStateType::OPAQUE,
128  0};
129  sal_Int16 nState = 0;
130  while(aStandardStates[nState])
131  {
132  pStateSetHelper->AddState(aStandardStates[nState++]);
133  }
134  if(mpFrameSel->IsEnabled())
135  {
136  pStateSetHelper->AddState(AccessibleStateType::ENABLED);
137  pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
138  }
139 
140  if (mpFrameSel->HasFocus())
141  {
142  pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
143  pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
144  pStateSetHelper->AddState(AccessibleStateType::SELECTED);
145  }
146  }
147  return pStateSetHelper;
148 }
149 
150 Reference< XAccessible > AccFrameSelector::getAccessibleAtPoint(
151  const css::awt::Point& aPt )
152 {
153  SolarMutexGuard aGuard;
154  IsValid();
155  //aPt is relative to the frame selector
156  return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
157 }
158 
160 {
161  SolarMutexGuard aGuard;
162  IsValid();
164 }
165 
167 {
168  SolarMutexGuard aGuard;
169 
170  //see FrameSelector::Paint
172  return sal_Int32(rStyles.GetLabelTextColor());
173 }
174 
176 {
177  SolarMutexGuard aGuard;
178 
179  //see FrameSelector::Paint
181  return sal_Int32(rStyles.GetDialogColor());
182 }
183 
184 css::awt::Rectangle AccFrameSelector::implGetBounds()
185 {
186  SolarMutexGuard aGuard;
187  IsValid();
188 
189  css::awt::Rectangle aRet;
190 
191  const Point aOutPos;
192  Size aOutSize(mpFrameSel->GetOutputSizePixel());
193 
194  aRet.X = aOutPos.X();
195  aRet.Y = aOutPos.Y();
196  aRet.Width = aOutSize.Width();
197  aRet.Height = aOutSize.Height();
198 
199  return aRet;
200 }
201 
203 {
204  if(!mpFrameSel)
205  throw RuntimeException();
206 }
207 
209 {
210  mpFrameSel = nullptr;
211 }
212 
214  : mpFrameSel(&rFrameSel)
215  , meBorder(eBorder)
216 {
217 }
218 
220 {
221 }
222 
224 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccFrameSelectorChild, OAccessibleComponentHelper, OAccessibleHelper_Base )
225 
226 Reference< XAccessibleContext > AccFrameSelectorChild::getAccessibleContext( )
227 {
228  return this;
229 }
230 
232 {
233  SolarMutexGuard aGuard;
234  IsValid();
235  return 0;
236 }
237 
238 Reference< XAccessible > AccFrameSelectorChild::getAccessibleChild( sal_Int32 )
239 {
240  throw RuntimeException();
241 }
242 
244 {
245  SolarMutexGuard aGuard;
246  IsValid();
247  Reference< XAccessible > xRet = mpFrameSel->CreateAccessible();
248  return xRet;
249 }
250 
252 {
253  return AccessibleRole::CHECK_BOX;
254 }
255 
257 {
258  SolarMutexGuard aGuard;
259  IsValid();
260  return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[static_cast<sal_uInt32>(meBorder)].first);
261 }
262 
264 {
265  SolarMutexGuard aGuard;
266  IsValid();
267  return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[static_cast<sal_uInt32>(meBorder)].first);
268 }
269 
270 Reference< XAccessibleRelationSet > AccFrameSelectorChild::getAccessibleRelationSet( )
271 {
272  SolarMutexGuard aGuard;
273  IsValid();
274  Reference< XAccessibleRelationSet > xRet = new utl::AccessibleRelationSetHelper;
275  return xRet;
276 }
277 
278 Reference< XAccessibleStateSet > AccFrameSelectorChild::getAccessibleStateSet( )
279 {
280  SolarMutexGuard aGuard;
282 
283  if(!mpFrameSel)
284  pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
285  else
286  {
287  const sal_Int16 aStandardStates[] =
288  {
289  AccessibleStateType::EDITABLE,
290  AccessibleStateType::FOCUSABLE,
291  AccessibleStateType::MULTI_SELECTABLE,
292  AccessibleStateType::SELECTABLE,
293  AccessibleStateType::SHOWING,
294  AccessibleStateType::VISIBLE,
295  AccessibleStateType::OPAQUE,
296  0};
297  sal_Int16 nState = 0;
298  while(aStandardStates[nState])
299  {
300  pStateSetHelper->AddState(aStandardStates[nState++]);
301  }
302  if(mpFrameSel->IsEnabled())
303  {
304  pStateSetHelper->AddState(AccessibleStateType::ENABLED);
305  pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
306  }
307 
309  {
310  pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
311  pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
312  pStateSetHelper->AddState(AccessibleStateType::SELECTED);
313  }
314  }
315  return pStateSetHelper;
316 }
317 
319  const css::awt::Point& aPt )
320 {
321  SolarMutexGuard aGuard;
322  IsValid();
323  //aPt is relative to the frame selector
324  return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
325 }
326 
328 {
329  SolarMutexGuard aGuard;
330  IsValid();
332  Point aPos = aSpot.TopLeft();
333  Size aSz = aSpot.GetSize();
334  css::awt::Rectangle aRet;
335  aRet.X = aPos.X();
336  aRet.Y = aPos.Y();
337  aRet.Width = aSz.Width();
338  aRet.Height = aSz.Height();
339  return aRet;
340 }
341 
343 {
344  SolarMutexGuard aGuard;
345  IsValid();
347 }
348 
350 {
351  SolarMutexGuard aGuard;
352 
353  //see FrameSelector::Paint
355  return sal_Int32(rStyles.GetLabelTextColor());
356 }
357 
359 {
360  SolarMutexGuard aGuard;
361 
362  //see FrameSelector::Paint
364  return sal_Int32(rStyles.GetDialogColor());
365 }
366 
368 {
369  if(!mpFrameSel)
370  throw RuntimeException();
371 }
372 
374 {
375  mpFrameSel = nullptr;
376 }
377 
378 }
379 
380 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Int32 SAL_CALL getBackground() override
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
virtual sal_Int16 SAL_CALL getAccessibleRole() override
const Color & GetDialogColor() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
tools::Rectangle GetClickBoundRect(FrameBorderType eBorder) const
Returns the bounding rectangle of the specified frame border (if enabled).
Definition: frmsel.cxx:1061
virtual OUString SAL_CALL getAccessibleName() override
virtual OUString SAL_CALL getAccessibleDescription() override
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
virtual OUString SAL_CALL getAccessibleDescription() override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override
const Color & GetLabelTextColor() const
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Size const & GetOutputSizePixel() const
constexpr tools::Long Width() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 i) override
virtual sal_Int32 SAL_CALL getBackground() override
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
a11yrelationset get_accessible_relation_set() const
Definition: frmsel.hxx:162
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
virtual sal_Int32 SAL_CALL getForeground() override
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
virtual css::awt::Rectangle implGetBounds() override
implements the calculation of the bounding rectangle
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: frmsel.cxx:1026
AccFrameSelectorChild(FrameSelector &rFrameSel, FrameBorderType eBorder)
FrameBorderType
Enumerates all borders a frame selection control can contain.
virtual css::awt::Rectangle implGetBounds() override
implements the calculation of the bounding rectangle
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 i) override
virtual void SAL_CALL grabFocus() override
AccFrameSelector(FrameSelector &rFrameSel)
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
constexpr Point TopLeft() const
bool IsBorderSelected(FrameBorderType eBorder) const
Returns true, if the specified frame border is selected.
Definition: frmsel.cxx:966
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: frmsel.hxx:160
constexpr Size GetSize() const
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
constexpr tools::Long Height() const
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
sal_Int32 GetEnabledBorderCount() const
Returns the number of enabled frame borders.
Definition: frmsel.cxx:856
virtual sal_Int32 SAL_CALL getForeground() override
virtual void SAL_CALL grabFocus() override
virtual OUString SAL_CALL getAccessibleName() override
rtl::Reference< a11y::AccFrameSelectorChild > GetChildAccessible(FrameBorderType eBorder)
Returns the accessibility child object of the specified frame border (if enabled).
Definition: frmsel.cxx:1033
constexpr OUStringLiteral first
sal_Int32 nState