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