1c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3c82f2877SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4c82f2877SAndrew Rist * or more contributor license agreements. See the NOTICE file
5c82f2877SAndrew Rist * distributed with this work for additional information
6c82f2877SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7c82f2877SAndrew Rist * to you under the Apache License, Version 2.0 (the
8c82f2877SAndrew Rist * "License"); you may not use this file except in compliance
9c82f2877SAndrew Rist * with the License. You may obtain a copy of the License at
10c82f2877SAndrew Rist *
11c82f2877SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12c82f2877SAndrew Rist *
13c82f2877SAndrew Rist * Unless required by applicable law or agreed to in writing,
14c82f2877SAndrew Rist * software distributed under the License is distributed on an
15c82f2877SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c82f2877SAndrew Rist * KIND, either express or implied. See the License for the
17c82f2877SAndrew Rist * specific language governing permissions and limitations
18c82f2877SAndrew Rist * under the License.
19c82f2877SAndrew Rist *
20c82f2877SAndrew Rist *************************************************************/
21c82f2877SAndrew Rist
22c82f2877SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // includes --------------------------------------------------------------
28cdf0e10cSrcweir #include <accessibility/standard/vclxaccessiblescrollbar.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <toolkit/awt/vclxwindows.hxx>
31cdf0e10cSrcweir #include <accessibility/helper/accresmgr.hxx>
32cdf0e10cSrcweir #include <accessibility/helper/accessiblestrings.hrc>
33cdf0e10cSrcweir
34cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
35cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
37cdf0e10cSrcweir #include <com/sun/star/awt/ScrollBarOrientation.hpp>
38cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
39cdf0e10cSrcweir #include <comphelper/sequence.hxx>
40cdf0e10cSrcweir #include <vcl/scrbar.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace ::com::sun::star;
43cdf0e10cSrcweir using namespace ::com::sun::star::uno;
44cdf0e10cSrcweir using namespace ::com::sun::star::awt;
45cdf0e10cSrcweir using namespace ::com::sun::star::lang;
46cdf0e10cSrcweir using namespace ::com::sun::star::beans;
47cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
48cdf0e10cSrcweir using namespace ::comphelper;
49cdf0e10cSrcweir
50cdf0e10cSrcweir
51cdf0e10cSrcweir // -----------------------------------------------------------------------------
52cdf0e10cSrcweir // VCLXAccessibleScrollBar
53cdf0e10cSrcweir // -----------------------------------------------------------------------------
54cdf0e10cSrcweir
VCLXAccessibleScrollBar(VCLXWindow * pVCLWindow)55cdf0e10cSrcweir VCLXAccessibleScrollBar::VCLXAccessibleScrollBar( VCLXWindow* pVCLWindow )
56cdf0e10cSrcweir :VCLXAccessibleComponent( pVCLWindow )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
60cdf0e10cSrcweir // -----------------------------------------------------------------------------
61cdf0e10cSrcweir
~VCLXAccessibleScrollBar()62cdf0e10cSrcweir VCLXAccessibleScrollBar::~VCLXAccessibleScrollBar()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
66cdf0e10cSrcweir // -----------------------------------------------------------------------------
67cdf0e10cSrcweir
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)68cdf0e10cSrcweir void VCLXAccessibleScrollBar::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir switch ( rVclWindowEvent.GetId() )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir case VCLEVENT_SCROLLBAR_SCROLL:
73cdf0e10cSrcweir {
74cdf0e10cSrcweir NotifyAccessibleEvent( AccessibleEventId::VALUE_CHANGED, Any(), Any() );
75cdf0e10cSrcweir }
76cdf0e10cSrcweir break;
77cdf0e10cSrcweir default:
78cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
79cdf0e10cSrcweir }
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir // -----------------------------------------------------------------------------
83cdf0e10cSrcweir
FillAccessibleStateSet(utl::AccessibleStateSetHelper & rStateSet)84cdf0e10cSrcweir void VCLXAccessibleScrollBar::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
87cdf0e10cSrcweir
88cdf0e10cSrcweir VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
89cdf0e10cSrcweir if ( pVCLXScrollBar )
90cdf0e10cSrcweir {
91*21075d77SSteve Yin // IA2 CWS: scroll bar should not have FOCUSABLE state.
92*21075d77SSteve Yin // rStateSet.AddState( AccessibleStateType::FOCUSABLE );
93cdf0e10cSrcweir if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::HORIZONTAL )
94cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::HORIZONTAL );
95cdf0e10cSrcweir else if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::VERTICAL )
96cdf0e10cSrcweir rStateSet.AddState( AccessibleStateType::VERTICAL );
97cdf0e10cSrcweir }
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
100cdf0e10cSrcweir // -----------------------------------------------------------------------------
101cdf0e10cSrcweir // XInterface
102cdf0e10cSrcweir // -----------------------------------------------------------------------------
103cdf0e10cSrcweir
IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleScrollBar,VCLXAccessibleComponent,VCLXAccessibleScrollBar_BASE)104cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleScrollBar, VCLXAccessibleComponent, VCLXAccessibleScrollBar_BASE )
105cdf0e10cSrcweir
106cdf0e10cSrcweir // -----------------------------------------------------------------------------
107cdf0e10cSrcweir // XTypeProvider
108cdf0e10cSrcweir // -----------------------------------------------------------------------------
109cdf0e10cSrcweir
110cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleScrollBar, VCLXAccessibleComponent, VCLXAccessibleScrollBar_BASE )
111cdf0e10cSrcweir
112cdf0e10cSrcweir // -----------------------------------------------------------------------------
113cdf0e10cSrcweir // XServiceInfo
114cdf0e10cSrcweir // -----------------------------------------------------------------------------
115cdf0e10cSrcweir
116cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleScrollBar::getImplementationName() throw (RuntimeException)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleScrollBar" );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir // -----------------------------------------------------------------------------
122cdf0e10cSrcweir
getSupportedServiceNames()123cdf0e10cSrcweir Sequence< ::rtl::OUString > VCLXAccessibleScrollBar::getSupportedServiceNames() throw (RuntimeException)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir Sequence< ::rtl::OUString > aNames(1);
126cdf0e10cSrcweir aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleScrollBar" );
127cdf0e10cSrcweir return aNames;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir // -----------------------------------------------------------------------------
131cdf0e10cSrcweir // XAccessibleAction
132cdf0e10cSrcweir // -----------------------------------------------------------------------------
133cdf0e10cSrcweir
getAccessibleActionCount()134cdf0e10cSrcweir sal_Int32 VCLXAccessibleScrollBar::getAccessibleActionCount( ) throw (RuntimeException)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir OExternalLockGuard aGuard( this );
137cdf0e10cSrcweir
138cdf0e10cSrcweir return 4;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141cdf0e10cSrcweir // -----------------------------------------------------------------------------
142cdf0e10cSrcweir
doAccessibleAction(sal_Int32 nIndex)143cdf0e10cSrcweir sal_Bool VCLXAccessibleScrollBar::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
144cdf0e10cSrcweir {
145cdf0e10cSrcweir OExternalLockGuard aGuard( this );
146cdf0e10cSrcweir
147cdf0e10cSrcweir if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
148cdf0e10cSrcweir throw IndexOutOfBoundsException();
149cdf0e10cSrcweir
150cdf0e10cSrcweir sal_Bool bReturn = sal_False;
151cdf0e10cSrcweir ScrollBar* pScrollBar = static_cast< ScrollBar* >( GetWindow() );
152cdf0e10cSrcweir if ( pScrollBar )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir ScrollType eScrollType;
155cdf0e10cSrcweir switch ( nIndex )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir case 0: eScrollType = SCROLL_LINEUP; break;
158cdf0e10cSrcweir case 1: eScrollType = SCROLL_LINEDOWN; break;
159cdf0e10cSrcweir case 2: eScrollType = SCROLL_PAGEUP; break;
160cdf0e10cSrcweir case 3: eScrollType = SCROLL_PAGEDOWN; break;
161cdf0e10cSrcweir default: eScrollType = SCROLL_DONTKNOW; break;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir if ( pScrollBar->DoScrollAction( eScrollType ) )
164cdf0e10cSrcweir bReturn = sal_True;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir
167cdf0e10cSrcweir return bReturn;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir // -----------------------------------------------------------------------------
171cdf0e10cSrcweir
getAccessibleActionDescription(sal_Int32 nIndex)172cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleScrollBar::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir OExternalLockGuard aGuard( this );
175cdf0e10cSrcweir
176cdf0e10cSrcweir if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
177cdf0e10cSrcweir throw IndexOutOfBoundsException();
178cdf0e10cSrcweir
179cdf0e10cSrcweir ::rtl::OUString sDescription;
180cdf0e10cSrcweir
181cdf0e10cSrcweir switch ( nIndex )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir case 0: sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_DECLINE ) ); break;
184cdf0e10cSrcweir case 1: sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_INCLINE ) ); break;
185cdf0e10cSrcweir case 2: sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_DECBLOCK ) ); break;
186cdf0e10cSrcweir case 3: sDescription = ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_INCBLOCK ) ); break;
187cdf0e10cSrcweir default: break;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir
190cdf0e10cSrcweir return sDescription;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir
193cdf0e10cSrcweir // -----------------------------------------------------------------------------
194cdf0e10cSrcweir
getAccessibleActionKeyBinding(sal_Int32 nIndex)195cdf0e10cSrcweir Reference< XAccessibleKeyBinding > VCLXAccessibleScrollBar::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
196cdf0e10cSrcweir {
197cdf0e10cSrcweir OExternalLockGuard aGuard( this );
198cdf0e10cSrcweir
199cdf0e10cSrcweir if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
200cdf0e10cSrcweir throw IndexOutOfBoundsException();
201cdf0e10cSrcweir
202cdf0e10cSrcweir return Reference< XAccessibleKeyBinding >();
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir // -----------------------------------------------------------------------------
206cdf0e10cSrcweir // XAccessibleValue
207cdf0e10cSrcweir // -----------------------------------------------------------------------------
208cdf0e10cSrcweir
getCurrentValue()209cdf0e10cSrcweir Any VCLXAccessibleScrollBar::getCurrentValue( ) throw (RuntimeException)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir OExternalLockGuard aGuard( this );
212cdf0e10cSrcweir
213cdf0e10cSrcweir Any aValue;
214cdf0e10cSrcweir
215cdf0e10cSrcweir VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
216cdf0e10cSrcweir if ( pVCLXScrollBar )
217cdf0e10cSrcweir aValue <<= (sal_Int32) pVCLXScrollBar->getValue();
218cdf0e10cSrcweir
219cdf0e10cSrcweir return aValue;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir // -----------------------------------------------------------------------------
223cdf0e10cSrcweir
setCurrentValue(const Any & aNumber)224cdf0e10cSrcweir sal_Bool VCLXAccessibleScrollBar::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir OExternalLockGuard aGuard( this );
227cdf0e10cSrcweir
228cdf0e10cSrcweir sal_Bool bReturn = sal_False;
229cdf0e10cSrcweir
230cdf0e10cSrcweir VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
231cdf0e10cSrcweir if ( pVCLXScrollBar )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir sal_Int32 nValue = 0, nValueMin = 0, nValueMax = 0;
234cdf0e10cSrcweir OSL_VERIFY( aNumber >>= nValue );
235cdf0e10cSrcweir OSL_VERIFY( getMinimumValue() >>= nValueMin );
236cdf0e10cSrcweir OSL_VERIFY( getMaximumValue() >>= nValueMax );
237cdf0e10cSrcweir
238cdf0e10cSrcweir if ( nValue < nValueMin )
239cdf0e10cSrcweir nValue = nValueMin;
240cdf0e10cSrcweir else if ( nValue > nValueMax )
241cdf0e10cSrcweir nValue = nValueMax;
242cdf0e10cSrcweir
243cdf0e10cSrcweir pVCLXScrollBar->setValue( nValue );
244cdf0e10cSrcweir bReturn = sal_True;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir
247cdf0e10cSrcweir return bReturn;
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir // -----------------------------------------------------------------------------
251cdf0e10cSrcweir
getMaximumValue()252cdf0e10cSrcweir Any VCLXAccessibleScrollBar::getMaximumValue( ) throw (RuntimeException)
253cdf0e10cSrcweir {
254cdf0e10cSrcweir OExternalLockGuard aGuard( this );
255cdf0e10cSrcweir
256cdf0e10cSrcweir Any aValue;
257cdf0e10cSrcweir
258cdf0e10cSrcweir VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
259cdf0e10cSrcweir if ( pVCLXScrollBar )
260cdf0e10cSrcweir aValue <<= (sal_Int32) pVCLXScrollBar->getMaximum();
261cdf0e10cSrcweir
262cdf0e10cSrcweir return aValue;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265cdf0e10cSrcweir // -----------------------------------------------------------------------------
266cdf0e10cSrcweir
getMinimumValue()267cdf0e10cSrcweir Any VCLXAccessibleScrollBar::getMinimumValue( ) throw (RuntimeException)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir OExternalLockGuard aGuard( this );
270cdf0e10cSrcweir
271cdf0e10cSrcweir Any aValue;
272cdf0e10cSrcweir aValue <<= (sal_Int32) 0;
273cdf0e10cSrcweir
274cdf0e10cSrcweir return aValue;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir
277cdf0e10cSrcweir // -----------------------------------------------------------------------------
278*21075d77SSteve Yin
getAccessibleName()279*21075d77SSteve Yin ::rtl::OUString VCLXAccessibleScrollBar::getAccessibleName( ) throw (uno::RuntimeException)
280*21075d77SSteve Yin {
281*21075d77SSteve Yin OExternalLockGuard aGuard( this );
282*21075d77SSteve Yin
283*21075d77SSteve Yin ::rtl::OUString aName;
284*21075d77SSteve Yin VCLXScrollBar* pVCLXScrollBar = static_cast< VCLXScrollBar* >( GetVCLXWindow() );
285*21075d77SSteve Yin if ( pVCLXScrollBar )
286*21075d77SSteve Yin {
287*21075d77SSteve Yin if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::HORIZONTAL )
288*21075d77SSteve Yin aName = TK_RES_STRING( RID_STR_ACC_SCROLLBAR_NAME_HORIZONTAL );
289*21075d77SSteve Yin else if ( pVCLXScrollBar->getOrientation() == ScrollBarOrientation::VERTICAL )
290*21075d77SSteve Yin aName = TK_RES_STRING( RID_STR_ACC_SCROLLBAR_NAME_VERTICAL );
291*21075d77SSteve Yin }
292*21075d77SSteve Yin return aName;
293*21075d77SSteve Yin }
294*21075d77SSteve Yin
295