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