xref: /aoo42x/main/editeng/source/uno/unoedprx.cxx (revision 190118d0)
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     if( aStartIndex.InBullet() )
512     {
513         // prepend leading bullet
514         String sBullet = aBulletInfo1.aText;
515 
516         DBG_ASSERT(aStartIndex.GetBulletOffset() >= 0 &&
517                    aStartIndex.GetBulletOffset() <= USHRT_MAX,
518                    "SvxAccessibleTextIndex::GetText: index value overflow");
519 
520         sBullet.Erase(0, static_cast< sal_uInt16 > (aStartIndex.GetBulletOffset()) );
521 
522         sBullet += sStr;
523         sStr = sBullet;
524     }
525 
526     if( aEndIndex.InBullet() )
527     {
528         // append trailing bullet
529         sStr += aBulletInfo2.aText;;
530 
531         DBG_ASSERT(sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) >= 0 &&
532                    sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) <= USHRT_MAX,
533                    "SvxAccessibleTextIndex::GetText: index value overflow");
534 
535         sStr = sStr.Copy(0, static_cast< sal_uInt16 > (sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset())) );
536     }
537     else if( aStartIndex.GetParagraph() != aEndIndex.GetParagraph() &&
538              HaveTextBullet( aEndIndex.GetParagraph() ) )
539     {
540         String sBullet = aBulletInfo2.aText;
541 
542         DBG_ASSERT(sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) >= 0 &&
543                    sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) <= USHRT_MAX,
544                    "SvxAccessibleTextIndex::GetText: index value overflow");
545 
546         sBullet = sBullet.Copy(0, static_cast< sal_uInt16 > (sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset())) );
547 
548         // insert bullet
549         sStr.Insert( sBullet,
550                      static_cast< sal_uInt16 > (GetTextLen(aStartIndex.GetParagraph()) - aStartIndex.GetIndex()) );
551     }
552 
553     return sStr;
554 }
555 
556 SfxItemSet SvxAccessibleTextAdapter::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib ) const
557 {
558     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
559 
560     SvxAccessibleTextIndex aStartIndex;
561     SvxAccessibleTextIndex aEndIndex;
562 
563     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
564     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
565 
566     return mrTextForwarder->GetAttribs( MakeEESelection(aStartIndex, aEndIndex),
567                                         bOnlyHardAttrib );
568 }
569 
570 SfxItemSet SvxAccessibleTextAdapter::GetParaAttribs( sal_uInt16 nPara ) const
571 {
572     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
573 
574     return mrTextForwarder->GetParaAttribs( nPara );
575 }
576 
577 void SvxAccessibleTextAdapter::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
578 {
579     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
580 
581     mrTextForwarder->SetParaAttribs( nPara, rSet );
582 }
583 
584 void SvxAccessibleTextAdapter::RemoveAttribs( const ESelection& , sal_Bool , sal_uInt16 )
585 {
586     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
587 }
588 
589 void SvxAccessibleTextAdapter::GetPortions( sal_uInt16 nPara, SvUShorts& rList ) const
590 {
591     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
592 
593     mrTextForwarder->GetPortions( nPara, rList );
594 }
595 
596 sal_uInt16 SvxAccessibleTextAdapter::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const
597 {
598     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
599 
600     SvxAccessibleTextIndex aStartIndex;
601     SvxAccessibleTextIndex aEndIndex;
602 
603     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
604     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
605 
606     return mrTextForwarder->GetItemState( MakeEESelection(aStartIndex, aEndIndex),
607                                           nWhich );
608 }
609 
610 sal_uInt16 SvxAccessibleTextAdapter::GetItemState( sal_uInt16 nPara, sal_uInt16 nWhich ) const
611 {
612     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
613 
614     return mrTextForwarder->GetItemState( nPara, nWhich );
615 }
616 
617 void SvxAccessibleTextAdapter::QuickInsertText( const String& rText, const ESelection& rSel )
618 {
619     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
620 
621     SvxAccessibleTextIndex aStartIndex;
622     SvxAccessibleTextIndex aEndIndex;
623 
624     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
625     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
626 
627     mrTextForwarder->QuickInsertText( rText,
628                                       MakeEESelection(aStartIndex, aEndIndex) );
629 }
630 
631 void SvxAccessibleTextAdapter::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
632 {
633     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
634 
635     SvxAccessibleTextIndex aStartIndex;
636     SvxAccessibleTextIndex aEndIndex;
637 
638     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
639     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
640 
641     mrTextForwarder->QuickInsertField( rFld,
642                                        MakeEESelection(aStartIndex, aEndIndex) );
643 }
644 
645 void SvxAccessibleTextAdapter::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
646 {
647     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
648 
649     SvxAccessibleTextIndex aStartIndex;
650     SvxAccessibleTextIndex aEndIndex;
651 
652     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
653     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
654 
655     mrTextForwarder->QuickSetAttribs( rSet,
656                                       MakeEESelection(aStartIndex, aEndIndex) );
657 }
658 
659 void SvxAccessibleTextAdapter::QuickInsertLineBreak( const ESelection& rSel )
660 {
661     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
662 
663     SvxAccessibleTextIndex aStartIndex;
664     SvxAccessibleTextIndex aEndIndex;
665 
666     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
667     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
668 
669     mrTextForwarder->QuickInsertLineBreak( MakeEESelection(aStartIndex, aEndIndex) );
670 }
671 
672 SfxItemPool* SvxAccessibleTextAdapter::GetPool() const
673 {
674     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
675 
676     return mrTextForwarder->GetPool();
677 }
678 
679 XubString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
680 {
681     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
682 
683     return mrTextForwarder->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
684 }
685 
686 void SvxAccessibleTextAdapter::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, xub_StrLen nPos )
687 {
688     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
689 
690     mrTextForwarder->FieldClicked( rField, nPara, nPos );
691 }
692 
693 sal_Int32 SvxAccessibleTextAdapter::CalcLogicalIndex( sal_uInt16 nPara, sal_uInt16 nEEIndex )
694 {
695     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
696 
697     SvxAccessibleTextIndex aIndex;
698     aIndex.SetEEIndex(nPara, nEEIndex, *mrTextForwarder);
699     return aIndex.GetIndex();
700 }
701 
702 sal_uInt16 SvxAccessibleTextAdapter::CalcEditEngineIndex( sal_uInt16 nPara, sal_Int32 nLogicalIndex )
703 {
704     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
705 
706     SvxAccessibleTextIndex aIndex;
707     aIndex.SetIndex(nPara, nLogicalIndex, *mrTextForwarder);
708     return aIndex.GetEEIndex();
709 }
710 
711 
712 
713 sal_Bool SvxAccessibleTextAdapter::IsValid() const
714 {
715     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
716 
717     if( mrTextForwarder )
718         return mrTextForwarder->IsValid();
719     else
720         return sal_False;
721 }
722 
723 LanguageType SvxAccessibleTextAdapter::GetLanguage( sal_uInt16 nPara, sal_uInt16 nPos ) const
724 {
725     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
726 
727     SvxAccessibleTextIndex aIndex;
728 
729     aIndex.SetIndex( nPara, nPos, *this );
730 
731     return mrTextForwarder->GetLanguage( nPara, aIndex.GetEEIndex() );
732 }
733 
734 sal_uInt16 SvxAccessibleTextAdapter::GetFieldCount( sal_uInt16 nPara ) const
735 {
736     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
737 
738     return mrTextForwarder->GetFieldCount( nPara );
739 }
740 
741 EFieldInfo SvxAccessibleTextAdapter::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const
742 {
743     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
744 
745     return mrTextForwarder->GetFieldInfo( nPara, nField );
746 }
747 
748 EBulletInfo SvxAccessibleTextAdapter::GetBulletInfo( sal_uInt16 nPara ) const
749 {
750     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
751 
752     return mrTextForwarder->GetBulletInfo( nPara );
753 }
754 
755 Rectangle SvxAccessibleTextAdapter::GetCharBounds( sal_uInt16 nPara, sal_uInt16 nIndex ) const
756 {
757     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
758 
759     SvxAccessibleTextIndex aIndex;
760     aIndex.SetIndex( nPara, nIndex, *this );
761 
762     // preset if anything goes wrong below
763     // n-th char in GetParagraphIndex's paragraph
764     Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) );
765 
766     if( aIndex.InBullet() )
767     {
768         EBulletInfo aBulletInfo = GetBulletInfo( nPara );
769 
770         OutputDevice* pOutDev = GetRefDevice();
771 
772         DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetCharBounds: No ref device");
773 
774         // preset if anything goes wrong below
775         aRect = aBulletInfo.aBounds; // better than nothing
776         if( pOutDev )
777         {
778             AccessibleStringWrap aStringWrap( *pOutDev, aBulletInfo.aFont, aBulletInfo.aText );
779 
780             if( aStringWrap.GetCharacterBounds( aIndex.GetBulletOffset(), aRect ) )
781                 aRect.Move( aBulletInfo.aBounds.Left(), aBulletInfo.aBounds.Top() );
782         }
783     }
784     else
785     {
786         // handle field content manually
787         if( aIndex.InField() )
788         {
789             OutputDevice* pOutDev = GetRefDevice();
790 
791             DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetCharBounds: No ref device");
792 
793             if( pOutDev )
794             {
795                 ESelection aSel = MakeEESelection( aIndex );
796 
797                 SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mrTextForwarder->GetAttribs( aSel ) );
798                 AccessibleStringWrap aStringWrap( *pOutDev,
799                                                   aFont,
800                                                   mrTextForwarder->GetText( aSel ) );
801 
802                 Rectangle aStartRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) );
803 
804                 if( !aStringWrap.GetCharacterBounds( aIndex.GetFieldOffset(), aRect ) )
805                     aRect = aStartRect;
806                 else
807                     aRect.Move( aStartRect.Left(), aStartRect.Top() );
808             }
809         }
810     }
811 
812     return aRect;
813 }
814 
815 Rectangle SvxAccessibleTextAdapter::GetParaBounds( sal_uInt16 nPara ) const
816 {
817     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
818 
819     EBulletInfo aBulletInfo = GetBulletInfo( nPara );
820 
821     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
822         aBulletInfo.bVisible &&
823         aBulletInfo.nType != SVX_NUM_BITMAP )
824     {
825         // include bullet in para bounding box
826         Rectangle aRect( mrTextForwarder->GetParaBounds( nPara ) );
827 
828         aRect.Union( aBulletInfo.aBounds );
829 
830         return aRect;
831     }
832 
833     return mrTextForwarder->GetParaBounds( nPara );
834 }
835 
836 MapMode SvxAccessibleTextAdapter::GetMapMode() const
837 {
838     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
839 
840     return mrTextForwarder->GetMapMode();
841 }
842 
843 OutputDevice* SvxAccessibleTextAdapter::GetRefDevice() const
844 {
845     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
846 
847     return mrTextForwarder->GetRefDevice();
848 }
849 
850 sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_uInt16& nPara, sal_uInt16& nIndex ) const
851 {
852     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
853 
854     if( !mrTextForwarder->GetIndexAtPoint( rPoint, nPara, nIndex ) )
855         return sal_False;
856 
857     SvxAccessibleTextIndex aIndex;
858     aIndex.SetEEIndex(nPara, nIndex, *this);
859 
860     DBG_ASSERT(aIndex.GetIndex() >= 0 && aIndex.GetIndex() <= USHRT_MAX,
861                "SvxAccessibleTextIndex::SetIndex: index value overflow");
862 
863     nIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
864 
865     EBulletInfo aBulletInfo = GetBulletInfo( nPara );
866 
867     // any text bullets?
868     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
869         aBulletInfo.bVisible &&
870         aBulletInfo.nType != SVX_NUM_BITMAP )
871     {
872         if( aBulletInfo.aBounds.IsInside( rPoint) )
873         {
874             OutputDevice* pOutDev = GetRefDevice();
875 
876             DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device");
877 
878             if( !pOutDev )
879                 return sal_False;
880 
881             AccessibleStringWrap aStringWrap( *pOutDev, aBulletInfo.aFont, aBulletInfo.aText );
882 
883             Point aPoint = rPoint;
884             aPoint.Move( -aBulletInfo.aBounds.Left(), -aBulletInfo.aBounds.Top() );
885 
886             DBG_ASSERT(aStringWrap.GetIndexAtPoint( aPoint ) >= 0 &&
887                        aStringWrap.GetIndexAtPoint( aPoint ) <= USHRT_MAX,
888                        "SvxAccessibleTextIndex::SetIndex: index value overflow");
889 
890             nIndex = static_cast< sal_uInt16 > (aStringWrap.GetIndexAtPoint( aPoint ));
891             return sal_True;
892         }
893     }
894 
895     if( aIndex.InField() )
896     {
897         OutputDevice* pOutDev = GetRefDevice();
898 
899         DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device");
900 
901         if( !pOutDev )
902             return sal_False;
903 
904         ESelection aSelection = MakeEESelection( aIndex );
905         SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mrTextForwarder->GetAttribs( aSelection ) );
906         AccessibleStringWrap aStringWrap( *pOutDev,
907                                           aFont,
908                                           mrTextForwarder->GetText( aSelection ) );
909 
910         Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() );
911         Point aPoint = rPoint;
912         aPoint.Move( -aRect.Left(), -aRect.Top() );
913 
914         DBG_ASSERT(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) >= 0 &&
915                    aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) <= USHRT_MAX,
916                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
917 
918         nIndex = static_cast< sal_uInt16 >(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint ));
919         return sal_True;
920     }
921 
922     return sal_True;
923 }
924 
925 sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
926 {
927     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
928 
929     SvxAccessibleTextIndex aIndex;
930     aIndex.SetIndex(nPara, nIndex, *this);
931     nIndex = aIndex.GetEEIndex();
932 
933     if( aIndex.InBullet() )
934     {
935         DBG_ASSERT(aIndex.GetBulletLen() >= 0 &&
936                    aIndex.GetBulletLen() <= USHRT_MAX,
937                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
938 
939         // always treat bullet as separate word
940         nStart = 0;
941         nEnd = static_cast< sal_uInt16 > (aIndex.GetBulletLen());
942 
943         return sal_True;
944     }
945 
946     if( aIndex.InField() )
947     {
948         DBG_ASSERT(aIndex.GetIndex() - aIndex.GetFieldOffset() >= 0 &&
949                    aIndex.GetIndex() - aIndex.GetFieldOffset() <= USHRT_MAX &&
950                    nStart + aIndex.GetFieldLen() >= 0 &&
951                    nStart + aIndex.GetFieldLen() <= USHRT_MAX,
952                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
953 
954         // always treat field as separate word
955         // TODO: to circumvent this, _we_ would have to do the break iterator stuff!
956         nStart = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset());
957         nEnd = static_cast< sal_uInt16 > (nStart + aIndex.GetFieldLen());
958 
959         return sal_True;
960     }
961 
962     if( !mrTextForwarder->GetWordIndices( nPara, nIndex, nStart, nEnd ) )
963         return sal_False;
964 
965     aIndex.SetEEIndex( nPara, nStart, *this );
966     DBG_ASSERT(aIndex.GetIndex() >= 0 &&
967                aIndex.GetIndex() <= USHRT_MAX,
968                "SvxAccessibleTextIndex::SetIndex: index value overflow");
969     nStart = static_cast< sal_uInt16 > (aIndex.GetIndex());
970 
971     aIndex.SetEEIndex( nPara, nEnd, *this );
972     DBG_ASSERT(aIndex.GetIndex() >= 0 &&
973                aIndex.GetIndex() <= USHRT_MAX,
974                "SvxAccessibleTextIndex::SetIndex: index value overflow");
975     nEnd = static_cast< sal_uInt16 > (aIndex.GetIndex());
976 
977     return sal_True;
978 }
979 
980 sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_uInt16 nPara, sal_uInt16 nIndex ) const
981 {
982     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
983 
984     SvxAccessibleTextIndex aIndex;
985     aIndex.SetIndex(nPara, nIndex, *this);
986     nIndex = aIndex.GetEEIndex();
987 
988     if( aIndex.InBullet() )
989     {
990         DBG_ASSERT(aIndex.GetBulletLen() >= 0 &&
991                    aIndex.GetBulletLen() <= USHRT_MAX,
992                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
993 
994         // always treat bullet as distinct attribute
995         nStartIndex = 0;
996         nEndIndex = static_cast< sal_uInt16 > (aIndex.GetBulletLen());
997 
998         return sal_True;
999     }
1000 
1001     if( aIndex.InField() )
1002     {
1003         DBG_ASSERT(aIndex.GetIndex() - aIndex.GetFieldOffset() >= 0 &&
1004                    aIndex.GetIndex() - aIndex.GetFieldOffset() <= USHRT_MAX,
1005                    "SvxAccessibleTextIndex::SetIndex: index value overflow");
1006 
1007         // always treat field as distinct attribute
1008         nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset());
1009         nEndIndex = static_cast< sal_uInt16 > (nStartIndex + aIndex.GetFieldLen());
1010 
1011         return sal_True;
1012     }
1013 
1014     if( !mrTextForwarder->GetAttributeRun( nStartIndex, nEndIndex, nPara, nIndex ) )
1015         return sal_False;
1016 
1017     aIndex.SetEEIndex( nPara, nStartIndex, *this );
1018     DBG_ASSERT(aIndex.GetIndex() >= 0 &&
1019                aIndex.GetIndex() <= USHRT_MAX,
1020                "SvxAccessibleTextIndex::SetIndex: index value overflow");
1021     nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
1022 
1023     aIndex.SetEEIndex( nPara, nEndIndex, *this );
1024     DBG_ASSERT(aIndex.GetIndex() >= 0 &&
1025                aIndex.GetIndex() <= USHRT_MAX,
1026                "SvxAccessibleTextIndex::SetIndex: index value overflow");
1027     nEndIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
1028 
1029     return sal_True;
1030 }
1031 
1032 sal_uInt16 SvxAccessibleTextAdapter::GetLineCount( sal_uInt16 nPara ) const
1033 {
1034     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1035 
1036     return mrTextForwarder->GetLineCount( nPara );
1037 }
1038 
1039 sal_uInt16 SvxAccessibleTextAdapter::GetLineLen( sal_uInt16 nPara, sal_uInt16 nLine ) const
1040 {
1041     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1042 
1043     SvxAccessibleTextIndex aStartIndex;
1044     SvxAccessibleTextIndex aEndIndex;
1045     sal_uInt16 nCurrLine;
1046     sal_uInt16 nCurrIndex, nLastIndex;
1047     for( nCurrLine=0, nCurrIndex=0, nLastIndex=0; nCurrLine<=nLine; ++nCurrLine )
1048     {
1049         nLastIndex = nCurrIndex;
1050         nCurrIndex =
1051             nCurrIndex + mrTextForwarder->GetLineLen( nPara, nCurrLine );
1052     }
1053 
1054     aEndIndex.SetEEIndex( nPara, nCurrIndex, *this );
1055     if( nLine > 0 )
1056     {
1057         aStartIndex.SetEEIndex( nPara, nLastIndex, *this );
1058 
1059         return static_cast< sal_uInt16 >(aEndIndex.GetIndex() - aStartIndex.GetIndex());
1060     }
1061     else
1062         return static_cast< sal_uInt16 >(aEndIndex.GetIndex());
1063 }
1064 
1065 void SvxAccessibleTextAdapter::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nParagraph, sal_uInt16 nLine ) const
1066 {
1067     mrTextForwarder->GetLineBoundaries( rStart, rEnd, nParagraph, nLine );
1068 }
1069 
1070 sal_uInt16 SvxAccessibleTextAdapter::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const
1071 {
1072     return mrTextForwarder->GetLineNumberAtIndex( nPara, nIndex );
1073 }
1074 
1075 sal_Bool SvxAccessibleTextAdapter::Delete( const ESelection& rSel )
1076 {
1077     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1078 
1079     SvxAccessibleTextIndex aStartIndex;
1080     SvxAccessibleTextIndex aEndIndex;
1081 
1082     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1083     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1084 
1085     return mrTextForwarder->Delete( MakeEESelection(aStartIndex, aEndIndex ) );
1086 }
1087 
1088 sal_Bool SvxAccessibleTextAdapter::InsertText( const String& rStr, const ESelection& rSel )
1089 {
1090     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1091 
1092     SvxAccessibleTextIndex aStartIndex;
1093     SvxAccessibleTextIndex aEndIndex;
1094 
1095     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1096     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1097 
1098     return mrTextForwarder->InsertText( rStr, MakeEESelection(aStartIndex, aEndIndex) );
1099 }
1100 
1101 sal_Bool SvxAccessibleTextAdapter::QuickFormatDoc( sal_Bool bFull )
1102 {
1103     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1104 
1105     return mrTextForwarder->QuickFormatDoc( bFull );
1106 }
1107 
1108 sal_Int16 SvxAccessibleTextAdapter::GetDepth( sal_uInt16 nPara ) const
1109 {
1110     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1111 
1112     return mrTextForwarder->GetDepth( nPara );
1113 }
1114 
1115 sal_Bool SvxAccessibleTextAdapter::SetDepth( sal_uInt16 nPara, sal_Int16 nNewDepth )
1116 {
1117     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1118 
1119     return mrTextForwarder->SetDepth( nPara, nNewDepth );
1120 }
1121 
1122 void SvxAccessibleTextAdapter::SetForwarder( SvxTextForwarder& rForwarder )
1123 {
1124     mrTextForwarder = &rForwarder;
1125 }
1126 
1127 sal_Bool SvxAccessibleTextAdapter::HaveImageBullet( sal_uInt16 nPara ) const
1128 {
1129     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1130 
1131     EBulletInfo aBulletInfo = GetBulletInfo( nPara );
1132 
1133     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
1134         aBulletInfo.bVisible &&
1135         aBulletInfo.nType == SVX_NUM_BITMAP )
1136     {
1137         return sal_True;
1138     }
1139     else
1140     {
1141         return sal_False;
1142     }
1143 }
1144 
1145 sal_Bool SvxAccessibleTextAdapter::HaveTextBullet( sal_uInt16 nPara ) const
1146 {
1147     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1148 
1149     EBulletInfo aBulletInfo = GetBulletInfo( nPara );
1150 
1151     if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
1152         aBulletInfo.bVisible &&
1153         aBulletInfo.nType != SVX_NUM_BITMAP )
1154     {
1155         return sal_True;
1156     }
1157     else
1158     {
1159         return sal_False;
1160     }
1161 }
1162 
1163 sal_Bool SvxAccessibleTextAdapter::IsEditable( const ESelection& rSel )
1164 {
1165     DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1166 
1167     SvxAccessibleTextIndex aStartIndex;
1168     SvxAccessibleTextIndex aEndIndex;
1169 
1170     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1171     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1172 
1173     // normalize selection
1174     if( rSel.nStartPara > rSel.nEndPara ||
1175         (rSel.nStartPara == rSel.nEndPara && rSel.nStartPos > rSel.nEndPos) )
1176     {
1177         ::std::swap( aStartIndex, aEndIndex );
1178     }
1179 
1180     return aStartIndex.IsEditableRange( aEndIndex );
1181 }
1182 
1183 const SfxItemSet * SvxAccessibleTextAdapter::GetEmptyItemSetPtr()
1184 {
1185     DBG_ERROR( "not implemented" );
1186     return 0;
1187 }
1188 
1189 void SvxAccessibleTextAdapter::AppendParagraph()
1190 {
1191     DBG_ERROR( "not implemented" );
1192 }
1193 
1194 xub_StrLen SvxAccessibleTextAdapter::AppendTextPortion( sal_uInt16, const String &, const SfxItemSet & )
1195 {
1196     DBG_ERROR( "not implemented" );
1197     return 0;
1198 }
1199 void        SvxAccessibleTextAdapter::CopyText(const SvxTextForwarder&)
1200 {
1201     DBG_ERROR( "not implemented" );
1202 }
1203 
1204 
1205 
1206 //---------------------------------------------------------------------------------------
1207 
1208 SvxAccessibleTextEditViewAdapter::SvxAccessibleTextEditViewAdapter()
1209 {
1210 }
1211 
1212 SvxAccessibleTextEditViewAdapter::~SvxAccessibleTextEditViewAdapter()
1213 {
1214 }
1215 
1216 sal_Bool SvxAccessibleTextEditViewAdapter::IsValid() const
1217 {
1218     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1219 
1220     if( mrViewForwarder )
1221         return mrViewForwarder->IsValid();
1222     else
1223         return sal_False;
1224 }
1225 
1226 Rectangle SvxAccessibleTextEditViewAdapter::GetVisArea() const
1227 {
1228     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1229 
1230     return mrViewForwarder->GetVisArea();
1231 }
1232 
1233 Point SvxAccessibleTextEditViewAdapter::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
1234 {
1235     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1236 
1237     return mrViewForwarder->LogicToPixel(rPoint, rMapMode);
1238 }
1239 
1240 Point SvxAccessibleTextEditViewAdapter::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
1241 {
1242     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1243 
1244     return mrViewForwarder->PixelToLogic(rPoint, rMapMode);
1245 }
1246 
1247 sal_Bool SvxAccessibleTextEditViewAdapter::GetSelection( ESelection& rSel ) const
1248 {
1249     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1250 
1251     ESelection aSelection;
1252 
1253     if( !mrViewForwarder->GetSelection( aSelection ) )
1254         return sal_False;
1255 
1256     SvxAccessibleTextIndex aStartIndex;
1257     SvxAccessibleTextIndex aEndIndex;
1258 
1259     aStartIndex.SetEEIndex( aSelection.nStartPara, aSelection.nStartPos, *mrTextForwarder );
1260     aEndIndex.SetEEIndex( aSelection.nEndPara, aSelection.nEndPos, *mrTextForwarder );
1261 
1262     DBG_ASSERT(aStartIndex.GetIndex() >= 0 && aStartIndex.GetIndex() <= USHRT_MAX &&
1263                aEndIndex.GetIndex() >= 0 && aEndIndex.GetIndex() <= USHRT_MAX,
1264                "SvxAccessibleTextEditViewAdapter::GetSelection: index value overflow");
1265 
1266     rSel = ESelection( aStartIndex.GetParagraph(), static_cast< sal_uInt16 > (aStartIndex.GetIndex()),
1267                        aEndIndex.GetParagraph(), static_cast< sal_uInt16 > (aEndIndex.GetIndex()) );
1268 
1269     return sal_True;
1270 }
1271 
1272 sal_Bool SvxAccessibleTextEditViewAdapter::SetSelection( const ESelection& rSel )
1273 {
1274     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1275 
1276     SvxAccessibleTextIndex aStartIndex;
1277     SvxAccessibleTextIndex aEndIndex;
1278 
1279     aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *mrTextForwarder );
1280     aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *mrTextForwarder );
1281 
1282     return mrViewForwarder->SetSelection( MakeEESelection(aStartIndex, aEndIndex) );
1283 }
1284 
1285 sal_Bool SvxAccessibleTextEditViewAdapter::Copy()
1286 {
1287     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1288 
1289     return mrViewForwarder->Copy();
1290 }
1291 
1292 sal_Bool SvxAccessibleTextEditViewAdapter::Cut()
1293 {
1294     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1295 
1296     return mrViewForwarder->Cut();
1297 }
1298 
1299 sal_Bool SvxAccessibleTextEditViewAdapter::Paste()
1300 {
1301     DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1302 
1303     return mrViewForwarder->Paste();
1304 }
1305 
1306 void SvxAccessibleTextEditViewAdapter::SetForwarder( SvxEditViewForwarder& 		rForwarder,
1307                                                      SvxAccessibleTextAdapter&	rTextForwarder )
1308 {
1309     mrViewForwarder = &rForwarder;
1310     mrTextForwarder = &rTextForwarder;
1311 }
1312 
1313