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