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