1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <AccessibleFrameSelector.hxx>
21 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
22 #include <com/sun/star/accessibility/AccessibleRole.hpp>
23 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24 #include <unotools/accessiblerelationsethelper.hxx>
25 #include <vcl/svapp.hxx>
26 #include <vcl/settings.hxx>
27 #include <svx/frmsel.hxx>
28 #include <svx/dialmgr.hxx>
34 using ::com::sun::star::lang::IndexOutOfBoundsException
;
35 using ::com::sun::star::uno::Reference
;
36 using ::com::sun::star::uno::RuntimeException
;
38 using namespace ::com::sun::star::accessibility
;
41 AccFrameSelector::AccFrameSelector(FrameSelector
& rFrameSel
)
42 : mpFrameSel(&rFrameSel
)
46 AccFrameSelector::~AccFrameSelector()
50 Reference
< XAccessibleContext
> AccFrameSelector::getAccessibleContext( )
55 sal_Int64
AccFrameSelector::getAccessibleChildCount( )
57 SolarMutexGuard aGuard
;
59 return mpFrameSel
->GetEnabledBorderCount();
62 Reference
< XAccessible
> AccFrameSelector::getAccessibleChild( sal_Int64 i
)
64 SolarMutexGuard aGuard
;
67 if (i
< 0 || i
>= getAccessibleChildCount())
68 throw IndexOutOfBoundsException();
70 Reference
< XAccessible
> xRet
= mpFrameSel
->GetChildAccessible( i
);
72 throw RuntimeException();
76 Reference
< XAccessible
> AccFrameSelector::getAccessibleParent( )
78 SolarMutexGuard aGuard
;
80 Reference
< XAccessible
> xRet
= mpFrameSel
->getAccessibleParent();
84 sal_Int16
AccFrameSelector::getAccessibleRole( )
86 return AccessibleRole::OPTION_PANE
;
89 OUString
AccFrameSelector::getAccessibleDescription( )
91 SolarMutexGuard aGuard
;
93 return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS
[0].first
);
96 OUString
AccFrameSelector::getAccessibleName( )
98 SolarMutexGuard aGuard
;
100 return SvxResId(RID_SVXSTR_FRMSEL_TEXTS
[0].first
);
103 Reference
< XAccessibleRelationSet
> AccFrameSelector::getAccessibleRelationSet( )
105 SolarMutexGuard aGuard
;
107 return mpFrameSel
->get_accessible_relation_set();
110 sal_Int64
AccFrameSelector::getAccessibleStateSet( )
112 SolarMutexGuard aGuard
;
113 sal_Int64 nStateSet
= 0;
116 nStateSet
|= AccessibleStateType::DEFUNC
;
119 // add standard states
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())
130 nStateSet
|= AccessibleStateType::ENABLED
;
131 nStateSet
|= AccessibleStateType::SENSITIVE
;
134 if (mpFrameSel
->HasFocus())
136 nStateSet
|= AccessibleStateType::ACTIVE
;
137 nStateSet
|= AccessibleStateType::FOCUSED
;
138 nStateSet
|= AccessibleStateType::SELECTED
;
144 Reference
< XAccessible
> AccFrameSelector::getAccessibleAtPoint(
145 const css::awt::Point
& aPt
)
147 SolarMutexGuard aGuard
;
149 //aPt is relative to the frame selector
150 return mpFrameSel
->GetChildAccessible( Point( aPt
.X
, aPt
.Y
) );
153 void AccFrameSelector::grabFocus( )
155 SolarMutexGuard aGuard
;
157 mpFrameSel
->GrabFocus();
160 sal_Int32
AccFrameSelector::getForeground( )
162 SolarMutexGuard aGuard
;
164 //see FrameSelector::Paint
165 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
166 return sal_Int32(rStyles
.GetLabelTextColor());
169 sal_Int32
AccFrameSelector::getBackground( )
171 SolarMutexGuard aGuard
;
173 //see FrameSelector::Paint
174 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
175 return sal_Int32(rStyles
.GetDialogColor());
178 css::awt::Rectangle
AccFrameSelector::implGetBounds()
180 SolarMutexGuard aGuard
;
183 css::awt::Rectangle aRet
;
186 Size
aOutSize(mpFrameSel
->GetOutputSizePixel());
188 aRet
.X
= aOutPos
.X();
189 aRet
.Y
= aOutPos
.Y();
190 aRet
.Width
= aOutSize
.Width();
191 aRet
.Height
= aOutSize
.Height();
196 css::awt::Point
AccFrameSelector::getLocationOnScreen()
198 SolarMutexGuard aGuard
;
201 css::awt::Point
aScreenLoc(0, 0);
203 if (weld::DrawingArea
* pDrawingArea
= mpFrameSel
->GetDrawingArea())
205 Point aPos
= pDrawingArea
->get_accessible_location_on_screen();
206 aScreenLoc
.X
= aPos
.X();
207 aScreenLoc
.Y
= aPos
.Y();
213 void AccFrameSelector::IsValid()
216 throw RuntimeException();
219 void AccFrameSelector::Invalidate()
221 mpFrameSel
= nullptr;
224 AccFrameSelectorChild::AccFrameSelectorChild(FrameSelector
& rFrameSel
, FrameBorderType eBorder
)
225 : mpFrameSel(&rFrameSel
)
230 AccFrameSelectorChild::~AccFrameSelectorChild()
234 Reference
< XAccessibleContext
> AccFrameSelectorChild::getAccessibleContext( )
239 sal_Int64
AccFrameSelectorChild::getAccessibleChildCount( )
241 SolarMutexGuard aGuard
;
246 Reference
< XAccessible
> AccFrameSelectorChild::getAccessibleChild( sal_Int64
)
248 throw RuntimeException();
251 Reference
< XAccessible
> AccFrameSelectorChild::getAccessibleParent( )
253 SolarMutexGuard aGuard
;
255 Reference
< XAccessible
> xRet
= mpFrameSel
->CreateAccessible();
259 sal_Int16
AccFrameSelectorChild::getAccessibleRole( )
261 return AccessibleRole::CHECK_BOX
;
264 OUString
AccFrameSelectorChild::getAccessibleDescription( )
266 SolarMutexGuard aGuard
;
268 return SvxResId(RID_SVXSTR_FRMSEL_DESCRIPTIONS
[static_cast<sal_uInt32
>(meBorder
)].first
);
271 OUString
AccFrameSelectorChild::getAccessibleName( )
273 SolarMutexGuard aGuard
;
275 return SvxResId(RID_SVXSTR_FRMSEL_TEXTS
[static_cast<sal_uInt32
>(meBorder
)].first
);
278 Reference
< XAccessibleRelationSet
> AccFrameSelectorChild::getAccessibleRelationSet( )
280 SolarMutexGuard aGuard
;
282 Reference
< XAccessibleRelationSet
> xRet
= new utl::AccessibleRelationSetHelper
;
286 sal_Int64
AccFrameSelectorChild::getAccessibleStateSet( )
288 SolarMutexGuard aGuard
;
289 sal_Int64 nStateSet
= 0;
292 nStateSet
|= AccessibleStateType::DEFUNC
;
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())
305 nStateSet
|= AccessibleStateType::ENABLED
;
306 nStateSet
|= AccessibleStateType::SENSITIVE
;
309 if (mpFrameSel
->HasFocus() && mpFrameSel
->IsBorderSelected(meBorder
))
311 nStateSet
|= AccessibleStateType::ACTIVE
;
312 nStateSet
|= AccessibleStateType::FOCUSED
;
313 nStateSet
|= AccessibleStateType::SELECTED
;
319 Reference
< XAccessible
> AccFrameSelectorChild::getAccessibleAtPoint(
320 const css::awt::Point
& aPt
)
322 SolarMutexGuard aGuard
;
324 //aPt is relative to the frame selector
325 return mpFrameSel
->GetChildAccessible( Point( aPt
.X
, aPt
.Y
) );
328 css::awt::Rectangle
AccFrameSelectorChild::implGetBounds( )
330 SolarMutexGuard aGuard
;
332 const tools::Rectangle aSpot
= mpFrameSel
->GetClickBoundRect( meBorder
);
333 Point aPos
= aSpot
.TopLeft();
334 Size aSz
= aSpot
.GetSize();
335 css::awt::Rectangle aRet
;
338 aRet
.Width
= aSz
.Width();
339 aRet
.Height
= aSz
.Height();
343 void AccFrameSelectorChild::grabFocus( )
345 SolarMutexGuard aGuard
;
347 mpFrameSel
->GrabFocus();
350 sal_Int32
AccFrameSelectorChild::getForeground( )
352 SolarMutexGuard aGuard
;
354 //see FrameSelector::Paint
355 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
356 return sal_Int32(rStyles
.GetLabelTextColor());
359 sal_Int32
AccFrameSelectorChild::getBackground( )
361 SolarMutexGuard aGuard
;
363 //see FrameSelector::Paint
364 const StyleSettings
& rStyles
= Application::GetSettings().GetStyleSettings();
365 return sal_Int32(rStyles
.GetDialogColor());
368 void AccFrameSelectorChild::IsValid()
371 throw RuntimeException();
374 void AccFrameSelectorChild::Invalidate()
376 mpFrameSel
= nullptr;
381 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */