1*c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c82f2877SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c82f2877SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c82f2877SAndrew Rist  * distributed with this work for additional information
6*c82f2877SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c82f2877SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c82f2877SAndrew Rist  * "License"); you may not use this file except in compliance
9*c82f2877SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c82f2877SAndrew Rist  *
11*c82f2877SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c82f2877SAndrew Rist  *
13*c82f2877SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c82f2877SAndrew Rist  * software distributed under the License is distributed on an
15*c82f2877SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c82f2877SAndrew Rist  * KIND, either express or implied.  See the License for the
17*c82f2877SAndrew Rist  * specific language governing permissions and limitations
18*c82f2877SAndrew Rist  * under the License.
19*c82f2877SAndrew Rist  *
20*c82f2877SAndrew Rist  *************************************************************/
21*c82f2877SAndrew Rist 
22*c82f2877SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir #include <accessibility/standard/vclxaccessibletabpage.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/tabctrl.hxx>
42cdf0e10cSrcweir #include <vcl/tabpage.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 VCLXAccessibleTabPage
57cdf0e10cSrcweir // -----------------------------------------------------------------------------
58cdf0e10cSrcweir 
VCLXAccessibleTabPage(TabControl * pTabControl,sal_uInt16 nPageId)59cdf0e10cSrcweir VCLXAccessibleTabPage::VCLXAccessibleTabPage( TabControl* pTabControl, sal_uInt16 nPageId )
60cdf0e10cSrcweir 	:AccessibleTextHelper_BASE( new VCLExternalSolarLock() )
61cdf0e10cSrcweir 	,m_pTabControl( pTabControl )
62cdf0e10cSrcweir 	,m_nPageId( nPageId )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
65cdf0e10cSrcweir 	m_bFocused	= IsFocused();
66cdf0e10cSrcweir 	m_bSelected = IsSelected();
67cdf0e10cSrcweir     m_sPageText = GetPageText();
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir // -----------------------------------------------------------------------------
71cdf0e10cSrcweir 
~VCLXAccessibleTabPage()72cdf0e10cSrcweir VCLXAccessibleTabPage::~VCLXAccessibleTabPage()
73cdf0e10cSrcweir {
74cdf0e10cSrcweir 	delete m_pExternalLock;
75cdf0e10cSrcweir 	m_pExternalLock = NULL;
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir // -----------------------------------------------------------------------------
79cdf0e10cSrcweir 
IsFocused()80cdf0e10cSrcweir bool VCLXAccessibleTabPage::IsFocused()
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     bool bFocused = false;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     if ( m_pTabControl && m_pTabControl->HasFocus() && m_pTabControl->GetCurPageId() == m_nPageId )
85cdf0e10cSrcweir         bFocused = true;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     return bFocused;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir // -----------------------------------------------------------------------------
91cdf0e10cSrcweir 
IsSelected()92cdf0e10cSrcweir bool VCLXAccessibleTabPage::IsSelected()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     bool bSelected = false;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     if ( m_pTabControl && m_pTabControl->GetCurPageId() == m_nPageId )
97cdf0e10cSrcweir         bSelected = true;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     return bSelected;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // -----------------------------------------------------------------------------
103cdf0e10cSrcweir 
SetFocused(bool bFocused)104cdf0e10cSrcweir void VCLXAccessibleTabPage::SetFocused( bool bFocused )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	if ( m_bFocused != bFocused )
107cdf0e10cSrcweir 	{
108cdf0e10cSrcweir 		Any aOldValue, aNewValue;
109cdf0e10cSrcweir 		if ( m_bFocused )
110cdf0e10cSrcweir 			aOldValue <<= AccessibleStateType::FOCUSED;
111cdf0e10cSrcweir 		else
112cdf0e10cSrcweir 			aNewValue <<= AccessibleStateType::FOCUSED;
113cdf0e10cSrcweir 		m_bFocused = bFocused;
114cdf0e10cSrcweir 		NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
115cdf0e10cSrcweir 	}
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir // -----------------------------------------------------------------------------
119cdf0e10cSrcweir 
SetSelected(bool bSelected)120cdf0e10cSrcweir void VCLXAccessibleTabPage::SetSelected( bool bSelected )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir 	if ( m_bSelected != bSelected )
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir 		Any aOldValue, aNewValue;
125cdf0e10cSrcweir 		if ( m_bSelected )
126cdf0e10cSrcweir 			aOldValue <<= AccessibleStateType::SELECTED;
127cdf0e10cSrcweir 		else
128cdf0e10cSrcweir 			aNewValue <<= AccessibleStateType::SELECTED;
129cdf0e10cSrcweir 		m_bSelected = bSelected;
130cdf0e10cSrcweir 	    NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
131cdf0e10cSrcweir 	}
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir // -----------------------------------------------------------------------------
135cdf0e10cSrcweir 
SetPageText(const::rtl::OUString & sPageText)136cdf0e10cSrcweir void VCLXAccessibleTabPage::SetPageText( const ::rtl::OUString& sPageText )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir     Any aOldValue, aNewValue;
139cdf0e10cSrcweir     if ( OCommonAccessibleText::implInitTextChangedEvent( m_sPageText, sPageText, aOldValue, aNewValue ) )
140cdf0e10cSrcweir     {
141cdf0e10cSrcweir         Any aOldName, aNewName;
142cdf0e10cSrcweir         aOldName <<= m_sPageText;
143cdf0e10cSrcweir         aNewName <<= sPageText;
144cdf0e10cSrcweir         m_sPageText = sPageText;
145cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldName, aNewName );
146cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue );
147cdf0e10cSrcweir     }
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir // -----------------------------------------------------------------------------
151cdf0e10cSrcweir 
GetPageText()152cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::GetPageText()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir 	::rtl::OUString sText;
155cdf0e10cSrcweir 	if ( m_pTabControl )
156cdf0e10cSrcweir 		sText = OutputDevice::GetNonMnemonicString( m_pTabControl->GetPageText( m_nPageId ) );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	return sText;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir // -----------------------------------------------------------------------------
162cdf0e10cSrcweir 
Update(bool bNew)163cdf0e10cSrcweir void VCLXAccessibleTabPage::Update( bool bNew )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir     if ( m_pTabControl )
166cdf0e10cSrcweir     {
167cdf0e10cSrcweir         TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId );
168cdf0e10cSrcweir         if ( pTabPage )
169cdf0e10cSrcweir         {
170cdf0e10cSrcweir 	        Reference< XAccessible > xChild( pTabPage->GetAccessible( bNew ) );
171cdf0e10cSrcweir 	        if ( xChild.is() )
172cdf0e10cSrcweir 	        {
173cdf0e10cSrcweir 		        Any aOldValue, aNewValue;
174cdf0e10cSrcweir                 if ( bNew )
175cdf0e10cSrcweir 			        aNewValue <<= xChild;
176cdf0e10cSrcweir                 else
177cdf0e10cSrcweir                     aOldValue <<= xChild;
178cdf0e10cSrcweir 		        NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
179cdf0e10cSrcweir 	        }
180cdf0e10cSrcweir         }
181cdf0e10cSrcweir     }
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir // -----------------------------------------------------------------------------
185cdf0e10cSrcweir 
FillAccessibleStateSet(utl::AccessibleStateSetHelper & rStateSet)186cdf0e10cSrcweir void VCLXAccessibleTabPage::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir 	rStateSet.AddState( AccessibleStateType::ENABLED );
189cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::SENSITIVE );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 	rStateSet.AddState( AccessibleStateType::FOCUSABLE );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	if ( IsFocused() )
194cdf0e10cSrcweir 		rStateSet.AddState( AccessibleStateType::FOCUSED );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	rStateSet.AddState( AccessibleStateType::VISIBLE );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	rStateSet.AddState( AccessibleStateType::SHOWING );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     rStateSet.AddState( AccessibleStateType::SELECTABLE );
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	if ( IsSelected() )
203cdf0e10cSrcweir 	    rStateSet.AddState( AccessibleStateType::SELECTED );
204cdf0e10cSrcweir }
205cdf0e10cSrcweir 
206cdf0e10cSrcweir // -----------------------------------------------------------------------------
207cdf0e10cSrcweir // OCommonAccessibleComponent
208cdf0e10cSrcweir // -----------------------------------------------------------------------------
209cdf0e10cSrcweir 
implGetBounds()210cdf0e10cSrcweir awt::Rectangle VCLXAccessibleTabPage::implGetBounds() throw (RuntimeException)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir 	awt::Rectangle aBounds( 0, 0, 0, 0 );
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	if ( m_pTabControl )
215cdf0e10cSrcweir         aBounds = AWTRectangle( m_pTabControl->GetTabBounds( m_nPageId ) );
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	return aBounds;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir // -----------------------------------------------------------------------------
221cdf0e10cSrcweir // OCommonAccessibleText
222cdf0e10cSrcweir // -----------------------------------------------------------------------------
223cdf0e10cSrcweir 
implGetText()224cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::implGetText()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir     return GetPageText();
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir // -----------------------------------------------------------------------------
230cdf0e10cSrcweir 
implGetLocale()231cdf0e10cSrcweir lang::Locale VCLXAccessibleTabPage::implGetLocale()
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	return Application::GetSettings().GetLocale();
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir // -----------------------------------------------------------------------------
237cdf0e10cSrcweir 
implGetSelection(sal_Int32 & nStartIndex,sal_Int32 & nEndIndex)238cdf0e10cSrcweir void VCLXAccessibleTabPage::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir 	nStartIndex = 0;
241cdf0e10cSrcweir 	nEndIndex = 0;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir // -----------------------------------------------------------------------------
245cdf0e10cSrcweir // XInterface
246cdf0e10cSrcweir // -----------------------------------------------------------------------------
247cdf0e10cSrcweir 
IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTabPage,AccessibleTextHelper_BASE,VCLXAccessibleTabPage_BASE)248cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleTabPage, AccessibleTextHelper_BASE, VCLXAccessibleTabPage_BASE )
249cdf0e10cSrcweir 
250cdf0e10cSrcweir // -----------------------------------------------------------------------------
251cdf0e10cSrcweir // XTypeProvider
252cdf0e10cSrcweir // -----------------------------------------------------------------------------
253cdf0e10cSrcweir 
254cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleTabPage, AccessibleTextHelper_BASE, VCLXAccessibleTabPage_BASE )
255cdf0e10cSrcweir 
256cdf0e10cSrcweir // -----------------------------------------------------------------------------
257cdf0e10cSrcweir // XComponent
258cdf0e10cSrcweir // -----------------------------------------------------------------------------
259cdf0e10cSrcweir 
260cdf0e10cSrcweir void VCLXAccessibleTabPage::disposing()
261cdf0e10cSrcweir {
262cdf0e10cSrcweir 	AccessibleTextHelper_BASE::disposing();
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	m_pTabControl = NULL;
265cdf0e10cSrcweir     m_sPageText = ::rtl::OUString();
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir // -----------------------------------------------------------------------------
269cdf0e10cSrcweir // XServiceInfo
270cdf0e10cSrcweir // -----------------------------------------------------------------------------
271cdf0e10cSrcweir 
getImplementationName()272cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getImplementationName() throw (RuntimeException)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleTabPage" );
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir // -----------------------------------------------------------------------------
278cdf0e10cSrcweir 
supportsService(const::rtl::OUString & rServiceName)279cdf0e10cSrcweir sal_Bool VCLXAccessibleTabPage::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
280cdf0e10cSrcweir {
281cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
282cdf0e10cSrcweir 	const ::rtl::OUString* pNames = aNames.getConstArray();
283cdf0e10cSrcweir 	const ::rtl::OUString* pEnd = pNames + aNames.getLength();
284cdf0e10cSrcweir 	for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
285cdf0e10cSrcweir 		;
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 	return pNames != pEnd;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir // -----------------------------------------------------------------------------
291cdf0e10cSrcweir 
getSupportedServiceNames()292cdf0e10cSrcweir Sequence< ::rtl::OUString > VCLXAccessibleTabPage::getSupportedServiceNames() throw (RuntimeException)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames(1);
295cdf0e10cSrcweir 	aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleTabPage" );
296cdf0e10cSrcweir 	return aNames;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir // -----------------------------------------------------------------------------
300cdf0e10cSrcweir // XAccessible
301cdf0e10cSrcweir // -----------------------------------------------------------------------------
302cdf0e10cSrcweir 
getAccessibleContext()303cdf0e10cSrcweir Reference< XAccessibleContext > VCLXAccessibleTabPage::getAccessibleContext(  ) throw (RuntimeException)
304cdf0e10cSrcweir {
305cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
306cdf0e10cSrcweir 
307cdf0e10cSrcweir 	return this;
308cdf0e10cSrcweir }
309cdf0e10cSrcweir 
310cdf0e10cSrcweir // -----------------------------------------------------------------------------
311cdf0e10cSrcweir // XAccessibleContext
312cdf0e10cSrcweir // -----------------------------------------------------------------------------
313cdf0e10cSrcweir 
getAccessibleChildCount()314cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getAccessibleChildCount() throw (RuntimeException)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 	sal_Int32 nCount = 0;
319cdf0e10cSrcweir 	if ( m_pTabControl )
320cdf0e10cSrcweir 	{
321cdf0e10cSrcweir 		TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId );
322cdf0e10cSrcweir 		if ( pTabPage && pTabPage->IsVisible() )
323cdf0e10cSrcweir             nCount = 1;
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 	return nCount;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir // -----------------------------------------------------------------------------
330cdf0e10cSrcweir 
getAccessibleChild(sal_Int32 i)331cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 	if ( i < 0 || i >= getAccessibleChildCount() )
336cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	Reference< XAccessible > xChild;
339cdf0e10cSrcweir 	if ( m_pTabControl )
340cdf0e10cSrcweir 	{
341cdf0e10cSrcweir 		TabPage* pTabPage = m_pTabControl->GetTabPage( m_nPageId );
342cdf0e10cSrcweir 		if ( pTabPage && pTabPage->IsVisible() )
343cdf0e10cSrcweir             xChild = pTabPage->GetAccessible();
344cdf0e10cSrcweir 	}
345cdf0e10cSrcweir 
346cdf0e10cSrcweir 	return xChild;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir // -----------------------------------------------------------------------------
350cdf0e10cSrcweir 
getAccessibleParent()351cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleParent(  ) throw (RuntimeException)
352cdf0e10cSrcweir {
353cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 	Reference< XAccessible > xParent;
356cdf0e10cSrcweir 	if ( m_pTabControl )
357cdf0e10cSrcweir 		xParent = m_pTabControl->GetAccessible();
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	return xParent;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir // -----------------------------------------------------------------------------
363cdf0e10cSrcweir 
getAccessibleIndexInParent()364cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getAccessibleIndexInParent(  ) throw (RuntimeException)
365cdf0e10cSrcweir {
366cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	sal_Int32 nIndexInParent = -1;
369cdf0e10cSrcweir 	if ( m_pTabControl )
370cdf0e10cSrcweir 		nIndexInParent = m_pTabControl->GetPagePos( m_nPageId );
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 	return nIndexInParent;
373cdf0e10cSrcweir }
374cdf0e10cSrcweir 
375cdf0e10cSrcweir // -----------------------------------------------------------------------------
376cdf0e10cSrcweir 
getAccessibleRole()377cdf0e10cSrcweir sal_Int16 VCLXAccessibleTabPage::getAccessibleRole(  ) throw (RuntimeException)
378cdf0e10cSrcweir {
379cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	return AccessibleRole::PAGE_TAB;
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir // -----------------------------------------------------------------------------
385cdf0e10cSrcweir 
getAccessibleDescription()386cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getAccessibleDescription(	) throw (RuntimeException)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     ::rtl::OUString sDescription;
391cdf0e10cSrcweir     if ( m_pTabControl )
392cdf0e10cSrcweir         sDescription = m_pTabControl->GetHelpText( m_nPageId );
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     return sDescription;
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir // -----------------------------------------------------------------------------
398cdf0e10cSrcweir 
getAccessibleName()399cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getAccessibleName(  ) throw (RuntimeException)
400cdf0e10cSrcweir {
401cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir     return GetPageText();
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir // -----------------------------------------------------------------------------
407cdf0e10cSrcweir 
getAccessibleRelationSet()408cdf0e10cSrcweir Reference< XAccessibleRelationSet > VCLXAccessibleTabPage::getAccessibleRelationSet(  ) throw (RuntimeException)
409cdf0e10cSrcweir {
410cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
411cdf0e10cSrcweir 
412cdf0e10cSrcweir     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
413cdf0e10cSrcweir 	Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
414cdf0e10cSrcweir     return xSet;
415cdf0e10cSrcweir }
416cdf0e10cSrcweir 
417cdf0e10cSrcweir // -----------------------------------------------------------------------------
418cdf0e10cSrcweir 
getAccessibleStateSet()419cdf0e10cSrcweir Reference< XAccessibleStateSet > VCLXAccessibleTabPage::getAccessibleStateSet(  ) throw (RuntimeException)
420cdf0e10cSrcweir {
421cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
424cdf0e10cSrcweir 	Reference< XAccessibleStateSet > xSet = pStateSetHelper;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
427cdf0e10cSrcweir 	{
428cdf0e10cSrcweir 		FillAccessibleStateSet( *pStateSetHelper );
429cdf0e10cSrcweir 	}
430cdf0e10cSrcweir 	else
431cdf0e10cSrcweir 	{
432cdf0e10cSrcweir         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	return xSet;
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir // -----------------------------------------------------------------------------
439cdf0e10cSrcweir 
getLocale()440cdf0e10cSrcweir Locale VCLXAccessibleTabPage::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException)
441cdf0e10cSrcweir {
442cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 	return Application::GetSettings().GetLocale();
445cdf0e10cSrcweir }
446cdf0e10cSrcweir 
447cdf0e10cSrcweir // -----------------------------------------------------------------------------
448cdf0e10cSrcweir // XAccessibleComponent
449cdf0e10cSrcweir // -----------------------------------------------------------------------------
450cdf0e10cSrcweir 
getAccessibleAtPoint(const awt::Point & rPoint)451cdf0e10cSrcweir Reference< XAccessible > VCLXAccessibleTabPage::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
452cdf0e10cSrcweir {
453cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 	Reference< XAccessible > xChild;
456cdf0e10cSrcweir 	for ( sal_uInt32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
457cdf0e10cSrcweir 	{
458cdf0e10cSrcweir 		Reference< XAccessible > xAcc = getAccessibleChild( i );
459cdf0e10cSrcweir 		if ( xAcc.is() )
460cdf0e10cSrcweir 		{
461cdf0e10cSrcweir 			Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
462cdf0e10cSrcweir 			if ( xComp.is() )
463cdf0e10cSrcweir 			{
464cdf0e10cSrcweir 				Rectangle aRect = VCLRectangle( xComp->getBounds() );
465cdf0e10cSrcweir 				Point aPos = VCLPoint( rPoint );
466cdf0e10cSrcweir 				if ( aRect.IsInside( aPos ) )
467cdf0e10cSrcweir 				{
468cdf0e10cSrcweir 					xChild = xAcc;
469cdf0e10cSrcweir 					break;
470cdf0e10cSrcweir 				}
471cdf0e10cSrcweir 			}
472cdf0e10cSrcweir 		}
473cdf0e10cSrcweir 	}
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 	return xChild;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir 
478cdf0e10cSrcweir // -----------------------------------------------------------------------------
479cdf0e10cSrcweir 
grabFocus()480cdf0e10cSrcweir void VCLXAccessibleTabPage::grabFocus(  ) throw (RuntimeException)
481cdf0e10cSrcweir {
482cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 	if ( m_pTabControl )
485cdf0e10cSrcweir     {
486cdf0e10cSrcweir 		m_pTabControl->SelectTabPage( m_nPageId );
487cdf0e10cSrcweir         m_pTabControl->GrabFocus();
488cdf0e10cSrcweir     }
489cdf0e10cSrcweir }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir // -----------------------------------------------------------------------------
492cdf0e10cSrcweir 
getForeground()493cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getForeground(	) throw (RuntimeException)
494cdf0e10cSrcweir {
495cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 	sal_Int32 nColor = 0;
498cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
499cdf0e10cSrcweir 	if ( xParent.is() )
500cdf0e10cSrcweir 	{
501cdf0e10cSrcweir 		Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
502cdf0e10cSrcweir 		if ( xParentComp.is() )
503cdf0e10cSrcweir 			nColor = xParentComp->getForeground();
504cdf0e10cSrcweir 	}
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 	return nColor;
507cdf0e10cSrcweir }
508cdf0e10cSrcweir 
509cdf0e10cSrcweir // -----------------------------------------------------------------------------
510cdf0e10cSrcweir 
getBackground()511cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getBackground(  ) throw (RuntimeException)
512cdf0e10cSrcweir {
513cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 	sal_Int32 nColor = 0;
516cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
517cdf0e10cSrcweir 	if ( xParent.is() )
518cdf0e10cSrcweir 	{
519cdf0e10cSrcweir 		Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
520cdf0e10cSrcweir 		if ( xParentComp.is() )
521cdf0e10cSrcweir 			nColor = xParentComp->getBackground();
522cdf0e10cSrcweir 	}
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 	return nColor;
525cdf0e10cSrcweir }
526cdf0e10cSrcweir 
527cdf0e10cSrcweir // -----------------------------------------------------------------------------
528cdf0e10cSrcweir // XAccessibleExtendedComponent
529cdf0e10cSrcweir // -----------------------------------------------------------------------------
530cdf0e10cSrcweir 
getFont()531cdf0e10cSrcweir Reference< awt::XFont > VCLXAccessibleTabPage::getFont(  ) throw (RuntimeException)
532cdf0e10cSrcweir {
533cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 	Reference< awt::XFont > xFont;
536cdf0e10cSrcweir 	Reference< XAccessible > xParent = getAccessibleParent();
537cdf0e10cSrcweir 	if ( xParent.is() )
538cdf0e10cSrcweir 	{
539cdf0e10cSrcweir 		Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
540cdf0e10cSrcweir 		if ( xParentComp.is() )
541cdf0e10cSrcweir 			xFont = xParentComp->getFont();
542cdf0e10cSrcweir 	}
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 	return xFont;
545cdf0e10cSrcweir }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir // -----------------------------------------------------------------------------
548cdf0e10cSrcweir 
getTitledBorderText()549cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getTitledBorderText(  ) throw (RuntimeException)
550cdf0e10cSrcweir {
551cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 	return ::rtl::OUString();
554cdf0e10cSrcweir }
555cdf0e10cSrcweir 
556cdf0e10cSrcweir // -----------------------------------------------------------------------------
557cdf0e10cSrcweir 
getToolTipText()558cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTabPage::getToolTipText(  ) throw (RuntimeException)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 	return ::rtl::OUString();
563cdf0e10cSrcweir }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir // -----------------------------------------------------------------------------
566cdf0e10cSrcweir // XAccessibleText
567cdf0e10cSrcweir // -----------------------------------------------------------------------------
568cdf0e10cSrcweir 
getCaretPosition()569cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getCaretPosition() throw (RuntimeException)
570cdf0e10cSrcweir {
571cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 	return -1;
574cdf0e10cSrcweir }
575cdf0e10cSrcweir 
576cdf0e10cSrcweir // -----------------------------------------------------------------------------
577cdf0e10cSrcweir 
setCaretPosition(sal_Int32 nIndex)578cdf0e10cSrcweir sal_Bool VCLXAccessibleTabPage::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
579cdf0e10cSrcweir {
580cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
581cdf0e10cSrcweir 
582cdf0e10cSrcweir     if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
583cdf0e10cSrcweir         throw IndexOutOfBoundsException();
584cdf0e10cSrcweir 
585cdf0e10cSrcweir 	return sal_False;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir 
588cdf0e10cSrcweir // -----------------------------------------------------------------------------
589cdf0e10cSrcweir 
getCharacterAttributes(sal_Int32 nIndex,const Sequence<::rtl::OUString> & aRequestedAttributes)590cdf0e10cSrcweir Sequence< PropertyValue > VCLXAccessibleTabPage::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
591cdf0e10cSrcweir {
592cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 	Sequence< PropertyValue > aValues;
595cdf0e10cSrcweir 	::rtl::OUString sText( implGetText() );
596cdf0e10cSrcweir 
597cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
598cdf0e10cSrcweir         throw IndexOutOfBoundsException();
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 	if ( m_pTabControl )
601cdf0e10cSrcweir 	{
602cdf0e10cSrcweir 		Font aFont = m_pTabControl->GetFont();
603cdf0e10cSrcweir 		sal_Int32 nBackColor = getBackground();
604cdf0e10cSrcweir 		sal_Int32 nColor = getForeground();
605cdf0e10cSrcweir         ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) );
606cdf0e10cSrcweir 		aValues = pHelper->GetCharacterAttributes( aRequestedAttributes );
607cdf0e10cSrcweir 	}
608cdf0e10cSrcweir 
609cdf0e10cSrcweir     return aValues;
610cdf0e10cSrcweir }
611cdf0e10cSrcweir 
612cdf0e10cSrcweir // -----------------------------------------------------------------------------
613cdf0e10cSrcweir 
getCharacterBounds(sal_Int32 nIndex)614cdf0e10cSrcweir awt::Rectangle VCLXAccessibleTabPage::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
615cdf0e10cSrcweir {
616cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
617cdf0e10cSrcweir 
618cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
619cdf0e10cSrcweir         throw IndexOutOfBoundsException();
620cdf0e10cSrcweir 
621cdf0e10cSrcweir 	awt::Rectangle aBounds( 0, 0, 0, 0 );
622cdf0e10cSrcweir 	if ( m_pTabControl )
623cdf0e10cSrcweir 	{
624cdf0e10cSrcweir 		Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
625cdf0e10cSrcweir 		Rectangle aCharRect = m_pTabControl->GetCharacterBounds( m_nPageId, nIndex );
626cdf0e10cSrcweir 		aCharRect.Move( -aPageRect.Left(), -aPageRect.Top() );
627cdf0e10cSrcweir 		aBounds = AWTRectangle( aCharRect );
628cdf0e10cSrcweir 	}
629cdf0e10cSrcweir 
630cdf0e10cSrcweir 	return aBounds;
631cdf0e10cSrcweir }
632cdf0e10cSrcweir 
633cdf0e10cSrcweir // -----------------------------------------------------------------------------
634cdf0e10cSrcweir 
getIndexAtPoint(const awt::Point & aPoint)635cdf0e10cSrcweir sal_Int32 VCLXAccessibleTabPage::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
636cdf0e10cSrcweir {
637cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
638cdf0e10cSrcweir 
639cdf0e10cSrcweir 	sal_Int32 nIndex = -1;
640cdf0e10cSrcweir 	if ( m_pTabControl )
641cdf0e10cSrcweir 	{
642cdf0e10cSrcweir 		sal_uInt16 nPageId = 0;
643cdf0e10cSrcweir 		Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
644cdf0e10cSrcweir         Point aPnt( VCLPoint( aPoint ) );
645cdf0e10cSrcweir 		aPnt += aPageRect.TopLeft();
646cdf0e10cSrcweir 		sal_Int32 nI = m_pTabControl->GetIndexForPoint( aPnt, nPageId );
647cdf0e10cSrcweir 		if ( nI != -1 && m_nPageId == nPageId )
648cdf0e10cSrcweir 			nIndex = nI;
649cdf0e10cSrcweir 	}
650cdf0e10cSrcweir 
651cdf0e10cSrcweir     return nIndex;
652cdf0e10cSrcweir }
653cdf0e10cSrcweir 
654cdf0e10cSrcweir // -----------------------------------------------------------------------------
655cdf0e10cSrcweir 
setSelection(sal_Int32 nStartIndex,sal_Int32 nEndIndex)656cdf0e10cSrcweir sal_Bool VCLXAccessibleTabPage::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
657cdf0e10cSrcweir {
658cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
659cdf0e10cSrcweir 
660cdf0e10cSrcweir     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
661cdf0e10cSrcweir         throw IndexOutOfBoundsException();
662cdf0e10cSrcweir 
663cdf0e10cSrcweir 	return sal_False;
664cdf0e10cSrcweir }
665cdf0e10cSrcweir 
666cdf0e10cSrcweir // -----------------------------------------------------------------------------
667cdf0e10cSrcweir 
copyText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)668cdf0e10cSrcweir sal_Bool VCLXAccessibleTabPage::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
669cdf0e10cSrcweir {
670cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
671cdf0e10cSrcweir 
672cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 	if ( m_pTabControl )
675cdf0e10cSrcweir 	{
676cdf0e10cSrcweir 		Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pTabControl->GetClipboard();
677cdf0e10cSrcweir 		if ( xClipboard.is() )
678cdf0e10cSrcweir 		{
679cdf0e10cSrcweir 			::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 			::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
682cdf0e10cSrcweir 			const sal_uInt32 nRef = Application::ReleaseSolarMutex();
683cdf0e10cSrcweir 			xClipboard->setContents( pDataObj, NULL );
684cdf0e10cSrcweir 
685cdf0e10cSrcweir 			Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
686cdf0e10cSrcweir 			if( xFlushableClipboard.is() )
687cdf0e10cSrcweir 				xFlushableClipboard->flushClipboard();
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 			Application::AcquireSolarMutex( nRef );
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 			bReturn = sal_True;
692cdf0e10cSrcweir 		}
693cdf0e10cSrcweir 	}
694cdf0e10cSrcweir 
695cdf0e10cSrcweir     return bReturn;
696cdf0e10cSrcweir }
697cdf0e10cSrcweir 
698cdf0e10cSrcweir // -----------------------------------------------------------------------------
699