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