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::UNO_QUERY;
36 using ::com::sun::star::uno::Reference;
37 using ::com::sun::star::uno::Sequence;
38 using ::com::sun::star::uno::RuntimeException;
39 using ::com::sun::star::uno::XInterface;
40 using ::com::sun::star::lang::Locale;
41 using ::com::sun::star::lang::EventObject;
42 
43 using namespace ::com::sun::star::accessibility;
44 
45 
47  : mpFrameSel(&rFrameSel)
48 {
49 }
50 
52 {
53 }
54 
56 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccFrameSelector, OAccessibleComponentHelper, OAccessibleHelper_Base )
57 
58 Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext( )
59 {
60  return this;
61 }
62 
64 {
65  SolarMutexGuard aGuard;
66  IsValid();
68 }
69 
70 Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int32 i )
71 {
72  SolarMutexGuard aGuard;
73  IsValid();
74  Reference< XAccessible > xRet = mpFrameSel->GetChildAccessible( i );
75  if( !xRet.is() )
76  throw RuntimeException();
77  return xRet;
78 }
79 
80 Reference< XAccessible > AccFrameSelector::getAccessibleParent( )
81 {
82  SolarMutexGuard aGuard;
83  IsValid();
84  Reference< XAccessible > xRet = mpFrameSel->getAccessibleParent();
85  return xRet;
86 }
87 
89 {
90  return AccessibleRole::OPTION_PANE;
91 }
92 
94 {
95  SolarMutexGuard aGuard;
96  IsValid();
97  return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[0].first);
98 }
99 
101 {
102  SolarMutexGuard aGuard;
103  IsValid();
104  return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[0].first);
105 }
106 
107 Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet( )
108 {
109  SolarMutexGuard aGuard;
110  IsValid();
112 }
113 
114 Reference< XAccessibleStateSet > AccFrameSelector::getAccessibleStateSet( )
115 {
116  SolarMutexGuard aGuard;
118  Reference< XAccessibleStateSet > xRet = pStateSetHelper;
119 
120  if(!mpFrameSel)
121  pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
122  else
123  {
124  const sal_Int16 aStandardStates[] =
125  {
126  AccessibleStateType::EDITABLE,
127  AccessibleStateType::FOCUSABLE,
128  AccessibleStateType::MULTI_SELECTABLE,
129  AccessibleStateType::SELECTABLE,
130  AccessibleStateType::SHOWING,
131  AccessibleStateType::VISIBLE,
132  AccessibleStateType::OPAQUE,
133  0};
134  sal_Int16 nState = 0;
135  while(aStandardStates[nState])
136  {
137  pStateSetHelper->AddState(aStandardStates[nState++]);
138  }
139  if(mpFrameSel->IsEnabled())
140  {
141  pStateSetHelper->AddState(AccessibleStateType::ENABLED);
142  pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
143  }
144 
145  if (mpFrameSel->HasFocus())
146  {
147  pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
148  pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
149  pStateSetHelper->AddState(AccessibleStateType::SELECTED);
150  }
151  }
152  return xRet;
153 }
154 
155 Reference< XAccessible > AccFrameSelector::getAccessibleAtPoint(
156  const css::awt::Point& aPt )
157 {
158  SolarMutexGuard aGuard;
159  IsValid();
160  //aPt is relative to the frame selector
161  return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
162 }
163 
165 {
166  SolarMutexGuard aGuard;
167  IsValid();
169 }
170 
172 {
173  SolarMutexGuard aGuard;
174 
175  //see FrameSelector::Paint
177  return sal_Int32(rStyles.GetLabelTextColor());
178 }
179 
181 {
182  SolarMutexGuard aGuard;
183 
184  //see FrameSelector::Paint
186  return sal_Int32(rStyles.GetDialogColor());
187 }
188 
189 css::awt::Rectangle AccFrameSelector::implGetBounds()
190 {
191  SolarMutexGuard aGuard;
192  IsValid();
193 
194  css::awt::Rectangle aRet;
195 
196  const Point aOutPos;
197  Size aOutSize(mpFrameSel->GetOutputSizePixel());
198 
199  aRet.X = aOutPos.X();
200  aRet.Y = aOutPos.Y();
201  aRet.Width = aOutSize.Width();
202  aRet.Height = aOutSize.Height();
203 
204  return aRet;
205 }
206 
208 {
209  if(!mpFrameSel)
210  throw RuntimeException();
211 }
212 
214 {
215  mpFrameSel = nullptr;
216 }
217 
219  : mpFrameSel(&rFrameSel)
220  , meBorder(eBorder)
221 {
222 }
223 
225 {
226 }
227 
229 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccFrameSelectorChild, OAccessibleComponentHelper, OAccessibleHelper_Base )
230 
231 Reference< XAccessibleContext > AccFrameSelectorChild::getAccessibleContext( )
232 {
233  return this;
234 }
235 
237 {
238  SolarMutexGuard aGuard;
239  IsValid();
240  return 0;
241 }
242 
243 Reference< XAccessible > AccFrameSelectorChild::getAccessibleChild( sal_Int32 )
244 {
245  throw RuntimeException();
246 }
247 
249 {
250  SolarMutexGuard aGuard;
251  IsValid();
252  Reference< XAccessible > xRet = mpFrameSel->CreateAccessible();
253  return xRet;
254 }
255 
257 {
258  return AccessibleRole::CHECK_BOX;
259 }
260 
262 {
263  SolarMutexGuard aGuard;
264  IsValid();
265  return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS[static_cast<sal_uInt32>(meBorder)].first);
266 }
267 
269 {
270  SolarMutexGuard aGuard;
271  IsValid();
272  return SvxResId(RID_SVXSTR_FRMSEL_TEXTS[static_cast<sal_uInt32>(meBorder)].first);
273 }
274 
275 Reference< XAccessibleRelationSet > AccFrameSelectorChild::getAccessibleRelationSet( )
276 {
277  SolarMutexGuard aGuard;
278  IsValid();
279  Reference< XAccessibleRelationSet > xRet = new utl::AccessibleRelationSetHelper;
280  return xRet;
281 }
282 
283 Reference< XAccessibleStateSet > AccFrameSelectorChild::getAccessibleStateSet( )
284 {
285  SolarMutexGuard aGuard;
287  Reference< XAccessibleStateSet > xRet = pStateSetHelper;
288 
289  if(!mpFrameSel)
290  pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
291  else
292  {
293  const sal_Int16 aStandardStates[] =
294  {
295  AccessibleStateType::EDITABLE,
296  AccessibleStateType::FOCUSABLE,
297  AccessibleStateType::MULTI_SELECTABLE,
298  AccessibleStateType::SELECTABLE,
299  AccessibleStateType::SHOWING,
300  AccessibleStateType::VISIBLE,
301  AccessibleStateType::OPAQUE,
302  0};
303  sal_Int16 nState = 0;
304  while(aStandardStates[nState])
305  {
306  pStateSetHelper->AddState(aStandardStates[nState++]);
307  }
308  if(mpFrameSel->IsEnabled())
309  {
310  pStateSetHelper->AddState(AccessibleStateType::ENABLED);
311  pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
312  }
313 
315  {
316  pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
317  pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
318  pStateSetHelper->AddState(AccessibleStateType::SELECTED);
319  }
320  }
321  return xRet;
322 }
323 
325  const css::awt::Point& aPt )
326 {
327  SolarMutexGuard aGuard;
328  IsValid();
329  //aPt is relative to the frame selector
330  return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
331 }
332 
334 {
335  SolarMutexGuard aGuard;
336  IsValid();
338  Point aPos = aSpot.TopLeft();
339  Size aSz = aSpot.GetSize();
340  css::awt::Rectangle aRet;
341  aRet.X = aPos.X();
342  aRet.Y = aPos.Y();
343  aRet.Width = aSz.Width();
344  aRet.Height = aSz.Height();
345  return aRet;
346 }
347 
349 {
350  SolarMutexGuard aGuard;
351  IsValid();
353 }
354 
356 {
357  SolarMutexGuard aGuard;
358 
359  //see FrameSelector::Paint
361  return sal_Int32(rStyles.GetLabelTextColor());
362 }
363 
365 {
366  SolarMutexGuard aGuard;
367 
368  //see FrameSelector::Paint
370  return sal_Int32(rStyles.GetDialogColor());
371 }
372 
374 {
375  if(!mpFrameSel)
376  throw RuntimeException();
377 }
378 
380 {
381  mpFrameSel = nullptr;
382 }
383 
384 }
385 
386 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Int32 SAL_CALL getBackground() override
Point TopLeft() const
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
long Width() const
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:1052
long Height() const
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
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 i) override
virtual sal_Int32 SAL_CALL getBackground() override
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
a11yrelationset get_accessible_relation_set() const
Definition: frmsel.hxx:160
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:1017
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)
long X() const
Size GetSize() const
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &aPoint) override
bool IsBorderSelected(FrameBorderType eBorder) const
Returns true, if the specified frame border is selected.
Definition: frmsel.cxx:962
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: frmsel.hxx:158
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
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:852
virtual sal_Int32 SAL_CALL getForeground() override
virtual void SAL_CALL grabFocus() override
virtual OUString SAL_CALL getAccessibleName() override
void SAL_CALL first(const css::awt::SpinEvent &rEvent) override
rtl::Reference< a11y::AccFrameSelectorChild > GetChildAccessible(FrameBorderType eBorder)
Returns the accessibility child object of the specified frame border (if enabled).
Definition: frmsel.cxx:1024
void AddState(sal_Int16 aState)
sal_Int32 nState
long Y() const