xref: /aoo42x/main/editeng/source/uno/unoedprx.cxx (revision 4d7c9de0)
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 <com/sun/star/uno/Any.hxx>
40 #include <com/sun/star/uno/Reference.hxx>
41 
42 //------------------------------------------------------------------------
43 //
44 // Project-local header
45 //
46 //------------------------------------------------------------------------
47 #include "editeng/unoedprx.hxx"
48 #include <editeng/unotext.hxx>
49 #include <editeng/unoedhlp.hxx>
50 #include <editeng/editdata.hxx>
51 #include <editeng/editeng.hxx>
52 #include <editeng/editview.hxx>
53 #include <editeng/AccessibleStringWrap.hxx>
54 #include <editeng/outliner.hxx>
55 
56 using namespace ::com::sun::star;
57 
58 
59 class SvxAccessibleTextIndex
60 {
61 public:
62     SvxAccessibleTextIndex() :
63         mnPara(0),
64         mnIndex(0),
65         mnEEIndex(0),
66         mnFieldOffset(0),
67         mnFieldLen(0),
68         mbInField(sal_False),
69         mnBulletOffset(0),
70         mnBulletLen(0),
71         mbInBullet(sal_False) {};
72     ~SvxAccessibleTextIndex() {};
73 
74     // Get/Set current paragraph
75     void SetParagraph( sal_uInt16 nPara )
76     {
77         mnPara = nPara;
78     }
79     sal_uInt16 GetParagraph() const { return mnPara; }
80 
81     /** Set the index in the UAA semantic
82 
83         @param nIndex
84      	The index from the UA API (fields and bullets are expanded)
85 
86         @param rTF
87         The text forwarder to use in the calculations
88      */
89     void SetIndex( sal_Int32 nIndex, const SvxTextForwarder& rTF );
90     void SetIndex( sal_uInt16 nPara, sal_Int32 nIndex, const SvxTextForwarder& rTF ) { SetParagraph(nPara); SetIndex(nIndex, rTF); }
91     sal_Int32 GetIndex() const { return mnIndex; }
92 
93     /** Set the index in the edit engine semantic
94 
95     	Update the object state to reflect the given index position in
96     	EditEngine/Outliner index values
97 
98         @param nEEIndex
99      	The index from the edit engine (fields span exactly one index increment)
100 
101         @param rTF
102         The text forwarder to use in the calculations
103      */
104     void SetEEIndex( sal_uInt16 nEEIndex, const SvxTextForwarder& rTF );
105     void SetEEIndex( sal_uInt16 nPara, sal_uInt16 nEEIndex, const SvxTextForwarder& rTF ) { SetParagraph(nPara); SetEEIndex(nEEIndex, rTF); }
106     sal_uInt16 GetEEIndex() const;
107 
108     void SetFieldOffset( sal_Int32 nOffset, sal_Int32 nLen ) { mnFieldOffset = nOffset; mnFieldLen = nLen; }
109     sal_Int32 GetFieldOffset() const { return mnFieldOffset; }
110     sal_Int32 GetFieldLen() const { return mnFieldLen; }
111     void AreInField( sal_Bool bInField = sal_True ) { mbInField = bInField; }
112     sal_Bool InField() const { return mbInField; }
113 
114     void SetBulletOffset( sal_Int32 nOffset, sal_Int32 nLen ) { mnBulletOffset = nOffset; mnBulletLen = nLen; }
115     sal_Int32 GetBulletOffset() const { return mnBulletOffset; }
116     sal_Int32 GetBulletLen() const { return mnBulletLen; }
117     void AreInBullet( sal_Bool bInBullet = sal_True ) { mbInBullet = bInBullet; }
118     sal_Bool InBullet() const { return mbInBullet; }
119 
120     /// returns false if the current index contains non-editable text (e.g. bullets)
121     sal_Bool IsEditable() const;
122 
123     /// returns false if the given range is non-editable (e.g. contains bullets or _parts_ of fields)
124     sal_Bool IsEditableRange( const SvxAccessibleTextIndex& rEnd ) const;
125 
126 private:
127     sal_uInt16 	  mnPara;
128     sal_Int32 mnIndex;
129     sal_Int32 mnEEIndex;
130     sal_Int32 mnFieldOffset;
131     sal_Int32 mnFieldLen;
132     sal_Bool  mbInField;
133     sal_Int32 mnBulletOffset;
134     sal_Int32 mnBulletLen;
135     sal_Bool  mbInBullet;
136 };
137 
138 ESelection MakeEESelection( const SvxAccessibleTextIndex& rStart, const SvxAccessibleTextIndex& rEnd )
139 {
140     // deal with field special case: to really get a field contained
141     // within a selection, the start index must be before or on the
142     // field, the end index after it.
143 
144     // The SvxAccessibleTextIndex.GetEEIndex method gives the index on
145     // the field, as long the input index is on the field. Thus,
146     // correction necessary for the end index
147 
148     // Therefore, for _ranges_, if part of the field is touched, all
149     // of the field must be selected
150     if( rStart.GetParagraph() <= rEnd.GetParagraph() ||
151         (rStart.GetParagraph() == rEnd.GetParagraph() &&
152          rStart.GetEEIndex() <= rEnd.GetEEIndex()) )
153     {
154         if( rEnd.InField() && rEnd.GetFieldOffset() )
155             return ESelection( rStart.GetParagraph(), rStart.GetEEIndex(),
156                                rEnd.GetParagraph(), rEnd.GetEEIndex()+1 );
157     }
158     else if( rStart.GetParagraph() > rEnd.GetParagraph() ||
159              (rStart.GetParagraph() == rEnd.GetParagraph() &&
160               rStart.GetEEIndex() > rEnd.GetEEIndex()) )
161     {
162         if( rStart.InField() && rStart.GetFieldOffset()  )
163             return ESelection( rStart.GetParagraph(), rStart.GetEEIndex()+1,
164                                rEnd.GetParagraph(), rEnd.GetEEIndex() );
165     }
166 
167     return ESelection( rStart.GetParagraph(), rStart.GetEEIndex(),
168                        rEnd.GetParagraph(), rEnd.GetEEIndex() );
169 }
170 
171 ESelection MakeEESelection( const SvxAccessibleTextIndex& rIndex )
172 {
173     return ESelection( rIndex.GetParagraph(), rIndex.GetEEIndex(),
174                        rIndex.GetParagraph(), rIndex.GetEEIndex() + 1 );
175 }
176 
177 sal_uInt16 SvxAccessibleTextIndex::GetEEIndex() const
178 {
179     DBG_ASSERT(mnEEIndex >= 0 && mnEEIndex <= USHRT_MAX,
180                "SvxAccessibleTextIndex::GetEEIndex: index value overflow");
181 
182     return static_cast< sal_uInt16 > (mnEEIndex);
183 }
184 
185 void SvxAccessibleTextIndex::SetEEIndex( sal_uInt16 nEEIndex, const SvxTextForwarder& rTF )
186 {
187     // reset
188     mnFieldOffset = 0;
189     mbInField = sal_False;
190     mnFieldLen = 0;
191     mnBulletOffset = 0;
192     mbInBullet = sal_False;
193     mnBulletLen = 0;
194 
195     // set known values
196     mnEEIndex = nEEIndex;
197 
198     // calculate unknowns
199     sal_uInt16					nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() );
200 
201     mnIndex = nEEIndex;
202 
203     EBulletInfo aBulletInfo = rTF.GetBulletInfo( GetParagraph() );
204 
205     // any text bullets?
206     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
207         aBulletInfo.bVisible &&
208         aBulletInfo.nType != SVX_NUM_BITMAP )
209     {
210         mnIndex += aBulletInfo.aText.Len();
211     }
212 
213     for( nCurrField=0; nCurrField < nFieldCount; ++nCurrField )
214     {
215         EFieldInfo aFieldInfo( rTF.GetFieldInfo( GetParagraph(), nCurrField ) );
216 
217         if( aFieldInfo.aPosition.nIndex > nEEIndex )
218             break;
219 
220         if( aFieldInfo.aPosition.nIndex == nEEIndex )
221         {
222             AreInField();
223             break;
224         }
225 
226         // #106010#
227         mnIndex += ::std::max(aFieldInfo.aCurrentText.Len()-1, 0);
228     }
229 }
230 
231 void SvxAccessibleTextIndex::SetIndex( sal_Int32 nIndex, const SvxTextForwarder& rTF )
232 {
233     // reset
234     mnFieldOffset = 0;
235     mbInField = sal_False;
236     mnFieldLen = 0;
237     mnBulletOffset = 0;
238     mbInBullet = sal_False;
239     mnBulletLen = 0;
240 
241     // set known values
242     mnIndex = nIndex;
243 
244     // calculate unknowns
245     sal_uInt16					nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() );
246 
247     DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
248                "SvxAccessibleTextIndex::SetIndex: index value overflow");
249 
250     mnEEIndex = nIndex;
251 
252     EBulletInfo aBulletInfo = rTF.GetBulletInfo( GetParagraph() );
253 
254     // any text bullets?
255     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
256         aBulletInfo.bVisible &&
257         aBulletInfo.nType != SVX_NUM_BITMAP )
258     {
259         sal_Int32 nBulletLen = aBulletInfo.aText.Len();
260 
261         if( nIndex < nBulletLen )
262         {
263             AreInBullet();
264             SetBulletOffset( nIndex, nBulletLen );
265             mnEEIndex = 0;
266             return;
267         }
268 
269         mnEEIndex = mnEEIndex - nBulletLen;
270     }
271 
272     for( nCurrField=0; nCurrField < nFieldCount; ++nCurrField )
273     {
274         EFieldInfo aFieldInfo( rTF.GetFieldInfo( GetParagraph(), nCurrField ) );
275 
276         // we're before a field
277         if( aFieldInfo.aPosition.nIndex > mnEEIndex )
278             break;
279 
280         // #106010#
281         mnEEIndex -= ::std::max(aFieldInfo.aCurrentText.Len()-1, 0);
282 
283         // we're within a field
284         if( aFieldInfo.aPosition.nIndex >= mnEEIndex )
285         {
286             AreInField();
287             SetFieldOffset( ::std::max(aFieldInfo.aCurrentText.Len()-1, 0) - (aFieldInfo.aPosition.nIndex - mnEEIndex),
288                             aFieldInfo.aCurrentText.Len() );
289             mnEEIndex = aFieldInfo.aPosition.nIndex ;
290             break;
291         }
292     }
293 }
294 
295 sal_Bool SvxAccessibleTextIndex::IsEditable() const
296 {
297     if( InBullet() || InField() )
298         return sal_False;
299 
300     return sal_True;
301 }
302 
303 sal_Bool SvxAccessibleTextIndex::IsEditableRange( const SvxAccessibleTextIndex& rEnd ) const
304 {
305     if( GetIndex() > rEnd.GetIndex() )
306         return rEnd.IsEditableRange( *this );
307 
308     if( InBullet() || rEnd.InBullet() )
309         return sal_False;
310 
311     if( InField() && GetFieldOffset() )
312         return sal_False; // within field
313 
314     if( rEnd.InField() && rEnd.GetFieldOffset() >= rEnd.GetFieldLen() - 1 )
315         return sal_False; // within field
316 
317     return sal_True;
318 }
319 
320 //---------------------------------------------------------------------------------
321 
322 SvxEditSourceAdapter::SvxEditSourceAdapter() : mbEditSourceValid( sal_False )
323 {
324 }
325 
326 SvxEditSourceAdapter::~SvxEditSourceAdapter()
327 {
328 }
329 
330 SvxEditSource* SvxEditSourceAdapter::Clone() const
331 {
332     if( mbEditSourceValid && mpAdaptee.get() )
333     {
334         ::std::auto_ptr< SvxEditSource > pClonedAdaptee( mpAdaptee->Clone() );
335 
336         if( pClonedAdaptee.get() )
337         {
338             SvxEditSourceAdapter* pClone = new SvxEditSourceAdapter();
339 
340             if( pClone )
341             {
342                 pClone->SetEditSource( pClonedAdaptee );
343                 return pClone;
344             }
345         }
346     }
347 
348     return NULL;
349 }
350 
351 SvxAccessibleTextAdapter* SvxEditSourceAdapter::GetTextForwarderAdapter()
352 {
353     if( mbEditSourceValid && mpAdaptee.get() )
354     {
355         SvxTextForwarder* pTextForwarder = mpAdaptee->GetTextForwarder();
356 
357         if( pTextForwarder )
358         {
359             maTextAdapter.SetForwarder(*pTextForwarder);
360 
361             return &maTextAdapter;
362         }
363     }
364 
365     return NULL;
366 }
367 
368 SvxTextForwarder* SvxEditSourceAdapter::GetTextForwarder()
369 {
370     return GetTextForwarderAdapter();
371 }
372 
373 SvxViewForwarder* SvxEditSourceAdapter::GetViewForwarder()
374 {
375     if( mbEditSourceValid && mpAdaptee.get() )
376         return mpAdaptee->GetViewForwarder();
377 
378     return NULL;
379 }
380 
381 SvxAccessibleTextEditViewAdapter* SvxEditSourceAdapter::GetEditViewForwarderAdapter( sal_Bool bCreate )
382 {
383     if( mbEditSourceValid && mpAdaptee.get() )
384     {
385         SvxEditViewForwarder* pEditViewForwarder = mpAdaptee->GetEditViewForwarder(bCreate);
386 
387         if( pEditViewForwarder )
388         {
389             SvxAccessibleTextAdapter* pTextAdapter = GetTextForwarderAdapter();
390 
391             if( pTextAdapter )
392             {
393                 maEditViewAdapter.SetForwarder(*pEditViewForwarder, *pTextAdapter);
394 
395                 return &maEditViewAdapter;
396             }
397         }
398     }
399 
400     return NULL;
401 }
402 
403 SvxEditViewForwarder* SvxEditSourceAdapter::GetEditViewForwarder( sal_Bool bCreate )
404 {
405     return GetEditViewForwarderAdapter( bCreate );
406 }
407 
408 void SvxEditSourceAdapter::UpdateData()
409 {
410     if( mbEditSourceValid && mpAdaptee.get() )
411         mpAdaptee->UpdateData();
412 }
413 
414 SfxBroadcaster& SvxEditSourceAdapter::GetBroadcaster() const
415 {
416     if( mbEditSourceValid && mpAdaptee.get() )
417         return mpAdaptee->GetBroadcaster();
418 
419     return maDummyBroadcaster;
420 }
421 
422 void SvxEditSourceAdapter::SetEditSource( ::std::auto_ptr< SvxEditSource > pAdaptee )
423 {
424     if( pAdaptee.get() )
425     {
426         mpAdaptee = pAdaptee;
427         mbEditSourceValid = sal_True;
428     }
429     else
430     {
431         // do a lazy delete (prevents us from deleting the broadcaster
432         // from within a broadcast in
433         // AccessibleTextHelper_Impl::Notify)
434         mbEditSourceValid = sal_False;
435     }
436 }
437 
438 sal_Bool SvxEditSourceAdapter::IsValid() const
439 {
440     return mbEditSourceValid;
441 }
442 
443 
444 //--------------------------------------------------------------------------------------
445 
446 SvxAccessibleTextAdapter::SvxAccessibleTextAdapter() : mrTextForwarder( NULL )
447 {
448 }
449 
450 SvxAccessibleTextAdapter::~SvxAccessibleTextAdapter()
451 {
452 }
453 
454 sal_uInt16 SvxAccessibleTextAdapter::GetParagraphCount() const
455 {
456     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
457 
458     return mrTextForwarder->GetParagraphCount();
459 }
460 
461 sal_uInt16 SvxAccessibleTextAdapter::GetTextLen( sal_uInt16 nParagraph ) const
462 {
463     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
464 
465     SvxAccessibleTextIndex aIndex;
466     aIndex.SetEEIndex( nParagraph, mrTextForwarder->GetTextLen( nParagraph ), *this );
467 
468     return static_cast< sal_uInt16 >(aIndex.GetIndex());
469 }
470 
471 String SvxAccessibleTextAdapter::GetText( const ESelection& rSel ) const
472 {
473     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
474 
475     SvxAccessibleTextIndex aStartIndex;
476     SvxAccessibleTextIndex aEndIndex;
477 
478     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
479     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
480 
481     // normalize selection
482     if( rSel.nStartPara > rSel.nEndPara ||
483         (rSel.nStartPara == rSel.nEndPara && rSel.nStartPos > rSel.nEndPos) )
484     {
485         ::std::swap( aStartIndex, aEndIndex );
486     }
487 
488     String sStr = mrTextForwarder->GetText( MakeEESelection(aStartIndex, aEndIndex) );
489 
490     // trim field text, if necessary
491     if( aStartIndex.InField() )
492     {
493         DBG_ASSERT(aStartIndex.GetFieldOffset() >= 0 &&
494                    aStartIndex.GetFieldOffset() <= USHRT_MAX,
495                    "SvxAccessibleTextIndex::GetText: index value overflow");
496 
497         sStr.Erase(0, static_cast< sal_uInt16 > (aStartIndex.GetFieldOffset()) );
498     }
499     if( aEndIndex.InField() && aEndIndex.GetFieldOffset() )
500     {
501         DBG_ASSERT(sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset()) >= 0 &&
502                    sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset()) <= USHRT_MAX,
503                    "SvxAccessibleTextIndex::GetText: index value overflow");
504 
505         sStr = sStr.Copy(0, static_cast< sal_uInt16 > (sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset())) );
506     }
507 
508     EBulletInfo aBulletInfo1 = GetBulletInfo( static_cast< sal_uInt16 >(aStartIndex.GetParagraph()) );
509     EBulletInfo aBulletInfo2 = GetBulletInfo( static_cast< sal_uInt16 >(aEndIndex.GetParagraph()) );
510 
511 	// MT: This was done in OOo, commented out in IA2 CWS...
512     /*
513     if( aStartIndex.InBullet() )
514     {
515         // prepend leading bullet
516         String sBullet = aBulletInfo1.aText;
517 
518         DBG_ASSERT(aStartIndex.GetBulletOffset() >= 0 &&
519                    aStartIndex.GetBulletOffset() <= USHRT_MAX,
520                    "SvxAccessibleTextIndex::GetText: index value overflow");
521 
522         sBullet.Erase(0, static_cast< sal_uInt16 > (aStartIndex.GetBulletOffset()) );
523 
524         sBullet += sStr;
525         sStr = sBullet;
526     }*/
527     if( aEndIndex.InBullet() )
528     {
529         // append trailing bullet
530         sStr += aBulletInfo2.aText;;
531 
532         DBG_ASSERT(sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) >= 0 &&
533                    sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) <= USHRT_MAX,
534                    "SvxAccessibleTextIndex::GetText: index value overflow");
535 
536         sStr = sStr.Copy(0, static_cast< sal_uInt16 > (sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset())) );
537     }
538     else if( aStartIndex.GetParagraph() != aEndIndex.GetParagraph() &&
539              HaveTextBullet( aEndIndex.GetParagraph() ) )
540     {
541         String sBullet = aBulletInfo2.aText;
542 
543         DBG_ASSERT(sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) >= 0 &&
544                    sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) <= USHRT_MAX,
545                    "SvxAccessibleTextIndex::GetText: index value overflow");
546 
547         sBullet = sBullet.Copy(0, static_cast< sal_uInt16 > (sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset())) );
548 
549         // insert bullet
550         sStr.Insert( sBullet,
551                      static_cast< sal_uInt16 > (GetTextLen(aStartIndex.GetParagraph()) - aStartIndex.GetIndex()) );
552     }
553 
554     return sStr;
555 }
556 
557 SfxItemSet SvxAccessibleTextAdapter::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib ) const
558 {
559     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
560 
561     SvxAccessibleTextIndex aStartIndex;
562     SvxAccessibleTextIndex aEndIndex;
563 
564     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
565     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
566 
567     return mrTextForwarder->GetAttribs( MakeEESelection(aStartIndex, aEndIndex),
568                                         bOnlyHardAttrib );
569 }
570 
571 SfxItemSet SvxAccessibleTextAdapter::GetParaAttribs( sal_uInt16 nPara ) const
572 {
573     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
574 
575     return mrTextForwarder->GetParaAttribs( nPara );
576 }
577 
578 void SvxAccessibleTextAdapter::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
579 {
580     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
581 
582     mrTextForwarder->SetParaAttribs( nPara, rSet );
583 }
584 
585 void SvxAccessibleTextAdapter::RemoveAttribs( const ESelection& , sal_Bool , sal_uInt16 )
586 {
587     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
588 }
589 
590 void SvxAccessibleTextAdapter::GetPortions( sal_uInt16 nPara, SvUShorts& rList ) const
591 {
592     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
593 
594     mrTextForwarder->GetPortions( nPara, rList );
595 }
596 
597 sal_uInt16 SvxAccessibleTextAdapter::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const
598 {
599     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
600 
601     SvxAccessibleTextIndex aStartIndex;
602     SvxAccessibleTextIndex aEndIndex;
603 
604     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
605     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
606 
607     return mrTextForwarder->GetItemState( MakeEESelection(aStartIndex, aEndIndex),
608                                           nWhich );
609 }
610 
611 sal_uInt16 SvxAccessibleTextAdapter::GetItemState( sal_uInt16 nPara, sal_uInt16 nWhich ) const
612 {
613     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
614 
615     return mrTextForwarder->GetItemState( nPara, nWhich );
616 }
617 
618 void SvxAccessibleTextAdapter::QuickInsertText( const String& rText, const ESelection& rSel )
619 {
620     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
621 
622     SvxAccessibleTextIndex aStartIndex;
623     SvxAccessibleTextIndex aEndIndex;
624 
625     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
626     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
627 
628     mrTextForwarder->QuickInsertText( rText,
629                                       MakeEESelection(aStartIndex, aEndIndex) );
630 }
631 
632 void SvxAccessibleTextAdapter::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
633 {
634     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
635 
636     SvxAccessibleTextIndex aStartIndex;
637     SvxAccessibleTextIndex aEndIndex;
638 
639     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
640     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
641 
642     mrTextForwarder->QuickInsertField( rFld,
643                                        MakeEESelection(aStartIndex, aEndIndex) );
644 }
645 
646 void SvxAccessibleTextAdapter::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
647 {
648     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
649 
650     SvxAccessibleTextIndex aStartIndex;
651     SvxAccessibleTextIndex aEndIndex;
652 
653     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
654     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
655 
656     mrTextForwarder->QuickSetAttribs( rSet,
657                                       MakeEESelection(aStartIndex, aEndIndex) );
658 }
659 
660 void SvxAccessibleTextAdapter::QuickInsertLineBreak( const ESelection& rSel )
661 {
662     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
663 
664     SvxAccessibleTextIndex aStartIndex;
665     SvxAccessibleTextIndex aEndIndex;
666 
667     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
668     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
669 
670     mrTextForwarder->QuickInsertLineBreak( MakeEESelection(aStartIndex, aEndIndex) );
671 }
672 
673 SfxItemPool* SvxAccessibleTextAdapter::GetPool() const
674 {
675     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
676 
677     return mrTextForwarder->GetPool();
678 }
679 
680 XubString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
681 {
682     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
683 
684     return mrTextForwarder->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
685 }
686 
687 void SvxAccessibleTextAdapter::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, xub_StrLen nPos )
688 {
689     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
690 
691     mrTextForwarder->FieldClicked( rField, nPara, nPos );
692 }
693 
694 sal_Int32 SvxAccessibleTextAdapter::CalcLogicalIndex( sal_uInt16 nPara, sal_uInt16 nEEIndex )
695 {
696     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
697 
698     SvxAccessibleTextIndex aIndex;
699     aIndex.SetEEIndex(nPara, nEEIndex, *mrTextForwarder);
700     return aIndex.GetIndex();
701 }
702 
703 sal_uInt16 SvxAccessibleTextAdapter::CalcEditEngineIndex( sal_uInt16 nPara, sal_Int32 nLogicalIndex )
704 {
705     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
706 
707     SvxAccessibleTextIndex aIndex;
708     aIndex.SetIndex(nPara, nLogicalIndex, *mrTextForwarder);
709     return aIndex.GetEEIndex();
710 }
711 
712 
713 
714 sal_Bool SvxAccessibleTextAdapter::IsValid() const
715 {
716     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
717 
718     if( mrTextForwarder )
719         return mrTextForwarder->IsValid();
720     else
721         return sal_False;
722 }
723 
724 LanguageType SvxAccessibleTextAdapter::GetLanguage( sal_uInt16 nPara, sal_uInt16 nPos ) const
725 {
726     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
727 
728     SvxAccessibleTextIndex aIndex;
729 
730     aIndex.SetIndex( nPara, nPos, *this );
731 
732     return mrTextForwarder->GetLanguage( nPara, aIndex.GetEEIndex() );
733 }
734 
735 sal_uInt16 SvxAccessibleTextAdapter::GetFieldCount( sal_uInt16 nPara ) const
736 {
737     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
738 
739     return mrTextForwarder->GetFieldCount( nPara );
740 }
741 
742 EFieldInfo SvxAccessibleTextAdapter::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const
743 {
744     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
745 
746     return mrTextForwarder->GetFieldInfo( nPara, nField );
747 }
748 
749 EBulletInfo SvxAccessibleTextAdapter::GetBulletInfo( sal_uInt16 nPara ) const
750 {
751     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
752 
753     return mrTextForwarder->GetBulletInfo( nPara );
754 }
755 void	SvxAccessibleTextAdapter::SetUpdateModeForAcc( sal_Bool bUp)
756 {
757 	return mrTextForwarder->SetUpdateModeForAcc( bUp );
758 }
759 sal_Bool	SvxAccessibleTextAdapter::GetUpdateModeForAcc( ) const
760 {
761 	return mrTextForwarder->GetUpdateModeForAcc( );
762 }
763 Rectangle SvxAccessibleTextAdapter::GetCharBounds( sal_uInt16 nPara, sal_uInt16 nIndex ) const
764 {
765     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
766 
767     SvxAccessibleTextIndex aIndex;
768     aIndex.SetIndex( nPara, nIndex, *this );
769 
770     // preset if anything goes wrong below
771     // n-th char in GetParagraphIndex's paragraph
772     Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) );
773 
774     if( aIndex.InBullet() )
775     {
776         EBulletInfo aBulletInfo = GetBulletInfo( nPara );
777 
778         OutputDevice* pOutDev = GetRefDevice();
779 
780         DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetCharBounds: No ref device");
781 
782         // preset if anything goes wrong below
783         aRect = aBulletInfo.aBounds; // better than nothing
784         if( pOutDev )
785         {
786             AccessibleStringWrap aStringWrap( *pOutDev, aBulletInfo.aFont, aBulletInfo.aText );
787 
788             if( aStringWrap.GetCharacterBounds( aIndex.GetBulletOffset(), aRect ) )
789                 aRect.Move( aBulletInfo.aBounds.Left(), aBulletInfo.aBounds.Top() );
790         }
791     }
792     else
793     {
794         // handle field content manually
795         if( aIndex.InField() )
796         {
797             OutputDevice* pOutDev = GetRefDevice();
798 
799             DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetCharBounds: No ref device");
800 
801             if( pOutDev )
802             {
803                 ESelection aSel = MakeEESelection( aIndex );
804 
805                 SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mrTextForwarder->GetAttribs( aSel ) );
806                 AccessibleStringWrap aStringWrap( *pOutDev,
807                                                   aFont,
808                                                   mrTextForwarder->GetText( aSel ) );
809 
810                 Rectangle aStartRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) );
811 
812                 if( !aStringWrap.GetCharacterBounds( aIndex.GetFieldOffset(), aRect ) )
813                     aRect = aStartRect;
814                 else
815                     aRect.Move( aStartRect.Left(), aStartRect.Top() );
816             }
817         }
818     }
819 
820     return aRect;
821 }
822 
823 Rectangle SvxAccessibleTextAdapter::GetParaBounds( sal_uInt16 nPara ) const
824 {
825     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
826 
827     EBulletInfo aBulletInfo = GetBulletInfo( nPara );
828 
829     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
830         aBulletInfo.bVisible &&
831         aBulletInfo.nType != SVX_NUM_BITMAP )
832     {
833         // include bullet in para bounding box
834         Rectangle aRect( mrTextForwarder->GetParaBounds( nPara ) );
835 
836         aRect.Union( aBulletInfo.aBounds );
837 
838         return aRect;
839     }
840 
841     return mrTextForwarder->GetParaBounds( nPara );
842 }
843 
844 MapMode SvxAccessibleTextAdapter::GetMapMode() const
845 {
846     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
847 
848     return mrTextForwarder->GetMapMode();
849 }
850 
851 OutputDevice* SvxAccessibleTextAdapter::GetRefDevice() const
852 {
853     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
854 
855     return mrTextForwarder->GetRefDevice();
856 }
857 
858 sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_uInt16& nPara, sal_uInt16& nIndex ) const
859 {
860     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
861 
862     if( !mrTextForwarder->GetIndexAtPoint( rPoint, nPara, nIndex ) )
863         return sal_False;
864 
865     SvxAccessibleTextIndex aIndex;
866     aIndex.SetEEIndex(nPara, nIndex, *this);
867 
868     DBG_ASSERT(aIndex.GetIndex() >= 0 && aIndex.GetIndex() <= USHRT_MAX,
869                "SvxAccessibleTextIndex::SetIndex: index value overflow");
870 
871     nIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
872 
873     EBulletInfo aBulletInfo = GetBulletInfo( nPara );
874 
875     // any text bullets?
876     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
877         aBulletInfo.bVisible &&
878         aBulletInfo.nType != SVX_NUM_BITMAP )
879     {
880         if( aBulletInfo.aBounds.IsInside( rPoint) )
881         {
882             OutputDevice* pOutDev = GetRefDevice();
883 
884             DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device");
885 
886             if( !pOutDev )
887                 return sal_False;
888 
889             AccessibleStringWrap aStringWrap( *pOutDev, aBulletInfo.aFont, aBulletInfo.aText );
890 
891             Point aPoint = rPoint;
892             aPoint.Move( -aBulletInfo.aBounds.Left(), -aBulletInfo.aBounds.Top() );
893 
894             DBG_ASSERT(aStringWrap.GetIndexAtPoint( aPoint ) >= 0 &&
895                        aStringWrap.GetIndexAtPoint( aPoint ) <= USHRT_MAX,
896                        "SvxAccessibleTextIndex::SetIndex: index value overflow");
897 
898             nIndex = static_cast< sal_uInt16 > (aStringWrap.GetIndexAtPoint( aPoint ));
899             return sal_True;
900         }
901     }
902 
903     if( aIndex.InField() )
904     {
905         OutputDevice* pOutDev = GetRefDevice();
906 
907         DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device");
908 
909         if( !pOutDev )
910             return sal_False;
911 
912         ESelection aSelection = MakeEESelection( aIndex );
913         SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mrTextForwarder->GetAttribs( aSelection ) );
914         AccessibleStringWrap aStringWrap( *pOutDev,
915                                           aFont,
916                                           mrTextForwarder->GetText( aSelection ) );
917 
918         Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() );
919         Point aPoint = rPoint;
920         aPoint.Move( -aRect.Left(), -aRect.Top() );
921 
922         DBG_ASSERT(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) >= 0 &&
923                    aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) <= USHRT_MAX,
924                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
925 
926         nIndex = static_cast< sal_uInt16 >(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint ));
927         return sal_True;
928     }
929 
930     return sal_True;
931 }
932 
933 sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
934 {
935     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
936 
937     SvxAccessibleTextIndex aIndex;
938     aIndex.SetIndex(nPara, nIndex, *this);
939     nIndex = aIndex.GetEEIndex();
940 
941     if( aIndex.InBullet() )
942     {
943         DBG_ASSERT(aIndex.GetBulletLen() >= 0 &&
944                    aIndex.GetBulletLen() <= USHRT_MAX,
945                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
946 
947         // always treat bullet as separate word
948         nStart = 0;
949         nEnd = static_cast< sal_uInt16 > (aIndex.GetBulletLen());
950 
951         return sal_True;
952     }
953 
954     if( aIndex.InField() )
955     {
956         DBG_ASSERT(aIndex.GetIndex() - aIndex.GetFieldOffset() >= 0 &&
957                    aIndex.GetIndex() - aIndex.GetFieldOffset() <= USHRT_MAX &&
958                    nStart + aIndex.GetFieldLen() >= 0 &&
959                    nStart + aIndex.GetFieldLen() <= USHRT_MAX,
960                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
961 
962         // always treat field as separate word
963         // TODO: to circumvent this, _we_ would have to do the break iterator stuff!
964         nStart = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset());
965         nEnd = static_cast< sal_uInt16 > (nStart + aIndex.GetFieldLen());
966 
967         return sal_True;
968     }
969 
970     if( !mrTextForwarder->GetWordIndices( nPara, nIndex, nStart, nEnd ) )
971         return sal_False;
972 
973     aIndex.SetEEIndex( nPara, nStart, *this );
974     DBG_ASSERT(aIndex.GetIndex() >= 0 &&
975                aIndex.GetIndex() <= USHRT_MAX,
976                "SvxAccessibleTextIndex::SetIndex: index value overflow");
977     nStart = static_cast< sal_uInt16 > (aIndex.GetIndex());
978 
979     aIndex.SetEEIndex( nPara, nEnd, *this );
980     DBG_ASSERT(aIndex.GetIndex() >= 0 &&
981                aIndex.GetIndex() <= USHRT_MAX,
982                "SvxAccessibleTextIndex::SetIndex: index value overflow");
983     nEnd = static_cast< sal_uInt16 > (aIndex.GetIndex());
984 
985     return sal_True;
986 }
987 sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_uInt16 nPara, sal_uInt16 nIndex, sal_Bool /* bInCell */) const
988 {
989     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
990 
991     SvxAccessibleTextIndex aIndex;
992     aIndex.SetIndex(nPara, nIndex, *this);
993     nIndex = aIndex.GetEEIndex();
994 
995     if( aIndex.InBullet() )
996     {
997         DBG_ASSERT(aIndex.GetBulletLen() >= 0 &&
998                    aIndex.GetBulletLen() <= USHRT_MAX,
999                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
1000 
1001         // always treat bullet as distinct attribute
1002         nStartIndex = 0;
1003         nEndIndex = static_cast< sal_uInt16 > (aIndex.GetBulletLen());
1004 
1005         return sal_True;
1006     }
1007 
1008     if( aIndex.InField() )
1009     {
1010         DBG_ASSERT(aIndex.GetIndex() - aIndex.GetFieldOffset() >= 0 &&
1011                    aIndex.GetIndex() - aIndex.GetFieldOffset() <= USHRT_MAX,
1012                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
1013 
1014         // always treat field as distinct attribute
1015         nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset());
1016         nEndIndex = static_cast< sal_uInt16 > (nStartIndex + aIndex.GetFieldLen());
1017 
1018         return sal_True;
1019     }
1020 
1021     if( !mrTextForwarder->GetAttributeRun( nStartIndex, nEndIndex, nPara, nIndex ) )
1022         return sal_False;
1023 
1024     aIndex.SetEEIndex( nPara, nStartIndex, *this );
1025     DBG_ASSERT(aIndex.GetIndex() >= 0 &&
1026                aIndex.GetIndex() <= USHRT_MAX,
1027                "SvxAccessibleTextIndex::SetIndex: index value overflow");
1028     nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
1029 
1030     aIndex.SetEEIndex( nPara, nEndIndex, *this );
1031     DBG_ASSERT(aIndex.GetIndex() >= 0 &&
1032                aIndex.GetIndex() <= USHRT_MAX,
1033                "SvxAccessibleTextIndex::SetIndex: index value overflow");
1034     nEndIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
1035 
1036     return sal_True;
1037 }
1038 
1039 sal_uInt16 SvxAccessibleTextAdapter::GetLineCount( sal_uInt16 nPara ) const
1040 {
1041     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1042 
1043     return mrTextForwarder->GetLineCount( nPara );
1044 }
1045 
1046 sal_uInt16 SvxAccessibleTextAdapter::GetLineLen( sal_uInt16 nPara, sal_uInt16 nLine ) const
1047 {
1048     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1049 
1050     SvxAccessibleTextIndex aStartIndex;
1051     SvxAccessibleTextIndex aEndIndex;
1052     sal_uInt16 nCurrLine;
1053     sal_uInt16 nCurrIndex, nLastIndex;
1054     for( nCurrLine=0, nCurrIndex=0, nLastIndex=0; nCurrLine<=nLine; ++nCurrLine )
1055     {
1056         nLastIndex = nCurrIndex;
1057         nCurrIndex =
1058             nCurrIndex + mrTextForwarder->GetLineLen( nPara, nCurrLine );
1059     }
1060 
1061     aEndIndex.SetEEIndex( nPara, nCurrIndex, *this );
1062     if( nLine > 0 )
1063     {
1064         aStartIndex.SetEEIndex( nPara, nLastIndex, *this );
1065 
1066         return static_cast< sal_uInt16 >(aEndIndex.GetIndex() - aStartIndex.GetIndex());
1067     }
1068     else
1069         return static_cast< sal_uInt16 >(aEndIndex.GetIndex());
1070 }
1071 
1072 void SvxAccessibleTextAdapter::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nParagraph, sal_uInt16 nLine ) const
1073 {
1074     mrTextForwarder->GetLineBoundaries( rStart, rEnd, nParagraph, nLine );
1075 }
1076 
1077 sal_uInt16 SvxAccessibleTextAdapter::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const
1078 {
1079     return mrTextForwarder->GetLineNumberAtIndex( nPara, nIndex );
1080 }
1081 
1082 sal_Bool SvxAccessibleTextAdapter::Delete( const ESelection& rSel )
1083 {
1084     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1085 
1086     SvxAccessibleTextIndex aStartIndex;
1087     SvxAccessibleTextIndex aEndIndex;
1088 
1089     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1090     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1091 
1092     return mrTextForwarder->Delete( MakeEESelection(aStartIndex, aEndIndex ) );
1093 }
1094 
1095 sal_Bool SvxAccessibleTextAdapter::InsertText( const String& rStr, const ESelection& rSel )
1096 {
1097     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1098 
1099     SvxAccessibleTextIndex aStartIndex;
1100     SvxAccessibleTextIndex aEndIndex;
1101 
1102     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1103     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1104 
1105     return mrTextForwarder->InsertText( rStr, MakeEESelection(aStartIndex, aEndIndex) );
1106 }
1107 
1108 sal_Bool SvxAccessibleTextAdapter::QuickFormatDoc( sal_Bool bFull )
1109 {
1110     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1111 
1112     return mrTextForwarder->QuickFormatDoc( bFull );
1113 }
1114 
1115 sal_Int16 SvxAccessibleTextAdapter::GetDepth( sal_uInt16 nPara ) const
1116 {
1117     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1118 
1119     return mrTextForwarder->GetDepth( nPara );
1120 }
1121 
1122 sal_Bool SvxAccessibleTextAdapter::SetDepth( sal_uInt16 nPara, sal_Int16 nNewDepth )
1123 {
1124     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1125 
1126     return mrTextForwarder->SetDepth( nPara, nNewDepth );
1127 }
1128 
1129 void SvxAccessibleTextAdapter::SetForwarder( SvxTextForwarder& rForwarder )
1130 {
1131     mrTextForwarder = &rForwarder;
1132 }
1133 
1134 sal_Bool SvxAccessibleTextAdapter::HaveImageBullet( sal_uInt16 nPara ) const
1135 {
1136     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1137 
1138     EBulletInfo aBulletInfo = GetBulletInfo( nPara );
1139 
1140     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
1141         aBulletInfo.bVisible &&
1142         aBulletInfo.nType == SVX_NUM_BITMAP )
1143     {
1144         return sal_True;
1145     }
1146     else
1147     {
1148         return sal_False;
1149     }
1150 }
1151 
1152 sal_Bool SvxAccessibleTextAdapter::HaveTextBullet( sal_uInt16 nPara ) const
1153 {
1154     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1155 
1156     EBulletInfo aBulletInfo = GetBulletInfo( nPara );
1157 
1158     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
1159         aBulletInfo.bVisible &&
1160         aBulletInfo.nType != SVX_NUM_BITMAP )
1161     {
1162         return sal_True;
1163     }
1164     else
1165     {
1166         return sal_False;
1167     }
1168 }
1169 
1170 sal_Bool SvxAccessibleTextAdapter::IsEditable( const ESelection& rSel )
1171 {
1172     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1173 
1174     SvxAccessibleTextIndex aStartIndex;
1175     SvxAccessibleTextIndex aEndIndex;
1176 
1177     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1178     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1179 
1180     // normalize selection
1181     if( rSel.nStartPara > rSel.nEndPara ||
1182         (rSel.nStartPara == rSel.nEndPara && rSel.nStartPos > rSel.nEndPos) )
1183     {
1184         ::std::swap( aStartIndex, aEndIndex );
1185     }
1186 
1187     return aStartIndex.IsEditableRange( aEndIndex );
1188 }
1189 
1190 const SfxItemSet * SvxAccessibleTextAdapter::GetEmptyItemSetPtr()
1191 {
1192     DBG_ERROR( "not implemented" );
1193     return 0;
1194 }
1195 
1196 void SvxAccessibleTextAdapter::AppendParagraph()
1197 {
1198     DBG_ERROR( "not implemented" );
1199 }
1200 
1201 xub_StrLen SvxAccessibleTextAdapter::AppendTextPortion( sal_uInt16, const String &, const SfxItemSet & )
1202 {
1203     DBG_ERROR( "not implemented" );
1204     return 0;
1205 }
1206 void        SvxAccessibleTextAdapter::CopyText(const SvxTextForwarder&)
1207 {
1208     DBG_ERROR( "not implemented" );
1209 }
1210 
1211 
1212 
1213 //---------------------------------------------------------------------------------------
1214 
1215 SvxAccessibleTextEditViewAdapter::SvxAccessibleTextEditViewAdapter()
1216 {
1217 }
1218 
1219 SvxAccessibleTextEditViewAdapter::~SvxAccessibleTextEditViewAdapter()
1220 {
1221 }
1222 
1223 sal_Bool SvxAccessibleTextEditViewAdapter::IsValid() const
1224 {
1225     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1226 
1227     if( mrViewForwarder )
1228         return mrViewForwarder->IsValid();
1229     else
1230         return sal_False;
1231 }
1232 
1233 Rectangle SvxAccessibleTextEditViewAdapter::GetVisArea() const
1234 {
1235     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1236 
1237     return mrViewForwarder->GetVisArea();
1238 }
1239 
1240 Point SvxAccessibleTextEditViewAdapter::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
1241 {
1242     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1243 
1244     return mrViewForwarder->LogicToPixel(rPoint, rMapMode);
1245 }
1246 
1247 Point SvxAccessibleTextEditViewAdapter::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
1248 {
1249     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1250 
1251     return mrViewForwarder->PixelToLogic(rPoint, rMapMode);
1252 }
1253 
1254 sal_Bool SvxAccessibleTextEditViewAdapter::GetSelection( ESelection& rSel ) const
1255 {
1256     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1257 
1258     ESelection aSelection;
1259 
1260     if( !mrViewForwarder->GetSelection( aSelection ) )
1261         return sal_False;
1262 
1263     SvxAccessibleTextIndex aStartIndex;
1264     SvxAccessibleTextIndex aEndIndex;
1265 
1266     aStartIndex.SetEEIndex( aSelection.nStartPara, aSelection.nStartPos, *mrTextForwarder );
1267     aEndIndex.SetEEIndex( aSelection.nEndPara, aSelection.nEndPos, *mrTextForwarder );
1268 
1269     DBG_ASSERT(aStartIndex.GetIndex() >= 0 && aStartIndex.GetIndex() <= USHRT_MAX &&
1270                aEndIndex.GetIndex() >= 0 && aEndIndex.GetIndex() <= USHRT_MAX,
1271                "SvxAccessibleTextEditViewAdapter::GetSelection: index value overflow");
1272 
1273     rSel = ESelection( aStartIndex.GetParagraph(), static_cast< sal_uInt16 > (aStartIndex.GetIndex()),
1274                        aEndIndex.GetParagraph(), static_cast< sal_uInt16 > (aEndIndex.GetIndex()) );
1275 
1276     return sal_True;
1277 }
1278 
1279 sal_Bool SvxAccessibleTextEditViewAdapter::SetSelection( const ESelection& rSel )
1280 {
1281     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1282 
1283     SvxAccessibleTextIndex aStartIndex;
1284     SvxAccessibleTextIndex aEndIndex;
1285 
1286     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *mrTextForwarder );
1287     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *mrTextForwarder );
1288 
1289     return mrViewForwarder->SetSelection( MakeEESelection(aStartIndex, aEndIndex) );
1290 }
1291 
1292 sal_Bool SvxAccessibleTextEditViewAdapter::Copy()
1293 {
1294     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1295 
1296     return mrViewForwarder->Copy();
1297 }
1298 
1299 sal_Bool SvxAccessibleTextEditViewAdapter::Cut()
1300 {
1301     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1302 
1303     return mrViewForwarder->Cut();
1304 }
1305 
1306 sal_Bool SvxAccessibleTextEditViewAdapter::Paste()
1307 {
1308     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1309 
1310     return mrViewForwarder->Paste();
1311 }
1312 
1313 void SvxAccessibleTextEditViewAdapter::SetForwarder( SvxEditViewForwarder& 		rForwarder,
1314                                                      SvxAccessibleTextAdapter&	rTextForwarder )
1315 {
1316     mrViewForwarder = &rForwarder;
1317     mrTextForwarder = &rTextForwarder;
1318 }
1319 
1320