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_editeng.hxx"
26 
27 //------------------------------------------------------------------------
28 //
29 // Global header
30 //
31 //------------------------------------------------------------------------
32 
33 #include <limits.h>
34 #include <vector>
35 #include <algorithm>
36 #include <vos/mutex.hxx>
37 #include <vcl/window.hxx>
38 #include <vcl/svapp.hxx>
39 #include <editeng/flditem.hxx>
40 #include <com/sun/star/uno/Any.hxx>
41 #include <com/sun/star/uno/Reference.hxx>
42 #include <com/sun/star/awt/Point.hpp>
43 #include <com/sun/star/awt/Rectangle.hpp>
44 #include <com/sun/star/lang/DisposedException.hpp>
45 #include <com/sun/star/accessibility/AccessibleRole.hpp>
46 #include <com/sun/star/accessibility/AccessibleTextType.hpp>
47 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
48 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
49 #include <comphelper/accessibleeventnotifier.hxx>
50 #include <comphelper/sequenceashashmap.hxx>
51 #include <unotools/accessiblestatesethelper.hxx>
52 #include <unotools/accessiblerelationsethelper.hxx>
53 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
54 #include <vcl/unohelp.hxx>
55 #include <editeng/editeng.hxx>
56 #include <editeng/unoprnms.hxx>
57 #include <editeng/unoipset.hxx>
58 #include <editeng/outliner.hxx>
59 #include <svl/intitem.hxx>
60 
61 //------------------------------------------------------------------------
62 //
63 // Project-local header
64 //
65 //------------------------------------------------------------------------
66 
67 #include <com/sun/star/beans/PropertyState.hpp>
68 
69 //!!!#include <svx/unoshape.hxx>
70 //!!!#include <svx/dialmgr.hxx>
71 //!!!#include "accessibility.hrc"
72 
73 #include <editeng/unolingu.hxx>
74 #include <editeng/unopracc.hxx>
75 #include "editeng/AccessibleEditableTextPara.hxx"
76 #include "AccessibleHyperlink.hxx"
77 
78 #include <svtools/colorcfg.hxx>
79 //IAccessibility2 Implementation 2009-----
80 #include <algorithm>
81 using namespace std;
82 #include "editeng.hrc"
83 #include <editeng/eerdll.hxx>
84 #include <editeng/numitem.hxx>
85 //-----IAccessibility2 Implementation 2009
86 
87 using namespace ::com::sun::star;
88 using namespace ::com::sun::star::beans;
89 using namespace ::com::sun::star::accessibility;
90 
91 
92 //------------------------------------------------------------------------
93 //
94 // AccessibleEditableTextPara implementation
95 //
96 //------------------------------------------------------------------------
97 
98 namespace accessibility
99 {
100 //IAccessibility2 Implementation 2009-----
101 
102     const SvxItemPropertySet* ImplGetSvxCharAndParaPropertiesSet()
103     {
104         // PropertyMap for character and paragraph properties
105         static const SfxItemPropertyMapEntry aPropMap[] =
106         {
107 			SVX_UNOEDIT_OUTLINER_PROPERTIES,
108             SVX_UNOEDIT_CHAR_PROPERTIES,
109             SVX_UNOEDIT_PARA_PROPERTIES,
110             SVX_UNOEDIT_NUMBERING_PROPERTIE,
111             {MAP_CHAR_LEN("TextUserDefinedAttributes"),     EE_CHAR_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
112             {MAP_CHAR_LEN("ParaUserDefinedAttributes"),     EE_PARA_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
113             {0,0,0,0,0,0}
114         };
115         static SvxItemPropertySet aPropSet( aPropMap, EditEngine::GetGlobalItemPool() );
116         return &aPropSet;
117     }
118 
119 
120     DBG_NAME( AccessibleEditableTextPara )
121 
122     // --> OD 2006-01-11 #i27138# - add parameter <_pParaManager>
123     AccessibleEditableTextPara::AccessibleEditableTextPara(
124                                 const uno::Reference< XAccessible >& rParent,
125                                 const AccessibleParaManager* _pParaManager )
126         : AccessibleTextParaInterfaceBase( m_aMutex ),
127           mnParagraphIndex( 0 ),
128           mnIndexInParent( 0 ),
129           mpEditSource( NULL ),
130           maEEOffset( 0, 0 ),
131           mxParent( rParent ),
132           // well, that's strictly (UNO) exception safe, though not
133           // really robust. We rely on the fact that this member is
134           // constructed last, and that the constructor body catches
135           // exceptions, thus no chance for exceptions once the Id is
136           // fetched. Nevertheless, normally should employ RAII here...
137           mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient()),
138           // --> OD 2006-01-11 #i27138#
139           mpParaManager( _pParaManager )
140           // <--
141     {
142 #ifdef DBG_UTIL
143         DBG_CTOR( AccessibleEditableTextPara, NULL );
144         OSL_TRACE( "AccessibleEditableTextPara received ID: %d\n", mnNotifierClientId );
145 #endif
146 
147 		try
148         {
149             // Create the state set.
150             ::utl::AccessibleStateSetHelper* pStateSet  = new ::utl::AccessibleStateSetHelper ();
151             mxStateSet = pStateSet;
152 
153             // these are always on
154             pStateSet->AddState( AccessibleStateType::MULTI_LINE );
155             pStateSet->AddState( AccessibleStateType::FOCUSABLE );
156             pStateSet->AddState( AccessibleStateType::VISIBLE );
157             pStateSet->AddState( AccessibleStateType::SHOWING );
158             pStateSet->AddState( AccessibleStateType::ENABLED );
159             pStateSet->AddState( AccessibleStateType::SENSITIVE );
160         }
161         catch( const uno::Exception& ) {}
162     }
163 
164     AccessibleEditableTextPara::~AccessibleEditableTextPara()
165     {
166         DBG_DTOR( AccessibleEditableTextPara, NULL );
167 
168         // sign off from event notifier
169         if( getNotifierClientId() != -1 )
170         {
171             try
172             {
173                 ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() );
174 #ifdef DBG_UTIL
175                 OSL_TRACE( "AccessibleEditableTextPara revoked ID: %d\n", mnNotifierClientId );
176 #endif
177             }
178             catch( const uno::Exception& ) {}
179         }
180     }
181 
182     ::rtl::OUString AccessibleEditableTextPara::implGetText()
183     {
184         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
185 
186         return GetTextRange( 0, GetTextLen() );
187     }
188 
189     ::com::sun::star::lang::Locale AccessibleEditableTextPara::implGetLocale()
190     {
191         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
192 
193         lang::Locale		aLocale;
194 
195         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
196                    "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
197 
198         // return locale of first character in the paragraph
199         return SvxLanguageToLocale(aLocale, GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 ));
200     }
201 
202     void AccessibleEditableTextPara::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
203     {
204         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
205 
206         sal_uInt16 nStart, nEnd;
207 
208         if( GetSelection( nStart, nEnd ) )
209         {
210             nStartIndex = nStart;
211             nEndIndex = nEnd;
212         }
213         else
214         {
215             // #102234# No exception, just set to 'invalid'
216             nStartIndex = -1;
217             nEndIndex = -1;
218         }
219     }
220 
221     void AccessibleEditableTextPara::implGetParagraphBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 /*nIndex*/ )
222     {
223         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
224         DBG_WARNING( "AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" );
225 
226         rBoundary.startPos = 0;
227 	//IAccessibility2 Implementation 2009-----
228         //rBoundary.endPos = GetTextLen();
229         ::rtl::OUString sText( implGetText() );
230         sal_Int32 nLength = sText.getLength();
231         rBoundary.endPos = nLength;
232 	//-----IAccessibility2 Implementation 2009
233     }
234 
235     void AccessibleEditableTextPara::implGetLineBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 nIndex )
236     {
237         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
238 
239         SvxTextForwarder&	rCacheTF = GetTextForwarder();
240         const sal_Int32		nParaIndex = GetParagraphIndex();
241 
242         DBG_ASSERT(nParaIndex >= 0 && nParaIndex <= USHRT_MAX,
243                    "AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow");
244 
245         const sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
246 
247         CheckPosition(nIndex);
248 
249         rBoundary.startPos = rBoundary.endPos = -1;
250 
251         const sal_uInt16 nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
252 
253         if( nIndex == nTextLen )
254         {
255             // #i17014# Special-casing one-behind-the-end character
256             if( nLineCount <= 1 )
257                 rBoundary.startPos = 0;
258             else
259                 rBoundary.startPos = nTextLen - rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ),
260                                                                      nLineCount-1 );
261 
262             rBoundary.endPos = nTextLen;
263         }
264         else
265         {
266             // normal line search
267             sal_uInt16 nLine;
268             sal_Int32 nCurIndex;
269             for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
270             {
271                 nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
272 
273                 if( nCurIndex > nIndex )
274                 {
275                     rBoundary.startPos = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
276                     rBoundary.endPos = nCurIndex;
277                     break;
278                 }
279             }
280         }
281     }
282 
283     int AccessibleEditableTextPara::getNotifierClientId() const
284     {
285         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
286 
287         return mnNotifierClientId;
288     }
289 
290     void AccessibleEditableTextPara::SetIndexInParent( sal_Int32 nIndex )
291     {
292         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
293 
294         mnIndexInParent = nIndex;
295     }
296 
297     sal_Int32 AccessibleEditableTextPara::GetIndexInParent() const
298     {
299         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
300 
301         return mnIndexInParent;
302     }
303 
304     void AccessibleEditableTextPara::SetParagraphIndex( sal_Int32 nIndex )
305     {
306         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
307 
308         sal_Int32 nOldIndex = mnParagraphIndex;
309 
310         mnParagraphIndex = nIndex;
311 
312         WeakBullet::HardRefType aChild( maImageBullet.get() );
313         if( aChild.is() )
314             aChild->SetParagraphIndex(mnParagraphIndex);
315 
316         try
317         {
318             if( nOldIndex != nIndex )
319             {
320 				uno::Any aOldDesc;
321 				uno::Any aOldName;
322 
323 				try
324 				{
325 					aOldDesc <<= getAccessibleDescription();
326 					aOldName <<= getAccessibleName();
327 				}
328 				catch( const uno::Exception& ) {} // optional behaviour
329                 // index and therefore description changed
330                 FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::makeAny( getAccessibleDescription() ), aOldDesc );
331                 FireEvent( AccessibleEventId::NAME_CHANGED, uno::makeAny( getAccessibleName() ), aOldName );
332             }
333         }
334         catch( const uno::Exception& ) {} // optional behaviour
335     }
336 
337     sal_Int32 AccessibleEditableTextPara::GetParagraphIndex() const SAL_THROW((uno::RuntimeException))
338     {
339         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
340 
341         return mnParagraphIndex;
342     }
343 
344     void AccessibleEditableTextPara::Dispose()
345     {
346         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
347 
348         int nClientId( getNotifierClientId() );
349 
350         // #108212# drop all references before notifying dispose
351         mxParent = NULL;
352         mnNotifierClientId = -1;
353         mpEditSource = NULL;
354 
355         // notify listeners
356         if( nClientId != -1 )
357         {
358             try
359             {
360                 uno::Reference < XAccessibleContext > xThis = getAccessibleContext();
361 
362                 // #106234# Delegate to EventNotifier
363                 ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis );
364 #ifdef DBG_UTIL
365                 OSL_TRACE( "Disposed ID: %d\n", nClientId );
366 #endif
367             }
368             catch( const uno::Exception& ) {}
369         }
370     }
371 
372     void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSource )
373     {
374         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
375 
376         WeakBullet::HardRefType aChild( maImageBullet.get() );
377         if( aChild.is() )
378             aChild->SetEditSource(pEditSource);
379 
380         if( !pEditSource )
381         {
382             // going defunc
383             UnSetState( AccessibleStateType::SHOWING );
384             UnSetState( AccessibleStateType::VISIBLE );
385             SetState( AccessibleStateType::INVALID );
386             SetState( AccessibleStateType::DEFUNC );
387 
388             Dispose();
389         }
390 //IAccessibility2 Implementation 2009-----
391 		mpEditSource = pEditSource;
392 //-----IAccessibility2 Implementation 2009
393         // #108900# Init last text content
394         try
395         {
396             TextChanged();
397         }
398         catch( const uno::RuntimeException& ) {}
399     }
400 
401     ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nStartEEIndex, sal_Int32 nEndEEIndex )
402     {
403         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
404 
405         // check overflow
406         DBG_ASSERT(nStartEEIndex >= 0 && nStartEEIndex <= USHRT_MAX &&
407                    nEndEEIndex >= 0 && nEndEEIndex <= USHRT_MAX &&
408                    GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
409                    "AccessibleEditableTextPara::MakeSelection: index value overflow");
410 
411 		sal_uInt16 nParaIndex = static_cast< sal_uInt16 >( GetParagraphIndex() );
412         return ESelection( nParaIndex, static_cast< sal_uInt16 >( nStartEEIndex ),
413                            nParaIndex, static_cast< sal_uInt16 >( nEndEEIndex ) );
414     }
415 
416     ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nEEIndex )
417     {
418         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
419 
420         return MakeSelection( nEEIndex, nEEIndex+1 );
421     }
422 
423     ESelection AccessibleEditableTextPara::MakeCursor( sal_Int32 nEEIndex )
424     {
425         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
426 
427         return MakeSelection( nEEIndex, nEEIndex );
428     }
429 
430     void AccessibleEditableTextPara::CheckIndex( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
431     {
432         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
433 
434         if( nIndex < 0 || nIndex >= getCharacterCount() )
435             throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character index out of bounds")),
436                                                   uno::Reference< uno::XInterface >
437                                                   ( static_cast< ::cppu::OWeakObject* > (this) ) );	// disambiguate hierarchy
438     }
439 
440     void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
441     {
442         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
443 
444         if( nIndex < 0 || nIndex > getCharacterCount() )
445             throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character position out of bounds")),
446                                                   uno::Reference< uno::XInterface >
447                                                   ( static_cast< ::cppu::OWeakObject* > (this) ) );	// disambiguate hierarchy
448     }
449 
450     void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
451     {
452         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
453 
454         CheckPosition( nStart );
455         CheckPosition( nEnd );
456     }
457 
458     sal_Bool AccessibleEditableTextPara::GetSelection( sal_uInt16& nStartPos, sal_uInt16& nEndPos ) SAL_THROW((uno::RuntimeException))
459     {
460         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
461 
462         ESelection aSelection;
463         sal_uInt16 nPara = static_cast< sal_uInt16 > ( GetParagraphIndex() );
464         if( !GetEditViewForwarder().GetSelection( aSelection ) )
465             return sal_False;
466 
467         if( aSelection.nStartPara < aSelection.nEndPara )
468         {
469             if( aSelection.nStartPara > nPara ||
470                 aSelection.nEndPara < nPara )
471                 return sal_False;
472 
473             if( nPara == aSelection.nStartPara )
474                 nStartPos = aSelection.nStartPos;
475             else
476                 nStartPos = 0;
477 
478             if( nPara == aSelection.nEndPara )
479                 nEndPos = aSelection.nEndPos;
480             else
481                 nEndPos = GetTextLen();
482         }
483         else
484         {
485             if( aSelection.nStartPara < nPara ||
486                 aSelection.nEndPara > nPara )
487                 return sal_False;
488 
489             if( nPara == aSelection.nStartPara )
490                 nStartPos = aSelection.nStartPos;
491             else
492                 nStartPos = GetTextLen();
493 
494             if( nPara == aSelection.nEndPara )
495                 nEndPos = aSelection.nEndPos;
496             else
497                 nEndPos = 0;
498         }
499 
500         return sal_True;
501     }
502 
503     String AccessibleEditableTextPara::GetText( sal_Int32 nIndex ) SAL_THROW((uno::RuntimeException))
504     {
505         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
506 
507         return GetTextForwarder().GetText( MakeSelection(nIndex) );
508     }
509 
510     String AccessibleEditableTextPara::GetTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) SAL_THROW((uno::RuntimeException))
511     {
512         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
513 
514         return GetTextForwarder().GetText( MakeSelection(nStartIndex, nEndIndex) );
515     }
516 
517     sal_uInt16 AccessibleEditableTextPara::GetTextLen() const SAL_THROW((uno::RuntimeException))
518     {
519         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
520 
521         return GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
522     }
523 
524     sal_Bool AccessibleEditableTextPara::IsVisible() const
525     {
526         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
527 
528         return mpEditSource ? sal_True : sal_False ;
529     }
530 
531     uno::Reference< XAccessibleText > AccessibleEditableTextPara::GetParaInterface( sal_Int32 nIndex )
532     {
533         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
534 
535         uno::Reference< XAccessible > xParent = getAccessibleParent();
536         if( xParent.is() )
537         {
538             uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
539             if( xParentContext.is() )
540             {
541                 uno::Reference< XAccessible > xPara = xParentContext->getAccessibleChild( nIndex );
542                 if( xPara.is() )
543                 {
544                     return uno::Reference< XAccessibleText > ( xPara, uno::UNO_QUERY );
545                 }
546             }
547         }
548 
549         return uno::Reference< XAccessibleText >();
550     }
551 
552     SvxEditSourceAdapter& AccessibleEditableTextPara::GetEditSource() const SAL_THROW((uno::RuntimeException))
553     {
554         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
555 
556         if( mpEditSource )
557             return *mpEditSource;
558         else
559             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No edit source, object is defunct")),
560                                         uno::Reference< uno::XInterface >
561                                         ( static_cast< ::cppu::OWeakObject* >
562                                           ( const_cast< AccessibleEditableTextPara* > (this) ) ) );	// disambiguate hierarchy
563     }
564 
565     SvxAccessibleTextAdapter& AccessibleEditableTextPara::GetTextForwarder() const SAL_THROW((uno::RuntimeException))
566     {
567         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
568 
569         SvxEditSourceAdapter& rEditSource = GetEditSource();
570         SvxAccessibleTextAdapter* pTextForwarder = rEditSource.GetTextForwarderAdapter();
571 
572         if( !pTextForwarder )
573             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch text forwarder, object is defunct")),
574                                         uno::Reference< uno::XInterface >
575                                         ( static_cast< ::cppu::OWeakObject* >
576                                           ( const_cast< AccessibleEditableTextPara* > (this) ) ) );	// disambiguate hierarchy
577 
578         if( pTextForwarder->IsValid() )
579             return *pTextForwarder;
580         else
581             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text forwarder is invalid, object is defunct")),
582                                         uno::Reference< uno::XInterface >
583                                         ( static_cast< ::cppu::OWeakObject* >
584                                           ( const_cast< AccessibleEditableTextPara* > (this) ) ) );	// disambiguate hierarchy
585     }
586 
587     SvxViewForwarder& AccessibleEditableTextPara::GetViewForwarder() const SAL_THROW((uno::RuntimeException))
588     {
589         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
590 
591         SvxEditSource& rEditSource = GetEditSource();
592         SvxViewForwarder* pViewForwarder = rEditSource.GetViewForwarder();
593 
594         if( !pViewForwarder )
595         {
596             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")),
597                                         uno::Reference< uno::XInterface >
598                                         ( static_cast< ::cppu::OWeakObject* >
599                                           ( const_cast< AccessibleEditableTextPara* > (this) ) ) );	// disambiguate hierarchy
600         }
601 
602         if( pViewForwarder->IsValid() )
603             return *pViewForwarder;
604         else
605             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")),
606                                         uno::Reference< uno::XInterface >
607                                         ( static_cast< ::cppu::OWeakObject* >
608                                           ( const_cast< AccessibleEditableTextPara* > (this) )  ) );	// disambiguate hierarchy
609     }
610 
611     SvxAccessibleTextEditViewAdapter& AccessibleEditableTextPara::GetEditViewForwarder( sal_Bool bCreate ) const SAL_THROW((uno::RuntimeException))
612     {
613         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
614 
615         SvxEditSourceAdapter& rEditSource = GetEditSource();
616         SvxAccessibleTextEditViewAdapter* pTextEditViewForwarder = rEditSource.GetEditViewForwarderAdapter( bCreate );
617 
618         if( !pTextEditViewForwarder )
619         {
620             if( bCreate )
621                 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")),
622                                             uno::Reference< uno::XInterface >
623                                             ( static_cast< ::cppu::OWeakObject* >
624                                               ( const_cast< AccessibleEditableTextPara* > (this) ) ) );	// disambiguate hierarchy
625             else
626                 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No view forwarder, object not in edit mode")),
627                                             uno::Reference< uno::XInterface >
628                                             ( static_cast< ::cppu::OWeakObject* >
629                                               ( const_cast< AccessibleEditableTextPara* > (this) ) ) );	// disambiguate hierarchy
630         }
631 
632         if( pTextEditViewForwarder->IsValid() )
633             return *pTextEditViewForwarder;
634         else
635         {
636             if( bCreate )
637                 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")),
638                                             uno::Reference< uno::XInterface >
639                                             ( static_cast< ::cppu::OWeakObject* >
640                                               ( const_cast< AccessibleEditableTextPara* > (this) )  ) );	// disambiguate hierarchy
641             else
642                 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object not in edit mode")),
643                                             uno::Reference< uno::XInterface >
644                                             ( static_cast< ::cppu::OWeakObject* >
645                                               ( const_cast< AccessibleEditableTextPara* > (this) )  ) );	// disambiguate hierarchy
646         }
647     }
648 
649     sal_Bool AccessibleEditableTextPara::HaveEditView() const
650     {
651         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
652 
653         SvxEditSource& rEditSource = GetEditSource();
654         SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder();
655 
656         if( !pViewForwarder )
657             return sal_False;
658 
659         if( !pViewForwarder->IsValid() )
660             return sal_False;
661 
662         return sal_True;
663     }
664 
665     sal_Bool AccessibleEditableTextPara::HaveChildren()
666     {
667         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
668 
669         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
670                    "AccessibleEditableTextPara::HaveChildren: paragraph index value overflow");
671 
672         return GetTextForwarder().HaveImageBullet( static_cast< sal_uInt16 >(GetParagraphIndex()) );
673     }
674 
675     sal_Bool AccessibleEditableTextPara::IsActive() const SAL_THROW((uno::RuntimeException))
676     {
677         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
678 
679         SvxEditSource& rEditSource = GetEditSource();
680         SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder();
681 
682         if( !pViewForwarder )
683             return sal_False;
684 
685         if( pViewForwarder->IsValid() )
686             return sal_False;
687         else
688             return sal_True;
689     }
690 
691     Rectangle AccessibleEditableTextPara::LogicToPixel( const Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder& rForwarder )
692     {
693         // convert to screen coordinates
694         return Rectangle( rForwarder.LogicToPixel( rRect.TopLeft(), rMapMode ),
695                           rForwarder.LogicToPixel( rRect.BottomRight(), rMapMode ) );
696     }
697 
698     const Point& AccessibleEditableTextPara::GetEEOffset() const
699     {
700         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
701 
702         return maEEOffset;
703     }
704 
705     void AccessibleEditableTextPara::SetEEOffset( const Point& rOffset )
706     {
707         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
708 
709         WeakBullet::HardRefType aChild( maImageBullet.get() );
710         if( aChild.is() )
711             aChild->SetEEOffset(rOffset);
712 
713         maEEOffset = rOffset;
714     }
715 
716     void AccessibleEditableTextPara::FireEvent(const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue) const
717     {
718         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
719 
720         uno::Reference < XAccessibleContext > xThis( const_cast< AccessibleEditableTextPara* > (this)->getAccessibleContext() );
721 
722         AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue);
723 
724         // #102261# Call global queue for focus events
725         if( nEventId == AccessibleEventId::STATE_CHANGED )
726             vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent );
727 
728         // #106234# Delegate to EventNotifier
729         if( getNotifierClientId() != -1 )
730             ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(),
731                                                              aEvent );
732     }
733 
734     void AccessibleEditableTextPara::GotPropertyEvent( const uno::Any& rNewValue, const sal_Int16 nEventId ) const
735     {
736         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
737 
738         FireEvent( nEventId, rNewValue );
739     }
740 
741     void AccessibleEditableTextPara::LostPropertyEvent( const uno::Any& rOldValue, const sal_Int16 nEventId ) const
742     {
743         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
744 
745         FireEvent( nEventId, uno::Any(), rOldValue );
746     }
747 
748     bool AccessibleEditableTextPara::HasState( const sal_Int16 nStateId )
749     {
750         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
751 
752         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
753         if( pStateSet != NULL )
754             return pStateSet->contains(nStateId) ? true : false;
755 
756         return false;
757     }
758 
759     void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId )
760     {
761         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
762 
763         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
764         if( pStateSet != NULL &&
765             !pStateSet->contains(nStateId) )
766         {
767             pStateSet->AddState( nStateId );
768 //IAccessibility2 Implementation 2009-----
769 		// MT: Removed method IsShapeParaFocusable which was introduced with IA2 - basically it was only about figuring out wether or not the window has the focus, should be solved differently
770 		// if(IsShapeParaFocusable())
771             GotPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
772 //-----IAccessibility2 Implementation 2009
773         }
774     }
775 
776     void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId )
777     {
778         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
779 
780         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
781         if( pStateSet != NULL &&
782             pStateSet->contains(nStateId) )
783         {
784             pStateSet->RemoveState( nStateId );
785             LostPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
786         }
787     }
788 
789     void AccessibleEditableTextPara::TextChanged()
790     {
791         ::rtl::OUString aCurrentString( OCommonAccessibleText::getText() );
792         uno::Any aDeleted;
793         uno::Any aInserted;
794         if( OCommonAccessibleText::implInitTextChangedEvent( maLastTextString, aCurrentString,
795                                                              aDeleted, aInserted) )
796         {
797             FireEvent( AccessibleEventId::TEXT_CHANGED, aInserted, aDeleted );
798             maLastTextString = aCurrentString;
799         }
800     }
801 
802     sal_Bool AccessibleEditableTextPara::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex )
803     {
804         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
805 
806         DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
807                    "AccessibleEditableTextPara::GetAttributeRun: index value overflow");
808 
809         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
810                    "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
811 
812         return GetTextForwarder().GetAttributeRun( nStartIndex,
813                                                    nEndIndex,
814                                                    static_cast< sal_uInt16 >(GetParagraphIndex()),
815                                                    static_cast< sal_uInt16 >(nIndex) );
816     }
817 
818     uno::Any SAL_CALL AccessibleEditableTextPara::queryInterface (const uno::Type & rType) throw (uno::RuntimeException)
819     {
820         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
821 
822         uno::Any aRet;
823 
824         // must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText
825         if ( rType == ::getCppuType((uno::Reference< XAccessibleText > *)0) )
826         {
827 	//IAccessibility2 Implementation 2009-----
828 			//	uno::Reference< XAccessibleText > aAccText = this;
829             uno::Reference< XAccessibleText > aAccText = static_cast< XAccessibleEditableText * >(this);
830 	//-----IAccessibility2 Implementation 2009
831             aRet <<= aAccText;
832         }
833         else if ( rType == ::getCppuType((uno::Reference< XAccessibleEditableText > *)0) )
834         {
835             uno::Reference< XAccessibleEditableText > aAccEditText = this;
836             aRet <<= aAccEditText;
837         }
838 	//IAccessibility2 Implementation 2009-----
839 	else if ( rType == ::getCppuType((uno::Reference< XAccessibleHypertext > *)0) )
840         {
841             uno::Reference< XAccessibleHypertext > aAccHyperText = this;
842             aRet <<= aAccHyperText;
843         }
844 	//-----IAccessibility2 Implementation 2009
845         else
846         {
847             aRet = AccessibleTextParaInterfaceBase::queryInterface(rType);
848         }
849 
850         return aRet;
851     }
852 
853 	// XAccessible
854     uno::Reference< XAccessibleContext > SAL_CALL AccessibleEditableTextPara::getAccessibleContext() throw (uno::RuntimeException)
855     {
856         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
857 
858         // We implement the XAccessibleContext interface in the same object
859         return uno::Reference< XAccessibleContext > ( this );
860     }
861 
862 	// XAccessibleContext
863     sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount() throw (uno::RuntimeException)
864     {
865         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
866 
867         ::vos::OGuard aGuard( Application::GetSolarMutex() );
868 
869         return HaveChildren() ? 1 : 0;
870     }
871 
872     uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
873     {
874         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
875 
876         ::vos::OGuard aGuard( Application::GetSolarMutex() );
877 
878         if( !HaveChildren() )
879             throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No childs available")),
880                                                   uno::Reference< uno::XInterface >
881                                                   ( static_cast< ::cppu::OWeakObject* > (this) ) );	// static_cast: disambiguate hierarchy
882 
883         if( i != 0 )
884             throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid child index")),
885                                                   uno::Reference< uno::XInterface >
886                                                   ( static_cast< ::cppu::OWeakObject* > (this) ) );	// static_cast: disambiguate hierarchy
887 
888         WeakBullet::HardRefType aChild( maImageBullet.get() );
889 
890         if( !aChild.is() )
891         {
892             // there is no hard reference available, create object then
893             AccessibleImageBullet* pChild = new AccessibleImageBullet( uno::Reference< XAccessible >( this ) );
894             uno::Reference< XAccessible > xChild( static_cast< ::cppu::OWeakObject* > (pChild), uno::UNO_QUERY );
895 
896             if( !xChild.is() )
897                 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Child creation failed")),
898                                             uno::Reference< uno::XInterface >
899                                             ( static_cast< ::cppu::OWeakObject* > (this) ) );
900 
901             aChild = WeakBullet::HardRefType( xChild, pChild );
902 
903             aChild->SetEditSource( &GetEditSource() );
904             aChild->SetParagraphIndex( GetParagraphIndex() );
905             aChild->SetIndexInParent( i );
906 
907             maImageBullet = aChild;
908         }
909 
910         return aChild.getRef();
911     }
912 
913     uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent() throw (uno::RuntimeException)
914     {
915         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
916 
917 #ifdef DBG_UTIL
918         if( !mxParent.is() )
919             DBG_TRACE( "AccessibleEditableTextPara::getAccessibleParent: no frontend set, did somebody forgot to call AccessibleTextHelper::SetEventSource()?");
920 #endif
921 
922         return mxParent;
923     }
924 
925     sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent() throw (uno::RuntimeException)
926     {
927         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
928 
929         return mnIndexInParent;
930     }
931 
932     sal_Int16 SAL_CALL AccessibleEditableTextPara::getAccessibleRole() throw (uno::RuntimeException)
933     {
934         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
935 
936         return AccessibleRole::PARAGRAPH;
937     }
938 
939     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleDescription() throw (uno::RuntimeException)
940     {
941         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
942 	//IAccessibility2 Implementation 2009-----
943         ::vos::OGuard aGuard( Application::GetSolarMutex() );
944 
945         // append first 40 characters from text, or first line, if shorter
946         // (writer takes first sentence here, but that's not supported
947         // from EditEngine)
948         // throws if defunc
949         ::rtl::OUString aLine;
950 
951         if( getCharacterCount() )
952             aLine = getTextAtIndex(0, AccessibleTextType::LINE).SegmentText;
953 
954         // Get the string from the resource for the specified id.
955         String sStr = ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION ) ) );
956         String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() );
957 		sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )),
958                                sParaIndex );
959 
960         if( aLine.getLength() > MaxDescriptionLen )
961         {
962             ::rtl::OUString aCurrWord;
963             sal_Int32 i;
964 
965             // search backward from MaxDescriptionLen for previous word start
966             for( aCurrWord=getTextAtIndex(MaxDescriptionLen, AccessibleTextType::WORD).SegmentText,
967                      i=MaxDescriptionLen,
968                      aLine=::rtl::OUString();
969                  i>=0;
970                  --i )
971             {
972                 if( getTextAtIndex(i, AccessibleTextType::WORD).SegmentText != aCurrWord )
973                 {
974                     if( i == 0 )
975                         // prevent completely empty string
976                         aLine = getTextAtIndex(0, AccessibleTextType::WORD).SegmentText;
977                     else
978                         aLine = getTextRange(0, i);
979                 }
980             }
981         }
982 
983         return ::rtl::OUString( sStr ) + aLine;
984 	//-----IAccessibility2 Implementation 2009
985     }
986 
987     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName() throw (uno::RuntimeException)
988     {
989         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
990 
991         ::vos::OGuard aGuard( Application::GetSolarMutex() );
992 
993         // throws if defunc
994         sal_Int32 nPara( GetParagraphIndex() );
995 
996         // Get the string from the resource for the specified id.
997         String sStr = ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_PARAGRAPH_NAME) ) );
998         String sParaIndex = ::rtl::OUString::valueOf( nPara );
999 		sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )),
1000                                sParaIndex );
1001 
1002         return ::rtl::OUString( sStr );
1003     }
1004 
1005     uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleEditableTextPara::getAccessibleRelationSet() throw (uno::RuntimeException)
1006     {
1007         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1008 
1009         // --> OD 2006-01-11 #i27138# - provide relations CONTENT_FLOWS_FROM
1010         // and CONTENT_FLOWS_TO
1011         if ( mpParaManager )
1012         {
1013             utl::AccessibleRelationSetHelper* pAccRelSetHelper =
1014                                         new utl::AccessibleRelationSetHelper();
1015             sal_Int32 nMyParaIndex( GetParagraphIndex() );
1016             // relation CONTENT_FLOWS_FROM
1017             if ( nMyParaIndex > 0 &&
1018                  mpParaManager->IsReferencable( nMyParaIndex - 1 ) )
1019             {
1020                 uno::Sequence<uno::Reference<XInterface> > aSequence(1);
1021                 aSequence[0] =
1022                     mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().getRef();
1023                 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM,
1024                                             aSequence );
1025                 pAccRelSetHelper->AddRelation( aAccRel );
1026             }
1027 
1028             // relation CONTENT_FLOWS_TO
1029             if ( (nMyParaIndex + 1) < (sal_Int32)mpParaManager->GetNum() &&
1030                  mpParaManager->IsReferencable( nMyParaIndex + 1 ) )
1031             {
1032                 uno::Sequence<uno::Reference<XInterface> > aSequence(1);
1033                 aSequence[0] =
1034                     mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().getRef();
1035                 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO,
1036                                             aSequence );
1037                 pAccRelSetHelper->AddRelation( aAccRel );
1038             }
1039 
1040             return pAccRelSetHelper;
1041         }
1042         else
1043         {
1044             // no relations, therefore empty
1045             return uno::Reference< XAccessibleRelationSet >();
1046         }
1047         // <--
1048     }
1049 
1050     uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() throw (uno::RuntimeException)
1051     {
1052         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1053 
1054         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1055 
1056         // Create a copy of the state set and return it.
1057         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
1058 
1059         if( !pStateSet )
1060             return uno::Reference<XAccessibleStateSet>();
1061 //IAccessibility2 Implementation 2009-----
1062 		uno::Reference<XAccessibleStateSet> xParentStates;
1063 		if (getAccessibleParent().is())
1064 		{
1065 			uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
1066 			xParentStates = xParentContext->getAccessibleStateSet();
1067 		}
1068 		if (xParentStates.is() && xParentStates->contains(AccessibleStateType::EDITABLE) )
1069 		{
1070 			pStateSet->AddState(AccessibleStateType::EDITABLE);
1071 		}
1072 //-----IAccessibility2 Implementation 2009
1073         return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) );
1074     }
1075 
1076     lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale() throw (IllegalAccessibleComponentStateException, uno::RuntimeException)
1077     {
1078         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1079 
1080         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1081 
1082         return implGetLocale();
1083     }
1084 
1085     void SAL_CALL AccessibleEditableTextPara::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
1086     {
1087         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1088 
1089         if( getNotifierClientId() != -1 )
1090             ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener );
1091     }
1092 
1093     void SAL_CALL AccessibleEditableTextPara::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
1094     {
1095         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1096 
1097         if( getNotifierClientId() != -1 )
1098             ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
1099     }
1100 
1101 	// XAccessibleComponent
1102     sal_Bool SAL_CALL AccessibleEditableTextPara::containsPoint( const awt::Point& aTmpPoint ) throw (uno::RuntimeException)
1103     {
1104         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1105 
1106         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1107 
1108         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1109                    "AccessibleEditableTextPara::contains: index value overflow");
1110 
1111         awt::Rectangle aTmpRect = getBounds();
1112         Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), Size(aTmpRect.Width, aTmpRect.Height) );
1113         Point aPoint( aTmpPoint.X, aTmpPoint.Y );
1114 
1115         return aRect.IsInside( aPoint );
1116     }
1117 
1118     uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (uno::RuntimeException)
1119     {
1120         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1121 
1122         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1123 
1124         if( HaveChildren() )
1125         {
1126             // #103862# No longer need to make given position relative
1127             Point aPoint( _aPoint.X, _aPoint.Y );
1128 
1129             // respect EditEngine offset to surrounding shape/cell
1130             aPoint -= GetEEOffset();
1131 
1132             // convert to EditEngine coordinate system
1133             SvxTextForwarder& rCacheTF = GetTextForwarder();
1134             Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) );
1135 
1136             EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 > (GetParagraphIndex()) );
1137 
1138             if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
1139                 aBulletInfo.bVisible &&
1140                 aBulletInfo.nType == SVX_NUM_BITMAP )
1141             {
1142                 Rectangle aRect = aBulletInfo.aBounds;
1143 
1144                 if( aRect.IsInside( aLogPoint ) )
1145                     return getAccessibleChild(0);
1146             }
1147         }
1148 
1149         // no children at all, or none at given position
1150         return uno::Reference< XAccessible >();
1151     }
1152 
1153     awt::Rectangle SAL_CALL AccessibleEditableTextPara::getBounds() throw (uno::RuntimeException)
1154     {
1155         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1156 
1157         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1158 
1159         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1160                    "AccessibleEditableTextPara::getBounds: index value overflow");
1161 
1162         SvxTextForwarder& rCacheTF = GetTextForwarder();
1163         Rectangle aRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
1164 
1165         // convert to screen coordinates
1166         Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
1167                                                                           rCacheTF.GetMapMode(),
1168                                                                           GetViewForwarder() );
1169 
1170         // offset from shape/cell
1171         Point aOffset = GetEEOffset();
1172 
1173         return awt::Rectangle( aScreenRect.Left() + aOffset.X(),
1174                                aScreenRect.Top() + aOffset.Y(),
1175                                aScreenRect.GetSize().Width(),
1176                                aScreenRect.GetSize().Height() );
1177     }
1178 
1179     awt::Point SAL_CALL AccessibleEditableTextPara::getLocation(  ) throw (uno::RuntimeException)
1180     {
1181         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1182 
1183         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1184 
1185         awt::Rectangle aRect = getBounds();
1186 
1187         return awt::Point( aRect.X, aRect.Y );
1188     }
1189 
1190     awt::Point SAL_CALL AccessibleEditableTextPara::getLocationOnScreen(  ) throw (uno::RuntimeException)
1191     {
1192         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1193 
1194         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1195 
1196         // relate us to parent
1197         uno::Reference< XAccessible > xParent = getAccessibleParent();
1198         if( xParent.is() )
1199         {
1200             uno::Reference< XAccessibleComponent > xParentComponent( xParent, uno::UNO_QUERY );
1201             if( xParentComponent.is() )
1202             {
1203                 awt::Point aRefPoint = xParentComponent->getLocationOnScreen();
1204                 awt::Point aPoint = getLocation();
1205                 aPoint.X += aRefPoint.X;
1206                 aPoint.Y += aRefPoint.Y;
1207 
1208                 return aPoint;
1209             }
1210             // --> OD 2009-12-16 #i88070#
1211             // fallback to parent's <XAccessibleContext> instance
1212             else
1213             {
1214                 uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
1215                 if ( xParentContext.is() )
1216                 {
1217                     uno::Reference< XAccessibleComponent > xParentContextComponent( xParentContext, uno::UNO_QUERY );
1218                     if( xParentContextComponent.is() )
1219                     {
1220                         awt::Point aRefPoint = xParentContextComponent->getLocationOnScreen();
1221                         awt::Point aPoint = getLocation();
1222                         aPoint.X += aRefPoint.X;
1223                         aPoint.Y += aRefPoint.Y;
1224 
1225                         return aPoint;
1226                     }
1227                 }
1228             }
1229             // <--
1230         }
1231 
1232         throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot access parent")),
1233                                     uno::Reference< uno::XInterface >
1234                                     ( static_cast< XAccessible* > (this) ) );	// disambiguate hierarchy
1235     }
1236 
1237     awt::Size SAL_CALL AccessibleEditableTextPara::getSize(  ) throw (uno::RuntimeException)
1238     {
1239         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1240 
1241         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1242 
1243         awt::Rectangle aRect = getBounds();
1244 
1245         return awt::Size( aRect.Width, aRect.Height );
1246     }
1247 
1248     void SAL_CALL AccessibleEditableTextPara::grabFocus(  ) throw (uno::RuntimeException)
1249     {
1250         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1251 
1252         // set cursor to this paragraph
1253         setSelection(0,0);
1254     }
1255 
1256     sal_Int32 SAL_CALL AccessibleEditableTextPara::getForeground(  ) throw (::com::sun::star::uno::RuntimeException)
1257     {
1258         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1259 
1260         // #104444# Added to XAccessibleComponent interface
1261 		svtools::ColorConfig aColorConfig;
1262 	    sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
1263         return static_cast<sal_Int32>(nColor);
1264     }
1265 
1266     sal_Int32 SAL_CALL AccessibleEditableTextPara::getBackground(  ) throw (::com::sun::star::uno::RuntimeException)
1267     {
1268         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1269 
1270         // #104444# Added to XAccessibleComponent interface
1271         Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor() );
1272 
1273         // the background is transparent
1274         aColor.SetTransparency( 0xFF);
1275 
1276         return static_cast<sal_Int32>( aColor.GetColor() );
1277     }
1278 
1279 	// XAccessibleText
1280     sal_Int32 SAL_CALL AccessibleEditableTextPara::getCaretPosition() throw (uno::RuntimeException)
1281     {
1282         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1283 
1284         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1285 
1286         if( !HaveEditView() )
1287             return -1;
1288 
1289         ESelection aSelection;
1290         if( GetEditViewForwarder().GetSelection( aSelection ) &&
1291             GetParagraphIndex() == aSelection.nEndPara )
1292         {
1293             // caret is always nEndPara,nEndPos
1294 			//IAccessibility2 Implementation 2009-----
1295 			EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
1296 			if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
1297 				aBulletInfo.bVisible &&
1298 				aBulletInfo.nType != SVX_NUM_BITMAP )
1299 			{
1300 				sal_Int32 nBulletLen = aBulletInfo.aText.Len();
1301 				if( aSelection.nEndPos - nBulletLen >= 0 )
1302 					return aSelection.nEndPos - nBulletLen;
1303 			}
1304 			//-----IAccessibility2 Implementation 2009
1305             return aSelection.nEndPos;
1306         }
1307 
1308         // not within this paragraph
1309         return -1;
1310     }
1311 
1312     sal_Bool SAL_CALL AccessibleEditableTextPara::setCaretPosition( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1313     {
1314         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1315 
1316         return setSelection(nIndex, nIndex);
1317     }
1318 
1319     sal_Unicode SAL_CALL AccessibleEditableTextPara::getCharacter( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1320     {
1321         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1322 
1323         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1324 
1325         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1326                    "AccessibleEditableTextPara::getCharacter: index value overflow");
1327 
1328         return OCommonAccessibleText::getCharacter( nIndex );
1329     }
1330     //IAccessibility2 Implementation 2009-----
1331 	static uno::Sequence< ::rtl::OUString > getAttributeNames()
1332 	{
1333 		static uno::Sequence< ::rtl::OUString >* pNames = NULL;
1334 
1335 		if( pNames == NULL )
1336 		{
1337 			uno::Sequence< ::rtl::OUString >* pSeq = new uno::Sequence< ::rtl::OUString >( 21 );
1338 			::rtl::OUString* pStrings = pSeq->getArray();
1339 			sal_Int32 i = 0;
1340 	#define STR(x) pStrings[i++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x))
1341 			//STR("CharBackColor");
1342 			STR("CharColor");
1343 	  STR("CharContoured");
1344 	  STR("CharEmphasis");
1345 			STR("CharEscapement");
1346 			STR("CharFontName");
1347 			STR("CharHeight");
1348 			STR("CharPosture");
1349 	  STR("CharShadowed");
1350 			STR("CharStrikeout");
1351 			STR("CharUnderline");
1352 			STR("CharUnderlineColor");
1353 			STR("CharWeight");
1354 		        STR("NumberingLevel");
1355 			STR("NumberingRules");
1356 			STR("ParaAdjust");
1357 			STR("ParaBottomMargin");
1358 			STR("ParaFirstLineIndent");
1359 			STR("ParaLeftMargin");
1360 			STR("ParaLineSpacing");
1361 			STR("ParaRightMargin");
1362 			STR("ParaTabStops");
1363 	#undef STR
1364 			DBG_ASSERT( i == pSeq->getLength(), "Please adjust length" );
1365 			if( i != pSeq->getLength() )
1366 				pSeq->realloc( i );
1367 			pNames = pSeq;
1368 		}
1369 		return *pNames;
1370 	}
1371 //-----IAccessibility2 Implementation 2009
1372 	struct IndexCompare
1373 	{
1374 		const PropertyValue* pValues;
1375 		IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {}
1376 		bool operator() ( const sal_Int32& a, const sal_Int32& b ) const
1377 		{
1378 			return (pValues[a].Name < pValues[b].Name) ? true : false;
1379 		}
1380 	};
1381 
1382 	String AccessibleEditableTextPara::GetFieldTypeNameAtIndex(sal_Int32 nIndex)
1383 	{
1384 		String strFldType;
1385         SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();
1386 		//For field object info
1387 		sal_Int32 nParaIndex = GetParagraphIndex();
1388 		sal_Int32 nAllFieldLen = 0;
1389 		sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1;
1390 		EFieldInfo ree;
1391 		sal_Int32  reeBegin, reeEnd;
1392 		sal_Int32 nFieldType = -1;
1393 		for(sal_uInt16 j = 0; j < nField; j++)
1394 		{
1395 			ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j);
1396 			reeBegin  = ree.aPosition.nIndex + nAllFieldLen;
1397 			reeEnd = reeBegin + ree.aCurrentText.Len();
1398 			nAllFieldLen += (ree.aCurrentText.Len() - 1);
1399 			if( reeBegin > nIndex )
1400 			{
1401 				break;
1402 			}
1403 			if(  nIndex >= reeBegin && nIndex < reeEnd )
1404 			{
1405 				nFoundFieldIndex = j;
1406 				break;
1407 			}
1408 		}
1409 		if( nFoundFieldIndex >= 0  )
1410 		{
1411 			// So we get a field, check its type now.
1412 			nFieldType = ree.pFieldItem->GetField()->GetClassId() ;
1413 		}
1414 		switch(nFieldType)
1415 		{
1416 		case SVX_DATEFIELD:
1417 			{
1418 				const SvxDateField* pDateField = static_cast< const SvxDateField* >(ree.pFieldItem->GetField());
1419 				if (pDateField)
1420 				{
1421 					if (pDateField->GetType() == SVXDATETYPE_FIX)
1422 						strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (fixed)"));
1423 					else if (pDateField->GetType() == SVXDATETYPE_VAR)
1424 						strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (variable)"));
1425 				}
1426 			}
1427 			break;
1428 		case SVX_PAGEFIELD:
1429 			strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-number"));
1430 			break;
1431 		//support the sheet name & pages fields
1432 		case SVX_PAGESFIELD:
1433 				strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-count"));
1434 			break;
1435 		case SVX_TABLEFIELD:
1436 				strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sheet-name"));
1437 			break;
1438 		//End
1439 		case SVX_TIMEFIELD:
1440 			strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time"));
1441 			break;
1442 		case SVX_EXT_TIMEFIELD:
1443 			{
1444 				const SvxExtTimeField* pTimeField = static_cast< const SvxExtTimeField* >(ree.pFieldItem->GetField());
1445 				if (pTimeField)
1446 				{
1447 					if (pTimeField->GetType() == SVXTIMETYPE_FIX)
1448 						strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (fixed)"));
1449 					else if (pTimeField->GetType() == SVXTIMETYPE_VAR)
1450 						strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (variable)"));
1451 				}
1452 			}
1453 			break;
1454 		case SVX_AUTHORFIELD:
1455 			strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("author"));
1456 			break;
1457 		case SVX_EXT_FILEFIELD:
1458 		case SVX_FILEFIELD:
1459 			strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file name"));
1460 		default:
1461 			break;
1462 		}
1463 		return strFldType;
1464 	}
1465 
1466     uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1467     {
1468         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1469         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1470 
1471 		//IAccessibility2 Implementation 2009-----
1472 		//Skip the bullet range to ingnore the bullet text
1473 		SvxTextForwarder& rCacheTF = GetTextForwarder();
1474 		EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
1475 		if (aBulletInfo.bVisible)
1476 			nIndex += aBulletInfo.aText.Len();
1477 		if (nIndex != 0 && nIndex >= getCharacterCount())
1478 			nIndex = getCharacterCount()-1;
1479 		//
1480 		if (nIndex != 0)
1481 			CheckIndex(nIndex);	// may throw IndexOutOfBoundsException
1482 
1483 		bool bSupplementalMode = false;
1484 		uno::Sequence< ::rtl::OUString > aPropertyNames = rRequestedAttributes;
1485 		if (aPropertyNames.getLength() == 0)
1486 		{
1487 			bSupplementalMode = true;
1488 			aPropertyNames = getAttributeNames();
1489 		}
1490         // get default attribues...
1491         ::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( aPropertyNames ) );
1492 
1493         // ... and override them with the direct attributes from the specific position
1494         uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, aPropertyNames ) );
1495 		//-----IAccessibility2 Implementation 2009
1496         sal_Int32 nRunAttribs = aRunAttribs.getLength();
1497         const beans::PropertyValue *pRunAttrib = aRunAttribs.getConstArray();
1498         for (sal_Int32 k = 0;  k < nRunAttribs;  ++k)
1499         {
1500             const beans::PropertyValue &rRunAttrib = pRunAttrib[k];
1501             aPropHashMap[ rRunAttrib.Name ] = rRunAttrib.Value; //!! should not only be the value !!
1502         }
1503 #ifdef TL_DEBUG
1504         {
1505             uno::Sequence< rtl::OUString > aNames(1);
1506             aNames.getArray()[0] = rtl::OUString::createFromAscii("CharHeight");
1507             const rtl::OUString *pNames = aNames.getConstArray();
1508             const uno::Sequence< beans::PropertyValue > aAttribs( getRunAttributes( nIndex, aNames ) );
1509             const beans::PropertyValue *pAttribs = aAttribs.getConstArray();
1510             double d1 = -1.0;
1511             float  f1 = -1.0;
1512             if (aAttribs.getLength())
1513             {
1514                 uno::Any aAny( pAttribs[0].Value );
1515                 aAny >>= d1;
1516                 aAny >>= f1;
1517             }
1518             int i = 3;
1519         }
1520 #endif
1521 
1522         // get resulting sequence
1523         uno::Sequence< beans::PropertyValue > aRes;
1524         aPropHashMap >> aRes;
1525 
1526         // since SequenceAsHashMap ignores property handles and property state
1527         // we have to restore the property state here (property handles are
1528         // of no use to the accessibility API).
1529         sal_Int32 nRes = aRes.getLength();
1530         beans::PropertyValue *pRes = aRes.getArray();
1531         for (sal_Int32 i = 0;  i < nRes;  ++i)
1532         {
1533 			beans::PropertyValue &rRes = pRes[i];
1534             sal_Bool bIsDirectVal = sal_False;
1535             for (sal_Int32 k = 0;  k < nRunAttribs && !bIsDirectVal;  ++k)
1536             {
1537                 if (rRes.Name == pRunAttrib[k].Name)
1538                     bIsDirectVal = sal_True;
1539             }
1540             rRes.Handle = -1;
1541             rRes.State  = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
1542         }
1543 		//IAccessibility2 Implementation 2009-----
1544 		if( bSupplementalMode )
1545 		{
1546 			_correctValues( nIndex, aRes );
1547 			// NumberingPrefix
1548 			nRes = aRes.getLength();
1549 			aRes.realloc( nRes + 1 );
1550 			pRes = aRes.getArray();
1551 			beans::PropertyValue &rRes = pRes[nRes];
1552 			rRes.Name = rtl::OUString::createFromAscii("NumberingPrefix");
1553 			::rtl::OUString numStr;
1554 			if (aBulletInfo.nType != SVX_NUM_CHAR_SPECIAL && aBulletInfo.nType != SVX_NUM_BITMAP)
1555 				numStr = (::rtl::OUString)aBulletInfo.aText;
1556 			rRes.Value <<= numStr;
1557 			rRes.Handle = -1;
1558 			rRes.State = PropertyState_DIRECT_VALUE;
1559 			//-----IAccessibility2 Implementation 2009
1560 			//For field object.
1561 			String strFieldType = GetFieldTypeNameAtIndex(nIndex);
1562 			if (strFieldType.Len() > 0)
1563 			{
1564 				nRes = aRes.getLength();
1565 				aRes.realloc( nRes + 1 );
1566 				pRes = aRes.getArray();
1567 				beans::PropertyValue &rResField = pRes[nRes];
1568 				beans::PropertyValue aFieldType;
1569 				rResField.Name = rtl::OUString::createFromAscii("FieldType");
1570 				rResField.Value <<= rtl::OUString(strFieldType.ToLowerAscii());
1571 				rResField.Handle = -1;
1572 				rResField.State = PropertyState_DIRECT_VALUE;
1573         }
1574 		//sort property values
1575 		// build sorted index array
1576 		sal_Int32 nLength = aRes.getLength();
1577 		const beans::PropertyValue* pPairs = aRes.getConstArray();
1578 		sal_Int32* pIndices = new sal_Int32[nLength];
1579 		sal_Int32 i = 0;
1580 		for( i = 0; i < nLength; i++ )
1581 			pIndices[i] = i;
1582 		sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) );
1583 		// create sorted sequences accoring to index array
1584 		uno::Sequence<beans::PropertyValue> aNewValues( nLength );
1585 		beans::PropertyValue* pNewValues = aNewValues.getArray();
1586 		for( i = 0; i < nLength; i++ )
1587 		{
1588 			pNewValues[i] = pPairs[pIndices[i]];
1589 		}
1590 		delete[] pIndices;
1591 		//
1592         return aNewValues;
1593 		}
1594 		return aRes;
1595     }
1596 
1597     awt::Rectangle SAL_CALL AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1598     {
1599         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1600 
1601         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1602 
1603         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1604                    "AccessibleEditableTextPara::getCharacterBounds: index value overflow");
1605 
1606         // #108900# Have position semantics now for nIndex, as
1607         // one-past-the-end values are legal, too.
1608         CheckPosition( nIndex );
1609 
1610         SvxTextForwarder& rCacheTF = GetTextForwarder();
1611         Rectangle aRect = rCacheTF.GetCharBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ), static_cast< sal_uInt16 >( nIndex ) );
1612 
1613         // convert to screen
1614         Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
1615                                                                           rCacheTF.GetMapMode(),
1616                                                                           GetViewForwarder() );
1617         // #109864# offset from parent (paragraph), but in screen
1618         // coordinates. This makes sure the internal text offset in
1619         // the outline view forwarder gets cancelled out here
1620         awt::Rectangle aParaRect( getBounds() );
1621         aScreenRect.Move( -aParaRect.X, -aParaRect.Y );
1622 
1623         // offset from shape/cell
1624         Point aOffset = GetEEOffset();
1625 
1626         return awt::Rectangle( aScreenRect.Left() + aOffset.X(),
1627                                aScreenRect.Top() + aOffset.Y(),
1628                                aScreenRect.GetSize().Width(),
1629                                aScreenRect.GetSize().Height() );
1630     }
1631 
1632     sal_Int32 SAL_CALL AccessibleEditableTextPara::getCharacterCount() throw (uno::RuntimeException)
1633     {
1634         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1635 
1636         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1637 
1638         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1639                    "AccessibleEditableTextPara::getCharacterCount: index value overflow");
1640 
1641         return OCommonAccessibleText::getCharacterCount();
1642     }
1643 
1644     sal_Int32 SAL_CALL AccessibleEditableTextPara::getIndexAtPoint( const awt::Point& rPoint ) throw (uno::RuntimeException)
1645     {
1646         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1647 
1648         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1649 	//IAccessibility2 Implementation 2009-----
1650 	if ((rPoint.X <= 0) && (rPoint.Y <= 0))
1651 		return 0;
1652 	//-----IAccessibility2 Implementation 2009
1653         sal_uInt16 nPara, nIndex;
1654 
1655         // offset from surrounding cell/shape
1656         Point aOffset( GetEEOffset() );
1657         Point aPoint( rPoint.X - aOffset.X(), rPoint.Y - aOffset.Y() );
1658 
1659         // convert to logical coordinates
1660         SvxTextForwarder& rCacheTF = GetTextForwarder();
1661         Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) );
1662 
1663         // re-offset to parent (paragraph)
1664         Rectangle aParaRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
1665         aLogPoint.Move( aParaRect.Left(), aParaRect.Top() );
1666 
1667         if( rCacheTF.GetIndexAtPoint( aLogPoint, nPara, nIndex ) &&
1668             GetParagraphIndex() == nPara )
1669         {
1670             // #102259# Double-check if we're _really_ on the given character
1671             try
1672             {
1673                 awt::Rectangle aRect1( getCharacterBounds(nIndex) );
1674                 Rectangle aRect2( aRect1.X, aRect1.Y,
1675                                   aRect1.Width + aRect1.X, aRect1.Height + aRect1.Y );
1676                 if( aRect2.IsInside( Point( rPoint.X, rPoint.Y ) ) )
1677                     return nIndex;
1678                 else
1679                     return -1;
1680             }
1681             catch( const lang::IndexOutOfBoundsException& )
1682             {
1683                 // #103927# Don't throw for invalid nIndex values
1684                 return -1;
1685             }
1686         }
1687         else
1688         {
1689             // not within our paragraph
1690             return -1;
1691         }
1692     }
1693 
1694     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getSelectedText() throw (uno::RuntimeException)
1695     {
1696         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1697 
1698         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1699 
1700         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1701                    "AccessibleEditableTextPara::getSelectedText: index value overflow");
1702 
1703         if( !HaveEditView() )
1704             return ::rtl::OUString();
1705 
1706         return OCommonAccessibleText::getSelectedText();
1707     }
1708 
1709     sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionStart() throw (uno::RuntimeException)
1710     {
1711         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1712 
1713         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1714 
1715         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1716                    "AccessibleEditableTextPara::getSelectionStart: index value overflow");
1717 
1718         if( !HaveEditView() )
1719             return -1;
1720 
1721         return OCommonAccessibleText::getSelectionStart();
1722     }
1723 
1724     sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionEnd() throw (uno::RuntimeException)
1725     {
1726         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1727 
1728         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1729 
1730         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1731                    "AccessibleEditableTextPara::getSelectionEnd: index value overflow");
1732 
1733         if( !HaveEditView() )
1734             return -1;
1735 
1736         return OCommonAccessibleText::getSelectionEnd();
1737     }
1738 
1739     sal_Bool SAL_CALL AccessibleEditableTextPara::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1740     {
1741         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1742 
1743         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1744 
1745         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1746                    "AccessibleEditableTextPara::setSelection: paragraph index value overflow");
1747 
1748         CheckRange(nStartIndex, nEndIndex);
1749 
1750         try
1751         {
1752             SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
1753             return rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
1754         }
1755         catch( const uno::RuntimeException& )
1756         {
1757             return sal_False;
1758         }
1759     }
1760 
1761     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getText() throw (uno::RuntimeException)
1762     {
1763         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1764 
1765         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1766 
1767         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1768                    "AccessibleEditableTextPara::getText: paragraph index value overflow");
1769 
1770         return OCommonAccessibleText::getText();
1771     }
1772 
1773     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1774     {
1775         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1776 
1777         ::vos::OGuard aGuard( Application::GetSolarMutex() );
1778 
1779         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1780                    "AccessibleEditableTextPara::getTextRange: paragraph index value overflow");
1781 
1782         return OCommonAccessibleText::getTextRange(nStartIndex, nEndIndex);
1783     }
1784 //IAccessibility2 Implementation 2009-----
1785 	void AccessibleEditableTextPara::_correctValues( const sal_Int32 /* nIndex */,
1786 										   uno::Sequence< PropertyValue >& rValues)
1787 	{
1788 		SvxTextForwarder& rCacheTF = GetTextForwarder();
1789 		sal_Int32 nRes = rValues.getLength();
1790 		beans::PropertyValue *pRes = rValues.getArray();
1791 		for (sal_Int32 i = 0;  i < nRes;  ++i)
1792 		{
1793 			beans::PropertyValue &rRes = pRes[i];
1794 			// Char color
1795 			if (rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharColor"))==0)
1796 			{
1797 				uno::Any &anyChar = rRes.Value;
1798 				sal_uInt32 crChar = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved));
1799 				if (COL_AUTO == crChar )
1800 				{
1801 					uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent;
1802 					if (mxParent.is())
1803 					{
1804 						xComponent.set(mxParent,uno::UNO_QUERY);
1805 					}
1806 					else
1807 					{
1808 						xComponent.set(m_xAccInfo,uno::UNO_QUERY);
1809 					}
1810 					if (xComponent.is())
1811 					{
1812 						uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY);
1813 						if (xContext->getAccessibleRole() == AccessibleRole::SHAPE
1814 							|| xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL)
1815 						{
1816 							anyChar <<= COL_BLACK;
1817 						}
1818 						else
1819 						{
1820 							Color cr(xComponent->getBackground());
1821 							crChar = cr.IsDark() ? COL_WHITE : COL_BLACK;
1822 							anyChar <<= crChar;
1823 						}
1824 					}
1825 				}
1826 				continue;
1827 			}
1828 			// Underline
1829 			if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderline"))==0)
1830 			{
1831 				/*
1832 				// MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW.
1833 				if (IsCurrentEditorEnableAutoSpell( mxParent ))
1834 				{
1835 					try
1836 					{
1837 						SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False );
1838 						sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex );
1839 						if ( bWrong )
1840 						{
1841 							uno::Any &anyUnderLine = pRes[9].Value;
1842 							// MT IA2: Not needed? sal_uInt16 crUnderLine = (sal_uInt16)(anyUnderLine.pReserved);
1843 							anyUnderLine <<= (sal_uInt16)UNDERLINE_WAVE;
1844 						}
1845 					}
1846 					catch( const uno::RuntimeException& )
1847 					{
1848 					}
1849 				}
1850 				*/
1851 				continue;
1852 			}
1853 			// Underline color && Mis-spell
1854 			if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderlineColor"))==0)
1855 			{
1856 				uno::Any &anyCharUnderLine = rRes.Value;
1857 				sal_uInt32 crCharUnderLine = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>( anyCharUnderLine.pReserved));
1858 				if (COL_AUTO == crCharUnderLine )
1859 				{
1860 					uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent;
1861 					if (mxParent.is())
1862 					{
1863 						xComponent.set(mxParent,uno::UNO_QUERY);
1864 					}
1865 					else
1866 					{
1867 						xComponent.set(m_xAccInfo,uno::UNO_QUERY);
1868 					}
1869 					if (xComponent.is())
1870 					{
1871 						uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY);
1872 						if (xContext->getAccessibleRole() == AccessibleRole::SHAPE
1873 							|| xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL)
1874 						{
1875 							anyCharUnderLine <<= COL_BLACK;
1876 						}
1877 						else
1878 						{
1879 							Color cr(xComponent->getBackground());
1880 							crCharUnderLine = cr.IsDark() ? COL_WHITE : COL_BLACK;
1881 							anyCharUnderLine <<= crCharUnderLine;
1882 						}
1883 					}
1884 				}
1885 				// MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW.
1886 				/*
1887 				if (IsCurrentEditorEnableAutoSpell( mxParent ))
1888 				{
1889 					try
1890 					{
1891 						SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False );
1892 						sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex );
1893 						if ( bWrong )
1894 						{
1895 							uno::Any &anyUnderLineColor = rRes.Value;
1896 							// MT IA2: Not needed? sal_uInt16 crUnderLineColor = (sal_uInt16)(anyUnderLineColor.pReserved);
1897 							anyUnderLineColor <<= COL_LIGHTRED;
1898 						}
1899 					}
1900 					catch( const uno::RuntimeException& )
1901 					{
1902 					}
1903 				}
1904 				*/
1905 				continue;
1906 			}
1907 			// NumberingLevel
1908 			if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingLevel"))==0)
1909 			{
1910 				const SvxNumBulletItem& rNumBullet = ( SvxNumBulletItem& )rCacheTF.GetParaAttribs(static_cast< sal_uInt16 >(GetParagraphIndex())).Get(EE_PARA_NUMBULLET);
1911 				if(rNumBullet.GetNumRule()->GetLevelCount()==0)
1912 				{
1913 					rRes.Value <<= (sal_Int16)-1;
1914 					rRes.Handle = -1;
1915 					rRes.State = PropertyState_DIRECT_VALUE;
1916 				}
1917 				else
1918 				{
1919 //					SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
1920 //						ImplGetSvxCharAndParaPropertiesMap() );
1921 					// MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap
1922             		SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() );
1923 
1924 					aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
1925 					rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex );
1926 					rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex );
1927 					rRes.Handle = -1;
1928 				}
1929 				continue;
1930 			}
1931 			// NumberingRules
1932 			if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingRules"))==0)
1933 			{
1934 				SfxItemSet aAttribs = rCacheTF.GetParaAttribs( static_cast< sal_uInt16 >(GetParagraphIndex()) );
1935 				sal_Bool bVis = ((const SfxUInt16Item&)aAttribs.Get( EE_PARA_BULLETSTATE )).GetValue() ? sal_True : sal_False;
1936 				if(bVis)
1937 				{
1938 					rRes.Value <<= (sal_Int16)-1;
1939 					rRes.Handle = -1;
1940 					rRes.State = PropertyState_DIRECT_VALUE;
1941 				}
1942 				else
1943 				{
1944 					// MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap
1945             		SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() );
1946 					aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
1947 					rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex );
1948 					rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex );
1949 					rRes.Handle = -1;
1950 				}
1951 				continue;
1952 			}
1953 		}
1954 	}
1955     sal_Int32 AccessibleEditableTextPara::SkipField(sal_Int32 nIndex, sal_Bool bForward)
1956     {
1957 		sal_Int32 nParaIndex = GetParagraphIndex();
1958 		SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();
1959 		sal_Int32 nAllFieldLen = 0;
1960 		sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1;
1961 		EFieldInfo ree;
1962 		sal_Int32  reeBegin=0, reeEnd=0;
1963 		for(sal_uInt16 j = 0; j < nField; j++)
1964 		{
1965 			ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j);
1966 			reeBegin  = ree.aPosition.nIndex + nAllFieldLen;
1967 			reeEnd = reeBegin + ree.aCurrentText.Len();
1968 			nAllFieldLen += (ree.aCurrentText.Len() - 1);
1969 			if( reeBegin > nIndex )
1970 			{
1971 				break;
1972 			}
1973 			if(  nIndex >= reeBegin && nIndex < reeEnd )
1974 			{
1975 				if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD)
1976 				{
1977 					nFoundFieldIndex = j;
1978 					break;
1979 				}
1980 			}
1981 		}
1982 		if( nFoundFieldIndex >= 0  )
1983 		{
1984 			if( bForward )
1985 				return reeEnd - 1;
1986 			else
1987 				return reeBegin;
1988 		}
1989 		return nIndex;
1990     }
1991     sal_Bool AccessibleEditableTextPara::ExtendByField( ::com::sun::star::accessibility::TextSegment& Segment )
1992     {
1993 		sal_Int32 nParaIndex = GetParagraphIndex();
1994 		SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();
1995 		sal_Int32 nAllFieldLen = 0;
1996 		sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1;
1997 		EFieldInfo ree;
1998 		sal_Int32  reeBegin=0, reeEnd=0;
1999 		for(sal_uInt16 j = 0; j < nField; j++)
2000 		{
2001 			ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j);
2002 			reeBegin  = ree.aPosition.nIndex + nAllFieldLen;
2003 			reeEnd = reeBegin + ree.aCurrentText.Len();
2004 			nAllFieldLen += (ree.aCurrentText.Len() - 1);
2005 			if( reeBegin > Segment.SegmentEnd )
2006 			{
2007 				break;
2008 			}
2009 			if(  (Segment.SegmentEnd > reeBegin && Segment.SegmentEnd <= reeEnd) ||
2010 			      (Segment.SegmentStart >= reeBegin && Segment.SegmentStart < reeEnd)  )
2011 			{
2012 				if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD)
2013 				{
2014 					nFoundFieldIndex = j;
2015 					break;
2016 				}
2017 			}
2018 		}
2019 		sal_Bool bExtend = sal_False;
2020 		if( nFoundFieldIndex >= 0 )
2021 		{
2022 			if( Segment.SegmentEnd < reeEnd )
2023 			{
2024 				Segment.SegmentEnd  = reeEnd;
2025 				bExtend = sal_True;
2026 			}
2027 			if( Segment.SegmentStart > reeBegin )
2028 			{
2029 				Segment.SegmentStart = reeBegin;
2030 				bExtend = sal_True;
2031 			}
2032 			if( bExtend )
2033 			{
2034 				//If there is a bullet before the field, should add the bullet length into the segment.
2035 				EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo(sal_uInt16(nParaIndex));
2036 				int nBulletLen = aBulletInfo.aText.Len();
2037 				if (nBulletLen > 0)
2038 				{
2039 					Segment.SegmentEnd += nBulletLen;
2040 					if (nFoundFieldIndex > 0)
2041 						Segment.SegmentStart += nBulletLen;
2042 					Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
2043 					//After get the correct field name, should restore the offset value which don't contain the bullet.
2044 					Segment.SegmentEnd -= nBulletLen;
2045 					if (nFoundFieldIndex > 0)
2046 						Segment.SegmentStart -= nBulletLen;
2047 				}
2048 				else
2049 					Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd);
2050 			}
2051 		}
2052 		return bExtend;
2053     }
2054 //-----IAccessibility2 Implementation 2009
2055     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
2056     {
2057         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2058 
2059         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2060 
2061         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2062                    "AccessibleEditableTextPara::getTextAtIndex: paragraph index value overflow");
2063 
2064         ::com::sun::star::accessibility::TextSegment aResult;
2065         aResult.SegmentStart = -1;
2066         aResult.SegmentEnd = -1;
2067 
2068         switch( aTextType )
2069         {
2070 	//IAccessibility2 Implementation 2009-----
2071 		case AccessibleTextType::CHARACTER:
2072 		case AccessibleTextType::WORD:
2073 		{
2074 			aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
2075 			ExtendByField( aResult );
2076 			break;
2077             	}
2078 	//-----IAccessibility2 Implementation 2009
2079             // Not yet handled by OCommonAccessibleText. Missing
2080             // implGetAttributeRunBoundary() method there
2081             case AccessibleTextType::ATTRIBUTE_RUN:
2082             {
2083                 const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
2084 
2085                 if( nIndex == nTextLen )
2086                 {
2087                     // #i17014# Special-casing one-behind-the-end character
2088                     aResult.SegmentStart = aResult.SegmentEnd = nTextLen;
2089                 }
2090                 else
2091                 {
2092                     sal_uInt16 nStartIndex, nEndIndex;
2093 					//For the bullet paragraph, the bullet string is ingnored for IAText::attributes() function.
2094 					SvxTextForwarder&	rCacheTF = GetTextForwarder();
2095 					// MT IA2: Not used? sal_Int32 nBulletLen = 0;
2096 					EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
2097 					if (aBulletInfo.bVisible)
2098 						nIndex += aBulletInfo.aText.Len();
2099 					if (nIndex != 0  && nIndex >= getCharacterCount())
2100 						nIndex = getCharacterCount()-1;
2101 					CheckPosition(nIndex);
2102                     if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
2103                     {
2104                         aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
2105 						if (aBulletInfo.bVisible)
2106 						{
2107 							nStartIndex -= aBulletInfo.aText.Len();
2108 							nEndIndex -= aBulletInfo.aText.Len();
2109 						}
2110                         aResult.SegmentStart = nStartIndex;
2111                         aResult.SegmentEnd = nEndIndex;
2112                     }
2113 		}
2114                 break;
2115             }
2116 //IAccessibility2 Implementation 2009-----
2117             case AccessibleTextType::LINE:
2118             {
2119                 SvxTextForwarder&	rCacheTF = GetTextForwarder();
2120                 sal_Int32			nParaIndex = GetParagraphIndex();
2121                 // MT IA2: Not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
2122                 CheckPosition(nIndex);
2123 		if (nIndex != 0  && nIndex == getCharacterCount())
2124 			--nIndex;
2125                 sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
2126                 sal_Int32 nCurIndex;
2127                 //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
2128                 //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
2129                 //by the IAText::attributes(). So here must do special support for bullet line.
2130                 sal_Int32 nBulletLen = 0;
2131                 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
2132                 {
2133                     if (nLine == 0)
2134                     {
2135                         EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) );
2136                         if (aBulletInfo.bVisible)
2137                         {
2138                             //in bullet or numbering;
2139                             nBulletLen = aBulletInfo.aText.Len();
2140                         }
2141                     }
2142                     //nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
2143                     sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
2144                     if (nLine == 0)
2145                         nCurIndex += nLineLen - nBulletLen;
2146                     else
2147                         nCurIndex += nLineLen;
2148                     if( nCurIndex > nIndex )
2149                     {
2150                         if (nLine ==0)
2151                         {
2152                             //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
2153                             aResult.SegmentStart = 0;
2154                             aResult.SegmentEnd = nCurIndex;
2155                             //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd );
2156                             aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen);
2157                             break;
2158                         }
2159                         else
2160                         {
2161                             //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
2162                             aResult.SegmentStart = nCurIndex - nLineLen;
2163                             aResult.SegmentEnd = nCurIndex;
2164                             //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd );
2165                             aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
2166                             break;
2167                         }
2168                     }
2169                 }
2170                 break;
2171             }
2172 //-----IAccessibility2 Implementation 2009
2173             default:
2174                 aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
2175                 break;
2176         } /* end of switch( aTextType ) */
2177 
2178         return aResult;
2179     }
2180 
2181     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
2182     {
2183         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2184 
2185         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2186 
2187         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2188                    "AccessibleEditableTextPara::getTextBeforeIndex: paragraph index value overflow");
2189 
2190         ::com::sun::star::accessibility::TextSegment aResult;
2191         aResult.SegmentStart = -1;
2192         aResult.SegmentEnd = -1;
2193 //IAccessibility2 Implementation 2009-----
2194 		i18n::Boundary aBoundary;
2195 //-----IAccessibility2 Implementation 2009
2196         switch( aTextType )
2197         {
2198             // Not yet handled by OCommonAccessibleText. Missing
2199             // implGetAttributeRunBoundary() method there
2200             case AccessibleTextType::ATTRIBUTE_RUN:
2201             {
2202                 const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
2203                 sal_uInt16 nStartIndex, nEndIndex;
2204 
2205                 if( nIndex == nTextLen )
2206                 {
2207                     // #i17014# Special-casing one-behind-the-end character
2208                     if( nIndex > 0 &&
2209                         GetAttributeRun(nStartIndex, nEndIndex, nIndex-1) )
2210                     {
2211                         aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
2212                         aResult.SegmentStart = nStartIndex;
2213                         aResult.SegmentEnd = nEndIndex;
2214                     }
2215                 }
2216                 else
2217                 {
2218                     if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
2219                     {
2220                         // already at the left border? If not, query
2221                         // one index further left
2222                         if( nStartIndex > 0 &&
2223                             GetAttributeRun(nStartIndex, nEndIndex, nStartIndex-1) )
2224                         {
2225                             aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
2226                             aResult.SegmentStart = nStartIndex;
2227                             aResult.SegmentEnd = nEndIndex;
2228                         }
2229                     }
2230                 }
2231                 break;
2232             }
2233 	    //IAccessibility2 Implementation 2009-----
2234             case AccessibleTextType::LINE:
2235             {
2236                 SvxTextForwarder&	rCacheTF = GetTextForwarder();
2237                 sal_Int32			nParaIndex = GetParagraphIndex();
2238                 // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
2239 
2240                 CheckPosition(nIndex);
2241 
2242                 sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
2243                 //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
2244                 //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
2245                 //by the IAText::attributes(). So here must do special support for bullet line.
2246                 sal_Int32 nCurIndex=0, nLastIndex=0, nCurLineLen=0;
2247                 sal_Int32 nLastLineLen = 0, nBulletLen = 0;;
2248                 // get the line before the line the index points into
2249                 for( nLine=0, nCurIndex=0, nLastIndex=0; nLine<nLineCount; ++nLine )
2250                 {
2251                     nLastIndex = nCurIndex;
2252                     if (nLine == 0)
2253                     {
2254                         EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) );
2255                         if (aBulletInfo.bVisible)
2256                         {
2257                             //in bullet or numbering;
2258                             nBulletLen = aBulletInfo.aText.Len();
2259                         }
2260                     }
2261                     if (nLine == 1)
2262                         nLastLineLen = nCurLineLen - nBulletLen;
2263                     else
2264                         nLastLineLen = nCurLineLen;
2265                     nCurLineLen = rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
2266                     //nCurIndex += nCurLineLen;
2267                     if (nLine == 0)
2268                         nCurIndex += nCurLineLen - nBulletLen;
2269                     else
2270                         nCurIndex += nCurLineLen;
2271 
2272                     //if( nCurIndex > nIndex &&
2273                     //nLastIndex > nCurLineLen )
2274                     if (nCurIndex > nIndex)
2275                     {
2276                         if (nLine == 0)
2277                         {
2278                             break;
2279                         }
2280                         else if (nLine == 1)
2281                         {
2282                             aResult.SegmentStart = 0;
2283                             aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex );
2284                             aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen);
2285                             break;
2286                         }
2287                         else
2288                         {
2289                             //aResult.SegmentStart = nLastIndex - nCurLineLen;
2290                             aResult.SegmentStart = nLastIndex - nLastLineLen;
2291                             aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex );
2292                             aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
2293                             break;
2294                         }
2295                     }
2296                 }
2297 
2298                 break;
2299             }
2300 			case AccessibleTextType::WORD:
2301 			{
2302 				nIndex = SkipField( nIndex, sal_False);
2303 				::rtl::OUString sText( implGetText() );
2304 				sal_Int32 nLength = sText.getLength();
2305 
2306 				// get word at index
2307 				implGetWordBoundary( aBoundary, nIndex );
2308 
2309 
2310 				//sal_Int32 curWordStart = aBoundary.startPos;
2311 				//sal_Int32 preWordStart = curWordStart;
2312 				sal_Int32 curWordStart , preWordStart;
2313 				if( aBoundary.startPos == -1 || aBoundary.startPos > nIndex)
2314 					curWordStart = preWordStart = nIndex;
2315 				else
2316 					curWordStart = preWordStart = aBoundary.startPos;
2317 
2318 				// get previous word
2319 
2320 				sal_Bool bWord = sal_False;
2321 
2322 				//while ( preWordStart > 0 && aBoundary.startPos == curWordStart)
2323 				while ( (preWordStart >= 0 && !bWord ) || ( aBoundary.endPos > curWordStart ) )
2324 					{
2325 					preWordStart--;
2326 					bWord = implGetWordBoundary( aBoundary, preWordStart );
2327 				}
2328 				if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
2329 				{
2330 					aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
2331 					aResult.SegmentStart = aBoundary.startPos;
2332 					aResult.SegmentEnd = aBoundary.endPos;
2333 					ExtendByField( aResult );
2334 				}
2335 			}
2336 			break;
2337 			case AccessibleTextType::CHARACTER:
2338 			{
2339 				nIndex = SkipField( nIndex, sal_False);
2340 				aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
2341 				ExtendByField( aResult );
2342 				break;
2343 			}
2344 			//-----IAccessibility2 Implementation 2009
2345             default:
2346                 aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
2347                 break;
2348         } /* end of switch( aTextType ) */
2349 
2350         return aResult;
2351     }
2352 
2353     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
2354     {
2355         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2356 
2357         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2358 
2359         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2360                    "AccessibleEditableTextPara::getTextBehindIndex: paragraph index value overflow");
2361 
2362         ::com::sun::star::accessibility::TextSegment aResult;
2363         aResult.SegmentStart = -1;
2364         aResult.SegmentEnd = -1;
2365 //IAccessibility2 Implementation 2009-----
2366 		i18n::Boundary aBoundary;
2367 //-----IAccessibility2 Implementation 2009
2368         switch( aTextType )
2369         {
2370             case AccessibleTextType::ATTRIBUTE_RUN:
2371             {
2372                 sal_uInt16 nStartIndex, nEndIndex;
2373 
2374                 if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
2375                 {
2376                     // already at the right border?
2377                     if( nEndIndex < GetTextLen() )
2378                     {
2379                         if( GetAttributeRun(nStartIndex, nEndIndex, nEndIndex) )
2380                         {
2381                             aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
2382                             aResult.SegmentStart = nStartIndex;
2383                             aResult.SegmentEnd = nEndIndex;
2384                         }
2385                     }
2386                 }
2387                 break;
2388             }
2389 
2390 //IAccessibility2 Implementation 2009-----
2391             case AccessibleTextType::LINE:
2392             {
2393                 SvxTextForwarder&	rCacheTF = GetTextForwarder();
2394                 sal_Int32			nParaIndex = GetParagraphIndex();
2395                 // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
2396 
2397                 CheckPosition(nIndex);
2398 
2399                 sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
2400                 sal_Int32 nCurIndex;
2401                 //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line,
2402                 //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed
2403                 //by the IAText::attributes(). So here must do special support for bullet line.
2404                 sal_Int32 nBulletLen = 0;
2405                 // get the line after the line the index points into
2406                 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
2407                 {
2408                     if (nLine == 0)
2409                     {
2410                         EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) );
2411                         if (aBulletInfo.bVisible)
2412                         {
2413                             //in bullet or numbering;
2414                             nBulletLen = aBulletInfo.aText.Len();
2415                         }
2416                     }
2417                     //nCurIndex += rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
2418                     sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
2419 
2420                     if (nLine == 0)
2421                         nCurIndex += nLineLen - nBulletLen;
2422                     else
2423                         nCurIndex += nLineLen;
2424 
2425                     if( nCurIndex > nIndex &&
2426                         nLine < nLineCount-1 )
2427                     {
2428                         aResult.SegmentStart = nCurIndex;
2429                         aResult.SegmentEnd = nCurIndex + rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine+1);
2430                         aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen);
2431                         break;
2432                     }
2433                 }
2434 
2435                 break;
2436             }
2437 			case AccessibleTextType::WORD:
2438 			{
2439 				nIndex = SkipField( nIndex, sal_True);
2440 				::rtl::OUString sText( implGetText() );
2441 				sal_Int32 nLength = sText.getLength();
2442 
2443 				// get word at index
2444 				sal_Bool bWord = implGetWordBoundary( aBoundary, nIndex );
2445 
2446 				// real current world
2447 				sal_Int32 nextWord = nIndex;
2448 				//if( nIndex >= aBoundary.startPos && nIndex <= aBoundary.endPos )
2449 				if( nIndex <= aBoundary.endPos )
2450 				{
2451 					nextWord = 	aBoundary.endPos;
2452 					if( sText.getStr()[nextWord] == sal_Unicode(' ') ) nextWord++;
2453 					bWord = implGetWordBoundary( aBoundary, nextWord );
2454 				}
2455 
2456 				if ( bWord && implIsValidBoundary( aBoundary, nLength ) )
2457 				{
2458 					aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos );
2459 					aResult.SegmentStart = aBoundary.startPos;
2460 					aResult.SegmentEnd = aBoundary.endPos;
2461 
2462 					// If the end position of aBoundary is inside a field, extend the result to the end of the field
2463 
2464 					ExtendByField( aResult );
2465 				}
2466 			}
2467 			break;
2468 
2469 			case AccessibleTextType::CHARACTER:
2470 			{
2471 				nIndex = SkipField( nIndex, sal_True);
2472 				aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
2473 				ExtendByField( aResult );
2474 				break;
2475 			}
2476 			//-----IAccessibility2 Implementation 2009
2477             default:
2478                 aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
2479                 break;
2480         } /* end of switch( aTextType ) */
2481 
2482         return aResult;
2483     }
2484 
2485     sal_Bool SAL_CALL AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2486     {
2487         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2488 
2489         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2490 
2491         try
2492         {
2493             SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
2494             #if OSL_DEBUG_LEVEL > 0
2495             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();    // MUST be after GetEditViewForwarder(), see method docs
2496             (void)rCacheTF;
2497             #else
2498             GetTextForwarder();                                         // MUST be after GetEditViewForwarder(), see method docs
2499             #endif
2500 
2501             sal_Bool aRetVal;
2502 
2503             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2504                        "AccessibleEditableTextPara::copyText: index value overflow");
2505 
2506             CheckRange(nStartIndex, nEndIndex);
2507 
2508             //Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
2509             sal_Int32 nBulletLen = 0;
2510             EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
2511             if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
2512                         nBulletLen = aBulletInfo.aText.Len();
2513             // save current selection
2514             ESelection aOldSelection;
2515 
2516             rCacheVF.GetSelection( aOldSelection );
2517             //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
2518             rCacheVF.SetSelection( MakeSelection(nStartIndex + nBulletLen, nEndIndex + nBulletLen) );
2519             aRetVal = rCacheVF.Copy();
2520             rCacheVF.SetSelection( aOldSelection ); // restore
2521 
2522             return aRetVal;
2523         }
2524         catch( const uno::RuntimeException& )
2525         {
2526             return sal_False;
2527         }
2528     }
2529 
2530 	// XAccessibleEditableText
2531     sal_Bool SAL_CALL AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2532     {
2533         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2534 
2535         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2536 
2537         try
2538         {
2539             SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
2540             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();	// MUST be after GetEditViewForwarder(), see method docs
2541 
2542             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2543                        "AccessibleEditableTextPara::cutText: index value overflow");
2544 
2545             CheckRange(nStartIndex, nEndIndex);
2546 
2547             // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
2548             sal_Int32 nBulletLen = 0;
2549             EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
2550             if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
2551                         nBulletLen = aBulletInfo.aText.Len();
2552             ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen);
2553             //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
2554             if( !rCacheTF.IsEditable( aSelection ) )
2555                 return sal_False; // non-editable area selected
2556 
2557             // don't save selection, might become invalid after cut!
2558             //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
2559             rCacheVF.SetSelection( aSelection );
2560 
2561             return rCacheVF.Cut();
2562         }
2563         catch( const uno::RuntimeException& )
2564         {
2565             return sal_False;
2566         }
2567     }
2568 
2569     sal_Bool SAL_CALL AccessibleEditableTextPara::pasteText( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2570     {
2571         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2572 
2573         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2574 
2575         try
2576         {
2577             SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
2578             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();	// MUST be after GetEditViewForwarder(), see method docs
2579 
2580             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2581                        "AccessibleEditableTextPara::pasteText: index value overflow");
2582 
2583             CheckPosition(nIndex);
2584 
2585             // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
2586             sal_Int32 nBulletLen = 0;
2587             EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
2588             if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
2589                         nBulletLen = aBulletInfo.aText.Len();
2590             //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
2591             if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) )
2592                 return sal_False; // non-editable area selected
2593 
2594             // #104400# set empty selection (=> cursor) to given index
2595             //rCacheVF.SetSelection( MakeCursor(nIndex) );
2596             rCacheVF.SetSelection( MakeCursor(nIndex + nBulletLen) );
2597 
2598             return rCacheVF.Paste();
2599         }
2600         catch( const uno::RuntimeException& )
2601         {
2602             return sal_False;
2603         }
2604     }
2605 
2606     sal_Bool SAL_CALL AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2607     {
2608         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2609 
2610         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2611 
2612         try
2613         {
2614             // #102710# Request edit view when doing changes
2615             // AccessibleEmptyEditSource relies on this behaviour
2616             GetEditViewForwarder( sal_True );
2617             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();	// MUST be after GetEditViewForwarder(), see method docs
2618 
2619             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2620                        "AccessibleEditableTextPara::deleteText: index value overflow");
2621 
2622             CheckRange(nStartIndex, nEndIndex);
2623 
2624             // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
2625             sal_Int32 nBulletLen = 0;
2626             EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
2627             if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
2628                         nBulletLen = aBulletInfo.aText.Len();
2629             ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen);
2630 
2631             //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
2632             if( !rCacheTF.IsEditable( aSelection ) )
2633                 return sal_False; // non-editable area selected
2634 
2635             //sal_Bool bRet = rCacheTF.Delete( MakeSelection(nStartIndex, nEndIndex) );
2636             sal_Bool bRet = rCacheTF.Delete( aSelection );
2637 
2638             GetEditSource().UpdateData();
2639 
2640             return bRet;
2641         }
2642         catch( const uno::RuntimeException& )
2643         {
2644             return sal_False;
2645         }
2646     }
2647 
2648     sal_Bool SAL_CALL AccessibleEditableTextPara::insertText( const ::rtl::OUString& sText, sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2649     {
2650         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2651 
2652         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2653 
2654         try
2655         {
2656             // #102710# Request edit view when doing changes
2657             // AccessibleEmptyEditSource relies on this behaviour
2658             GetEditViewForwarder( sal_True );
2659             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();	// MUST be after GetEditViewForwarder(), see method docs
2660 
2661             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2662                        "AccessibleEditableTextPara::insertText: index value overflow");
2663 
2664             CheckPosition(nIndex);
2665 
2666             // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
2667             sal_Int32 nBulletLen = 0;
2668             EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
2669             if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
2670                         nBulletLen = aBulletInfo.aText.Len();
2671 
2672             //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
2673             if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) )
2674                 return sal_False; // non-editable area selected
2675 
2676             // #104400# insert given text at empty selection (=> cursor)
2677             //sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex) );
2678             sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex + nBulletLen) );
2679 
2680             rCacheTF.QuickFormatDoc();
2681             GetEditSource().UpdateData();
2682 
2683             return bRet;
2684         }
2685         catch( const uno::RuntimeException& )
2686         {
2687             return sal_False;
2688         }
2689     }
2690 
2691     sal_Bool SAL_CALL AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const ::rtl::OUString& sReplacement ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2692     {
2693         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2694 
2695         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2696 
2697         try
2698         {
2699             // #102710# Request edit view when doing changes
2700             // AccessibleEmptyEditSource relies on this behaviour
2701             GetEditViewForwarder( sal_True );
2702             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();	// MUST be after GetEditViewForwarder(), see method docs
2703 
2704             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2705                        "AccessibleEditableTextPara::replaceText: index value overflow");
2706 
2707             CheckRange(nStartIndex, nEndIndex);
2708 
2709             // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet
2710             sal_Int32 nBulletLen = 0;
2711             EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) );
2712             if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible )
2713                         nBulletLen = aBulletInfo.aText.Len();
2714             ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen);
2715 
2716             //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
2717             if( !rCacheTF.IsEditable( aSelection ) )
2718                 return sal_False; // non-editable area selected
2719 
2720             // insert given text into given range => replace
2721             //sal_Bool bRet = rCacheTF.InsertText( sReplacement, MakeSelection(nStartIndex, nEndIndex) );
2722             sal_Bool bRet = rCacheTF.InsertText( sReplacement, aSelection );
2723 
2724             rCacheTF.QuickFormatDoc();
2725             GetEditSource().UpdateData();
2726 
2727             return bRet;
2728         }
2729         catch( const uno::RuntimeException& )
2730         {
2731             return sal_False;
2732         }
2733     }
2734 
2735     sal_Bool SAL_CALL AccessibleEditableTextPara::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const uno::Sequence< beans::PropertyValue >& aAttributeSet ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2736     {
2737         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2738 
2739         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2740 
2741         try
2742         {
2743             // #102710# Request edit view when doing changes
2744             // AccessibleEmptyEditSource relies on this behaviour
2745             GetEditViewForwarder( sal_True );
2746             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();	// MUST be after GetEditViewForwarder(), see method docs
2747             sal_uInt16 nPara = static_cast< sal_uInt16 >( GetParagraphIndex() );
2748 
2749             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2750                        "AccessibleEditableTextPara::setAttributes: index value overflow");
2751 
2752             CheckRange(nStartIndex, nEndIndex);
2753 
2754             if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
2755                 return sal_False; // non-editable area selected
2756 
2757             // do the indices span the whole paragraph? Then use the outliner map
2758             // TODO: hold it as a member?
2759             SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
2760                                                    0 == nStartIndex &&
2761                                                    rCacheTF.GetTextLen(nPara) == nEndIndex ?
2762                                                    ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() :
2763                                                    ImplGetSvxTextPortionSvxPropertySet() );
2764 
2765             aPropSet.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
2766 
2767             // convert from PropertyValue to Any
2768             sal_Int32 i, nLength( aAttributeSet.getLength() );
2769             const beans::PropertyValue*	pPropArray = aAttributeSet.getConstArray();
2770             for(i=0; i<nLength; ++i)
2771             {
2772                 try
2773                 {
2774                     aPropSet.setPropertyValue(pPropArray->Name, pPropArray->Value);
2775                 }
2776                 catch( const uno::Exception& )
2777                 {
2778                     DBG_ERROR("AccessibleEditableTextPara::setAttributes exception in setPropertyValue");
2779                 }
2780 
2781                 ++pPropArray;
2782             }
2783 
2784             rCacheTF.QuickFormatDoc();
2785             GetEditSource().UpdateData();
2786 
2787             return sal_True;
2788         }
2789         catch( const uno::RuntimeException& )
2790         {
2791             return sal_False;
2792         }
2793     }
2794 
2795     sal_Bool SAL_CALL AccessibleEditableTextPara::setText( const ::rtl::OUString& sText ) throw (uno::RuntimeException)
2796     {
2797         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2798 
2799         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2800 
2801         return replaceText(0, getCharacterCount(), sText);
2802     }
2803 
2804     // XAccessibleTextAttributes
2805     uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getDefaultAttributes(
2806             const uno::Sequence< ::rtl::OUString >& rRequestedAttributes )
2807         throw (uno::RuntimeException)
2808     {
2809         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2810         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2811 
2812         #if OSL_DEBUG_LEVEL > 0
2813         SvxAccessibleTextAdapter& rCacheTF =
2814         #endif
2815             GetTextForwarder();
2816 
2817         #if OSL_DEBUG_LEVEL > 0
2818         (void)rCacheTF;
2819         #endif
2820 
2821         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2822                    "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
2823 
2824         // get XPropertySetInfo for paragraph attributes and
2825         // character attributes that span all the paragraphs text.
2826         SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
2827                 ImplGetSvxCharAndParaPropertiesSet() );
2828         aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
2829         uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
2830         if (!xPropSetInfo.is())
2831             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")),
2832                         uno::Reference< uno::XInterface >
2833                         ( static_cast< XAccessible* > (this) ) );   // disambiguate hierarchy
2834 
2835         // build sequence of available properties to check
2836         sal_Int32 nLenReqAttr = rRequestedAttributes.getLength();
2837         uno::Sequence< beans::Property > aProperties;
2838         if (nLenReqAttr)
2839         {
2840             const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray();
2841 
2842             aProperties.realloc( nLenReqAttr );
2843             beans::Property *pProperties = aProperties.getArray();
2844             sal_Int32 nCurLen = 0;
2845             for (sal_Int32 i = 0;  i < nLenReqAttr;  ++i)
2846             {
2847                 beans::Property aProp;
2848                 try
2849                 {
2850                     aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] );
2851                 }
2852                 catch (beans::UnknownPropertyException &)
2853                 {
2854                     continue;
2855                 }
2856                 pProperties[ nCurLen++ ] = aProp;
2857             }
2858             aProperties.realloc( nCurLen );
2859         }
2860         else
2861             aProperties = xPropSetInfo->getProperties();
2862 
2863         sal_Int32 nLength = aProperties.getLength();
2864         const beans::Property *pProperties = aProperties.getConstArray();
2865 
2866         // build resulting sequence
2867         uno::Sequence< beans::PropertyValue > aOutSequence( nLength );
2868         beans::PropertyValue* pOutSequence = aOutSequence.getArray();
2869         sal_Int32 nOutLen = 0;
2870         for (sal_Int32 i = 0;  i < nLength;  ++i)
2871         {
2872             // calling implementation functions:
2873             // _getPropertyState and _getPropertyValue (see below) to provide
2874             // the proper paragraph number when retrieving paragraph attributes
2875             PropertyState eState = aPropSet._getPropertyState( pProperties->Name, mnParagraphIndex );
2876             if ( eState == PropertyState_AMBIGUOUS_VALUE )
2877             {
2878                 OSL_ENSURE( false, "ambiguous property value encountered" );
2879             }
2880 
2881             //if (eState == PropertyState_DIRECT_VALUE)
2882             // per definition all paragraph properties and all character
2883             // properties spanning the whole paragraph should be returned
2884             // and declared as default value
2885             {
2886                 pOutSequence->Name      = pProperties->Name;
2887                 pOutSequence->Handle    = pProperties->Handle;
2888                 pOutSequence->Value     = aPropSet._getPropertyValue( pProperties->Name, mnParagraphIndex );
2889                 pOutSequence->State     = PropertyState_DEFAULT_VALUE;
2890 
2891                 ++pOutSequence;
2892                 ++nOutLen;
2893             }
2894             ++pProperties;
2895         }
2896         aOutSequence.realloc( nOutLen );
2897 
2898         return aOutSequence;
2899     }
2900 
2901 
2902     uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getRunAttributes(
2903             sal_Int32 nIndex,
2904             const uno::Sequence< ::rtl::OUString >& rRequestedAttributes )
2905         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2906     {
2907         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2908 
2909         ::vos::OGuard aGuard( Application::GetSolarMutex() );
2910 
2911         #if OSL_DEBUG_LEVEL > 0
2912         SvxAccessibleTextAdapter& rCacheTF =
2913         #endif
2914             GetTextForwarder();
2915 
2916         #if OSL_DEBUG_LEVEL > 0
2917         (void)rCacheTF;
2918         #endif
2919 
2920         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
2921                    "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
2922 
2923 		if( getCharacterCount() > 0 )
2924 			CheckIndex(nIndex);
2925 		else
2926 			CheckPosition(nIndex);
2927 
2928         SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
2929                                                ImplGetSvxCharAndParaPropertiesSet() );
2930         aPropSet.SetSelection( MakeSelection( nIndex ) );
2931         uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
2932         if (!xPropSetInfo.is())
2933             throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")),
2934                                         uno::Reference< uno::XInterface >
2935                                         ( static_cast< XAccessible* > (this) ) );   // disambiguate hierarchy
2936 
2937         // build sequence of available properties to check
2938         sal_Int32 nLenReqAttr = rRequestedAttributes.getLength();
2939         uno::Sequence< beans::Property > aProperties;
2940         if (nLenReqAttr)
2941         {
2942             const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray();
2943 
2944             aProperties.realloc( nLenReqAttr );
2945             beans::Property *pProperties = aProperties.getArray();
2946             sal_Int32 nCurLen = 0;
2947             for (sal_Int32 i = 0;  i < nLenReqAttr;  ++i)
2948             {
2949                 beans::Property aProp;
2950                 try
2951                 {
2952                     aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] );
2953                 }
2954                 catch (beans::UnknownPropertyException &)
2955                 {
2956                     continue;
2957                 }
2958                 pProperties[ nCurLen++ ] = aProp;
2959             }
2960             aProperties.realloc( nCurLen );
2961         }
2962         else
2963             aProperties = xPropSetInfo->getProperties();
2964 
2965         sal_Int32 nLength = aProperties.getLength();
2966         const beans::Property *pProperties = aProperties.getConstArray();
2967 
2968         // build resulting sequence
2969         uno::Sequence< beans::PropertyValue > aOutSequence( nLength );
2970         beans::PropertyValue* pOutSequence = aOutSequence.getArray();
2971         sal_Int32 nOutLen = 0;
2972         for (sal_Int32 i = 0;  i < nLength;  ++i)
2973         {
2974             // calling 'regular' functions that will operate on the selection
2975             PropertyState eState = aPropSet.getPropertyState( pProperties->Name );
2976             if (eState == PropertyState_DIRECT_VALUE)
2977             {
2978                 pOutSequence->Name      = pProperties->Name;
2979                 pOutSequence->Handle    = pProperties->Handle;
2980                 pOutSequence->Value     = aPropSet.getPropertyValue( pProperties->Name );
2981                 pOutSequence->State     = eState;
2982 
2983                 ++pOutSequence;
2984                 ++nOutLen;
2985             }
2986             ++pProperties;
2987         }
2988         aOutSequence.realloc( nOutLen );
2989 
2990         return aOutSequence;
2991     }
2992 
2993     // XAccessibleHypertext
2994     ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkCount(  ) throw (::com::sun::star::uno::RuntimeException)
2995     {
2996         SvxAccessibleTextAdapter& rT = GetTextForwarder();
2997         const sal_Int32 nPara = GetParagraphIndex();
2998 
2999         sal_uInt16 nHyperLinks = 0;
3000         sal_uInt16 nFields = rT.GetFieldCount( nPara );
3001         for ( sal_uInt16 n = 0; n < nFields; n++ )
3002         {
3003             EFieldInfo aField = rT.GetFieldInfo( nPara, n );
3004             if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
3005                 nHyperLinks++;
3006         }
3007         return nHyperLinks;
3008     }
3009 
3010     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > SAL_CALL AccessibleEditableTextPara::getHyperLink( ::sal_Int32 nLinkIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
3011     {
3012         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > xRef;
3013 
3014         SvxAccessibleTextAdapter& rT = GetTextForwarder();
3015         const sal_Int32 nPara = GetParagraphIndex();
3016 
3017         sal_uInt16 nHyperLink = 0;
3018         sal_uInt16 nFields = rT.GetFieldCount( nPara );
3019         for ( sal_uInt16 n = 0; n < nFields; n++ )
3020         {
3021             EFieldInfo aField = rT.GetFieldInfo( nPara, n );
3022             if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
3023             {
3024                 if ( nHyperLink == nLinkIndex )
3025                 {
3026                     sal_uInt16 nEEStart = aField.aPosition.nIndex;
3027 
3028                     // Translate EE Index to accessible index
3029                     sal_uInt16 nStart = rT.CalcEditEngineIndex( nPara, nEEStart );
3030                     sal_uInt16 nEnd = nStart + aField.aCurrentText.Len();
3031                     xRef = new AccessibleHyperlink( rT, new SvxFieldItem( *aField.pFieldItem ), nPara, nEEStart, nStart, nEnd, aField.aCurrentText );
3032                     break;
3033                 }
3034                 nHyperLink++;
3035             }
3036         }
3037 
3038         return xRef;
3039     }
3040 
3041     ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkIndex( ::sal_Int32 nCharIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
3042     {
3043         const sal_Int32 nPara = GetParagraphIndex();
3044         SvxAccessibleTextAdapter& rT = GetTextForwarder();
3045 
3046 //        SvxAccessibleTextIndex aIndex;
3047 //        aIndex.SetIndex(nPara, nCharIndex, rT);
3048 //        const sal_uInt16 nEEIndex = aIndex.GetEEIndex();
3049 
3050         const sal_uInt16 nEEIndex = rT.CalcEditEngineIndex( nPara, nCharIndex );
3051         sal_Int32 nHLIndex = 0;
3052         sal_uInt16 nHyperLink = 0;
3053         sal_uInt16 nFields = rT.GetFieldCount( nPara );
3054         for ( sal_uInt16 n = 0; n < nFields; n++ )
3055         {
3056             EFieldInfo aField = rT.GetFieldInfo( nPara, n );
3057             if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
3058             {
3059                 if ( aField.aPosition.nIndex == nEEIndex )
3060                 {
3061                     nHLIndex = nHyperLink;
3062                     break;
3063                 }
3064                 nHyperLink++;
3065             }
3066         }
3067 
3068         return nHLIndex;
3069     }
3070 
3071     // XAccessibleMultiLineText
3072     sal_Int32 SAL_CALL AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
3073     {
3074         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
3075 
3076         sal_Int32 nRes = -1;
3077         sal_Int32 nPara = GetParagraphIndex();
3078 
3079         SvxTextForwarder &rCacheTF = GetTextForwarder();
3080         const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount();
3081         DBG_ASSERT( bValidPara, "getLineNumberAtIndex: current paragraph index out of range" );
3082         if (bValidPara)
3083         {
3084             // we explicitly allow for the index to point at the character right behind the text
3085             if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( static_cast< sal_uInt16 >(nPara) ))
3086                 nRes = rCacheTF.GetLineNumberAtIndex( static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nIndex) );
3087             else
3088                 throw lang::IndexOutOfBoundsException();
3089         }
3090         return nRes;
3091     }
3092 
3093     // XAccessibleMultiLineText
3094     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
3095     {
3096         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
3097 
3098         ::com::sun::star::accessibility::TextSegment aResult;
3099         sal_Int32 nPara = GetParagraphIndex();
3100         SvxTextForwarder &rCacheTF = GetTextForwarder();
3101         const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount();
3102         DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" );
3103         if (bValidPara)
3104         {
3105             if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( static_cast< sal_uInt16 >(nPara) ))
3106             {
3107                 sal_uInt16 nStart = 0, nEnd = 0;
3108                 rCacheTF.GetLineBoundaries( nStart, nEnd, static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nLineNo) );
3109                 if (nStart != 0xFFFF && nEnd != 0xFFFF)
3110                 {
3111                     try
3112                     {
3113                         aResult.SegmentText     = getTextRange( nStart, nEnd );
3114                         aResult.SegmentStart    = nStart;
3115                         aResult.SegmentEnd      = nEnd;
3116                     }
3117                     catch (lang::IndexOutOfBoundsException)
3118                     {
3119                         // this is not the exception that should be raised in this function ...
3120                         DBG_ASSERT( 0, "unexpected exception" );
3121                     }
3122                 }
3123             }
3124             else
3125                 throw lang::IndexOutOfBoundsException();
3126         }
3127         return aResult;
3128     }
3129 
3130     // XAccessibleMultiLineText
3131     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineWithCaret(  ) throw (uno::RuntimeException)
3132     {
3133         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
3134 
3135         ::com::sun::star::accessibility::TextSegment aResult;
3136         try
3137         {
3138             aResult = getTextAtLineNumber( getNumberOfLineWithCaret() );
3139         }
3140         catch (lang::IndexOutOfBoundsException &)
3141         {
3142             // this one needs to be catched since this interface does not allow for it.
3143         }
3144         return aResult;
3145     }
3146 
3147     // XAccessibleMultiLineText
3148     sal_Int32 SAL_CALL AccessibleEditableTextPara::getNumberOfLineWithCaret(  ) throw (uno::RuntimeException)
3149     {
3150         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
3151 
3152         sal_Int32 nRes = -1;
3153         try
3154         {
3155             nRes = getLineNumberAtIndex( getCaretPosition() );
3156         }
3157         catch (lang::IndexOutOfBoundsException &)
3158         {
3159             // this one needs to be catched since this interface does not allow for it.
3160         }
3161         return nRes;
3162     }
3163 
3164 
3165 	// XServiceInfo
3166     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getImplementationName (void) throw (uno::RuntimeException)
3167     {
3168         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
3169 
3170         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("AccessibleEditableTextPara"));
3171     }
3172 
3173     sal_Bool SAL_CALL AccessibleEditableTextPara::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException)
3174     {
3175         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
3176 
3177         //  Iterate over all supported service names and return true if on of them
3178         //  matches the given name.
3179         uno::Sequence< ::rtl::OUString> aSupportedServices (
3180             getSupportedServiceNames ());
3181         for (int i=0; i<aSupportedServices.getLength(); i++)
3182             if (sServiceName == aSupportedServices[i])
3183                 return sal_True;
3184         return sal_False;
3185     }
3186 
3187     uno::Sequence< ::rtl::OUString> SAL_CALL AccessibleEditableTextPara::getSupportedServiceNames (void) throw (uno::RuntimeException)
3188     {
3189         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
3190 
3191         const ::rtl::OUString sServiceName( getServiceName() );
3192         return uno::Sequence< ::rtl::OUString > (&sServiceName, 1);
3193     }
3194 
3195 	// XServiceName
3196     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getServiceName (void) throw (uno::RuntimeException)
3197     {
3198         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
3199 
3200         // #105185# Using correct service now
3201         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AccessibleParagraphView"));
3202     }
3203 
3204 }  // end of namespace accessibility
3205 
3206 //------------------------------------------------------------------------
3207