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