xref: /AOO41X/main/svx/source/accessibility/charmapacc.cxx (revision 9b8096d048072d5e312699b7e51b3b8a9f64fe9a)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define _SVX_CHARMAP_CXX_
28cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
29cdf0e10cSrcweir #include <vcl/svapp.hxx>
30cdf0e10cSrcweir #include <stdio.h>
31cdf0e10cSrcweir #include <svx/charmap.hxx>
32cdf0e10cSrcweir #include "charmapacc.hxx"
33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
34cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
35cdf0e10cSrcweir #include <toolkit/helper/externallock.hxx>
36cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
37cdf0e10cSrcweir #include <osl/interlck.h>
38cdf0e10cSrcweir #include <svx/dialmgr.hxx>
39cdf0e10cSrcweir #include "accessibility.hrc"
40cdf0e10cSrcweir #include <comphelper/types.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace svx
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	using namespace comphelper;
45cdf0e10cSrcweir 	using namespace ::com::sun::star;
46cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
47cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
48cdf0e10cSrcweir 	using namespace ::com::sun::star::accessibility;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // ----------------
51cdf0e10cSrcweir // - SvxShowCharSetVirtualAcc -
52cdf0e10cSrcweir // ----------------
53cdf0e10cSrcweir SvxShowCharSetVirtualAcc::SvxShowCharSetVirtualAcc( SvxShowCharSet* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
54cdf0e10cSrcweir ,mpParent( pParent )
55cdf0e10cSrcweir ,m_pTable(NULL)
56cdf0e10cSrcweir {
57cdf0e10cSrcweir 	osl_incrementInterlockedCount(&m_refCount);
58cdf0e10cSrcweir 	{ // #b6211265 #
59cdf0e10cSrcweir 		lateInit(this);
60cdf0e10cSrcweir 	}
61cdf0e10cSrcweir 	osl_decrementInterlockedCount(&m_refCount);
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir // -----------------------------------------------------------------------------
65cdf0e10cSrcweir 
66cdf0e10cSrcweir SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc()
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	ensureDisposed();
69cdf0e10cSrcweir 	delete getExternalLock();
70cdf0e10cSrcweir }
71cdf0e10cSrcweir // -----------------------------------------------------------------------------
72cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetVirtualAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
73cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetVirtualAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
74cdf0e10cSrcweir 
75cdf0e10cSrcweir void SAL_CALL SvxShowCharSetVirtualAcc::fireEvent(
76cdf0e10cSrcweir 					const sal_Int16 _nEventId,
77cdf0e10cSrcweir 					const ::com::sun::star::uno::Any& _rOldValue,
78cdf0e10cSrcweir 					const ::com::sun::star::uno::Any& _rNewValue
79cdf0e10cSrcweir 				)
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	if ( m_pTable )
82cdf0e10cSrcweir 		m_pTable->fireEvent(_nEventId,_rOldValue,_rNewValue);
83cdf0e10cSrcweir }
84cdf0e10cSrcweir // -----------------------------------------------------------------------------
85cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChildCount(  ) throw (RuntimeException)
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
88cdf0e10cSrcweir 	ensureAlive();
89cdf0e10cSrcweir 	return ( mpParent->getScrollBar()->IsVisible() ) ? 2 : 1;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir // -----------------------------------------------------------------------------
92cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleAtPoint( const awt::Point& aPoint )
93cdf0e10cSrcweir     throw (uno::RuntimeException)
94cdf0e10cSrcweir {
95cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
96cdf0e10cSrcweir 	ensureAlive();
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	uno::Reference< accessibility::XAccessible >    xRet;
99cdf0e10cSrcweir 	const sal_uInt16 nItemId = sal::static_int_cast<sal_uInt16>(mpParent->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) ));
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	if( sal_uInt16(-1) != nItemId )
102cdf0e10cSrcweir 	{
103cdf0e10cSrcweir 		if ( !m_pTable )
104cdf0e10cSrcweir 			m_pTable = new SvxShowCharSetAcc(this);
105cdf0e10cSrcweir 		xRet = m_pTable;
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir 	else if ( mpParent->getScrollBar()->IsVisible() )
108cdf0e10cSrcweir 	{
109cdf0e10cSrcweir 		const Point aOutPos( mpParent->getScrollBar()->GetPosPixel() );
110cdf0e10cSrcweir 		const Size  aScrollBar = mpParent->getScrollBar()->GetOutputSizePixel();
111cdf0e10cSrcweir 		Rectangle aRect(aOutPos,aScrollBar);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		if ( aRect.IsInside(VCLPoint(aPoint)) )
114cdf0e10cSrcweir 			xRet = mpParent->getScrollBar()->GetAccessible();
115cdf0e10cSrcweir 	}
116cdf0e10cSrcweir     return xRet;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir // -----------------------------------------------------------------------------
119cdf0e10cSrcweir uno::Any SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleKeyBinding()
120cdf0e10cSrcweir     throw (uno::RuntimeException)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     return uno::Any();
123cdf0e10cSrcweir }
124cdf0e10cSrcweir // -----------------------------------------------------------------------------
125cdf0e10cSrcweir void SAL_CALL SvxShowCharSetVirtualAcc::grabFocus()
126cdf0e10cSrcweir     throw (uno::RuntimeException)
127cdf0e10cSrcweir {
128cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
129cdf0e10cSrcweir 	ensureAlive();
130cdf0e10cSrcweir     mpParent->GrabFocus();
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 
134cdf0e10cSrcweir // -----------------------------------------------------------------------------
135cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
138cdf0e10cSrcweir 	ensureAlive();
139cdf0e10cSrcweir 	if ( mpParent->getScrollBar()->IsVisible() && i == 0 )
140cdf0e10cSrcweir 		return mpParent->getScrollBar()->GetAccessible();
141cdf0e10cSrcweir 	else if ( i == 1 )
142cdf0e10cSrcweir 	{
143cdf0e10cSrcweir 		if ( !m_xAcc.is() )
144cdf0e10cSrcweir 		{
145cdf0e10cSrcweir 			m_pTable = new SvxShowCharSetAcc(this);
146cdf0e10cSrcweir 			m_xAcc = m_pTable;
147cdf0e10cSrcweir 		}
148cdf0e10cSrcweir 	}
149cdf0e10cSrcweir 	else
150cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
151cdf0e10cSrcweir 	return m_xAcc;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir // -----------------------------------------------------------------------------
154cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleParent(  ) throw (RuntimeException)
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
157cdf0e10cSrcweir 	ensureAlive();
158cdf0e10cSrcweir     Window*                                         pParent = mpParent->GetParent();
159cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xRet;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     if ( pParent )
162cdf0e10cSrcweir         xRet = pParent->GetAccessible();
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     return xRet;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir // -----------------------------------------------------------------------------
167cdf0e10cSrcweir ::com::sun::star::awt::Rectangle SAL_CALL SvxShowCharSetVirtualAcc::implGetBounds(  ) throw (RuntimeException)
168cdf0e10cSrcweir {
169*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
170*9b8096d0SSteve Yin /*	const Point   aOutPos( mpParent->GetPosPixel() );
171cdf0e10cSrcweir     Size          aOutSize( mpParent->GetOutputSizePixel() );
172cdf0e10cSrcweir 	if ( mpParent->getScrollBar()->IsVisible() )
173cdf0e10cSrcweir 	{
174cdf0e10cSrcweir 		const Size aScrollBar = mpParent->getScrollBar()->GetOutputSizePixel();
175cdf0e10cSrcweir 		aOutSize.Width() -= aScrollBar.Width();
176cdf0e10cSrcweir 		aOutSize.Height() -= aScrollBar.Height();
177cdf0e10cSrcweir 	}
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     awt::Rectangle aRet;
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     aRet.X = aOutPos.X();
182cdf0e10cSrcweir     aRet.Y = aOutPos.Y();
183cdf0e10cSrcweir     aRet.Width = aOutSize.Width();
184cdf0e10cSrcweir     aRet.Height = aOutSize.Height();
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     return aRet;
187*9b8096d0SSteve Yin */
188*9b8096d0SSteve Yin 	::com::sun::star::awt::Rectangle aBounds ( 0, 0, 0, 0 );
189*9b8096d0SSteve Yin 	Window* pWindow = mpParent;
190*9b8096d0SSteve Yin 	if ( pWindow )
191*9b8096d0SSteve Yin 	{
192*9b8096d0SSteve Yin 		Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL );
193*9b8096d0SSteve Yin 		aBounds = AWTRectangle( aRect );
194*9b8096d0SSteve Yin 		Window* pParent = pWindow->GetAccessibleParentWindow();
195*9b8096d0SSteve Yin 		if ( pParent )
196*9b8096d0SSteve Yin 		{
197*9b8096d0SSteve Yin 			Rectangle aParentRect = pParent->GetWindowExtentsRelative( NULL );
198*9b8096d0SSteve Yin 			::com::sun::star::awt::Point aParentScreenLoc = AWTPoint( aParentRect.TopLeft() );
199*9b8096d0SSteve Yin 			aBounds.X -= aParentScreenLoc.X;
200*9b8096d0SSteve Yin 			aBounds.Y -= aParentScreenLoc.Y;
201*9b8096d0SSteve Yin 		}
202*9b8096d0SSteve Yin 	}
203*9b8096d0SSteve Yin 	return aBounds;
204*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
205cdf0e10cSrcweir }
206cdf0e10cSrcweir // -----------------------------------------------------------------------------
207cdf0e10cSrcweir sal_Int16 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRole(  ) throw (RuntimeException)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	return accessibility::AccessibleRole::SCROLL_PANE;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir // -----------------------------------------------------------------------------
212cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleDescription(  ) throw (RuntimeException)
213cdf0e10cSrcweir {
214cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
215cdf0e10cSrcweir     return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION);
216cdf0e10cSrcweir }
217cdf0e10cSrcweir // -----------------------------------------------------------------------------
218cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleName(  ) throw (RuntimeException)
219cdf0e10cSrcweir {
220cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
221cdf0e10cSrcweir     return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC);
222cdf0e10cSrcweir }
223cdf0e10cSrcweir // -----------------------------------------------------------------------------
224cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRelationSet(  ) throw (RuntimeException)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	return Reference< XAccessibleRelationSet >();
227cdf0e10cSrcweir }
228cdf0e10cSrcweir // -----------------------------------------------------------------------------
229cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleStateSet(  ) throw (RuntimeException)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     if( mpParent )
236cdf0e10cSrcweir     {
237cdf0e10cSrcweir 	    // SELECTABLE
238cdf0e10cSrcweir 	    pStateSet->AddState( AccessibleStateType::FOCUSABLE );
239cdf0e10cSrcweir 		if ( mpParent->HasFocus() )
240cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::FOCUSED );
241cdf0e10cSrcweir 		if ( mpParent->IsActive() )
242cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::ACTIVE );
243cdf0e10cSrcweir 		if ( mpParent->IsEnabled() )
244cdf0e10cSrcweir         {
245cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::ENABLED );
246cdf0e10cSrcweir             pStateSet->AddState( AccessibleStateType::SENSITIVE );
247cdf0e10cSrcweir         }
248cdf0e10cSrcweir 		if ( mpParent->IsReallyVisible() )
249cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::VISIBLE );
250cdf0e10cSrcweir     }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     return pStateSet;
253cdf0e10cSrcweir }
254cdf0e10cSrcweir // -----------------------------------------------------------------------------
255cdf0e10cSrcweir void SAL_CALL SvxShowCharSetVirtualAcc::disposing()
256cdf0e10cSrcweir {
257cdf0e10cSrcweir 	OAccessibleContextHelper::disposing();
258cdf0e10cSrcweir 	if ( m_pTable )
259cdf0e10cSrcweir 		m_pTable->dispose();
260cdf0e10cSrcweir 	m_pTable = NULL;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir // -----------------------------------------------------------------------------
263cdf0e10cSrcweir // ----------------
264cdf0e10cSrcweir // - SvxShowCharSetItem -
265cdf0e10cSrcweir // ----------------
266cdf0e10cSrcweir 
267cdf0e10cSrcweir SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc*	_pParent,sal_uInt16 _nPos ) :
268cdf0e10cSrcweir     mrParent( rParent )
269cdf0e10cSrcweir     ,mnId( _nPos )
270cdf0e10cSrcweir     ,m_pItem(NULL)
271cdf0e10cSrcweir 	,m_pParent(_pParent)
272cdf0e10cSrcweir {
273cdf0e10cSrcweir }
274cdf0e10cSrcweir // -----------------------------------------------------------------------
275cdf0e10cSrcweir 
276cdf0e10cSrcweir SvxShowCharSetItem::~SvxShowCharSetItem()
277cdf0e10cSrcweir {
278cdf0e10cSrcweir     if ( m_xAcc.is() )
279cdf0e10cSrcweir     {
280cdf0e10cSrcweir         m_pItem->ParentDestroyed();
281cdf0e10cSrcweir         ClearAccessible();
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir // -----------------------------------------------------------------------
286cdf0e10cSrcweir 
287cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SvxShowCharSetItem::GetAccessible()
288cdf0e10cSrcweir {
289cdf0e10cSrcweir     if( !m_xAcc.is() )
290cdf0e10cSrcweir 	{
291cdf0e10cSrcweir 		m_pItem = new SvxShowCharSetItemAcc( this );
292cdf0e10cSrcweir         m_xAcc = m_pItem;
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir 
295cdf0e10cSrcweir     return m_xAcc;
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir // -----------------------------------------------------------------------
299cdf0e10cSrcweir 
300cdf0e10cSrcweir void SvxShowCharSetItem::ClearAccessible()
301cdf0e10cSrcweir {
302cdf0e10cSrcweir     if ( m_xAcc.is() )
303cdf0e10cSrcweir 	{
304cdf0e10cSrcweir 		m_pItem = NULL;
305cdf0e10cSrcweir 		m_xAcc  = NULL;
306cdf0e10cSrcweir 	}
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 
310cdf0e10cSrcweir // ---------------
311cdf0e10cSrcweir // - SvxShowCharSetAcc -
312cdf0e10cSrcweir // ---------------
313cdf0e10cSrcweir 
314cdf0e10cSrcweir SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent ) : OAccessibleSelectionHelper(new VCLExternalSolarLock())
315cdf0e10cSrcweir   ,m_pParent( _pParent )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir 	osl_incrementInterlockedCount(&m_refCount);
318cdf0e10cSrcweir 	{ // #b6211265 #
319cdf0e10cSrcweir 		lateInit(this);
320cdf0e10cSrcweir 	}
321cdf0e10cSrcweir 	osl_decrementInterlockedCount(&m_refCount);
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir // -----------------------------------------------------------------------------
325cdf0e10cSrcweir 
326cdf0e10cSrcweir SvxShowCharSetAcc::~SvxShowCharSetAcc()
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	ensureDisposed();
329cdf0e10cSrcweir 	delete getExternalLock();
330cdf0e10cSrcweir }
331cdf0e10cSrcweir // -----------------------------------------------------------------------------
332cdf0e10cSrcweir void SAL_CALL SvxShowCharSetAcc::disposing()
333cdf0e10cSrcweir {
334cdf0e10cSrcweir 	OAccessibleSelectionHelper::disposing();
335cdf0e10cSrcweir 	::std::vector< Reference< XAccessible > >::iterator aIter = m_aChildren.begin();
336cdf0e10cSrcweir 	::std::vector< Reference< XAccessible > >::iterator aEnd  = m_aChildren.end();
337cdf0e10cSrcweir 	for (;aIter != aEnd ; ++aIter)
338cdf0e10cSrcweir 		::comphelper::disposeComponent(*aIter);
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 	m_aChildren.clear();
341cdf0e10cSrcweir 	m_pParent = NULL;
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir // -----------------------------------------------------------------------------
345cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base )
346cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base )
347cdf0e10cSrcweir // -----------------------------------------------------------------------
348cdf0e10cSrcweir sal_Bool SvxShowCharSetAcc::implIsSelected( sal_Int32 nAccessibleChildIndex ) throw (RuntimeException)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir 	return m_pParent && m_pParent->getCharSetControl()->IsSelected(
351cdf0e10cSrcweir         sal::static_int_cast<sal_uInt16>(nAccessibleChildIndex));
352cdf0e10cSrcweir }
353cdf0e10cSrcweir // -----------------------------------------------------------------------------
354cdf0e10cSrcweir 	    // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
355cdf0e10cSrcweir void SvxShowCharSetAcc::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) throw (IndexOutOfBoundsException, RuntimeException)
356cdf0e10cSrcweir {
357cdf0e10cSrcweir 	if ( m_pParent )
358cdf0e10cSrcweir 	{
359cdf0e10cSrcweir 		if ( bSelect )
360cdf0e10cSrcweir 			m_pParent->getCharSetControl()->SelectIndex(nAccessibleChildIndex,sal_True);
361cdf0e10cSrcweir 		else
362cdf0e10cSrcweir 			m_pParent->getCharSetControl()->DeSelect();
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir }
365cdf0e10cSrcweir // -----------------------------------------------------------------------------
366cdf0e10cSrcweir ::com::sun::star::awt::Rectangle SAL_CALL SvxShowCharSetAcc::implGetBounds(  ) throw (RuntimeException)
367cdf0e10cSrcweir {
368*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
369*9b8096d0SSteve Yin 	const Point   aOutPos;//( m_pParent->getCharSetControl()->GetPosPixel() );
370cdf0e10cSrcweir     Size          aOutSize( m_pParent->getCharSetControl()->GetOutputSizePixel());
371cdf0e10cSrcweir 	if ( m_pParent->getCharSetControl()->getScrollBar()->IsVisible() )
372cdf0e10cSrcweir 	{
373cdf0e10cSrcweir 		const Size aScrollBar = m_pParent->getCharSetControl()->getScrollBar()->GetOutputSizePixel();
374cdf0e10cSrcweir 		aOutSize.Width() -= aScrollBar.Width();
375*9b8096d0SSteve Yin 		//aOutSize.Height() -= aScrollBar.Height();
376*9b8096d0SSteve Yin 		//-----IAccessibility2 Implementation 2009
377cdf0e10cSrcweir 	}
378cdf0e10cSrcweir 
379cdf0e10cSrcweir     awt::Rectangle aRet;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir     aRet.X = aOutPos.X();
382cdf0e10cSrcweir     aRet.Y = aOutPos.Y();
383cdf0e10cSrcweir     aRet.Width = aOutSize.Width();
384cdf0e10cSrcweir     aRet.Height = aOutSize.Height();
385cdf0e10cSrcweir 
386cdf0e10cSrcweir     return aRet;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir // -----------------------------------------------------------------------------
389cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleChildCount()
390cdf0e10cSrcweir     throw (uno::RuntimeException)
391cdf0e10cSrcweir {
392cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
393cdf0e10cSrcweir 	ensureAlive();
394cdf0e10cSrcweir     return m_pParent->getCharSetControl()->getMaxCharCount();
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir // -----------------------------------------------------------------------------
398cdf0e10cSrcweir 
399cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleChild( sal_Int32 i )
400cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
401cdf0e10cSrcweir {
402cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
403cdf0e10cSrcweir 	ensureAlive();
404cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xRet;
405cdf0e10cSrcweir 	SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( static_cast< sal_uInt16 >( i ) );
406cdf0e10cSrcweir 
407cdf0e10cSrcweir 	if( pItem )
408cdf0e10cSrcweir 	{
409cdf0e10cSrcweir 		pItem->m_pParent = this;
410cdf0e10cSrcweir 		xRet = pItem->GetAccessible();
411cdf0e10cSrcweir 		m_aChildren.push_back(xRet);
412cdf0e10cSrcweir 	}
413cdf0e10cSrcweir 	else
414cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
415cdf0e10cSrcweir 
416cdf0e10cSrcweir     return xRet;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir 
419cdf0e10cSrcweir // -----------------------------------------------------------------------------
420cdf0e10cSrcweir 
421cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleParent()
422cdf0e10cSrcweir     throw (uno::RuntimeException)
423cdf0e10cSrcweir {
424cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
425cdf0e10cSrcweir 	ensureAlive();
426cdf0e10cSrcweir     return m_pParent;
427cdf0e10cSrcweir }
428cdf0e10cSrcweir 
429cdf0e10cSrcweir // -----------------------------------------------------------------------------
430cdf0e10cSrcweir 
431cdf0e10cSrcweir sal_Int16 SAL_CALL SvxShowCharSetAcc::getAccessibleRole()
432cdf0e10cSrcweir     throw (uno::RuntimeException)
433cdf0e10cSrcweir {
434cdf0e10cSrcweir     return accessibility::AccessibleRole::TABLE;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
437cdf0e10cSrcweir // -----------------------------------------------------------------------------
438cdf0e10cSrcweir 
439cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleDescription()
440cdf0e10cSrcweir     throw (uno::RuntimeException)
441cdf0e10cSrcweir {
442cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
443cdf0e10cSrcweir     return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION );
444cdf0e10cSrcweir }
445cdf0e10cSrcweir 
446cdf0e10cSrcweir // -----------------------------------------------------------------------------
447cdf0e10cSrcweir 
448cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleName()
449cdf0e10cSrcweir     throw (uno::RuntimeException)
450cdf0e10cSrcweir {
451cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
452cdf0e10cSrcweir 	ensureAlive();
453cdf0e10cSrcweir     return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC );
454cdf0e10cSrcweir }
455cdf0e10cSrcweir 
456cdf0e10cSrcweir // -----------------------------------------------------------------------------
457cdf0e10cSrcweir 
458cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetAcc::getAccessibleRelationSet()
459cdf0e10cSrcweir     throw (uno::RuntimeException)
460cdf0e10cSrcweir {
461cdf0e10cSrcweir     return uno::Reference< accessibility::XAccessibleRelationSet >();
462cdf0e10cSrcweir }
463cdf0e10cSrcweir 
464cdf0e10cSrcweir // -----------------------------------------------------------------------------
465cdf0e10cSrcweir 
466cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetAcc::getAccessibleStateSet()
467cdf0e10cSrcweir     throw (uno::RuntimeException)
468cdf0e10cSrcweir {
469cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
470cdf0e10cSrcweir 
471cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
472cdf0e10cSrcweir 
473cdf0e10cSrcweir     if( m_pParent->getCharSetControl() )
474cdf0e10cSrcweir     {
475cdf0e10cSrcweir 	    // SELECTABLE
476cdf0e10cSrcweir 	    pStateSet->AddState( AccessibleStateType::FOCUSABLE );
477cdf0e10cSrcweir 		if ( m_pParent->getCharSetControl()->HasFocus() )
478cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::FOCUSED );
479cdf0e10cSrcweir 		if ( m_pParent->getCharSetControl()->IsActive() )
480cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::ACTIVE );
481cdf0e10cSrcweir 		if ( m_pParent->getCharSetControl()->IsEnabled() )
482cdf0e10cSrcweir         {
483cdf0e10cSrcweir             pStateSet->AddState( AccessibleStateType::ENABLED );
484cdf0e10cSrcweir             pStateSet->AddState( AccessibleStateType::SENSITIVE );
485cdf0e10cSrcweir         }
486cdf0e10cSrcweir 		if ( m_pParent->getCharSetControl()->IsReallyVisible() )
487cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::VISIBLE );
488cdf0e10cSrcweir 
489cdf0e10cSrcweir 		pStateSet->AddState( AccessibleStateType::MANAGES_DESCENDANTS );
490cdf0e10cSrcweir     }
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     return pStateSet;
493cdf0e10cSrcweir }
494cdf0e10cSrcweir // -----------------------------------------------------------------------------
495cdf0e10cSrcweir 
496cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
497cdf0e10cSrcweir     throw (uno::RuntimeException)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
500cdf0e10cSrcweir 	ensureAlive();
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 	uno::Reference< accessibility::XAccessible >    xRet;
503cdf0e10cSrcweir 	const sal_uInt16 nItemId = sal::static_int_cast<sal_uInt16>(
504cdf0e10cSrcweir         m_pParent->getCharSetControl()->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) ));
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	if( sal_uInt16(-1) != nItemId )
507cdf0e10cSrcweir 	{
508cdf0e10cSrcweir 		SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( nItemId );
509cdf0e10cSrcweir 		xRet = pItem->GetAccessible();
510cdf0e10cSrcweir 	}
511cdf0e10cSrcweir     return xRet;
512cdf0e10cSrcweir }
513cdf0e10cSrcweir 
514cdf0e10cSrcweir // -----------------------------------------------------------------------------
515cdf0e10cSrcweir // -----------------------------------------------------------------------------
516cdf0e10cSrcweir 
517cdf0e10cSrcweir void SAL_CALL SvxShowCharSetAcc::grabFocus()
518cdf0e10cSrcweir     throw (uno::RuntimeException)
519cdf0e10cSrcweir {
520cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
521cdf0e10cSrcweir 	ensureAlive();
522cdf0e10cSrcweir     m_pParent->getCharSetControl()->GrabFocus();
523cdf0e10cSrcweir }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir // -----------------------------------------------------------------------------
526cdf0e10cSrcweir 
527cdf0e10cSrcweir uno::Any SAL_CALL SvxShowCharSetAcc::getAccessibleKeyBinding()
528cdf0e10cSrcweir     throw (uno::RuntimeException)
529cdf0e10cSrcweir {
530cdf0e10cSrcweir     return uno::Any();
531cdf0e10cSrcweir }
532cdf0e10cSrcweir // -----------------------------------------------------------------------------
533cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowCount(  ) throw (RuntimeException)
534cdf0e10cSrcweir {
535cdf0e10cSrcweir 	return ((getAccessibleChildCount()-1) / COLUMN_COUNT) + 1;
536cdf0e10cSrcweir }
537cdf0e10cSrcweir // -----------------------------------------------------------------------------
538cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnCount(  ) throw (RuntimeException)
539cdf0e10cSrcweir {
540cdf0e10cSrcweir 	return COLUMN_COUNT;
541cdf0e10cSrcweir }
542cdf0e10cSrcweir // -----------------------------------------------------------------------------
543cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleRowDescription( sal_Int32 /*nRow*/ ) throw (IndexOutOfBoundsException, RuntimeException)
544cdf0e10cSrcweir {
545cdf0e10cSrcweir 	return ::rtl::OUString();
546cdf0e10cSrcweir }
547cdf0e10cSrcweir // -----------------------------------------------------------------------------
548cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleColumnDescription( sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
549cdf0e10cSrcweir {
550cdf0e10cSrcweir 	return ::rtl::OUString();
551cdf0e10cSrcweir }
552cdf0e10cSrcweir // -----------------------------------------------------------------------------
553cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
554cdf0e10cSrcweir {
555cdf0e10cSrcweir 	return 1;
556cdf0e10cSrcweir }
557cdf0e10cSrcweir // -----------------------------------------------------------------------------
558cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir 	return 1;
561cdf0e10cSrcweir }
562cdf0e10cSrcweir // -----------------------------------------------------------------------------
563cdf0e10cSrcweir Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleRowHeaders(  ) throw (RuntimeException)
564cdf0e10cSrcweir {
565cdf0e10cSrcweir 	return Reference< XAccessibleTable >();
566cdf0e10cSrcweir }
567cdf0e10cSrcweir // -----------------------------------------------------------------------------
568cdf0e10cSrcweir Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleColumnHeaders(  ) throw (RuntimeException)
569cdf0e10cSrcweir {
570cdf0e10cSrcweir 	return Reference< XAccessibleTable >();
571cdf0e10cSrcweir }
572cdf0e10cSrcweir // -----------------------------------------------------------------------------
573cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleRows(  ) throw (RuntimeException)
574cdf0e10cSrcweir {
575cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
576cdf0e10cSrcweir 	ensureAlive();
577cdf0e10cSrcweir 	Sequence< sal_Int32 > aSel(1);
578cdf0e10cSrcweir 	aSel[0] = m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId());
579cdf0e10cSrcweir 	return aSel;
580cdf0e10cSrcweir }
581cdf0e10cSrcweir // -----------------------------------------------------------------------------
582cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleColumns(  ) throw (RuntimeException)
583cdf0e10cSrcweir {
584cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
585cdf0e10cSrcweir 	ensureAlive();
586cdf0e10cSrcweir 	Sequence< sal_Int32 > aSel(1);
587cdf0e10cSrcweir 	aSel[0] = m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId());
588cdf0e10cSrcweir 	return aSel;
589cdf0e10cSrcweir }
590cdf0e10cSrcweir // -----------------------------------------------------------------------------
591cdf0e10cSrcweir sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
594cdf0e10cSrcweir 	ensureAlive();
595cdf0e10cSrcweir 	return m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nRow;
596cdf0e10cSrcweir }
597cdf0e10cSrcweir // -----------------------------------------------------------------------------
598cdf0e10cSrcweir sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
599cdf0e10cSrcweir {
600cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
601cdf0e10cSrcweir 	ensureAlive();
602cdf0e10cSrcweir 	return m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nColumn;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir // -----------------------------------------------------------------------------
605cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
606cdf0e10cSrcweir {
607cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
608cdf0e10cSrcweir 	ensureAlive();
609cdf0e10cSrcweir 	::svx::SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem(
610cdf0e10cSrcweir         sal::static_int_cast<sal_uInt16>(getAccessibleIndex(nRow,nColumn) ));
611cdf0e10cSrcweir 	if ( !pItem  )
612cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
613cdf0e10cSrcweir 	return pItem->GetAccessible();
614cdf0e10cSrcweir }
615cdf0e10cSrcweir // -----------------------------------------------------------------------------
616cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCaption(  ) throw (RuntimeException)
617cdf0e10cSrcweir {
618cdf0e10cSrcweir 	return Reference< XAccessible >();
619cdf0e10cSrcweir }
620cdf0e10cSrcweir // -----------------------------------------------------------------------------
621cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleSummary(  ) throw (RuntimeException)
622cdf0e10cSrcweir {
623cdf0e10cSrcweir 	return Reference< XAccessible >();
624cdf0e10cSrcweir }
625cdf0e10cSrcweir // -----------------------------------------------------------------------------
626cdf0e10cSrcweir sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
627cdf0e10cSrcweir {
628cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
629cdf0e10cSrcweir 	ensureAlive();
630cdf0e10cSrcweir 	return m_pParent->getCharSetControl()->GetSelectIndexId() == getAccessibleIndex(nRow,nColumn);
631cdf0e10cSrcweir }
632cdf0e10cSrcweir // -----------------------------------------------------------------------------
633cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
634cdf0e10cSrcweir {
635cdf0e10cSrcweir 	return (nRow*COLUMN_COUNT) + nColumn;
636cdf0e10cSrcweir }
637cdf0e10cSrcweir // -----------------------------------------------------------------------------
638cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
639cdf0e10cSrcweir {
640cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
641cdf0e10cSrcweir 	ensureAlive();
642cdf0e10cSrcweir 	return m_pParent->getCharSetControl()->GetRowPos(sal::static_int_cast<sal_uInt16>(nChildIndex));
643cdf0e10cSrcweir }
644cdf0e10cSrcweir // -----------------------------------------------------------------------------
645cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
646cdf0e10cSrcweir {
647cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
648cdf0e10cSrcweir 	ensureAlive();
649cdf0e10cSrcweir 	return m_pParent->getCharSetControl()->GetColumnPos(sal::static_int_cast<sal_uInt16>(nChildIndex));
650cdf0e10cSrcweir }
651cdf0e10cSrcweir // -----------------------------------------------------------------------------
652cdf0e10cSrcweir 
653cdf0e10cSrcweir // -----------------------------------------------------------------------------
654cdf0e10cSrcweir // ----------------
655cdf0e10cSrcweir // - SvxShowCharSetItemAcc -
656cdf0e10cSrcweir // ----------------
657cdf0e10cSrcweir 
658cdf0e10cSrcweir SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
659cdf0e10cSrcweir ,mpParent( pParent )
660cdf0e10cSrcweir {
661cdf0e10cSrcweir 	OSL_ENSURE(pParent,"NO parent supplied!");
662cdf0e10cSrcweir 	osl_incrementInterlockedCount(&m_refCount);
663cdf0e10cSrcweir 	{ // #b6211265 #
664cdf0e10cSrcweir 		lateInit(this);
665cdf0e10cSrcweir 	}
666cdf0e10cSrcweir 	osl_decrementInterlockedCount(&m_refCount);
667cdf0e10cSrcweir }
668cdf0e10cSrcweir 
669cdf0e10cSrcweir // -----------------------------------------------------------------------------
670cdf0e10cSrcweir 
671cdf0e10cSrcweir SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc()
672cdf0e10cSrcweir {
673cdf0e10cSrcweir 	ensureDisposed();
674cdf0e10cSrcweir 	delete getExternalLock();
675cdf0e10cSrcweir }
676cdf0e10cSrcweir // -----------------------------------------------------------------------------
677cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
678cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
679cdf0e10cSrcweir // -----------------------------------------------------------------------------
680cdf0e10cSrcweir 
681cdf0e10cSrcweir void SvxShowCharSetItemAcc::ParentDestroyed()
682cdf0e10cSrcweir {
683cdf0e10cSrcweir     const ::osl::MutexGuard aGuard( GetMutex() );
684cdf0e10cSrcweir     mpParent = NULL;
685cdf0e10cSrcweir }
686cdf0e10cSrcweir 
687cdf0e10cSrcweir // -----------------------------------------------------------------------------
688cdf0e10cSrcweir 
689cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetItemAcc::getAccessibleChildCount()
690cdf0e10cSrcweir     throw (uno::RuntimeException)
691cdf0e10cSrcweir {
692cdf0e10cSrcweir     return 0;
693cdf0e10cSrcweir }
694cdf0e10cSrcweir 
695cdf0e10cSrcweir // -----------------------------------------------------------------------------
696cdf0e10cSrcweir 
697cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleChild( sal_Int32 /*i*/ )
698cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
699cdf0e10cSrcweir {
700cdf0e10cSrcweir     throw lang::IndexOutOfBoundsException();
701cdf0e10cSrcweir }
702cdf0e10cSrcweir 
703cdf0e10cSrcweir // -----------------------------------------------------------------------------
704cdf0e10cSrcweir 
705cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleParent()
706cdf0e10cSrcweir     throw (uno::RuntimeException)
707cdf0e10cSrcweir {
708cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
709cdf0e10cSrcweir 	ensureAlive();
710cdf0e10cSrcweir     return mpParent->m_pParent;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir 
713cdf0e10cSrcweir // -----------------------------------------------------------------------------
714cdf0e10cSrcweir 
715cdf0e10cSrcweir sal_Int16 SAL_CALL SvxShowCharSetItemAcc::getAccessibleRole()
716cdf0e10cSrcweir     throw (uno::RuntimeException)
717cdf0e10cSrcweir {
718*9b8096d0SSteve Yin     //return accessibility::AccessibleRole::LABEL;
719*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
720*9b8096d0SSteve Yin     return accessibility::AccessibleRole::TABLE_CELL;
721*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
722cdf0e10cSrcweir }
723cdf0e10cSrcweir 
724cdf0e10cSrcweir // -----------------------------------------------------------------------------
725cdf0e10cSrcweir 
726cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleDescription()
727cdf0e10cSrcweir     throw (uno::RuntimeException)
728cdf0e10cSrcweir {
729cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
730cdf0e10cSrcweir 	ensureAlive();
731cdf0e10cSrcweir 	String sDescription = SVX_RESSTR( RID_SVXSTR_CHARACTER_CODE );
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 	sal_Unicode c = mpParent->maText.GetChar(0);
734cdf0e10cSrcweir 	char buf[16] = "0x0000";
735cdf0e10cSrcweir     sal_Unicode c_Shifted = c;
736*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
737*9b8096d0SSteve Yin /*
738cdf0e10cSrcweir     for( int i = 0; i < 4; ++i )
739cdf0e10cSrcweir     {
740cdf0e10cSrcweir         char h = (char)(c_Shifted & 0x0F);
741cdf0e10cSrcweir         buf[5-i] = (h > 9) ? (h - 10 + 'A') : (h + '0');
742cdf0e10cSrcweir         c_Shifted >>= 4;
743cdf0e10cSrcweir     }
744*9b8096d0SSteve Yin */
745*9b8096d0SSteve Yin 	int tmp_len = 4;
746*9b8096d0SSteve Yin 	if(c_Shifted>0xFFFF) tmp_len = 8;
747*9b8096d0SSteve Yin     for( int i = 0; i < tmp_len; ++i )
748*9b8096d0SSteve Yin     {
749*9b8096d0SSteve Yin         char h = c_Shifted & 0x0F;
750*9b8096d0SSteve Yin         //buf[9-i] = (h > 9) ? (h - 10 + 'A') : (h + '0');
751*9b8096d0SSteve Yin 		buf[tmp_len+1-i] = (h > 9) ? (h - 10 + 'A') : (h + '0');
752*9b8096d0SSteve Yin         c_Shifted >>= 4;
753*9b8096d0SSteve Yin     }
754*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
755cdf0e10cSrcweir     if( c < 256 )
756cdf0e10cSrcweir         snprintf( buf+6, 10, " (%d)", c );
757*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
758*9b8096d0SSteve Yin 	sDescription.AppendAscii(" ");
759*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
760cdf0e10cSrcweir 	sDescription.AppendAscii(buf);
761cdf0e10cSrcweir 
762cdf0e10cSrcweir     return sDescription;
763cdf0e10cSrcweir }
764cdf0e10cSrcweir 
765cdf0e10cSrcweir // -----------------------------------------------------------------------------
766cdf0e10cSrcweir 
767cdf0e10cSrcweir ::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleName()
768cdf0e10cSrcweir     throw (uno::RuntimeException)
769cdf0e10cSrcweir {
770cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
771cdf0e10cSrcweir 	ensureAlive();
772cdf0e10cSrcweir     String aRet;
773cdf0e10cSrcweir 
774cdf0e10cSrcweir     if( mpParent )
775cdf0e10cSrcweir     {
776cdf0e10cSrcweir         aRet = mpParent->maText;
777cdf0e10cSrcweir 
778cdf0e10cSrcweir         if( !aRet.Len() )
779cdf0e10cSrcweir 			aRet = getAccessibleDescription();
780cdf0e10cSrcweir     }
781cdf0e10cSrcweir 
782cdf0e10cSrcweir     return aRet;
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir // -----------------------------------------------------------------------------
786cdf0e10cSrcweir 
787cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleRelationSet()
788cdf0e10cSrcweir     throw (uno::RuntimeException)
789cdf0e10cSrcweir {
790cdf0e10cSrcweir     return uno::Reference< accessibility::XAccessibleRelationSet >();
791cdf0e10cSrcweir }
792cdf0e10cSrcweir 
793cdf0e10cSrcweir // -----------------------------------------------------------------------------
794cdf0e10cSrcweir 
795cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleStateSet()
796cdf0e10cSrcweir     throw (uno::RuntimeException)
797cdf0e10cSrcweir {
798cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
799cdf0e10cSrcweir 	ensureAlive();
800cdf0e10cSrcweir 
801cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
802cdf0e10cSrcweir 
803cdf0e10cSrcweir     if( mpParent )
804cdf0e10cSrcweir     {
805*9b8096d0SSteve Yin     //IAccessibility2 Implementation 2009-----
806*9b8096d0SSteve Yin 		if(mpParent->mrParent.IsEnabled())
807*9b8096d0SSteve Yin 		{
808*9b8096d0SSteve Yin 			pStateSet->AddState( accessibility::AccessibleStateType::ENABLED );
809cdf0e10cSrcweir 			// SELECTABLE
810cdf0e10cSrcweir 			pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
811cdf0e10cSrcweir 			pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
812*9b8096d0SSteve Yin 		}
813*9b8096d0SSteve Yin 		//-----IAccessibility2 Implementation 2009
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 	    // SELECTED
816cdf0e10cSrcweir         if( mpParent->mrParent.GetSelectIndexId() == mpParent->mnId )
817cdf0e10cSrcweir         {
818cdf0e10cSrcweir             pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
819cdf0e10cSrcweir        	    pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
820cdf0e10cSrcweir         }
821cdf0e10cSrcweir 		if ( mpParent->mnId >= mpParent->mrParent.FirstInView() && mpParent->mnId <= mpParent->mrParent.LastInView() )
822*9b8096d0SSteve Yin 		//IAccessibility2 Implementation 2009-----
823*9b8096d0SSteve Yin 		{
824cdf0e10cSrcweir 			pStateSet->AddState( AccessibleStateType::VISIBLE );
825*9b8096d0SSteve Yin 			pStateSet->AddState( AccessibleStateType::SHOWING );
826*9b8096d0SSteve Yin 		}
827*9b8096d0SSteve Yin 		//-----IAccessibility2 Implementation 2009
828cdf0e10cSrcweir 		pStateSet->AddState( AccessibleStateType::TRANSIENT );
829cdf0e10cSrcweir     }
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     return pStateSet;
832cdf0e10cSrcweir }
833cdf0e10cSrcweir 
834cdf0e10cSrcweir // -----------------------------------------------------------------------------
835cdf0e10cSrcweir void SAL_CALL SvxShowCharSetItemAcc::grabFocus()
836cdf0e10cSrcweir     throw (uno::RuntimeException)
837cdf0e10cSrcweir {
838cdf0e10cSrcweir     // nothing to do
839cdf0e10cSrcweir }
840cdf0e10cSrcweir 
841cdf0e10cSrcweir // -----------------------------------------------------------------------------
842cdf0e10cSrcweir 
843cdf0e10cSrcweir uno::Any SAL_CALL SvxShowCharSetItemAcc::getAccessibleKeyBinding()
844cdf0e10cSrcweir     throw (uno::RuntimeException)
845cdf0e10cSrcweir {
846cdf0e10cSrcweir     return uno::Any();
847cdf0e10cSrcweir }
848cdf0e10cSrcweir // -----------------------------------------------------------------------------
849cdf0e10cSrcweir awt::Rectangle SAL_CALL SvxShowCharSetItemAcc::implGetBounds(  ) throw (RuntimeException)
850cdf0e10cSrcweir {
851cdf0e10cSrcweir 	awt::Rectangle      aRet;
852cdf0e10cSrcweir 
853cdf0e10cSrcweir     if( mpParent )
854cdf0e10cSrcweir     {
855cdf0e10cSrcweir         Rectangle   aRect( mpParent->maRect );
856cdf0e10cSrcweir         Point       aOrigin;
857cdf0e10cSrcweir         Rectangle   aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() );
858cdf0e10cSrcweir 
859cdf0e10cSrcweir         aRect.Intersection( aParentRect );
860cdf0e10cSrcweir 
861cdf0e10cSrcweir         aRet.X = aRect.Left();
862cdf0e10cSrcweir         aRet.Y = aRect.Top();
863cdf0e10cSrcweir         aRet.Width = aRect.GetWidth();
864cdf0e10cSrcweir         aRet.Height = aRect.GetHeight();
865cdf0e10cSrcweir     }
866cdf0e10cSrcweir 
867cdf0e10cSrcweir     return aRet;
868cdf0e10cSrcweir }
869cdf0e10cSrcweir // -----------------------------------------------------------------------------
870cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleAtPoint( const awt::Point& /*aPoint*/ )
871cdf0e10cSrcweir     throw (uno::RuntimeException)
872cdf0e10cSrcweir {
873cdf0e10cSrcweir     return uno::Reference< accessibility::XAccessible >();
874cdf0e10cSrcweir }
875cdf0e10cSrcweir // -----------------------------------------------------------------------------
876cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getForeground(  ) throw (RuntimeException)
877cdf0e10cSrcweir {
878cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
879cdf0e10cSrcweir 
880cdf0e10cSrcweir 	sal_Int32 nColor = 0;
881cdf0e10cSrcweir 	if ( mpParent )
882cdf0e10cSrcweir 	{
883cdf0e10cSrcweir 		if ( mpParent->IsControlForeground() )
884cdf0e10cSrcweir 			nColor = mpParent->GetControlForeground().GetColor();
885cdf0e10cSrcweir 		else
886cdf0e10cSrcweir 		{
887cdf0e10cSrcweir 			Font aFont;
888cdf0e10cSrcweir 			if ( mpParent->IsControlFont() )
889cdf0e10cSrcweir 				aFont = mpParent->GetControlFont();
890cdf0e10cSrcweir 			else
891cdf0e10cSrcweir 				aFont = mpParent->GetFont();
892cdf0e10cSrcweir 			nColor = aFont.GetColor().GetColor();
893cdf0e10cSrcweir 		}
894cdf0e10cSrcweir 	}
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 	return nColor;
897cdf0e10cSrcweir }
898cdf0e10cSrcweir // -----------------------------------------------------------------------------
899cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getBackground(  ) throw (RuntimeException)
900cdf0e10cSrcweir {
901cdf0e10cSrcweir 	OExternalLockGuard aGuard( this  );
902cdf0e10cSrcweir 	sal_Int32 nColor = 0;
903cdf0e10cSrcweir 	if ( mpParent )
904cdf0e10cSrcweir 	{
905cdf0e10cSrcweir 		if ( mpParent->IsControlBackground() )
906cdf0e10cSrcweir 			nColor = mpParent->GetControlBackground().GetColor();
907cdf0e10cSrcweir 		else
908cdf0e10cSrcweir 			nColor = mpParent->GetBackground().GetColor().GetColor();
909cdf0e10cSrcweir 	}
910cdf0e10cSrcweir 
911cdf0e10cSrcweir 	return nColor;
912cdf0e10cSrcweir }
913cdf0e10cSrcweir // -----------------------------------------------------------------------------
914cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getForeground(  ) throw (RuntimeException)
915cdf0e10cSrcweir {
916cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
917cdf0e10cSrcweir 
918cdf0e10cSrcweir 	sal_Int32 nColor = 0;
919cdf0e10cSrcweir 	if ( m_pParent )
920cdf0e10cSrcweir 		nColor = m_pParent->getForeground();
921cdf0e10cSrcweir 	return nColor;
922cdf0e10cSrcweir }
923cdf0e10cSrcweir // -----------------------------------------------------------------------------
924cdf0e10cSrcweir sal_Int32 SAL_CALL SvxShowCharSetAcc::getBackground(  ) throw (RuntimeException)
925cdf0e10cSrcweir {
926cdf0e10cSrcweir 	OExternalLockGuard aGuard( this  );
927cdf0e10cSrcweir 	sal_Int32 nColor = 0;
928cdf0e10cSrcweir 	if ( m_pParent )
929cdf0e10cSrcweir 		nColor = m_pParent->getBackground();
930cdf0e10cSrcweir 	return nColor;
931cdf0e10cSrcweir }
932cdf0e10cSrcweir // -----------------------------------------------------------------------------
933cdf0e10cSrcweir 
934cdf0e10cSrcweir // -----------------------------------------------------------------------------
935cdf0e10cSrcweir } // namespace svx
936cdf0e10cSrcweir // -----------------------------------------------------------------------------
937cdf0e10cSrcweir 
938cdf0e10cSrcweir 
939