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