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_accessibility.hxx"
30*cdf0e10cSrcweir #include <accessibility/standard/vclxaccessiblestatusbaritem.hxx>
31*cdf0e10cSrcweir #include <toolkit/helper/externallock.hxx>
32*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
33*cdf0e10cSrcweir #include <accessibility/helper/characterattributeshelper.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
42*cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
43*cdf0e10cSrcweir #include <vcl/svapp.hxx>
44*cdf0e10cSrcweir #include <vcl/unohelp2.hxx>
45*cdf0e10cSrcweir #include <vcl/status.hxx>
46*cdf0e10cSrcweir #include <vcl/controllayout.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <memory>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
52*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
53*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
54*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
55*cdf0e10cSrcweir using namespace ::com::sun::star;
56*cdf0e10cSrcweir using namespace ::comphelper;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir // -----------------------------------------------------------------------------
60*cdf0e10cSrcweir // class VCLXAccessibleStatusBarItem
61*cdf0e10cSrcweir // -----------------------------------------------------------------------------
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir VCLXAccessibleStatusBarItem::VCLXAccessibleStatusBarItem( StatusBar* pStatusBar, sal_uInt16 nItemId )
64*cdf0e10cSrcweir 	:AccessibleTextHelper_BASE( new VCLExternalSolarLock() )
65*cdf0e10cSrcweir 	,m_pStatusBar( pStatusBar )
66*cdf0e10cSrcweir 	,m_nItemId( nItemId )
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir 	m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir 	m_sItemName = GetItemName();
71*cdf0e10cSrcweir 	m_sItemText = GetItemText();
72*cdf0e10cSrcweir 	m_bShowing	= IsShowing();
73*cdf0e10cSrcweir }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir // -----------------------------------------------------------------------------
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir VCLXAccessibleStatusBarItem::~VCLXAccessibleStatusBarItem()
78*cdf0e10cSrcweir {
79*cdf0e10cSrcweir 	delete m_pExternalLock;
80*cdf0e10cSrcweir 	m_pExternalLock = NULL;
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir // -----------------------------------------------------------------------------
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir sal_Bool VCLXAccessibleStatusBarItem::IsShowing()
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir 	sal_Bool bShowing = sal_False;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	if ( m_pStatusBar )
90*cdf0e10cSrcweir 		bShowing = m_pStatusBar->IsItemVisible( m_nItemId );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	return bShowing;
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir // -----------------------------------------------------------------------------
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir void VCLXAccessibleStatusBarItem::SetShowing( sal_Bool bShowing )
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir 	if ( m_bShowing != bShowing )
100*cdf0e10cSrcweir 	{
101*cdf0e10cSrcweir 		Any aOldValue, aNewValue;
102*cdf0e10cSrcweir 		if ( m_bShowing )
103*cdf0e10cSrcweir 			aOldValue <<= AccessibleStateType::SHOWING;
104*cdf0e10cSrcweir 		else
105*cdf0e10cSrcweir 			aNewValue <<= AccessibleStateType::SHOWING;
106*cdf0e10cSrcweir 		m_bShowing = bShowing;
107*cdf0e10cSrcweir 		NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
108*cdf0e10cSrcweir 	}
109*cdf0e10cSrcweir }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir // -----------------------------------------------------------------------------
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir void VCLXAccessibleStatusBarItem::SetItemName( const ::rtl::OUString& sItemName )
114*cdf0e10cSrcweir {
115*cdf0e10cSrcweir 	if ( !m_sItemName.equals( sItemName ) )
116*cdf0e10cSrcweir 	{
117*cdf0e10cSrcweir 		Any aOldValue, aNewValue;
118*cdf0e10cSrcweir 		aOldValue <<= m_sItemName;
119*cdf0e10cSrcweir 		aNewValue <<= sItemName;
120*cdf0e10cSrcweir 		m_sItemName = sItemName;
121*cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
122*cdf0e10cSrcweir 	}
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir // -----------------------------------------------------------------------------
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleStatusBarItem::GetItemName()
128*cdf0e10cSrcweir {
129*cdf0e10cSrcweir 	::rtl::OUString sName;
130*cdf0e10cSrcweir 	if ( m_pStatusBar )
131*cdf0e10cSrcweir 		sName = m_pStatusBar->GetAccessibleName( m_nItemId );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 	return sName;
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir // -----------------------------------------------------------------------------
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir void VCLXAccessibleStatusBarItem::SetItemText( const ::rtl::OUString& sItemText )
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir 	Any aOldValue, aNewValue;
141*cdf0e10cSrcweir     if ( implInitTextChangedEvent( m_sItemText, sItemText, aOldValue, aNewValue ) )
142*cdf0e10cSrcweir     {
143*cdf0e10cSrcweir         m_sItemText = sItemText;
144*cdf0e10cSrcweir 		NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue );
145*cdf0e10cSrcweir     }
146*cdf0e10cSrcweir }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir // -----------------------------------------------------------------------------
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleStatusBarItem::GetItemText()
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir 	::rtl::OUString sText;
153*cdf0e10cSrcweir 	::vcl::ControlLayoutData aLayoutData;
154*cdf0e10cSrcweir 	if ( m_pStatusBar )
155*cdf0e10cSrcweir 	{
156*cdf0e10cSrcweir 		Rectangle aItemRect = m_pStatusBar->GetItemRect( m_nItemId );
157*cdf0e10cSrcweir 		m_pStatusBar->RecordLayoutData( &aLayoutData, aItemRect );
158*cdf0e10cSrcweir 		sText = aLayoutData.m_aDisplayText;
159*cdf0e10cSrcweir 	}
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 	return sText;
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir // -----------------------------------------------------------------------------
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir void VCLXAccessibleStatusBarItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir 	rStateSet.AddState( AccessibleStateType::ENABLED );
169*cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::SENSITIVE );
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	rStateSet.AddState( AccessibleStateType::VISIBLE );
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	if ( IsShowing() )
174*cdf0e10cSrcweir 		rStateSet.AddState( AccessibleStateType::SHOWING );
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir // -----------------------------------------------------------------------------
178*cdf0e10cSrcweir // OCommonAccessibleComponent
179*cdf0e10cSrcweir // -----------------------------------------------------------------------------
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir awt::Rectangle VCLXAccessibleStatusBarItem::implGetBounds() throw (RuntimeException)
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir 	awt::Rectangle aBounds( 0, 0, 0, 0 );
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	if ( m_pStatusBar )
186*cdf0e10cSrcweir 		aBounds = AWTRectangle( m_pStatusBar->GetItemRect( m_nItemId ) );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	return aBounds;
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir // -----------------------------------------------------------------------------
192*cdf0e10cSrcweir // OCommonAccessibleText
193*cdf0e10cSrcweir // -----------------------------------------------------------------------------
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleStatusBarItem::implGetText()
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir 	return GetItemText();
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir // -----------------------------------------------------------------------------
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir lang::Locale VCLXAccessibleStatusBarItem::implGetLocale()
203*cdf0e10cSrcweir {
204*cdf0e10cSrcweir 	return Application::GetSettings().GetLocale();
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir // -----------------------------------------------------------------------------
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir void VCLXAccessibleStatusBarItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir 	nStartIndex = 0;
212*cdf0e10cSrcweir 	nEndIndex = 0;
213*cdf0e10cSrcweir }
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir // -----------------------------------------------------------------------------
216*cdf0e10cSrcweir // XInterface
217*cdf0e10cSrcweir // -----------------------------------------------------------------------------
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleStatusBarItem, AccessibleTextHelper_BASE, VCLXAccessibleStatusBarItem_BASE )
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir // -----------------------------------------------------------------------------
222*cdf0e10cSrcweir // XTypeProvider
223*cdf0e10cSrcweir // -----------------------------------------------------------------------------
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleStatusBarItem, AccessibleTextHelper_BASE, VCLXAccessibleStatusBarItem_BASE )
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir // -----------------------------------------------------------------------------
228*cdf0e10cSrcweir // XComponent
229*cdf0e10cSrcweir // -----------------------------------------------------------------------------
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir void VCLXAccessibleStatusBarItem::disposing()
232*cdf0e10cSrcweir {
233*cdf0e10cSrcweir 	AccessibleTextHelper_BASE::disposing();
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir 	m_pStatusBar = NULL;
236*cdf0e10cSrcweir 	m_sItemName = ::rtl::OUString();
237*cdf0e10cSrcweir 	m_sItemText = ::rtl::OUString();
238*cdf0e10cSrcweir }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir // -----------------------------------------------------------------------------
241*cdf0e10cSrcweir // XServiceInfo
242*cdf0e10cSrcweir // -----------------------------------------------------------------------------
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleStatusBarItem::getImplementationName() throw (RuntimeException)
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleStatusBarItem" );
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir // -----------------------------------------------------------------------------
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir sal_Bool VCLXAccessibleStatusBarItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
252*cdf0e10cSrcweir {
253*cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
254*cdf0e10cSrcweir 	const ::rtl::OUString* pNames = aNames.getConstArray();
255*cdf0e10cSrcweir 	const ::rtl::OUString* pEnd = pNames + aNames.getLength();
256*cdf0e10cSrcweir 	for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
257*cdf0e10cSrcweir 		;
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	return pNames != pEnd;
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir // -----------------------------------------------------------------------------
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir Sequence< ::rtl::OUString > VCLXAccessibleStatusBarItem::getSupportedServiceNames() throw (RuntimeException)
265*cdf0e10cSrcweir {
266*cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames(1);
267*cdf0e10cSrcweir 	aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleStatusBarItem" );
268*cdf0e10cSrcweir 	return aNames;
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir // -----------------------------------------------------------------------------
272*cdf0e10cSrcweir // XAccessible
273*cdf0e10cSrcweir // -----------------------------------------------------------------------------
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir Reference< XAccessibleContext > VCLXAccessibleStatusBarItem::getAccessibleContext(  ) throw (RuntimeException)
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 	return this;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir // -----------------------------------------------------------------------------
283*cdf0e10cSrcweir // XAccessibleContext
284*cdf0e10cSrcweir // -----------------------------------------------------------------------------
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir sal_Int32 VCLXAccessibleStatusBarItem::getAccessibleChildCount() throw (RuntimeException)
287*cdf0e10cSrcweir {
288*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir 	return 0;
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir // -----------------------------------------------------------------------------
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleStatusBarItem::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
296*cdf0e10cSrcweir {
297*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir 	if ( i < 0 || i >= getAccessibleChildCount() )
300*cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir 	return Reference< XAccessible >();
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir // -----------------------------------------------------------------------------
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleStatusBarItem::getAccessibleParent(  ) throw (RuntimeException)
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir 	Reference< XAccessible > xParent;
312*cdf0e10cSrcweir 	if ( m_pStatusBar )
313*cdf0e10cSrcweir 		xParent = m_pStatusBar->GetAccessible();
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 	return xParent;
316*cdf0e10cSrcweir }
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir // -----------------------------------------------------------------------------
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir sal_Int32 VCLXAccessibleStatusBarItem::getAccessibleIndexInParent(  ) throw (RuntimeException)
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir 	sal_Int32 nIndexInParent = -1;
325*cdf0e10cSrcweir 	if ( m_pStatusBar )
326*cdf0e10cSrcweir 		nIndexInParent = m_pStatusBar->GetItemPos( m_nItemId );
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 	return nIndexInParent;
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir // -----------------------------------------------------------------------------
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir sal_Int16 VCLXAccessibleStatusBarItem::getAccessibleRole(  ) throw (RuntimeException)
334*cdf0e10cSrcweir {
335*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	return AccessibleRole::LABEL;
338*cdf0e10cSrcweir }
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir // -----------------------------------------------------------------------------
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleStatusBarItem::getAccessibleDescription(	) throw (RuntimeException)
343*cdf0e10cSrcweir {
344*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 	::rtl::OUString sDescription;
347*cdf0e10cSrcweir 	if ( m_pStatusBar )
348*cdf0e10cSrcweir 		sDescription = m_pStatusBar->GetHelpText( m_nItemId );
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 	return sDescription;
351*cdf0e10cSrcweir }
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir // -----------------------------------------------------------------------------
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleStatusBarItem::getAccessibleName(  ) throw (RuntimeException)
356*cdf0e10cSrcweir {
357*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 	return GetItemName();
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir // -----------------------------------------------------------------------------
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir Reference< XAccessibleRelationSet > VCLXAccessibleStatusBarItem::getAccessibleRelationSet(  ) throw (RuntimeException)
365*cdf0e10cSrcweir {
366*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
369*cdf0e10cSrcweir 	Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
370*cdf0e10cSrcweir     return xSet;
371*cdf0e10cSrcweir }
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir // -----------------------------------------------------------------------------
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir Reference< XAccessibleStateSet > VCLXAccessibleStatusBarItem::getAccessibleStateSet(  ) throw (RuntimeException)
376*cdf0e10cSrcweir {
377*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 	utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
380*cdf0e10cSrcweir 	Reference< XAccessibleStateSet > xSet = pStateSetHelper;
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 	if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
383*cdf0e10cSrcweir 	{
384*cdf0e10cSrcweir 		FillAccessibleStateSet( *pStateSetHelper );
385*cdf0e10cSrcweir 	}
386*cdf0e10cSrcweir 	else
387*cdf0e10cSrcweir 	{
388*cdf0e10cSrcweir         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
389*cdf0e10cSrcweir 	}
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir 	return xSet;
392*cdf0e10cSrcweir }
393*cdf0e10cSrcweir 
394*cdf0e10cSrcweir // -----------------------------------------------------------------------------
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir Locale VCLXAccessibleStatusBarItem::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException)
397*cdf0e10cSrcweir {
398*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir 	return Application::GetSettings().GetLocale();
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir // -----------------------------------------------------------------------------
404*cdf0e10cSrcweir // XAccessibleComponent
405*cdf0e10cSrcweir // -----------------------------------------------------------------------------
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleStatusBarItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir 	return Reference< XAccessible >();
412*cdf0e10cSrcweir }
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir // -----------------------------------------------------------------------------
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir void VCLXAccessibleStatusBarItem::grabFocus(  ) throw (RuntimeException)
417*cdf0e10cSrcweir {
418*cdf0e10cSrcweir 	// no focus for status bar items
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir // -----------------------------------------------------------------------------
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir sal_Int32 VCLXAccessibleStatusBarItem::getForeground(	) throw (RuntimeException)
424*cdf0e10cSrcweir {
425*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 	sal_Int32 nColor = 0;
428*cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
429*cdf0e10cSrcweir 	if ( xParent.is() )
430*cdf0e10cSrcweir 	{
431*cdf0e10cSrcweir 		Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
432*cdf0e10cSrcweir 		if ( xParentComp.is() )
433*cdf0e10cSrcweir 			nColor = xParentComp->getForeground();
434*cdf0e10cSrcweir 	}
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 	return nColor;
437*cdf0e10cSrcweir }
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir // -----------------------------------------------------------------------------
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir sal_Int32 VCLXAccessibleStatusBarItem::getBackground(  ) throw (RuntimeException)
442*cdf0e10cSrcweir {
443*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir 	sal_Int32 nColor = 0;
446*cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
447*cdf0e10cSrcweir 	if ( xParent.is() )
448*cdf0e10cSrcweir 	{
449*cdf0e10cSrcweir 		Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
450*cdf0e10cSrcweir 		if ( xParentComp.is() )
451*cdf0e10cSrcweir 			nColor = xParentComp->getBackground();
452*cdf0e10cSrcweir 	}
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 	return nColor;
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir // -----------------------------------------------------------------------------
458*cdf0e10cSrcweir // XAccessibleExtendedComponent
459*cdf0e10cSrcweir // -----------------------------------------------------------------------------
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir Reference< awt::XFont > VCLXAccessibleStatusBarItem::getFont(  ) throw (RuntimeException)
462*cdf0e10cSrcweir {
463*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 	Reference< awt::XFont > xFont;
466*cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
467*cdf0e10cSrcweir 	if ( xParent.is() )
468*cdf0e10cSrcweir 	{
469*cdf0e10cSrcweir 		Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
470*cdf0e10cSrcweir 		if ( xParentComp.is() )
471*cdf0e10cSrcweir 			xFont = xParentComp->getFont();
472*cdf0e10cSrcweir 	}
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	return xFont;
475*cdf0e10cSrcweir }
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir // -----------------------------------------------------------------------------
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleStatusBarItem::getTitledBorderText(  ) throw (RuntimeException)
480*cdf0e10cSrcweir {
481*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir 	return GetItemText();
484*cdf0e10cSrcweir }
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir // -----------------------------------------------------------------------------
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleStatusBarItem::getToolTipText(  ) throw (RuntimeException)
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir 	return ::rtl::OUString();
493*cdf0e10cSrcweir }
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir // -----------------------------------------------------------------------------
496*cdf0e10cSrcweir // XAccessibleText
497*cdf0e10cSrcweir // -----------------------------------------------------------------------------
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir sal_Int32 VCLXAccessibleStatusBarItem::getCaretPosition() throw (RuntimeException)
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir 	return -1;
504*cdf0e10cSrcweir }
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir // -----------------------------------------------------------------------------
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir sal_Bool VCLXAccessibleStatusBarItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
509*cdf0e10cSrcweir {
510*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir     if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
513*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir 	return sal_False;
516*cdf0e10cSrcweir }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir // -----------------------------------------------------------------------------
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir Sequence< PropertyValue > VCLXAccessibleStatusBarItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
521*cdf0e10cSrcweir {
522*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir 	Sequence< PropertyValue > aValues;
525*cdf0e10cSrcweir 	::rtl::OUString sText( implGetText() );
526*cdf0e10cSrcweir 
527*cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
528*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 	if ( m_pStatusBar )
531*cdf0e10cSrcweir 	{
532*cdf0e10cSrcweir 		Font aFont = m_pStatusBar->GetFont();
533*cdf0e10cSrcweir 		sal_Int32 nBackColor = getBackground();
534*cdf0e10cSrcweir 		sal_Int32 nColor = getForeground();
535*cdf0e10cSrcweir         ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) );
536*cdf0e10cSrcweir 		aValues = pHelper->GetCharacterAttributes( aRequestedAttributes );
537*cdf0e10cSrcweir 	}
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir     return aValues;
540*cdf0e10cSrcweir }
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir // -----------------------------------------------------------------------------
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir awt::Rectangle VCLXAccessibleStatusBarItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
545*cdf0e10cSrcweir {
546*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
549*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir 	awt::Rectangle aBounds( 0, 0, 0, 0 );
552*cdf0e10cSrcweir 	if ( m_pStatusBar )
553*cdf0e10cSrcweir 	{
554*cdf0e10cSrcweir 		::vcl::ControlLayoutData aLayoutData;
555*cdf0e10cSrcweir 		Rectangle aItemRect = m_pStatusBar->GetItemRect( m_nItemId );
556*cdf0e10cSrcweir 		m_pStatusBar->RecordLayoutData( &aLayoutData, aItemRect );
557*cdf0e10cSrcweir 		Rectangle aCharRect = aLayoutData.GetCharacterBounds( nIndex );
558*cdf0e10cSrcweir 		aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
559*cdf0e10cSrcweir 		aBounds = AWTRectangle( aCharRect );
560*cdf0e10cSrcweir 	}
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir 	return aBounds;
563*cdf0e10cSrcweir }
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir // -----------------------------------------------------------------------------
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir sal_Int32 VCLXAccessibleStatusBarItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
568*cdf0e10cSrcweir {
569*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir 	sal_Int32 nIndex = -1;
572*cdf0e10cSrcweir 	if ( m_pStatusBar )
573*cdf0e10cSrcweir 	{
574*cdf0e10cSrcweir 		::vcl::ControlLayoutData aLayoutData;
575*cdf0e10cSrcweir 		Rectangle aItemRect = m_pStatusBar->GetItemRect( m_nItemId );
576*cdf0e10cSrcweir 		m_pStatusBar->RecordLayoutData( &aLayoutData, aItemRect );
577*cdf0e10cSrcweir 		Point aPnt( VCLPoint( aPoint ) );
578*cdf0e10cSrcweir 		aPnt += aItemRect.TopLeft();
579*cdf0e10cSrcweir 		nIndex = aLayoutData.GetIndexForPoint( aPnt );
580*cdf0e10cSrcweir 	}
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir     return nIndex;
583*cdf0e10cSrcweir }
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir // -----------------------------------------------------------------------------
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir sal_Bool VCLXAccessibleStatusBarItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
588*cdf0e10cSrcweir {
589*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
592*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir 	return sal_False;
595*cdf0e10cSrcweir }
596*cdf0e10cSrcweir 
597*cdf0e10cSrcweir // -----------------------------------------------------------------------------
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir sal_Bool VCLXAccessibleStatusBarItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
600*cdf0e10cSrcweir {
601*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir 	if ( m_pStatusBar )
606*cdf0e10cSrcweir 	{
607*cdf0e10cSrcweir 		Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pStatusBar->GetClipboard();
608*cdf0e10cSrcweir 		if ( xClipboard.is() )
609*cdf0e10cSrcweir 		{
610*cdf0e10cSrcweir 			::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir 			::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
613*cdf0e10cSrcweir 			const sal_uInt32 nRef = Application::ReleaseSolarMutex();
614*cdf0e10cSrcweir 			xClipboard->setContents( pDataObj, NULL );
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 			Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
617*cdf0e10cSrcweir 			if( xFlushableClipboard.is() )
618*cdf0e10cSrcweir 				xFlushableClipboard->flushClipboard();
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir 			Application::AcquireSolarMutex( nRef );
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir 			bReturn = sal_True;
623*cdf0e10cSrcweir 		}
624*cdf0e10cSrcweir 	}
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir     return bReturn;
627*cdf0e10cSrcweir }
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir // -----------------------------------------------------------------------------
630