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 <editeng/flditem.hxx>
43 : : #include <com/sun/star/uno/Any.hxx>
44 : : #include <com/sun/star/uno/Reference.hxx>
45 : : #include <com/sun/star/awt/Point.hpp>
46 : : #include <com/sun/star/awt/Rectangle.hpp>
47 : : #include <com/sun/star/lang/DisposedException.hpp>
48 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
49 : : #include <com/sun/star/accessibility/AccessibleTextType.hpp>
50 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
51 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
52 : : #include <comphelper/accessibleeventnotifier.hxx>
53 : : #include <comphelper/sequenceashashmap.hxx>
54 : : #include <unotools/accessiblestatesethelper.hxx>
55 : : #include <unotools/accessiblerelationsethelper.hxx>
56 : : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
57 : : #include <vcl/unohelp.hxx>
58 : : #include <editeng/editeng.hxx>
59 : : #include <editeng/unoprnms.hxx>
60 : : #include <editeng/unoipset.hxx>
61 : : #include <editeng/outliner.hxx>
62 : :
63 : : //------------------------------------------------------------------------
64 : : //
65 : : // Project-local header
66 : : //
67 : : //------------------------------------------------------------------------
68 : :
69 : : #include <com/sun/star/beans/PropertyState.hpp>
70 : :
71 : : //!!!#include <svx/unoshape.hxx>
72 : : //!!!#include <svx/dialmgr.hxx>
73 : : //!!!#include "accessibility.hrc"
74 : :
75 : : #include <editeng/unolingu.hxx>
76 : : #include <editeng/unopracc.hxx>
77 : : #include "editeng/AccessibleEditableTextPara.hxx"
78 : : #include "AccessibleHyperlink.hxx"
79 : :
80 : : #include <svtools/colorcfg.hxx>
81 : :
82 : :
83 : : using namespace ::com::sun::star;
84 : : using namespace ::com::sun::star::beans;
85 : : using namespace ::com::sun::star::accessibility;
86 : :
87 : :
88 : : //------------------------------------------------------------------------
89 : : //
90 : : // AccessibleEditableTextPara implementation
91 : : //
92 : : //------------------------------------------------------------------------
93 : :
94 : : namespace accessibility
95 : : {
96 : :
97 : 4 : const SvxItemPropertySet* ImplGetSvxCharAndParaPropertiesSet()
98 : : {
99 : : // PropertyMap for character and paragraph properties
100 : : static const SfxItemPropertyMapEntry aPropMap[] =
101 : : {
102 [ + - ][ + - ]: 2 : SVX_UNOEDIT_CHAR_PROPERTIES,
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
103 [ + - ][ + - ]: 2 : SVX_UNOEDIT_PARA_PROPERTIES,
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
104 [ + - ][ + - ]: 2 : SVX_UNOEDIT_NUMBERING_PROPERTIE,
105 [ + - ]: 2 : {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
106 [ + - ]: 2 : {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
107 : : {0,0,0,0,0,0}
108 [ + + ][ + - ]: 6 : };
[ # # ]
109 [ + + ][ + - ]: 4 : static SvxItemPropertySet aPropSet( aPropMap, EditEngine::GetGlobalItemPool() );
[ + - ][ + - ]
[ # # ]
110 : 4 : return &aPropSet;
111 : : }
112 : :
113 : :
114 : : DBG_NAME( AccessibleEditableTextPara )
115 : :
116 : : // #i27138# - add parameter <_pParaManager>
117 : 56 : AccessibleEditableTextPara::AccessibleEditableTextPara(
118 : : const uno::Reference< XAccessible >& rParent,
119 : : const AccessibleParaManager* _pParaManager )
120 : : : AccessibleTextParaInterfaceBase( m_aMutex ),
121 : : mnParagraphIndex( 0 ),
122 : : mnIndexInParent( 0 ),
123 : : mpEditSource( NULL ),
124 : : maEEOffset( 0, 0 ),
125 : : mxParent( rParent ),
126 : : // well, that's strictly (UNO) exception safe, though not
127 : : // really robust. We rely on the fact that this member is
128 : : // constructed last, and that the constructor body catches
129 : : // exceptions, thus no chance for exceptions once the Id is
130 : : // fetched. Nevertheless, normally should employ RAII here...
131 [ + - ]: 56 : mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient()),
132 : : // #i27138#
133 [ + - ][ + - ]: 56 : mpParaManager( _pParaManager )
134 : : {
135 : : #ifdef DBG_UTIL
136 : : DBG_CTOR( AccessibleEditableTextPara, NULL );
137 : : OSL_TRACE( "AccessibleEditableTextPara received ID: %d", mnNotifierClientId );
138 : : #endif
139 : :
140 : : try
141 : : {
142 : : // Create the state set.
143 [ + - # # ]: 56 : ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper ();
144 [ + - ][ + - ]: 56 : mxStateSet = pStateSet;
145 : :
146 : : // these are always on
147 [ + - ]: 56 : pStateSet->AddState( AccessibleStateType::MULTI_LINE );
148 [ + - ]: 56 : pStateSet->AddState( AccessibleStateType::FOCUSABLE );
149 [ + - ]: 56 : pStateSet->AddState( AccessibleStateType::VISIBLE );
150 [ + - ]: 56 : pStateSet->AddState( AccessibleStateType::SHOWING );
151 [ + - ]: 56 : pStateSet->AddState( AccessibleStateType::ENABLED );
152 [ + - ]: 56 : pStateSet->AddState( AccessibleStateType::SENSITIVE );
153 : : }
154 [ # # ]: 0 : catch (const uno::Exception&)
155 : : {
156 : : }
157 : 56 : }
158 : :
159 [ + - ][ + - ]: 56 : AccessibleEditableTextPara::~AccessibleEditableTextPara()
[ + - ]
160 : : {
161 : : DBG_DTOR( AccessibleEditableTextPara, NULL );
162 : :
163 : : // sign off from event notifier
164 [ + - ][ + + ]: 56 : if( getNotifierClientId() != -1 )
165 : : {
166 : : try
167 : : {
168 [ + - ][ + - ]: 10 : ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() );
169 : : #ifdef DBG_UTIL
170 : : OSL_TRACE( "AccessibleEditableTextPara revoked ID: %d", mnNotifierClientId );
171 : : #endif
172 : : }
173 [ # # ]: 0 : catch (const uno::Exception&)
174 : : {
175 : : }
176 : : }
177 [ - + ][ # # ]: 112 : }
178 : :
179 : 199 : ::rtl::OUString AccessibleEditableTextPara::implGetText()
180 : : {
181 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
182 : :
183 [ + - ]: 199 : return GetTextRange( 0, GetTextLen() );
184 : : }
185 : :
186 : 6 : ::com::sun::star::lang::Locale AccessibleEditableTextPara::implGetLocale()
187 : : {
188 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
189 : :
190 : 6 : lang::Locale aLocale;
191 : :
192 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
193 : : "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
194 : :
195 : : // return locale of first character in the paragraph
196 [ + - ][ + - ]: 6 : return SvxLanguageToLocale(aLocale, GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 ));
[ + - ][ + - ]
197 : : }
198 : :
199 : 0 : void AccessibleEditableTextPara::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
200 : : {
201 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
202 : :
203 : : sal_uInt16 nStart, nEnd;
204 : :
205 [ # # ][ # # ]: 0 : if( GetSelection( nStart, nEnd ) )
206 : : {
207 : 0 : nStartIndex = nStart;
208 : 0 : nEndIndex = nEnd;
209 : : }
210 : : else
211 : : {
212 : : // #102234# No exception, just set to 'invalid'
213 : 0 : nStartIndex = -1;
214 : 0 : nEndIndex = -1;
215 : : }
216 : 0 : }
217 : :
218 : 8 : void AccessibleEditableTextPara::implGetParagraphBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 /*nIndex*/ )
219 : : {
220 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
221 : : DBG_WARNING( "AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" );
222 : :
223 : 8 : rBoundary.startPos = 0;
224 : 8 : rBoundary.endPos = GetTextLen();
225 : 8 : }
226 : :
227 : 0 : void AccessibleEditableTextPara::implGetLineBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 nIndex )
228 : : {
229 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
230 : :
231 : 0 : SvxTextForwarder& rCacheTF = GetTextForwarder();
232 : 0 : const sal_Int32 nParaIndex = GetParagraphIndex();
233 : :
234 : : DBG_ASSERT(nParaIndex >= 0 && nParaIndex <= USHRT_MAX,
235 : : "AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow");
236 : :
237 : 0 : const sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
238 : :
239 : 0 : CheckPosition(nIndex);
240 : :
241 : 0 : rBoundary.startPos = rBoundary.endPos = -1;
242 : :
243 : 0 : const sal_uInt16 nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
244 : :
245 [ # # ]: 0 : if( nIndex == nTextLen )
246 : : {
247 : : // #i17014# Special-casing one-behind-the-end character
248 [ # # ]: 0 : if( nLineCount <= 1 )
249 : 0 : rBoundary.startPos = 0;
250 : : else
251 : : rBoundary.startPos = nTextLen - rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ),
252 : 0 : nLineCount-1 );
253 : :
254 : 0 : rBoundary.endPos = nTextLen;
255 : : }
256 : : else
257 : : {
258 : : // normal line search
259 : : sal_uInt16 nLine;
260 : : sal_Int32 nCurIndex;
261 [ # # ]: 0 : for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
262 : : {
263 : 0 : nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
264 : :
265 [ # # ]: 0 : if( nCurIndex > nIndex )
266 : : {
267 : 0 : rBoundary.startPos = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
268 : 0 : rBoundary.endPos = nCurIndex;
269 : 0 : break;
270 : : }
271 : : }
272 : : }
273 : 0 : }
274 : :
275 : 262 : int AccessibleEditableTextPara::getNotifierClientId() const
276 : : {
277 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
278 : :
279 : 262 : return mnNotifierClientId;
280 : : }
281 : :
282 : 45 : void AccessibleEditableTextPara::SetIndexInParent( sal_Int32 nIndex )
283 : : {
284 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
285 : :
286 : 45 : mnIndexInParent = nIndex;
287 : 45 : }
288 : :
289 : 0 : sal_Int32 AccessibleEditableTextPara::GetIndexInParent() const
290 : : {
291 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
292 : :
293 : 0 : return mnIndexInParent;
294 : : }
295 : :
296 : 45 : void AccessibleEditableTextPara::SetParagraphIndex( sal_Int32 nIndex )
297 : : {
298 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
299 : :
300 : 45 : sal_Int32 nOldIndex = mnParagraphIndex;
301 : :
302 : 45 : mnParagraphIndex = nIndex;
303 : :
304 [ + - ]: 45 : WeakBullet::HardRefType aChild( maImageBullet.get() );
305 [ - + ]: 45 : if( aChild.is() )
306 [ # # ]: 0 : aChild->SetParagraphIndex(mnParagraphIndex);
307 : :
308 : : try
309 : : {
310 [ - + ]: 45 : if( nOldIndex != nIndex )
311 : : {
312 : 0 : uno::Any aOldDesc;
313 : 0 : uno::Any aOldName;
314 : :
315 : : try
316 : : {
317 [ # # ][ # # ]: 0 : aOldDesc <<= getAccessibleDescription();
318 [ # # ][ # # ]: 0 : aOldName <<= getAccessibleName();
[ # # ]
319 : : }
320 [ # # ]: 0 : catch (const uno::Exception&) // optional behaviour
321 : : {
322 : : }
323 : : // index and therefore description changed
324 [ # # ][ # # ]: 0 : FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::makeAny( getAccessibleDescription() ), aOldDesc );
[ # # ]
325 [ # # ][ # # ]: 0 : FireEvent( AccessibleEventId::NAME_CHANGED, uno::makeAny( getAccessibleName() ), aOldName );
[ # # ][ # # ]
326 : : }
327 : : }
328 [ # # ]: 0 : catch (const uno::Exception&) // optional behaviour
329 : : {
330 [ + - ]: 45 : }
331 : 45 : }
332 : :
333 : 693 : sal_Int32 AccessibleEditableTextPara::GetParagraphIndex() const SAL_THROW((uno::RuntimeException))
334 : : {
335 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
336 : :
337 : 693 : return mnParagraphIndex;
338 : : }
339 : :
340 : 50 : void AccessibleEditableTextPara::Dispose()
341 : : {
342 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
343 : :
344 : 50 : int nClientId( getNotifierClientId() );
345 : :
346 : : // #108212# drop all references before notifying dispose
347 : 50 : mxParent = NULL;
348 : 50 : mnNotifierClientId = -1;
349 : 50 : mpEditSource = NULL;
350 : :
351 : : // notify listeners
352 [ + + ]: 50 : if( nClientId != -1 )
353 : : {
354 : : try
355 : : {
356 [ + - ]: 46 : uno::Reference < XAccessibleContext > xThis = getAccessibleContext();
357 : :
358 : : // #106234# Delegate to EventNotifier
359 [ + - ][ # # ]: 46 : ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis );
360 : : #ifdef DBG_UTIL
361 : : OSL_TRACE( "Disposed ID: %d", nClientId );
362 : : #endif
363 : : }
364 : 0 : catch (const uno::Exception&)
365 : : {
366 : : }
367 : : }
368 : 50 : }
369 : :
370 : 61 : void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSource )
371 : : {
372 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
373 : :
374 : 61 : mpEditSource = pEditSource;
375 : :
376 [ + - ]: 61 : WeakBullet::HardRefType aChild( maImageBullet.get() );
377 [ - + ]: 61 : if( aChild.is() )
378 [ # # ]: 0 : aChild->SetEditSource(pEditSource);
379 : :
380 [ + + ]: 61 : if( !mpEditSource )
381 : : {
382 : : // going defunc
383 [ + - ]: 5 : UnSetState( AccessibleStateType::SHOWING );
384 [ + - ]: 5 : UnSetState( AccessibleStateType::VISIBLE );
385 [ + - ]: 5 : SetState( AccessibleStateType::INVALID );
386 [ + - ]: 5 : SetState( AccessibleStateType::DEFUNC );
387 : :
388 [ + - ]: 5 : Dispose();
389 : : }
390 : :
391 : : // #108900# Init last text content
392 : : try
393 : : {
394 [ + + ]: 61 : TextChanged();
395 : : }
396 [ + - ]: 5 : catch (const uno::RuntimeException&)
397 : : {
398 [ + - ]: 61 : }
399 [ - + ]: 66 : }
400 : :
401 : 198 : ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nStartEEIndex, sal_Int32 nEndEEIndex )
402 : : {
403 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
404 : :
405 : : // check overflow
406 : : DBG_ASSERT(nStartEEIndex >= 0 && nStartEEIndex <= USHRT_MAX &&
407 : : nEndEEIndex >= 0 && nEndEEIndex <= USHRT_MAX &&
408 : : GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
409 : : "AccessibleEditableTextPara::MakeSelection: index value overflow");
410 : :
411 : 198 : sal_uInt16 nParaIndex = static_cast< sal_uInt16 >( GetParagraphIndex() );
412 : : return ESelection( nParaIndex, static_cast< sal_uInt16 >( nStartEEIndex ),
413 : 198 : nParaIndex, static_cast< sal_uInt16 >( nEndEEIndex ) );
414 : : }
415 : :
416 : 2 : ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nEEIndex )
417 : : {
418 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
419 : :
420 : 2 : return MakeSelection( nEEIndex, nEEIndex+1 );
421 : : }
422 : :
423 : 0 : ESelection AccessibleEditableTextPara::MakeCursor( sal_Int32 nEEIndex )
424 : : {
425 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
426 : :
427 : 0 : return MakeSelection( nEEIndex, nEEIndex );
428 : : }
429 : :
430 : 8 : void AccessibleEditableTextPara::CheckIndex( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
431 : : {
432 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
433 : :
434 [ + + ][ + + ]: 8 : if( nIndex < 0 || nIndex >= getCharacterCount() )
[ + + ]
435 : : throw lang::IndexOutOfBoundsException(::rtl::OUString("AccessibleEditableTextPara: character index out of bounds"),
436 : : uno::Reference< uno::XInterface >
437 [ + - ][ + - ]: 4 : ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy
438 : 4 : }
439 : :
440 : 54 : void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
441 : : {
442 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
443 : :
444 [ + + ][ + + ]: 54 : if( nIndex < 0 || nIndex > getCharacterCount() )
[ + + ]
445 : : throw lang::IndexOutOfBoundsException(::rtl::OUString("AccessibleEditableTextPara: character position out of bounds"),
446 : : uno::Reference< uno::XInterface >
447 [ + - ][ + - ]: 8 : ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy
448 : 46 : }
449 : :
450 : 6 : void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
451 : : {
452 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
453 : :
454 : 6 : CheckPosition( nStart );
455 : 2 : CheckPosition( nEnd );
456 : 2 : }
457 : :
458 : 0 : sal_Bool AccessibleEditableTextPara::GetSelection( sal_uInt16& nStartPos, sal_uInt16& nEndPos ) SAL_THROW((uno::RuntimeException))
459 : : {
460 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
461 : :
462 : 0 : ESelection aSelection;
463 [ # # ]: 0 : sal_uInt16 nPara = static_cast< sal_uInt16 > ( GetParagraphIndex() );
464 [ # # ][ # # ]: 0 : if( !GetEditViewForwarder().GetSelection( aSelection ) )
[ # # ]
465 : 0 : return sal_False;
466 : :
467 [ # # ]: 0 : if( aSelection.nStartPara < aSelection.nEndPara )
468 : : {
469 [ # # ][ # # ]: 0 : if( aSelection.nStartPara > nPara ||
470 : : aSelection.nEndPara < nPara )
471 : 0 : return sal_False;
472 : :
473 [ # # ]: 0 : if( nPara == aSelection.nStartPara )
474 : 0 : nStartPos = aSelection.nStartPos;
475 : : else
476 : 0 : nStartPos = 0;
477 : :
478 [ # # ]: 0 : if( nPara == aSelection.nEndPara )
479 : 0 : nEndPos = aSelection.nEndPos;
480 : : else
481 [ # # ]: 0 : nEndPos = GetTextLen();
482 : : }
483 : : else
484 : : {
485 [ # # ][ # # ]: 0 : if( aSelection.nStartPara < nPara ||
486 : : aSelection.nEndPara > nPara )
487 : 0 : return sal_False;
488 : :
489 [ # # ]: 0 : if( nPara == aSelection.nStartPara )
490 : 0 : nStartPos = aSelection.nStartPos;
491 : : else
492 [ # # ]: 0 : nStartPos = GetTextLen();
493 : :
494 [ # # ]: 0 : if( nPara == aSelection.nEndPara )
495 : 0 : nEndPos = aSelection.nEndPos;
496 : : else
497 : 0 : nEndPos = 0;
498 : : }
499 : :
500 : 0 : return sal_True;
501 : : }
502 : :
503 : 194 : String AccessibleEditableTextPara::GetTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) SAL_THROW((uno::RuntimeException))
504 : : {
505 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
506 : :
507 [ + - ]: 194 : return GetTextForwarder().GetText( MakeSelection(nStartIndex, nEndIndex) );
508 : : }
509 : :
510 : 209 : sal_uInt16 AccessibleEditableTextPara::GetTextLen() const SAL_THROW((uno::RuntimeException))
511 : : {
512 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
513 : :
514 : 209 : return GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
515 : : }
516 : :
517 : 851 : SvxEditSourceAdapter& AccessibleEditableTextPara::GetEditSource() const SAL_THROW((uno::RuntimeException))
518 : : {
519 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
520 : :
521 [ + + ]: 851 : if( mpEditSource )
522 : 846 : return *mpEditSource;
523 : : else
524 : : throw uno::RuntimeException(::rtl::OUString("No edit source, object is defunct"),
525 : : uno::Reference< uno::XInterface >
526 : : ( static_cast< ::cppu::OWeakObject* >
527 [ + - ][ + - ]: 5 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
528 : : }
529 : :
530 : 674 : SvxAccessibleTextAdapter& AccessibleEditableTextPara::GetTextForwarder() const SAL_THROW((uno::RuntimeException))
531 : : {
532 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
533 : :
534 : 674 : SvxEditSourceAdapter& rEditSource = GetEditSource();
535 : 669 : SvxAccessibleTextAdapter* pTextForwarder = rEditSource.GetTextForwarderAdapter();
536 : :
537 [ - + ]: 669 : if( !pTextForwarder )
538 : : throw uno::RuntimeException(::rtl::OUString("Unable to fetch text forwarder, object is defunct"),
539 : : uno::Reference< uno::XInterface >
540 : : ( static_cast< ::cppu::OWeakObject* >
541 [ # # ][ # # ]: 0 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
542 : :
543 [ + - ]: 669 : if( pTextForwarder->IsValid() )
544 : 669 : return *pTextForwarder;
545 : : else
546 : : throw uno::RuntimeException(::rtl::OUString("Text forwarder is invalid, object is defunct"),
547 : : uno::Reference< uno::XInterface >
548 : : ( static_cast< ::cppu::OWeakObject* >
549 [ # # ][ # # ]: 0 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
550 : : }
551 : :
552 : 171 : SvxViewForwarder& AccessibleEditableTextPara::GetViewForwarder() const SAL_THROW((uno::RuntimeException))
553 : : {
554 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
555 : :
556 : 171 : SvxEditSource& rEditSource = GetEditSource();
557 : 171 : SvxViewForwarder* pViewForwarder = rEditSource.GetViewForwarder();
558 : :
559 [ - + ]: 171 : if( !pViewForwarder )
560 : : {
561 : : throw uno::RuntimeException(::rtl::OUString("Unable to fetch view forwarder, object is defunct"),
562 : : uno::Reference< uno::XInterface >
563 : : ( static_cast< ::cppu::OWeakObject* >
564 [ # # ][ # # ]: 0 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
565 : : }
566 : :
567 [ + - ]: 171 : if( pViewForwarder->IsValid() )
568 : 171 : return *pViewForwarder;
569 : : else
570 : : throw uno::RuntimeException(::rtl::OUString("View forwarder is invalid, object is defunct"),
571 : : uno::Reference< uno::XInterface >
572 : : ( static_cast< ::cppu::OWeakObject* >
573 [ # # ][ # # ]: 0 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
574 : : }
575 : :
576 : 2 : SvxAccessibleTextEditViewAdapter& AccessibleEditableTextPara::GetEditViewForwarder( sal_Bool bCreate ) const SAL_THROW((uno::RuntimeException))
577 : : {
578 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
579 : :
580 : 2 : SvxEditSourceAdapter& rEditSource = GetEditSource();
581 : 2 : SvxAccessibleTextEditViewAdapter* pTextEditViewForwarder = rEditSource.GetEditViewForwarderAdapter( bCreate );
582 : :
583 [ + - ]: 2 : if( !pTextEditViewForwarder )
584 : : {
585 [ + - ]: 2 : if( bCreate )
586 : : throw uno::RuntimeException(::rtl::OUString("Unable to fetch view forwarder, object is defunct"),
587 : : uno::Reference< uno::XInterface >
588 : : ( static_cast< ::cppu::OWeakObject* >
589 [ + - ][ + - ]: 2 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
590 : : else
591 : : throw uno::RuntimeException(::rtl::OUString("No view forwarder, object not in edit mode"),
592 : : uno::Reference< uno::XInterface >
593 : : ( static_cast< ::cppu::OWeakObject* >
594 [ # # ][ # # ]: 0 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
595 : : }
596 : :
597 [ # # ]: 0 : if( pTextEditViewForwarder->IsValid() )
598 : 0 : return *pTextEditViewForwarder;
599 : : else
600 : : {
601 [ # # ]: 0 : if( bCreate )
602 : : throw uno::RuntimeException(::rtl::OUString("View forwarder is invalid, object is defunct"),
603 : : uno::Reference< uno::XInterface >
604 : : ( static_cast< ::cppu::OWeakObject* >
605 [ # # ][ # # ]: 0 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
606 : : else
607 : : throw uno::RuntimeException(::rtl::OUString("View forwarder is invalid, object not in edit mode"),
608 : : uno::Reference< uno::XInterface >
609 : : ( static_cast< ::cppu::OWeakObject* >
610 [ # # ][ # # ]: 0 : ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
611 : : }
612 : : }
613 : :
614 : 0 : sal_Bool AccessibleEditableTextPara::HaveEditView() const
615 : : {
616 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
617 : :
618 : 0 : SvxEditSource& rEditSource = GetEditSource();
619 : 0 : SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder();
620 : :
621 [ # # ]: 0 : if( !pViewForwarder )
622 : 0 : return sal_False;
623 : :
624 [ # # ]: 0 : if( !pViewForwarder->IsValid() )
625 : 0 : return sal_False;
626 : :
627 : 0 : return sal_True;
628 : : }
629 : :
630 : 90 : sal_Bool AccessibleEditableTextPara::HaveChildren()
631 : : {
632 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
633 : :
634 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
635 : : "AccessibleEditableTextPara::HaveChildren: paragraph index value overflow");
636 : :
637 : 90 : return GetTextForwarder().HaveImageBullet( static_cast< sal_uInt16 >(GetParagraphIndex()) );
638 : : }
639 : :
640 : 225 : Rectangle AccessibleEditableTextPara::LogicToPixel( const Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder& rForwarder )
641 : : {
642 : : // convert to screen coordinates
643 : 225 : return Rectangle( rForwarder.LogicToPixel( rRect.TopLeft(), rMapMode ),
644 [ + - + - ]: 450 : rForwarder.LogicToPixel( rRect.BottomRight(), rMapMode ) );
[ + - ]
645 : : }
646 : :
647 : 171 : const Point& AccessibleEditableTextPara::GetEEOffset() const
648 : : {
649 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
650 : :
651 : 171 : return maEEOffset;
652 : : }
653 : :
654 : 67 : void AccessibleEditableTextPara::SetEEOffset( const Point& rOffset )
655 : : {
656 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
657 : :
658 [ + - ]: 67 : WeakBullet::HardRefType aChild( maImageBullet.get() );
659 [ - + ]: 67 : if( aChild.is() )
660 [ # # ]: 0 : aChild->SetEEOffset(rOffset);
661 : :
662 [ + - ]: 67 : maEEOffset = rOffset;
663 : 67 : }
664 : :
665 : 77 : void AccessibleEditableTextPara::FireEvent(const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue) const
666 : : {
667 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
668 : :
669 [ + - ]: 77 : uno::Reference < XAccessibleContext > xThis( const_cast< AccessibleEditableTextPara* > (this)->getAccessibleContext() );
670 : :
671 [ + - ]: 77 : AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue);
672 : :
673 : : // #102261# Call global queue for focus events
674 [ + + ]: 77 : if( nEventId == AccessibleEventId::STATE_CHANGED )
675 [ + - ]: 33 : vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent );
676 : :
677 : : // #106234# Delegate to EventNotifier
678 [ + - ][ + + ]: 77 : if( getNotifierClientId() != -1 )
679 [ + - ]: 61 : ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(),
680 [ + - ][ + - ]: 77 : aEvent );
681 : 77 : }
682 : :
683 : 23 : void AccessibleEditableTextPara::GotPropertyEvent( const uno::Any& rNewValue, const sal_Int16 nEventId ) const
684 : : {
685 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
686 : :
687 [ + - ]: 23 : FireEvent( nEventId, rNewValue );
688 : 23 : }
689 : :
690 : 10 : void AccessibleEditableTextPara::LostPropertyEvent( const uno::Any& rOldValue, const sal_Int16 nEventId ) const
691 : : {
692 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
693 : :
694 [ + - ]: 10 : FireEvent( nEventId, uno::Any(), rOldValue );
695 : 10 : }
696 : :
697 : 23 : void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId )
698 : : {
699 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
700 : :
701 [ + - ]: 23 : ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
702 [ + - + - ]: 46 : if( pStateSet != NULL &&
[ + - ]
703 : 23 : !pStateSet->contains(nStateId) )
704 : : {
705 : 23 : pStateSet->AddState( nStateId );
706 [ + - ]: 23 : GotPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
707 : : }
708 : 23 : }
709 : :
710 : 10 : void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId )
711 : : {
712 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
713 : :
714 [ + - ]: 10 : ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
715 [ + - + - ]: 20 : if( pStateSet != NULL &&
[ + - ]
716 : 10 : pStateSet->contains(nStateId) )
717 : : {
718 : 10 : pStateSet->RemoveState( nStateId );
719 [ + - ]: 10 : LostPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
720 : : }
721 : 10 : }
722 : :
723 : 61 : void AccessibleEditableTextPara::TextChanged()
724 : : {
725 [ + + ]: 61 : ::rtl::OUString aCurrentString( OCommonAccessibleText::getText() );
726 : 56 : uno::Any aDeleted;
727 : 56 : uno::Any aInserted;
728 [ + + ][ + - ]: 56 : if( OCommonAccessibleText::implInitTextChangedEvent( maLastTextString, aCurrentString,
729 : 56 : aDeleted, aInserted) )
730 : : {
731 [ + - ]: 40 : FireEvent( AccessibleEventId::TEXT_CHANGED, aInserted, aDeleted );
732 : 40 : maLastTextString = aCurrentString;
733 : 61 : }
734 : 56 : }
735 : :
736 : 0 : sal_Bool AccessibleEditableTextPara::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex )
737 : : {
738 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
739 : :
740 : : DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
741 : : "AccessibleEditableTextPara::GetAttributeRun: index value overflow");
742 : :
743 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
744 : : "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
745 : :
746 : 0 : return GetTextForwarder().GetAttributeRun( nStartIndex,
747 : : nEndIndex,
748 : 0 : static_cast< sal_uInt16 >(GetParagraphIndex()),
749 : 0 : static_cast< sal_uInt16 >(nIndex) );
750 : : }
751 : :
752 : 573 : uno::Any SAL_CALL AccessibleEditableTextPara::queryInterface (const uno::Type & rType) throw (uno::RuntimeException)
753 : : {
754 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
755 : :
756 : 573 : uno::Any aRet;
757 : :
758 : : // must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText
759 [ + + ][ + - ]: 573 : if ( rType == ::getCppuType((uno::Reference< XAccessibleText > *)0) )
760 : : {
761 [ + - ]: 2 : uno::Reference< XAccessibleText > aAccText = static_cast< XAccessibleEditableText * >(this);
762 [ + - ]: 2 : aRet <<= aAccText;
763 : : }
764 [ + - ][ - + ]: 571 : else if ( rType == ::getCppuType((uno::Reference< XAccessibleEditableText > *)0) )
765 : : {
766 [ # # ]: 0 : uno::Reference< XAccessibleEditableText > aAccEditText = this;
767 [ # # ]: 0 : aRet <<= aAccEditText;
768 : : }
769 [ + - ][ - + ]: 571 : else if ( rType == ::getCppuType((uno::Reference< XAccessibleHypertext > *)0) )
770 : : {
771 [ # # ]: 0 : uno::Reference< XAccessibleHypertext > aAccHyperText = this;
772 [ # # ]: 0 : aRet <<= aAccHyperText;
773 : : }
774 : : else
775 : : {
776 [ + - ]: 571 : aRet = AccessibleTextParaInterfaceBase::queryInterface(rType);
777 : : }
778 : :
779 : 573 : return aRet;
780 : : }
781 : :
782 : : // XAccessible
783 : 197 : uno::Reference< XAccessibleContext > SAL_CALL AccessibleEditableTextPara::getAccessibleContext() throw (uno::RuntimeException)
784 : : {
785 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
786 : :
787 : : // We implement the XAccessibleContext interface in the same object
788 : 197 : return uno::Reference< XAccessibleContext > ( this );
789 : : }
790 : :
791 : : // XAccessibleContext
792 : 90 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount() throw (uno::RuntimeException)
793 : : {
794 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
795 : :
796 [ + - ]: 90 : SolarMutexGuard aGuard;
797 : :
798 [ + - ][ - + ]: 90 : return HaveChildren() ? 1 : 0;
[ + - ]
799 : : }
800 : :
801 : 0 : uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
802 : : {
803 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
804 : :
805 [ # # ]: 0 : SolarMutexGuard aGuard;
806 : :
807 [ # # ][ # # ]: 0 : if( !HaveChildren() )
808 : : throw lang::IndexOutOfBoundsException(::rtl::OUString("No children available"),
809 : : uno::Reference< uno::XInterface >
810 [ # # ][ # # ]: 0 : ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy
811 : :
812 [ # # ]: 0 : if( i != 0 )
813 : : throw lang::IndexOutOfBoundsException(::rtl::OUString("Invalid child index"),
814 : : uno::Reference< uno::XInterface >
815 [ # # ][ # # ]: 0 : ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy
816 : :
817 [ # # ]: 0 : WeakBullet::HardRefType aChild( maImageBullet.get() );
818 : :
819 [ # # ]: 0 : if( !aChild.is() )
820 : : {
821 : : // there is no hard reference available, create object then
822 [ # # ][ # # ]: 0 : AccessibleImageBullet* pChild = new AccessibleImageBullet( uno::Reference< XAccessible >( this ) );
823 [ # # ]: 0 : uno::Reference< XAccessible > xChild( static_cast< ::cppu::OWeakObject* > (pChild), uno::UNO_QUERY );
824 : :
825 [ # # ]: 0 : if( !xChild.is() )
826 : : throw uno::RuntimeException(::rtl::OUString("Child creation failed"),
827 : : uno::Reference< uno::XInterface >
828 [ # # ][ # # ]: 0 : ( static_cast< ::cppu::OWeakObject* > (this) ) );
829 : :
830 [ # # ][ # # ]: 0 : aChild = WeakBullet::HardRefType( xChild, pChild );
[ # # ][ # # ]
[ # # ]
831 : :
832 [ # # ][ # # ]: 0 : aChild->SetEditSource( &GetEditSource() );
833 [ # # ][ # # ]: 0 : aChild->SetParagraphIndex( GetParagraphIndex() );
834 [ # # ]: 0 : aChild->SetIndexInParent( i );
835 : :
836 [ # # ][ # # ]: 0 : maImageBullet = aChild;
[ # # ]
837 : : }
838 : :
839 [ # # ][ # # ]: 0 : return aChild.getRef();
840 : : }
841 : :
842 : 26 : uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent() throw (uno::RuntimeException)
843 : : {
844 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
845 : :
846 : : #ifdef DBG_UTIL
847 : : if( !mxParent.is() )
848 : : OSL_TRACE( "AccessibleEditableTextPara::getAccessibleParent: no frontend set, did somebody forgot to call AccessibleTextHelper::SetEventSource()?");
849 : : #endif
850 : :
851 : 26 : return mxParent;
852 : : }
853 : :
854 : 12 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent() throw (uno::RuntimeException)
855 : : {
856 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
857 : :
858 : 12 : return mnIndexInParent;
859 : : }
860 : :
861 : 66 : sal_Int16 SAL_CALL AccessibleEditableTextPara::getAccessibleRole() throw (uno::RuntimeException)
862 : : {
863 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
864 : :
865 : 66 : return AccessibleRole::PARAGRAPH;
866 : : }
867 : :
868 : 28 : ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleDescription() throw (uno::RuntimeException)
869 : : {
870 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
871 : :
872 : : // SolarMutexGuard aGuard;
873 : :
874 : 28 : return ::rtl::OUString();
875 : : }
876 : :
877 : 32 : ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName() throw (uno::RuntimeException)
878 : : {
879 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
880 : :
881 : : // SolarMutexGuard aGuard;
882 : :
883 : 32 : return ::rtl::OUString();
884 : : }
885 : :
886 : 2 : uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleEditableTextPara::getAccessibleRelationSet() throw (uno::RuntimeException)
887 : : {
888 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
889 : :
890 : : // #i27138# - provide relations CONTENT_FLOWS_FROM
891 : : // and CONTENT_FLOWS_TO
892 [ + - ]: 2 : if ( mpParaManager )
893 : : {
894 : : utl::AccessibleRelationSetHelper* pAccRelSetHelper =
895 [ + - ]: 2 : new utl::AccessibleRelationSetHelper();
896 : 2 : sal_Int32 nMyParaIndex( GetParagraphIndex() );
897 : : // relation CONTENT_FLOWS_FROM
898 [ - + ]: 2 : if ( nMyParaIndex > 0 &&
[ - + # # ]
899 : 0 : mpParaManager->IsReferencable( nMyParaIndex - 1 ) )
900 : : {
901 [ # # ]: 0 : uno::Sequence<uno::Reference<XInterface> > aSequence(1);
902 [ # # ]: 0 : aSequence[0] =
903 [ # # ][ # # ]: 0 : mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().getRef();
[ # # ][ # # ]
[ # # ]
904 : : AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM,
905 [ # # ]: 0 : aSequence );
906 [ # # ][ # # ]: 0 : pAccRelSetHelper->AddRelation( aAccRel );
[ # # ]
907 : : }
908 : :
909 : : // relation CONTENT_FLOWS_TO
910 [ - + # # ]: 2 : if ( (nMyParaIndex + 1) < (sal_Int32)mpParaManager->GetNum() &&
[ - + ]
911 : 0 : mpParaManager->IsReferencable( nMyParaIndex + 1 ) )
912 : : {
913 [ # # ]: 0 : uno::Sequence<uno::Reference<XInterface> > aSequence(1);
914 [ # # ]: 0 : aSequence[0] =
915 [ # # ][ # # ]: 0 : mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().getRef();
[ # # ][ # # ]
[ # # ]
916 : : AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO,
917 [ # # ]: 0 : aSequence );
918 [ # # ][ # # ]: 0 : pAccRelSetHelper->AddRelation( aAccRel );
[ # # ]
919 : : }
920 : :
921 [ + - ]: 2 : return pAccRelSetHelper;
922 : : }
923 : : else
924 : : {
925 : : // no relations, therefore empty
926 : 2 : return uno::Reference< XAccessibleRelationSet >();
927 : : }
928 : : }
929 : :
930 : 39 : uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() throw (uno::RuntimeException)
931 : : {
932 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
933 : :
934 [ + - ]: 39 : SolarMutexGuard aGuard;
935 : :
936 : : // Create a copy of the state set and return it.
937 [ + - ][ + - ]: 39 : ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
938 : :
939 [ - + ]: 39 : if( !pStateSet )
940 : 0 : return uno::Reference<XAccessibleStateSet>();
941 : :
942 [ + - ][ + - ]: 39 : return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) );
[ + - ][ + - ]
943 : : }
944 : :
945 : 2 : lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale() throw (IllegalAccessibleComponentStateException, uno::RuntimeException)
946 : : {
947 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
948 : :
949 [ + - ]: 2 : SolarMutexGuard aGuard;
950 : :
951 [ + - ][ + - ]: 2 : return implGetLocale();
952 : : }
953 : :
954 : 2 : void SAL_CALL AccessibleEditableTextPara::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
955 : : {
956 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
957 : :
958 [ + - ]: 2 : if( getNotifierClientId() != -1 )
959 : 2 : ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener );
960 : 2 : }
961 : :
962 : 4 : void SAL_CALL AccessibleEditableTextPara::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
963 : : {
964 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
965 : :
966 [ - + ]: 4 : if( getNotifierClientId() != -1 )
967 : 0 : ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
968 : 4 : }
969 : :
970 : : // XAccessibleComponent
971 : 4 : sal_Bool SAL_CALL AccessibleEditableTextPara::containsPoint( const awt::Point& aTmpPoint ) throw (uno::RuntimeException)
972 : : {
973 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
974 : :
975 [ + - ]: 4 : SolarMutexGuard aGuard;
976 : :
977 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
978 : : "AccessibleEditableTextPara::contains: index value overflow");
979 : :
980 [ + - ]: 4 : awt::Rectangle aTmpRect = getBounds();
981 [ + - ]: 4 : Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), Size(aTmpRect.Width, aTmpRect.Height) );
982 : 4 : Point aPoint( aTmpPoint.X, aTmpPoint.Y );
983 : :
984 [ + - ][ + - ]: 4 : return aRect.IsInside( aPoint );
985 : : }
986 : :
987 : 0 : uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (uno::RuntimeException)
988 : : {
989 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
990 : :
991 [ # # ]: 0 : SolarMutexGuard aGuard;
992 : :
993 [ # # ][ # # ]: 0 : if( HaveChildren() )
994 : : {
995 : : // #103862# No longer need to make given position relative
996 : 0 : Point aPoint( _aPoint.X, _aPoint.Y );
997 : :
998 : : // respect EditEngine offset to surrounding shape/cell
999 [ # # ]: 0 : aPoint -= GetEEOffset();
1000 : :
1001 : : // convert to EditEngine coordinate system
1002 [ # # ]: 0 : SvxTextForwarder& rCacheTF = GetTextForwarder();
1003 [ # # ][ # # ]: 0 : Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) );
[ # # ][ # # ]
1004 : :
1005 [ # # ][ # # ]: 0 : EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 > (GetParagraphIndex()) );
1006 : :
1007 [ # # ][ # # ]: 0 : if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
[ # # ]
1008 : : aBulletInfo.bVisible &&
1009 : : aBulletInfo.nType == SVX_NUM_BITMAP )
1010 : : {
1011 : 0 : Rectangle aRect = aBulletInfo.aBounds;
1012 : :
1013 [ # # ][ # # ]: 0 : if( aRect.IsInside( aLogPoint ) )
1014 [ # # ]: 0 : return getAccessibleChild(0);
1015 [ # # ][ # # ]: 0 : }
1016 : : }
1017 : :
1018 : : // no children at all, or none at given position
1019 [ # # ]: 0 : return uno::Reference< XAccessible >();
1020 : : }
1021 : :
1022 : 107 : awt::Rectangle SAL_CALL AccessibleEditableTextPara::getBounds() throw (uno::RuntimeException)
1023 : : {
1024 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1025 : :
1026 [ + - ]: 107 : SolarMutexGuard aGuard;
1027 : :
1028 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1029 : : "AccessibleEditableTextPara::getBounds: index value overflow");
1030 : :
1031 [ + - ]: 107 : SvxTextForwarder& rCacheTF = GetTextForwarder();
1032 [ + - ][ + - ]: 107 : Rectangle aRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
1033 : :
1034 : : // convert to screen coordinates
1035 : : Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
1036 : 107 : rCacheTF.GetMapMode(),
1037 [ + - ][ + - ]: 107 : GetViewForwarder() );
[ + - ][ + - ]
1038 : :
1039 : : // offset from shape/cell
1040 [ + - ]: 107 : Point aOffset = GetEEOffset();
1041 : :
1042 : 107 : return awt::Rectangle( aScreenRect.Left() + aOffset.X(),
1043 : 107 : aScreenRect.Top() + aOffset.Y(),
1044 [ + - ]: 107 : aScreenRect.GetSize().Width(),
1045 [ + - ][ + - ]: 214 : aScreenRect.GetSize().Height() );
1046 : : }
1047 : :
1048 : 0 : awt::Point SAL_CALL AccessibleEditableTextPara::getLocation( ) throw (uno::RuntimeException)
1049 : : {
1050 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1051 : :
1052 [ # # ]: 0 : SolarMutexGuard aGuard;
1053 : :
1054 [ # # ]: 0 : awt::Rectangle aRect = getBounds();
1055 : :
1056 [ # # ]: 0 : return awt::Point( aRect.X, aRect.Y );
1057 : : }
1058 : :
1059 : 0 : awt::Point SAL_CALL AccessibleEditableTextPara::getLocationOnScreen( ) throw (uno::RuntimeException)
1060 : : {
1061 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1062 : :
1063 [ # # ]: 0 : SolarMutexGuard aGuard;
1064 : :
1065 : : // relate us to parent
1066 [ # # ]: 0 : uno::Reference< XAccessible > xParent = getAccessibleParent();
1067 [ # # ]: 0 : if( xParent.is() )
1068 : : {
1069 [ # # ]: 0 : uno::Reference< XAccessibleComponent > xParentComponent( xParent, uno::UNO_QUERY );
1070 [ # # ]: 0 : if( xParentComponent.is() )
1071 : : {
1072 [ # # ][ # # ]: 0 : awt::Point aRefPoint = xParentComponent->getLocationOnScreen();
1073 [ # # ]: 0 : awt::Point aPoint = getLocation();
1074 : 0 : aPoint.X += aRefPoint.X;
1075 : 0 : aPoint.Y += aRefPoint.Y;
1076 : :
1077 : 0 : return aPoint;
1078 : : }
1079 : : // #i88070#
1080 : : // fallback to parent's <XAccessibleContext> instance
1081 : : else
1082 : : {
1083 [ # # ][ # # ]: 0 : uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
1084 [ # # ]: 0 : if ( xParentContext.is() )
1085 : : {
1086 [ # # ]: 0 : uno::Reference< XAccessibleComponent > xParentContextComponent( xParentContext, uno::UNO_QUERY );
1087 [ # # ]: 0 : if( xParentContextComponent.is() )
1088 : : {
1089 [ # # ][ # # ]: 0 : awt::Point aRefPoint = xParentContextComponent->getLocationOnScreen();
1090 [ # # ]: 0 : awt::Point aPoint = getLocation();
1091 : 0 : aPoint.X += aRefPoint.X;
1092 : 0 : aPoint.Y += aRefPoint.Y;
1093 : :
1094 : 0 : return aPoint;
1095 [ # # ]: 0 : }
1096 [ # # ]: 0 : }
1097 [ # # ]: 0 : }
1098 : : }
1099 : :
1100 : : throw uno::RuntimeException(::rtl::OUString("Cannot access parent"),
1101 : : uno::Reference< uno::XInterface >
1102 [ # # ][ # # ]: 0 : ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
[ # # ]
1103 : : }
1104 : :
1105 : 0 : awt::Size SAL_CALL AccessibleEditableTextPara::getSize( ) throw (uno::RuntimeException)
1106 : : {
1107 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1108 : :
1109 [ # # ]: 0 : SolarMutexGuard aGuard;
1110 : :
1111 [ # # ]: 0 : awt::Rectangle aRect = getBounds();
1112 : :
1113 [ # # ]: 0 : return awt::Size( aRect.Width, aRect.Height );
1114 : : }
1115 : :
1116 : 0 : void SAL_CALL AccessibleEditableTextPara::grabFocus( ) throw (uno::RuntimeException)
1117 : : {
1118 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1119 : :
1120 : : // set cursor to this paragraph
1121 : 0 : setSelection(0,0);
1122 : 0 : }
1123 : :
1124 : 0 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getForeground( ) throw (::com::sun::star::uno::RuntimeException)
1125 : : {
1126 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1127 : :
1128 : : // #104444# Added to XAccessibleComponent interface
1129 [ # # ]: 0 : svtools::ColorConfig aColorConfig;
1130 [ # # ]: 0 : sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
1131 [ # # ]: 0 : return static_cast<sal_Int32>(nColor);
1132 : : }
1133 : :
1134 : 0 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getBackground( ) throw (::com::sun::star::uno::RuntimeException)
1135 : : {
1136 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1137 : :
1138 : : // #104444# Added to XAccessibleComponent interface
1139 [ # # ]: 0 : Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor() );
1140 : :
1141 : : // the background is transparent
1142 [ # # ]: 0 : aColor.SetTransparency( 0xFF);
1143 : :
1144 : 0 : return static_cast<sal_Int32>( aColor.GetColor() );
1145 : : }
1146 : :
1147 : : // XAccessibleText
1148 : 0 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getCaretPosition() throw (uno::RuntimeException)
1149 : : {
1150 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1151 : :
1152 [ # # ]: 0 : SolarMutexGuard aGuard;
1153 : :
1154 [ # # ][ # # ]: 0 : if( !HaveEditView() )
1155 : 0 : return -1;
1156 : :
1157 : 0 : ESelection aSelection;
1158 [ # # ][ # # ]: 0 : if( GetEditViewForwarder().GetSelection( aSelection ) &&
[ # # ][ # # ]
[ # # ]
1159 [ # # ]: 0 : GetParagraphIndex() == aSelection.nEndPara )
1160 : : {
1161 : : // caret is always nEndPara,nEndPos
1162 : 0 : return aSelection.nEndPos;
1163 : : }
1164 : :
1165 : : // not within this paragraph
1166 [ # # ]: 0 : return -1;
1167 : : }
1168 : :
1169 : 6 : sal_Bool SAL_CALL AccessibleEditableTextPara::setCaretPosition( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1170 : : {
1171 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1172 : :
1173 : 6 : return setSelection(nIndex, nIndex);
1174 : : }
1175 : :
1176 : 14 : sal_Unicode SAL_CALL AccessibleEditableTextPara::getCharacter( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1177 : : {
1178 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1179 : :
1180 [ + - ]: 14 : SolarMutexGuard aGuard;
1181 : :
1182 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1183 : : "AccessibleEditableTextPara::getCharacter: index value overflow");
1184 : :
1185 [ + + ][ + - ]: 14 : return OCommonAccessibleText::getCharacter( nIndex );
1186 : : }
1187 : :
1188 : 6 : uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1189 : : {
1190 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1191 [ + - ]: 6 : SolarMutexGuard aGuard;
1192 : :
1193 [ + + ]: 6 : CheckIndex(nIndex); // may throw IndexOutOfBoundsException
1194 : :
1195 : : // get default attribues...
1196 [ + - ][ + - ]: 2 : ::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( rRequestedAttributes ) );
[ + - ]
1197 : :
1198 : : // ... and override them with the direct attributes from the specific position
1199 [ + - ]: 2 : uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, rRequestedAttributes ) );
1200 : 2 : sal_Int32 nRunAttribs = aRunAttribs.getLength();
1201 : 2 : const beans::PropertyValue *pRunAttrib = aRunAttribs.getConstArray();
1202 [ - + ]: 2 : for (sal_Int32 k = 0; k < nRunAttribs; ++k)
1203 : : {
1204 : 0 : const beans::PropertyValue &rRunAttrib = pRunAttrib[k];
1205 [ # # ]: 0 : aPropHashMap[ rRunAttrib.Name ] = rRunAttrib.Value; //!! should not only be the value !!
1206 : : }
1207 : :
1208 : : // get resulting sequence
1209 [ + - ]: 2 : uno::Sequence< beans::PropertyValue > aRes;
1210 [ + - ]: 2 : aPropHashMap >> aRes;
1211 : :
1212 : : // since SequenceAsHashMap ignores property handles and property state
1213 : : // we have to restore the property state here (property handles are
1214 : : // of no use to the accessibility API).
1215 : 2 : sal_Int32 nRes = aRes.getLength();
1216 [ + - ]: 2 : beans::PropertyValue *pRes = aRes.getArray();
1217 [ - + ]: 2 : for (sal_Int32 i = 0; i < nRes; ++i)
1218 : : {
1219 : 0 : beans::PropertyValue &rRes = pRes[i];
1220 : 0 : sal_Bool bIsDirectVal = sal_False;
1221 [ # # ][ # # ]: 0 : for (sal_Int32 k = 0; k < nRunAttribs && !bIsDirectVal; ++k)
[ # # ]
1222 : : {
1223 [ # # ]: 0 : if (rRes.Name == pRunAttrib[k].Name)
1224 : 0 : bIsDirectVal = sal_True;
1225 : : }
1226 : 0 : rRes.Handle = -1;
1227 : 0 : rRes.State = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
1228 : : }
1229 : :
1230 [ + - ][ + - ]: 6 : return aRes;
[ + - ]
1231 : : }
1232 : :
1233 : 46 : awt::Rectangle SAL_CALL AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1234 : : {
1235 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1236 : :
1237 [ + - ]: 46 : SolarMutexGuard aGuard;
1238 : :
1239 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1240 : : "AccessibleEditableTextPara::getCharacterBounds: index value overflow");
1241 : :
1242 : : // #108900# Have position semantics now for nIndex, as
1243 : : // one-past-the-end values are legal, too.
1244 [ + + ]: 46 : CheckPosition( nIndex );
1245 : :
1246 [ + - ]: 42 : SvxTextForwarder& rCacheTF = GetTextForwarder();
1247 [ + - ][ + - ]: 42 : Rectangle aRect = rCacheTF.GetCharBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ), static_cast< sal_uInt16 >( nIndex ) );
1248 : :
1249 : : // convert to screen
1250 : : Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
1251 : 42 : rCacheTF.GetMapMode(),
1252 [ + - ][ + - ]: 42 : GetViewForwarder() );
[ + - ][ + - ]
1253 : : // #109864# offset from parent (paragraph), but in screen
1254 : : // coordinates. This makes sure the internal text offset in
1255 : : // the outline view forwarder gets cancelled out here
1256 [ + - ]: 42 : awt::Rectangle aParaRect( getBounds() );
1257 [ + - ]: 42 : aScreenRect.Move( -aParaRect.X, -aParaRect.Y );
1258 : :
1259 : : // offset from shape/cell
1260 [ + - ]: 42 : Point aOffset = GetEEOffset();
1261 : :
1262 : 42 : return awt::Rectangle( aScreenRect.Left() + aOffset.X(),
1263 : 42 : aScreenRect.Top() + aOffset.Y(),
1264 [ + - ]: 42 : aScreenRect.GetSize().Width(),
1265 [ + - ][ + - ]: 88 : aScreenRect.GetSize().Height() );
1266 : : }
1267 : :
1268 : 58 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getCharacterCount() throw (uno::RuntimeException)
1269 : : {
1270 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1271 : :
1272 [ + - ]: 58 : SolarMutexGuard aGuard;
1273 : :
1274 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1275 : : "AccessibleEditableTextPara::getCharacterCount: index value overflow");
1276 : :
1277 [ + - ][ + - ]: 58 : return OCommonAccessibleText::getCharacterCount();
1278 : : }
1279 : :
1280 : 22 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getIndexAtPoint( const awt::Point& rPoint ) throw (uno::RuntimeException)
1281 : : {
1282 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1283 : :
1284 [ + - ]: 22 : SolarMutexGuard aGuard;
1285 : :
1286 : : sal_uInt16 nPara, nIndex;
1287 : :
1288 : : // offset from surrounding cell/shape
1289 [ + - ]: 22 : Point aOffset( GetEEOffset() );
1290 : 22 : Point aPoint( rPoint.X - aOffset.X(), rPoint.Y - aOffset.Y() );
1291 : :
1292 : : // convert to logical coordinates
1293 [ + - ]: 22 : SvxTextForwarder& rCacheTF = GetTextForwarder();
1294 [ + - ][ + - ]: 22 : Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) );
[ + - ][ + - ]
1295 : :
1296 : : // re-offset to parent (paragraph)
1297 [ + - ][ + - ]: 22 : Rectangle aParaRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
1298 : 22 : aLogPoint.Move( aParaRect.Left(), aParaRect.Top() );
1299 : :
1300 [ + - ][ + - ]: 44 : if( rCacheTF.GetIndexAtPoint( aLogPoint, nPara, nIndex ) &&
[ + - ][ + - ]
1301 [ + - ]: 22 : GetParagraphIndex() == nPara )
1302 : : {
1303 : : // #102259# Double-check if we're _really_ on the given character
1304 : : try
1305 : : {
1306 [ + - ]: 22 : awt::Rectangle aRect1( getCharacterBounds(nIndex) );
1307 : : Rectangle aRect2( aRect1.X, aRect1.Y,
1308 [ + - ]: 22 : aRect1.Width + aRect1.X, aRect1.Height + aRect1.Y );
1309 [ + - ]: 22 : if( aRect2.IsInside( Point( rPoint.X, rPoint.Y ) ) )
[ + + # # ]
1310 : 20 : return nIndex;
1311 : : else
1312 : 22 : return -1;
1313 : : }
1314 [ # # ]: 0 : catch (const lang::IndexOutOfBoundsException&)
1315 : : {
1316 : : // #103927# Don't throw for invalid nIndex values
1317 : 0 : return -1;
1318 : : }
1319 : : }
1320 : : else
1321 : : {
1322 : : // not within our paragraph
1323 : 0 : return -1;
1324 [ + - ]: 22 : }
1325 : : }
1326 : :
1327 : 0 : ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getSelectedText() throw (uno::RuntimeException)
1328 : : {
1329 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1330 : :
1331 [ # # ]: 0 : SolarMutexGuard aGuard;
1332 : :
1333 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1334 : : "AccessibleEditableTextPara::getSelectedText: index value overflow");
1335 : :
1336 [ # # ][ # # ]: 0 : if( !HaveEditView() )
1337 : 0 : return ::rtl::OUString();
1338 : :
1339 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectedText();
1340 : : }
1341 : :
1342 : 0 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionStart() throw (uno::RuntimeException)
1343 : : {
1344 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1345 : :
1346 [ # # ]: 0 : SolarMutexGuard aGuard;
1347 : :
1348 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1349 : : "AccessibleEditableTextPara::getSelectionStart: index value overflow");
1350 : :
1351 [ # # ][ # # ]: 0 : if( !HaveEditView() )
1352 : 0 : return -1;
1353 : :
1354 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectionStart();
1355 : : }
1356 : :
1357 : 0 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionEnd() throw (uno::RuntimeException)
1358 : : {
1359 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1360 : :
1361 [ # # ]: 0 : SolarMutexGuard aGuard;
1362 : :
1363 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1364 : : "AccessibleEditableTextPara::getSelectionEnd: index value overflow");
1365 : :
1366 [ # # ][ # # ]: 0 : if( !HaveEditView() )
1367 : 0 : return -1;
1368 : :
1369 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectionEnd();
1370 : : }
1371 : :
1372 : 6 : sal_Bool SAL_CALL AccessibleEditableTextPara::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1373 : : {
1374 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1375 : :
1376 [ + - ]: 6 : SolarMutexGuard aGuard;
1377 : :
1378 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1379 : : "AccessibleEditableTextPara::setSelection: paragraph index value overflow");
1380 : :
1381 [ + + ]: 6 : CheckRange(nStartIndex, nEndIndex);
1382 : :
1383 : : try
1384 : : {
1385 [ - + ]: 2 : SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
1386 [ # # ][ # # ]: 2 : return rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
[ - + ]
1387 : : }
1388 [ + - ]: 2 : catch (const uno::RuntimeException&)
1389 : : {
1390 : 2 : return sal_False;
1391 [ + - ]: 6 : }
1392 : : }
1393 : :
1394 : 4 : ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getText() throw (uno::RuntimeException)
1395 : : {
1396 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1397 : :
1398 [ + - ]: 4 : SolarMutexGuard aGuard;
1399 : :
1400 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1401 : : "AccessibleEditableTextPara::getText: paragraph index value overflow");
1402 : :
1403 [ + - ][ + - ]: 4 : return OCommonAccessibleText::getText();
1404 : : }
1405 : :
1406 : 14 : ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1407 : : {
1408 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1409 : :
1410 [ + - ]: 14 : SolarMutexGuard aGuard;
1411 : :
1412 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1413 : : "AccessibleEditableTextPara::getTextRange: paragraph index value overflow");
1414 : :
1415 [ + + ][ + - ]: 14 : return OCommonAccessibleText::getTextRange(nStartIndex, nEndIndex);
1416 : : }
1417 : :
1418 : 18 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1419 : : {
1420 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1421 : :
1422 [ + - ]: 18 : SolarMutexGuard aGuard;
1423 : :
1424 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1425 : : "AccessibleEditableTextPara::getTextAtIndex: paragraph index value overflow");
1426 : :
1427 : 18 : ::com::sun::star::accessibility::TextSegment aResult;
1428 : 18 : aResult.SegmentStart = -1;
1429 : 18 : aResult.SegmentEnd = -1;
1430 : :
1431 [ - + ]: 18 : switch( aTextType )
1432 : : {
1433 : : // Not yet handled by OCommonAccessibleText. Missing
1434 : : // implGetAttributeRunBoundary() method there
1435 : : case AccessibleTextType::ATTRIBUTE_RUN:
1436 : : {
1437 [ # # ][ # # ]: 0 : const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
[ # # ]
1438 : :
1439 [ # # ]: 0 : if( nIndex == nTextLen )
1440 : : {
1441 : : // #i17014# Special-casing one-behind-the-end character
1442 : 0 : aResult.SegmentStart = aResult.SegmentEnd = nTextLen;
1443 : : }
1444 : : else
1445 : : {
1446 : : sal_uInt16 nStartIndex, nEndIndex;
1447 : :
1448 [ # # ][ # # ]: 0 : if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
1449 : : {
1450 [ # # ][ # # ]: 0 : aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
[ # # ]
1451 : 0 : aResult.SegmentStart = nStartIndex;
1452 : 0 : aResult.SegmentEnd = nEndIndex;
1453 : : }
1454 : : }
1455 : 0 : break;
1456 : : }
1457 : :
1458 : : default:
1459 [ + + ]: 18 : aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
1460 : 14 : break;
1461 : : } /* end of switch( aTextType ) */
1462 : :
1463 [ + - ]: 18 : return aResult;
1464 : : }
1465 : :
1466 : 12 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1467 : : {
1468 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1469 : :
1470 [ + - ]: 12 : SolarMutexGuard aGuard;
1471 : :
1472 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1473 : : "AccessibleEditableTextPara::getTextBeforeIndex: paragraph index value overflow");
1474 : :
1475 : 12 : ::com::sun::star::accessibility::TextSegment aResult;
1476 : 12 : aResult.SegmentStart = -1;
1477 : 12 : aResult.SegmentEnd = -1;
1478 : :
1479 [ - + ]: 12 : switch( aTextType )
1480 : : {
1481 : : // Not yet handled by OCommonAccessibleText. Missing
1482 : : // implGetAttributeRunBoundary() method there
1483 : : case AccessibleTextType::ATTRIBUTE_RUN:
1484 : : {
1485 [ # # ][ # # ]: 0 : const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
[ # # ]
1486 : : sal_uInt16 nStartIndex, nEndIndex;
1487 : :
1488 [ # # ]: 0 : if( nIndex == nTextLen )
1489 : : {
1490 : : // #i17014# Special-casing one-behind-the-end character
1491 [ # # ][ # # ]: 0 : if( nIndex > 0 &&
[ # # ]
1492 [ # # ]: 0 : GetAttributeRun(nStartIndex, nEndIndex, nIndex-1) )
1493 : : {
1494 [ # # ][ # # ]: 0 : aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
[ # # ]
1495 : 0 : aResult.SegmentStart = nStartIndex;
1496 : 0 : aResult.SegmentEnd = nEndIndex;
1497 : : }
1498 : : }
1499 : : else
1500 : : {
1501 [ # # ][ # # ]: 0 : if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
1502 : : {
1503 : : // already at the left border? If not, query
1504 : : // one index further left
1505 [ # # ][ # # ]: 0 : if( nStartIndex > 0 &&
[ # # ]
1506 [ # # ]: 0 : GetAttributeRun(nStartIndex, nEndIndex, nStartIndex-1) )
1507 : : {
1508 [ # # ][ # # ]: 0 : aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
[ # # ]
1509 : 0 : aResult.SegmentStart = nStartIndex;
1510 : 0 : aResult.SegmentEnd = nEndIndex;
1511 : : }
1512 : : }
1513 : : }
1514 : : break;
1515 : : }
1516 : :
1517 : : default:
1518 [ + + ]: 12 : aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
1519 : 8 : break;
1520 : : } /* end of switch( aTextType ) */
1521 : :
1522 [ + - ]: 12 : return aResult;
1523 : : }
1524 : :
1525 : 12 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1526 : : {
1527 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1528 : :
1529 [ + - ]: 12 : SolarMutexGuard aGuard;
1530 : :
1531 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1532 : : "AccessibleEditableTextPara::getTextBehindIndex: paragraph index value overflow");
1533 : :
1534 : 12 : ::com::sun::star::accessibility::TextSegment aResult;
1535 : 12 : aResult.SegmentStart = -1;
1536 : 12 : aResult.SegmentEnd = -1;
1537 : :
1538 [ - + ]: 12 : switch( aTextType )
1539 : : {
1540 : : case AccessibleTextType::ATTRIBUTE_RUN:
1541 : : {
1542 : : sal_uInt16 nStartIndex, nEndIndex;
1543 : :
1544 [ # # ][ # # ]: 0 : if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
1545 : : {
1546 : : // already at the right border?
1547 [ # # ][ # # ]: 0 : if( nEndIndex < GetTextLen() )
1548 : : {
1549 [ # # ][ # # ]: 0 : if( GetAttributeRun(nStartIndex, nEndIndex, nEndIndex) )
1550 : : {
1551 [ # # ][ # # ]: 0 : aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
[ # # ]
1552 : 0 : aResult.SegmentStart = nStartIndex;
1553 : 0 : aResult.SegmentEnd = nEndIndex;
1554 : : }
1555 : : }
1556 : : }
1557 : : break;
1558 : : }
1559 : :
1560 : : default:
1561 [ + + ]: 12 : aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
1562 : 8 : break;
1563 : : } /* end of switch( aTextType ) */
1564 : :
1565 [ + - ]: 12 : return aResult;
1566 : : }
1567 : :
1568 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1569 : : {
1570 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1571 : :
1572 [ # # ]: 0 : SolarMutexGuard aGuard;
1573 : :
1574 : : try
1575 : : {
1576 [ # # ]: 0 : SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
1577 : : #if OSL_DEBUG_LEVEL > 0
1578 : : SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1579 : : (void)rCacheTF;
1580 : : #else
1581 [ # # ]: 0 : GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1582 : : #endif
1583 : :
1584 : : sal_Bool aRetVal;
1585 : :
1586 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1587 : : "AccessibleEditableTextPara::copyText: index value overflow");
1588 : :
1589 [ # # ]: 0 : CheckRange(nStartIndex, nEndIndex);
1590 : :
1591 : : // save current selection
1592 : 0 : ESelection aOldSelection;
1593 : :
1594 [ # # ]: 0 : rCacheVF.GetSelection( aOldSelection );
1595 [ # # ]: 0 : rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
[ # # # # ]
1596 [ # # ]: 0 : aRetVal = rCacheVF.Copy();
1597 [ # # ]: 0 : rCacheVF.SetSelection( aOldSelection ); // restore
1598 : :
1599 : 0 : return aRetVal;
1600 : : }
1601 [ # # ]: 0 : catch (const uno::RuntimeException&)
1602 : : {
1603 : 0 : return sal_False;
1604 [ # # ]: 0 : }
1605 : : }
1606 : :
1607 : : // XAccessibleEditableText
1608 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1609 : : {
1610 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1611 : :
1612 [ # # ]: 0 : SolarMutexGuard aGuard;
1613 : :
1614 : : try
1615 : : {
1616 [ # # ]: 0 : SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
1617 [ # # ]: 0 : SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1618 : :
1619 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1620 : : "AccessibleEditableTextPara::cutText: index value overflow");
1621 : :
1622 [ # # ]: 0 : CheckRange(nStartIndex, nEndIndex);
1623 : :
1624 [ # # ][ # # ]: 0 : if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
[ # # ]
1625 : 0 : return sal_False; // non-editable area selected
1626 : :
1627 : : // don't save selection, might become invalid after cut!
1628 [ # # ]: 0 : rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
[ # # # # ]
1629 : :
1630 [ # # ]: 0 : return rCacheVF.Cut();
1631 : : }
1632 [ # # ]: 0 : catch (const uno::RuntimeException&)
1633 : : {
1634 : 0 : return sal_False;
1635 [ # # ]: 0 : }
1636 : : }
1637 : :
1638 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::pasteText( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1639 : : {
1640 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1641 : :
1642 [ # # ]: 0 : SolarMutexGuard aGuard;
1643 : :
1644 : : try
1645 : : {
1646 [ # # ]: 0 : SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
1647 [ # # ]: 0 : SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1648 : :
1649 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1650 : : "AccessibleEditableTextPara::pasteText: index value overflow");
1651 : :
1652 [ # # ]: 0 : CheckPosition(nIndex);
1653 : :
1654 [ # # ][ # # ]: 0 : if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
[ # # ]
1655 : 0 : return sal_False; // non-editable area selected
1656 : :
1657 : : // #104400# set empty selection (=> cursor) to given index
1658 [ # # ]: 0 : rCacheVF.SetSelection( MakeCursor(nIndex) );
[ # # # # ]
1659 : :
1660 [ # # ]: 0 : return rCacheVF.Paste();
1661 : : }
1662 [ # # ]: 0 : catch (const uno::RuntimeException&)
1663 : : {
1664 : 0 : return sal_False;
1665 [ # # ]: 0 : }
1666 : : }
1667 : :
1668 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1669 : : {
1670 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1671 : :
1672 [ # # ]: 0 : SolarMutexGuard aGuard;
1673 : :
1674 : : try
1675 : : {
1676 : : // #102710# Request edit view when doing changes
1677 : : // AccessibleEmptyEditSource relies on this behaviour
1678 [ # # ]: 0 : GetEditViewForwarder( sal_True );
1679 [ # # ]: 0 : SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1680 : :
1681 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1682 : : "AccessibleEditableTextPara::deleteText: index value overflow");
1683 : :
1684 [ # # ]: 0 : CheckRange(nStartIndex, nEndIndex);
1685 : :
1686 [ # # ][ # # ]: 0 : if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
[ # # ]
1687 : 0 : return sal_False; // non-editable area selected
1688 : :
1689 [ # # ]: 0 : sal_Bool bRet = rCacheTF.Delete( MakeSelection(nStartIndex, nEndIndex) );
[ # # # # ]
1690 : :
1691 [ # # ][ # # ]: 0 : GetEditSource().UpdateData();
1692 : :
1693 : 0 : return bRet;
1694 : : }
1695 [ # # ]: 0 : catch (const uno::RuntimeException&)
1696 : : {
1697 : 0 : return sal_False;
1698 [ # # ]: 0 : }
1699 : : }
1700 : :
1701 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::insertText( const ::rtl::OUString& sText, sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1702 : : {
1703 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1704 : :
1705 [ # # ]: 0 : SolarMutexGuard aGuard;
1706 : :
1707 : : try
1708 : : {
1709 : : // #102710# Request edit view when doing changes
1710 : : // AccessibleEmptyEditSource relies on this behaviour
1711 [ # # ]: 0 : GetEditViewForwarder( sal_True );
1712 [ # # ]: 0 : SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1713 : :
1714 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1715 : : "AccessibleEditableTextPara::insertText: index value overflow");
1716 : :
1717 [ # # ]: 0 : CheckPosition(nIndex);
1718 : :
1719 [ # # ][ # # ]: 0 : if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
[ # # ]
1720 : 0 : return sal_False; // non-editable area selected
1721 : :
1722 : : // #104400# insert given text at empty selection (=> cursor)
1723 [ # # ][ # # ]: 0 : sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex) );
[ # # ]
[ # # # # ]
1724 : :
1725 [ # # ]: 0 : rCacheTF.QuickFormatDoc();
1726 [ # # ][ # # ]: 0 : GetEditSource().UpdateData();
1727 : :
1728 : 0 : return bRet;
1729 : : }
1730 [ # # ]: 0 : catch (const uno::RuntimeException&)
1731 : : {
1732 : 0 : return sal_False;
1733 [ # # ]: 0 : }
1734 : : }
1735 : :
1736 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const ::rtl::OUString& sReplacement ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1737 : : {
1738 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1739 : :
1740 [ # # ]: 0 : SolarMutexGuard aGuard;
1741 : :
1742 : : try
1743 : : {
1744 : : // #102710# Request edit view when doing changes
1745 : : // AccessibleEmptyEditSource relies on this behaviour
1746 [ # # ]: 0 : GetEditViewForwarder( sal_True );
1747 [ # # ]: 0 : SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1748 : :
1749 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1750 : : "AccessibleEditableTextPara::replaceText: index value overflow");
1751 : :
1752 [ # # ]: 0 : CheckRange(nStartIndex, nEndIndex);
1753 : :
1754 [ # # ][ # # ]: 0 : if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
[ # # ]
1755 : 0 : return sal_False; // non-editable area selected
1756 : :
1757 : : // insert given text into given range => replace
1758 [ # # ][ # # ]: 0 : sal_Bool bRet = rCacheTF.InsertText( sReplacement, MakeSelection(nStartIndex, nEndIndex) );
[ # # ]
[ # # # # ]
1759 : :
1760 [ # # ]: 0 : rCacheTF.QuickFormatDoc();
1761 [ # # ][ # # ]: 0 : GetEditSource().UpdateData();
1762 : :
1763 : 0 : return bRet;
1764 : : }
1765 [ # # ]: 0 : catch (const uno::RuntimeException&)
1766 : : {
1767 : 0 : return sal_False;
1768 [ # # ]: 0 : }
1769 : : }
1770 : :
1771 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const uno::Sequence< beans::PropertyValue >& aAttributeSet ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1772 : : {
1773 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1774 : :
1775 [ # # ]: 0 : SolarMutexGuard aGuard;
1776 : :
1777 : : try
1778 : : {
1779 : : // #102710# Request edit view when doing changes
1780 : : // AccessibleEmptyEditSource relies on this behaviour
1781 [ # # ]: 0 : GetEditViewForwarder( sal_True );
1782 [ # # ]: 0 : SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1783 [ # # ]: 0 : sal_uInt16 nPara = static_cast< sal_uInt16 >( GetParagraphIndex() );
1784 : :
1785 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1786 : : "AccessibleEditableTextPara::setAttributes: index value overflow");
1787 : :
1788 [ # # ]: 0 : CheckRange(nStartIndex, nEndIndex);
1789 : :
1790 [ # # ][ # # ]: 0 : if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
[ # # # # ]
1791 : 0 : return sal_False; // non-editable area selected
1792 : :
1793 : : // do the indices span the whole paragraph? Then use the outliner map
1794 : : // TODO: hold it as a member?
1795 [ # # ]: 0 : SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
1796 : : 0 == nStartIndex &&
1797 [ # # ]: 0 : rCacheTF.GetTextLen(nPara) == nEndIndex ?
1798 : : ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() :
1799 [ # # ][ # # ]: 0 : ImplGetSvxTextPortionSvxPropertySet() );
[ # # ][ # # ]
[ # # ]
1800 : :
1801 [ # # ]: 0 : aPropSet.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
1802 : :
1803 : : // convert from PropertyValue to Any
1804 : 0 : sal_Int32 i, nLength( aAttributeSet.getLength() );
1805 : 0 : const beans::PropertyValue* pPropArray = aAttributeSet.getConstArray();
1806 [ # # ]: 0 : for(i=0; i<nLength; ++i)
1807 : : {
1808 : : try
1809 : : {
1810 [ # # ]: 0 : aPropSet.setPropertyValue(pPropArray->Name, pPropArray->Value);
1811 : : }
1812 [ # # ]: 0 : catch (const uno::Exception&)
1813 : : {
1814 : : OSL_FAIL("AccessibleEditableTextPara::setAttributes exception in setPropertyValue");
1815 : : }
1816 : :
1817 : 0 : ++pPropArray;
1818 : : }
1819 : :
1820 [ # # ]: 0 : rCacheTF.QuickFormatDoc();
1821 [ # # ][ # # ]: 0 : GetEditSource().UpdateData();
1822 : :
1823 [ # # ]: 0 : return sal_True;
1824 : : }
1825 [ # # ]: 0 : catch (const uno::RuntimeException&)
1826 : : {
1827 : 0 : return sal_False;
1828 [ # # ]: 0 : }
1829 : : }
1830 : :
1831 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::setText( const ::rtl::OUString& sText ) throw (uno::RuntimeException)
1832 : : {
1833 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1834 : :
1835 [ # # ]: 0 : SolarMutexGuard aGuard;
1836 : :
1837 [ # # ][ # # ]: 0 : return replaceText(0, getCharacterCount(), sText);
[ # # ]
1838 : : }
1839 : :
1840 : : // XAccessibleTextAttributes
1841 : 2 : uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getDefaultAttributes(
1842 : : const uno::Sequence< ::rtl::OUString >& rRequestedAttributes )
1843 : : throw (uno::RuntimeException)
1844 : : {
1845 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1846 [ + - ]: 2 : SolarMutexGuard aGuard;
1847 : :
1848 : : #if OSL_DEBUG_LEVEL > 0
1849 : : SvxAccessibleTextAdapter& rCacheTF =
1850 : : #endif
1851 [ + - ]: 2 : GetTextForwarder();
1852 : :
1853 : : #if OSL_DEBUG_LEVEL > 0
1854 : : (void)rCacheTF;
1855 : : #endif
1856 : :
1857 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1858 : : "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
1859 : :
1860 : : // get XPropertySetInfo for paragraph attributes and
1861 : : // character attributes that span all the paragraphs text.
1862 [ + - ]: 2 : SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
1863 [ + - ][ + - ]: 4 : ImplGetSvxCharAndParaPropertiesSet() );
1864 [ + - ][ + - ]: 2 : aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
1865 [ + - ]: 2 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
1866 [ - + ]: 2 : if (!xPropSetInfo.is())
1867 : : throw uno::RuntimeException(::rtl::OUString("Cannot query XPropertySetInfo"),
1868 : : uno::Reference< uno::XInterface >
1869 [ # # ][ # # ]: 2 : ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
[ - + ]
1870 : :
1871 : : // build sequence of available properties to check
1872 : 2 : sal_Int32 nLenReqAttr = rRequestedAttributes.getLength();
1873 [ + - ]: 2 : uno::Sequence< beans::Property > aProperties;
1874 [ + - ]: 2 : if (nLenReqAttr)
1875 : : {
1876 : 2 : const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray();
1877 : :
1878 [ + - ]: 2 : aProperties.realloc( nLenReqAttr );
1879 [ + - ]: 2 : beans::Property *pProperties = aProperties.getArray();
1880 : 2 : sal_Int32 nCurLen = 0;
1881 [ + + ]: 4 : for (sal_Int32 i = 0; i < nLenReqAttr; ++i)
1882 : : {
1883 : 2 : beans::Property aProp;
1884 : : try
1885 : : {
1886 [ - + ][ + - ]: 2 : aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] );
1887 : : }
1888 [ + - ]: 2 : catch (const beans::UnknownPropertyException&)
1889 : : {
1890 : 2 : continue;
1891 : : }
1892 [ - + ]: 2 : pProperties[ nCurLen++ ] = aProp;
1893 : 2 : }
1894 [ + - ]: 2 : aProperties.realloc( nCurLen );
1895 : : }
1896 : : else
1897 [ # # ][ # # ]: 0 : aProperties = xPropSetInfo->getProperties();
[ # # ][ # # ]
1898 : :
1899 : 2 : sal_Int32 nLength = aProperties.getLength();
1900 : 2 : const beans::Property *pProperties = aProperties.getConstArray();
1901 : :
1902 : : // build resulting sequence
1903 [ + - ]: 2 : uno::Sequence< beans::PropertyValue > aOutSequence( nLength );
1904 [ + - ]: 2 : beans::PropertyValue* pOutSequence = aOutSequence.getArray();
1905 : 2 : sal_Int32 nOutLen = 0;
1906 [ - + ]: 2 : for (sal_Int32 i = 0; i < nLength; ++i)
1907 : : {
1908 : : // calling implementation functions:
1909 : : // _getPropertyState and _getPropertyValue (see below) to provide
1910 : : // the proper paragraph number when retrieving paragraph attributes
1911 [ # # ]: 0 : PropertyState eState = aPropSet._getPropertyState( pProperties->Name, mnParagraphIndex );
1912 : : if ( eState == PropertyState_AMBIGUOUS_VALUE )
1913 : : {
1914 : : OSL_FAIL( "ambiguous property value encountered" );
1915 : : }
1916 : :
1917 : : //if (eState == PropertyState_DIRECT_VALUE)
1918 : : // per definition all paragraph properties and all character
1919 : : // properties spanning the whole paragraph should be returned
1920 : : // and declared as default value
1921 : : {
1922 : 0 : pOutSequence->Name = pProperties->Name;
1923 : 0 : pOutSequence->Handle = pProperties->Handle;
1924 [ # # ]: 0 : pOutSequence->Value = aPropSet._getPropertyValue( pProperties->Name, mnParagraphIndex );
1925 : 0 : pOutSequence->State = PropertyState_DEFAULT_VALUE;
1926 : :
1927 : 0 : ++pOutSequence;
1928 : 0 : ++nOutLen;
1929 : : }
1930 : 0 : ++pProperties;
1931 : : }
1932 [ + - ]: 2 : aOutSequence.realloc( nOutLen );
1933 : :
1934 [ + - ][ + - ]: 2 : return aOutSequence;
1935 : : }
1936 : :
1937 : :
1938 : 2 : uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getRunAttributes(
1939 : : sal_Int32 nIndex,
1940 : : const uno::Sequence< ::rtl::OUString >& rRequestedAttributes )
1941 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1942 : : {
1943 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
1944 : :
1945 [ + - ]: 2 : SolarMutexGuard aGuard;
1946 : :
1947 : : #if OSL_DEBUG_LEVEL > 0
1948 : : SvxAccessibleTextAdapter& rCacheTF =
1949 : : #endif
1950 [ + - ]: 2 : GetTextForwarder();
1951 : :
1952 : : #if OSL_DEBUG_LEVEL > 0
1953 : : (void)rCacheTF;
1954 : : #endif
1955 : :
1956 : : DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
1957 : : "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
1958 : :
1959 [ + - ]: 2 : CheckIndex(nIndex);
1960 : :
1961 [ + - ]: 2 : SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
1962 [ + - ][ + - ]: 4 : ImplGetSvxCharAndParaPropertiesSet() );
1963 [ + - ]: 2 : aPropSet.SetSelection( MakeSelection( nIndex ) );
1964 [ + - ]: 2 : uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
1965 [ - + ]: 2 : if (!xPropSetInfo.is())
1966 : : throw uno::RuntimeException(::rtl::OUString("Cannot query XPropertySetInfo"),
1967 : : uno::Reference< uno::XInterface >
1968 [ # # ][ # # ]: 2 : ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy
[ - + ]
1969 : :
1970 : : // build sequence of available properties to check
1971 : 2 : sal_Int32 nLenReqAttr = rRequestedAttributes.getLength();
1972 [ + - ]: 2 : uno::Sequence< beans::Property > aProperties;
1973 [ + - ]: 2 : if (nLenReqAttr)
1974 : : {
1975 : 2 : const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray();
1976 : :
1977 [ + - ]: 2 : aProperties.realloc( nLenReqAttr );
1978 [ + - ]: 2 : beans::Property *pProperties = aProperties.getArray();
1979 : 2 : sal_Int32 nCurLen = 0;
1980 [ + + ]: 4 : for (sal_Int32 i = 0; i < nLenReqAttr; ++i)
1981 : : {
1982 : 2 : beans::Property aProp;
1983 : : try
1984 : : {
1985 [ - + ][ + - ]: 2 : aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] );
1986 : : }
1987 [ + - ]: 2 : catch (const beans::UnknownPropertyException&)
1988 : : {
1989 : 2 : continue;
1990 : : }
1991 [ - + ]: 2 : pProperties[ nCurLen++ ] = aProp;
1992 : 2 : }
1993 [ + - ]: 2 : aProperties.realloc( nCurLen );
1994 : : }
1995 : : else
1996 [ # # ][ # # ]: 0 : aProperties = xPropSetInfo->getProperties();
[ # # ][ # # ]
1997 : :
1998 : 2 : sal_Int32 nLength = aProperties.getLength();
1999 : 2 : const beans::Property *pProperties = aProperties.getConstArray();
2000 : :
2001 : : // build resulting sequence
2002 [ + - ]: 2 : uno::Sequence< beans::PropertyValue > aOutSequence( nLength );
2003 [ + - ]: 2 : beans::PropertyValue* pOutSequence = aOutSequence.getArray();
2004 : 2 : sal_Int32 nOutLen = 0;
2005 [ - + ]: 2 : for (sal_Int32 i = 0; i < nLength; ++i)
2006 : : {
2007 : : // calling 'regular' functions that will operate on the selection
2008 [ # # ]: 0 : PropertyState eState = aPropSet.getPropertyState( pProperties->Name );
2009 [ # # ]: 0 : if (eState == PropertyState_DIRECT_VALUE)
2010 : : {
2011 : 0 : pOutSequence->Name = pProperties->Name;
2012 : 0 : pOutSequence->Handle = pProperties->Handle;
2013 [ # # ]: 0 : pOutSequence->Value = aPropSet.getPropertyValue( pProperties->Name );
2014 : 0 : pOutSequence->State = eState;
2015 : :
2016 : 0 : ++pOutSequence;
2017 : 0 : ++nOutLen;
2018 : : }
2019 : 0 : ++pProperties;
2020 : : }
2021 [ + - ]: 2 : aOutSequence.realloc( nOutLen );
2022 : :
2023 [ + - ][ + - ]: 2 : return aOutSequence;
2024 : : }
2025 : :
2026 : : // XAccessibleHypertext
2027 : 0 : ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkCount( ) throw (::com::sun::star::uno::RuntimeException)
2028 : : {
2029 : 0 : SvxAccessibleTextAdapter& rT = GetTextForwarder();
2030 : 0 : const sal_Int32 nPara = GetParagraphIndex();
2031 : :
2032 : 0 : sal_uInt16 nHyperLinks = 0;
2033 : 0 : sal_uInt16 nFields = rT.GetFieldCount( nPara );
2034 [ # # ]: 0 : for ( sal_uInt16 n = 0; n < nFields; n++ )
2035 : : {
2036 [ # # ]: 0 : EFieldInfo aField = rT.GetFieldInfo( nPara, n );
2037 [ # # ][ # # ]: 0 : if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
[ # # ]
2038 : 0 : nHyperLinks++;
2039 [ # # ]: 0 : }
2040 : 0 : return nHyperLinks;
2041 : : }
2042 : :
2043 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > SAL_CALL AccessibleEditableTextPara::getHyperLink( ::sal_Int32 nLinkIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
2044 : : {
2045 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > xRef;
2046 : :
2047 [ # # ]: 0 : SvxAccessibleTextAdapter& rT = GetTextForwarder();
2048 [ # # ]: 0 : const sal_Int32 nPara = GetParagraphIndex();
2049 : :
2050 : 0 : sal_uInt16 nHyperLink = 0;
2051 [ # # ]: 0 : sal_uInt16 nFields = rT.GetFieldCount( nPara );
2052 [ # # ]: 0 : for ( sal_uInt16 n = 0; n < nFields; n++ )
2053 : : {
2054 [ # # ]: 0 : EFieldInfo aField = rT.GetFieldInfo( nPara, n );
2055 [ # # ][ # # ]: 0 : if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
[ # # ]
2056 : : {
2057 [ # # ]: 0 : if ( nHyperLink == nLinkIndex )
2058 : : {
2059 : 0 : sal_uInt16 nEEStart = aField.aPosition.nIndex;
2060 : :
2061 : : // Translate EE Index to accessible index
2062 [ # # ]: 0 : sal_uInt16 nStart = rT.CalcEditEngineIndex( nPara, nEEStart );
2063 : 0 : sal_uInt16 nEnd = nStart + aField.aCurrentText.Len();
2064 [ # # ][ # # ]: 0 : xRef = new AccessibleHyperlink( rT, new SvxFieldItem( *aField.pFieldItem ), nPara, nEEStart, nStart, nEnd, aField.aCurrentText );
[ # # ][ # # ]
[ # # ][ # # ]
2065 : : break;
2066 : : }
2067 : 0 : nHyperLink++;
2068 : : }
2069 [ # # ][ # # ]: 0 : }
2070 : :
2071 : 0 : return xRef;
2072 : : }
2073 : :
2074 : 0 : ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkIndex( ::sal_Int32 nCharIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
2075 : : {
2076 : 0 : const sal_Int32 nPara = GetParagraphIndex();
2077 : 0 : SvxAccessibleTextAdapter& rT = GetTextForwarder();
2078 : :
2079 : : // SvxAccessibleTextIndex aIndex;
2080 : : // aIndex.SetIndex(nPara, nCharIndex, rT);
2081 : : // const sal_uInt16 nEEIndex = aIndex.GetEEIndex();
2082 : :
2083 : 0 : const sal_uInt16 nEEIndex = rT.CalcEditEngineIndex( nPara, nCharIndex );
2084 : 0 : sal_Int32 nHLIndex = 0;
2085 : 0 : sal_uInt16 nHyperLink = 0;
2086 : 0 : sal_uInt16 nFields = rT.GetFieldCount( nPara );
2087 [ # # ]: 0 : for ( sal_uInt16 n = 0; n < nFields; n++ )
2088 : : {
2089 [ # # ]: 0 : EFieldInfo aField = rT.GetFieldInfo( nPara, n );
2090 [ # # ][ # # ]: 0 : if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
[ # # ]
2091 : : {
2092 [ # # ]: 0 : if ( aField.aPosition.nIndex == nEEIndex )
2093 : : {
2094 : 0 : nHLIndex = nHyperLink;
2095 : : break;
2096 : : }
2097 : 0 : nHyperLink++;
2098 : : }
2099 [ # # ][ # # ]: 0 : }
2100 : :
2101 : 0 : return nHLIndex;
2102 : : }
2103 : :
2104 : : // XAccessibleMultiLineText
2105 : 0 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2106 : : {
2107 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2108 : :
2109 : 0 : sal_Int32 nRes = -1;
2110 : 0 : sal_Int32 nPara = GetParagraphIndex();
2111 : :
2112 : 0 : SvxTextForwarder &rCacheTF = GetTextForwarder();
2113 [ # # ][ # # ]: 0 : const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount();
2114 : : DBG_ASSERT( bValidPara, "getLineNumberAtIndex: current paragraph index out of range" );
2115 [ # # ]: 0 : if (bValidPara)
2116 : : {
2117 : : // we explicitly allow for the index to point at the character right behind the text
2118 [ # # ][ # # ]: 0 : if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( static_cast< sal_uInt16 >(nPara) ))
[ # # ]
2119 : 0 : nRes = rCacheTF.GetLineNumberAtIndex( static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nIndex) );
2120 : : else
2121 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
2122 : : }
2123 : 0 : return nRes;
2124 : : }
2125 : :
2126 : : // XAccessibleMultiLineText
2127 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2128 : : {
2129 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2130 : :
2131 : 0 : ::com::sun::star::accessibility::TextSegment aResult;
2132 [ # # ]: 0 : sal_Int32 nPara = GetParagraphIndex();
2133 [ # # ]: 0 : SvxTextForwarder &rCacheTF = GetTextForwarder();
2134 [ # # ][ # # ]: 0 : const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount();
[ # # ]
2135 : : DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" );
2136 [ # # ]: 0 : if (bValidPara)
2137 : : {
2138 [ # # ][ # # ]: 0 : if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( static_cast< sal_uInt16 >(nPara) ))
[ # # ][ # # ]
2139 : : {
2140 : 0 : sal_uInt16 nStart = 0, nEnd = 0;
2141 [ # # ]: 0 : rCacheTF.GetLineBoundaries( nStart, nEnd, static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nLineNo) );
2142 [ # # ][ # # ]: 0 : if (nStart != 0xFFFF && nEnd != 0xFFFF)
2143 : : {
2144 : : try
2145 : : {
2146 [ # # ]: 0 : aResult.SegmentText = getTextRange( nStart, nEnd );
2147 : 0 : aResult.SegmentStart = nStart;
2148 : 0 : aResult.SegmentEnd = nEnd;
2149 : : }
2150 [ # # ]: 0 : catch (const lang::IndexOutOfBoundsException&)
2151 : : {
2152 : : // this is not the exception that should be raised in this function ...
2153 : : DBG_ASSERT( 0, "unexpected exception" );
2154 : : }
2155 : : }
2156 : : }
2157 : : else
2158 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
2159 : : }
2160 [ # # ]: 0 : return aResult;
2161 : : }
2162 : :
2163 : : // XAccessibleMultiLineText
2164 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineWithCaret( ) throw (uno::RuntimeException)
2165 : : {
2166 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2167 : :
2168 : 0 : ::com::sun::star::accessibility::TextSegment aResult;
2169 : : try
2170 : : {
2171 [ # # ][ # # ]: 0 : aResult = getTextAtLineNumber( getNumberOfLineWithCaret() );
2172 : : }
2173 [ # # ]: 0 : catch (const lang::IndexOutOfBoundsException&)
2174 : : {
2175 : : // this one needs to be catched since this interface does not allow for it.
2176 : : }
2177 [ # # ]: 0 : return aResult;
2178 : : }
2179 : :
2180 : : // XAccessibleMultiLineText
2181 : 0 : sal_Int32 SAL_CALL AccessibleEditableTextPara::getNumberOfLineWithCaret( ) throw (uno::RuntimeException)
2182 : : {
2183 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2184 : :
2185 : 0 : sal_Int32 nRes = -1;
2186 : : try
2187 : : {
2188 [ # # ][ # # ]: 0 : nRes = getLineNumberAtIndex( getCaretPosition() );
2189 : : }
2190 : 0 : catch (const lang::IndexOutOfBoundsException&)
2191 : : {
2192 : : // this one needs to be catched since this interface does not allow for it.
2193 : : }
2194 [ # # ]: 0 : return nRes;
2195 : : }
2196 : :
2197 : :
2198 : : // XServiceInfo
2199 : 10 : ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getImplementationName (void) throw (uno::RuntimeException)
2200 : : {
2201 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2202 : :
2203 : 10 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("AccessibleEditableTextPara"));
2204 : : }
2205 : :
2206 : 0 : sal_Bool SAL_CALL AccessibleEditableTextPara::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException)
2207 : : {
2208 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2209 : :
2210 : : // Iterate over all supported service names and return true if on of them
2211 : : // matches the given name.
2212 : : uno::Sequence< ::rtl::OUString> aSupportedServices (
2213 [ # # ]: 0 : getSupportedServiceNames ());
2214 [ # # ]: 0 : for (int i=0; i<aSupportedServices.getLength(); i++)
2215 [ # # ][ # # ]: 0 : if (sServiceName == aSupportedServices[i])
2216 : 0 : return sal_True;
2217 [ # # ]: 0 : return sal_False;
2218 : : }
2219 : :
2220 : 0 : uno::Sequence< ::rtl::OUString> SAL_CALL AccessibleEditableTextPara::getSupportedServiceNames (void) throw (uno::RuntimeException)
2221 : : {
2222 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2223 : :
2224 [ # # ]: 0 : const ::rtl::OUString sServiceName( getServiceName() );
2225 [ # # ]: 0 : return uno::Sequence< ::rtl::OUString > (&sServiceName, 1);
2226 : : }
2227 : :
2228 : : // XServiceName
2229 : 0 : ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getServiceName (void) throw (uno::RuntimeException)
2230 : : {
2231 : : DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
2232 : :
2233 : : // #105185# Using correct service now
2234 : 0 : return ::rtl::OUString("com.sun.star.text.AccessibleParagraphView");
2235 : : }
2236 : :
2237 : : } // end of namespace accessibility
2238 : :
2239 : : //------------------------------------------------------------------------
2240 : :
2241 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|