xref: /trunk/main/accessibility/source/standard/vclxaccessibletextcomponent.cxx (revision 04c88002691bc4b2a5ac56d20828b7f32c699f8c)
10841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
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
10cdf0e10cSrcweir  *
110841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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/vclxaccessibletextcomponent.hxx>
27cdf0e10cSrcweir #include <toolkit/helper/macros.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/datatransfer/clipboard/XClipboard.hpp>
33cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
34cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
35cdf0e10cSrcweir #include <comphelper/sequence.hxx>
36cdf0e10cSrcweir #include <vcl/window.hxx>
37cdf0e10cSrcweir #include <vcl/svapp.hxx>
38cdf0e10cSrcweir #include <vcl/unohelp2.hxx>
39cdf0e10cSrcweir #include <vcl/ctrl.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <memory>
42cdf0e10cSrcweir #include <vector>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir using namespace ::com::sun::star;
45cdf0e10cSrcweir using namespace ::com::sun::star::uno;
46cdf0e10cSrcweir using namespace ::com::sun::star::lang;
47cdf0e10cSrcweir using namespace ::com::sun::star::beans;
48cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
49cdf0e10cSrcweir using namespace ::comphelper;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //  ----------------------------------------------------
53cdf0e10cSrcweir //  class VCLXAccessibleTextComponent
54cdf0e10cSrcweir //  ----------------------------------------------------
55cdf0e10cSrcweir 
VCLXAccessibleTextComponent(VCLXWindow * pVCLXWindow)56cdf0e10cSrcweir VCLXAccessibleTextComponent::VCLXAccessibleTextComponent( VCLXWindow* pVCLXWindow )
57cdf0e10cSrcweir     :VCLXAccessibleComponent( pVCLXWindow )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir     if ( GetWindow() )
60cdf0e10cSrcweir         m_sText = OutputDevice::GetNonMnemonicString( GetWindow()->GetText() );
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir // -----------------------------------------------------------------------------
64cdf0e10cSrcweir 
~VCLXAccessibleTextComponent()65cdf0e10cSrcweir VCLXAccessibleTextComponent::~VCLXAccessibleTextComponent()
66cdf0e10cSrcweir {
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir // -----------------------------------------------------------------------------
70cdf0e10cSrcweir 
SetText(const::rtl::OUString & sText)71cdf0e10cSrcweir void VCLXAccessibleTextComponent::SetText( const ::rtl::OUString& sText )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     Any aOldValue, aNewValue;
74cdf0e10cSrcweir     if ( implInitTextChangedEvent( m_sText, sText, aOldValue, aNewValue ) )
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir         m_sText = sText;
77cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue );
78cdf0e10cSrcweir     }
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir // -----------------------------------------------------------------------------
82cdf0e10cSrcweir 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)83cdf0e10cSrcweir void VCLXAccessibleTextComponent::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     switch ( rVclWindowEvent.GetId() )
86cdf0e10cSrcweir     {
87cdf0e10cSrcweir         case VCLEVENT_WINDOW_FRAMETITLECHANGED:
88cdf0e10cSrcweir         {
89cdf0e10cSrcweir             VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
90cdf0e10cSrcweir             SetText( implGetText() );
91cdf0e10cSrcweir         }
92cdf0e10cSrcweir         break;
93cdf0e10cSrcweir         default:
94cdf0e10cSrcweir             VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
95cdf0e10cSrcweir     }
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir // -----------------------------------------------------------------------------
99cdf0e10cSrcweir // OCommonAccessibleText
100cdf0e10cSrcweir // -----------------------------------------------------------------------------
101cdf0e10cSrcweir 
implGetText()102cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTextComponent::implGetText()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     ::rtl::OUString aText;
105cdf0e10cSrcweir     if ( GetWindow() )
106cdf0e10cSrcweir         aText = OutputDevice::GetNonMnemonicString( GetWindow()->GetText() );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     return aText;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // -----------------------------------------------------------------------------
112cdf0e10cSrcweir 
implGetLocale()113cdf0e10cSrcweir lang::Locale VCLXAccessibleTextComponent::implGetLocale()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     return Application::GetSettings().GetLocale();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir // -----------------------------------------------------------------------------
119cdf0e10cSrcweir 
implGetSelection(sal_Int32 & nStartIndex,sal_Int32 & nEndIndex)120cdf0e10cSrcweir void VCLXAccessibleTextComponent::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     nStartIndex = 0;
123cdf0e10cSrcweir     nEndIndex = 0;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir // -----------------------------------------------------------------------------
127cdf0e10cSrcweir // XComponent
128cdf0e10cSrcweir // -----------------------------------------------------------------------------
129cdf0e10cSrcweir 
disposing()130cdf0e10cSrcweir void VCLXAccessibleTextComponent::disposing()
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     VCLXAccessibleComponent::disposing();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     m_sText = ::rtl::OUString();
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // -----------------------------------------------------------------------------
138cdf0e10cSrcweir // XInterface
139cdf0e10cSrcweir // -----------------------------------------------------------------------------
140cdf0e10cSrcweir 
IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTextComponent,VCLXAccessibleComponent,VCLXAccessibleTextComponent_BASE)141cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleTextComponent, VCLXAccessibleComponent, VCLXAccessibleTextComponent_BASE )
142cdf0e10cSrcweir 
143cdf0e10cSrcweir // -----------------------------------------------------------------------------
144cdf0e10cSrcweir // XTypeProvider
145cdf0e10cSrcweir // -----------------------------------------------------------------------------
146cdf0e10cSrcweir 
147cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleTextComponent, VCLXAccessibleComponent, VCLXAccessibleTextComponent_BASE )
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // -----------------------------------------------------------------------------
150cdf0e10cSrcweir // XAccessibleText
151cdf0e10cSrcweir // -----------------------------------------------------------------------------
152cdf0e10cSrcweir 
153cdf0e10cSrcweir sal_Int32 VCLXAccessibleTextComponent::getCaretPosition() throw (RuntimeException)
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     return -1;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir // -----------------------------------------------------------------------------
161cdf0e10cSrcweir 
setCaretPosition(sal_Int32 nIndex)162cdf0e10cSrcweir sal_Bool VCLXAccessibleTextComponent::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     return setSelection( nIndex, nIndex );
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // -----------------------------------------------------------------------------
170cdf0e10cSrcweir 
getCharacter(sal_Int32 nIndex)171cdf0e10cSrcweir sal_Unicode VCLXAccessibleTextComponent::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     return OCommonAccessibleText::getCharacter( nIndex );
176cdf0e10cSrcweir }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir // -----------------------------------------------------------------------------
179cdf0e10cSrcweir 
getCharacterAttributes(sal_Int32 nIndex,const Sequence<::rtl::OUString> & aRequestedAttributes)180cdf0e10cSrcweir Sequence< PropertyValue > VCLXAccessibleTextComponent::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& aRequestedAttributes ) throw (IndexOutOfBoundsException, RuntimeException)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     Sequence< PropertyValue > aValues;
185cdf0e10cSrcweir     ::rtl::OUString sText( implGetText() );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
188cdf0e10cSrcweir         throw IndexOutOfBoundsException();
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     if ( GetWindow() )
191cdf0e10cSrcweir     {
192cdf0e10cSrcweir         Font aFont = GetWindow()->GetControlFont();
193*21075d77SSteve Yin 
194cdf0e10cSrcweir         sal_Int32 nBackColor = GetWindow()->GetControlBackground().GetColor();
195cdf0e10cSrcweir         sal_Int32 nColor = GetWindow()->GetControlForeground().GetColor();
196*21075d77SSteve Yin 
197*21075d77SSteve Yin         // MT: Code with default font was introduced with the IA2 CWS, but I am not convinced that this is the correct font...
198*21075d77SSteve Yin         // Decide what to do when we have a concrete issue.
199*21075d77SSteve Yin         /*
200*21075d77SSteve Yin         Font aDefaultVCLFont;
201*21075d77SSteve Yin         OutputDevice* pDev = Application::GetDefaultDevice();
202*21075d77SSteve Yin         if ( pDev )
203*21075d77SSteve Yin         {
204*21075d77SSteve Yin             aDefaultVCLFont = pDev->GetSettings().GetStyleSettings().GetAppFont();
205*21075d77SSteve Yin             if ( !aFont.GetName().Len() )
206*21075d77SSteve Yin             {
207*21075d77SSteve Yin                 String aDefaultName = aDefaultVCLFont.GetName();
208*21075d77SSteve Yin                 aFont.SetName( aDefaultName );
209*21075d77SSteve Yin             }
210*21075d77SSteve Yin             if ( !aFont.GetHeight() )
211*21075d77SSteve Yin             {
212*21075d77SSteve Yin                 aFont.SetHeight( aDefaultVCLFont.GetHeight() );
213*21075d77SSteve Yin             }
214*21075d77SSteve Yin             if ( aFont.GetWeight() == WEIGHT_DONTKNOW )
215*21075d77SSteve Yin             {
216*21075d77SSteve Yin                 aFont.SetWeight( aDefaultVCLFont.GetWeight() );
217*21075d77SSteve Yin             }
218*21075d77SSteve Yin 
219*21075d77SSteve Yin             //if nColor is -1, it may indicate that the default color black is using.
220*21075d77SSteve Yin             if ( nColor == -1)
221*21075d77SSteve Yin             {
222*21075d77SSteve Yin                 nColor = aDefaultVCLFont.GetColor().GetColor();
223*21075d77SSteve Yin             }
224*21075d77SSteve Yin         }
225*21075d77SSteve Yin         */
226*21075d77SSteve Yin 
227*21075d77SSteve Yin         // MT: Adjustment stuff was introduced with the IA2 CWS, but adjustment is not a character attribute...
228*21075d77SSteve Yin         // In case we reintroduce it, use adjustment as extra parameter for the CharacterAttributesHelper...
229*21075d77SSteve Yin         /*
230*21075d77SSteve Yin         WinBits aBits = GetWindow()->GetStyle();
231*21075d77SSteve Yin         sal_Int16 nAdjust = -1;
232*21075d77SSteve Yin         if ( aBits & WB_LEFT )
233*21075d77SSteve Yin         {
234*21075d77SSteve Yin             nAdjust = style::ParagraphAdjust_LEFT;
235*21075d77SSteve Yin         }
236*21075d77SSteve Yin         else if ( aBits & WB_RIGHT )
237*21075d77SSteve Yin         {
238*21075d77SSteve Yin             nAdjust = style::ParagraphAdjust_RIGHT;
239*21075d77SSteve Yin         }
240*21075d77SSteve Yin         else if ( aBits & WB_CENTER )
241*21075d77SSteve Yin         {
242*21075d77SSteve Yin             nAdjust = style::ParagraphAdjust_CENTER;
243*21075d77SSteve Yin         }
244*21075d77SSteve Yin         */
245*21075d77SSteve Yin 
246cdf0e10cSrcweir         ::std::auto_ptr< CharacterAttributesHelper > pHelper( new CharacterAttributesHelper( aFont, nBackColor, nColor ) );
247*21075d77SSteve Yin 
248cdf0e10cSrcweir         aValues = pHelper->GetCharacterAttributes( aRequestedAttributes );
249cdf0e10cSrcweir     }
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     return aValues;
252cdf0e10cSrcweir }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir // -----------------------------------------------------------------------------
255cdf0e10cSrcweir 
getCharacterBounds(sal_Int32 nIndex)256cdf0e10cSrcweir awt::Rectangle VCLXAccessibleTextComponent::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
257cdf0e10cSrcweir {
258cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
261cdf0e10cSrcweir         throw IndexOutOfBoundsException();
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     awt::Rectangle aRect;
264cdf0e10cSrcweir     Control* pControl = static_cast< Control* >( GetWindow() );
265cdf0e10cSrcweir     if ( pControl )
266cdf0e10cSrcweir         aRect = AWTRectangle( pControl->GetCharacterBounds( nIndex ) );
267cdf0e10cSrcweir 
268cdf0e10cSrcweir     return aRect;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir // -----------------------------------------------------------------------------
272cdf0e10cSrcweir 
getCharacterCount()273cdf0e10cSrcweir sal_Int32 VCLXAccessibleTextComponent::getCharacterCount() throw (RuntimeException)
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     return OCommonAccessibleText::getCharacterCount();
278cdf0e10cSrcweir }
279cdf0e10cSrcweir 
280cdf0e10cSrcweir // -----------------------------------------------------------------------------
281cdf0e10cSrcweir 
getIndexAtPoint(const awt::Point & aPoint)282cdf0e10cSrcweir sal_Int32 VCLXAccessibleTextComponent::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
285cdf0e10cSrcweir 
286cdf0e10cSrcweir     sal_Int32 nIndex = -1;
287cdf0e10cSrcweir     Control* pControl = static_cast< Control* >( GetWindow() );
288cdf0e10cSrcweir     if ( pControl )
289cdf0e10cSrcweir         nIndex = pControl->GetIndexForPoint( VCLPoint( aPoint ) );
290cdf0e10cSrcweir 
291cdf0e10cSrcweir     return nIndex;
292cdf0e10cSrcweir }
293cdf0e10cSrcweir 
294cdf0e10cSrcweir // -----------------------------------------------------------------------------
295cdf0e10cSrcweir 
getSelectedText()296cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTextComponent::getSelectedText() throw (RuntimeException)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     return OCommonAccessibleText::getSelectedText();
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir // -----------------------------------------------------------------------------
304cdf0e10cSrcweir 
getSelectionStart()305cdf0e10cSrcweir sal_Int32 VCLXAccessibleTextComponent::getSelectionStart() throw (RuntimeException)
306cdf0e10cSrcweir {
307cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
308cdf0e10cSrcweir 
309cdf0e10cSrcweir     return OCommonAccessibleText::getSelectionStart();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir // -----------------------------------------------------------------------------
313cdf0e10cSrcweir 
getSelectionEnd()314cdf0e10cSrcweir sal_Int32 VCLXAccessibleTextComponent::getSelectionEnd() throw (RuntimeException)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     return OCommonAccessibleText::getSelectionEnd();
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir // -----------------------------------------------------------------------------
322cdf0e10cSrcweir 
setSelection(sal_Int32 nStartIndex,sal_Int32 nEndIndex)323cdf0e10cSrcweir sal_Bool VCLXAccessibleTextComponent::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
324cdf0e10cSrcweir {
325cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
328cdf0e10cSrcweir         throw IndexOutOfBoundsException();
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     return sal_False;
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir // -----------------------------------------------------------------------------
334cdf0e10cSrcweir 
getText()335cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTextComponent::getText() throw (RuntimeException)
336cdf0e10cSrcweir {
337cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
338cdf0e10cSrcweir 
339cdf0e10cSrcweir     return OCommonAccessibleText::getText();
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir // -----------------------------------------------------------------------------
343cdf0e10cSrcweir 
getTextRange(sal_Int32 nStartIndex,sal_Int32 nEndIndex)344cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleTextComponent::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
345cdf0e10cSrcweir {
346cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
347cdf0e10cSrcweir 
348cdf0e10cSrcweir     return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir // -----------------------------------------------------------------------------
352cdf0e10cSrcweir 
getTextAtIndex(sal_Int32 nIndex,sal_Int16 aTextType)353cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment VCLXAccessibleTextComponent::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
356cdf0e10cSrcweir 
357cdf0e10cSrcweir     return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir // -----------------------------------------------------------------------------
361cdf0e10cSrcweir 
getTextBeforeIndex(sal_Int32 nIndex,sal_Int16 aTextType)362cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment VCLXAccessibleTextComponent::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
363cdf0e10cSrcweir {
364cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir     return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir // -----------------------------------------------------------------------------
370cdf0e10cSrcweir 
getTextBehindIndex(sal_Int32 nIndex,sal_Int16 aTextType)371cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment VCLXAccessibleTextComponent::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
374cdf0e10cSrcweir 
375cdf0e10cSrcweir     return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
378cdf0e10cSrcweir // -----------------------------------------------------------------------------
379cdf0e10cSrcweir 
copyText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)380cdf0e10cSrcweir sal_Bool VCLXAccessibleTextComponent::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
381cdf0e10cSrcweir {
382cdf0e10cSrcweir     OExternalLockGuard aGuard( this );
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
385cdf0e10cSrcweir 
386cdf0e10cSrcweir     if ( GetWindow() )
387cdf0e10cSrcweir     {
388cdf0e10cSrcweir         Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
389cdf0e10cSrcweir         if ( xClipboard.is() )
390cdf0e10cSrcweir         {
391cdf0e10cSrcweir             ::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
392cdf0e10cSrcweir 
393cdf0e10cSrcweir             ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
394cdf0e10cSrcweir             const sal_uInt32 nRef = Application::ReleaseSolarMutex();
395cdf0e10cSrcweir             xClipboard->setContents( pDataObj, NULL );
396cdf0e10cSrcweir 
397cdf0e10cSrcweir             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
398cdf0e10cSrcweir             if( xFlushableClipboard.is() )
399cdf0e10cSrcweir                 xFlushableClipboard->flushClipboard();
400cdf0e10cSrcweir 
401cdf0e10cSrcweir             Application::AcquireSolarMutex( nRef );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir             bReturn = sal_True;
404cdf0e10cSrcweir         }
405cdf0e10cSrcweir     }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir     return bReturn;
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir // -----------------------------------------------------------------------------
411