1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleEditableTextPara.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 //------------------------------------------------------------------------
38 //------------------------------------------------------------------------
43 #include <vos/mutex.hxx>
44 #include <vcl/window.hxx>
45 #include <vcl/svapp.hxx>
46 #include <com/sun/star/uno/Any.hxx>
47 #include <com/sun/star/uno/Reference.hxx>
48 #include <com/sun/star/awt/Point.hpp>
49 #include <com/sun/star/awt/Rectangle.hpp>
50 #include <com/sun/star/lang/DisposedException.hpp>
51 #include <com/sun/star/accessibility/AccessibleRole.hpp>
52 #include <com/sun/star/accessibility/AccessibleTextType.hpp>
53 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
54 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
55 #include <comphelper/accessibleeventnotifier.hxx>
56 #include <comphelper/sequenceashashmap.hxx>
57 #include <unotools/accessiblestatesethelper.hxx>
59 // --> OD 2006-01-11 #i27138#
60 #include <unotools/accessiblerelationsethelper.hxx>
61 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
63 #include <vcl/unohelp.hxx>
65 //------------------------------------------------------------------------
67 // Project-local header
69 //------------------------------------------------------------------------
71 #include <com/sun/star/beans/PropertyState.hpp>
72 #include <svx/unoshape.hxx>
73 #include "unolingu.hxx"
74 #include "unopracc.hxx"
75 #include "AccessibleEditableTextPara.hxx"
76 #include <svx/dialmgr.hxx>
78 #include "accessibility.hrc"
79 #include <svtools/colorcfg.hxx>
82 using namespace ::com::sun::star
;
83 using namespace ::com::sun::star::beans
;
84 using namespace ::com::sun::star::accessibility
;
87 //------------------------------------------------------------------------
89 // AccessibleEditableTextPara implementation
91 //------------------------------------------------------------------------
93 namespace accessibility
96 const SvxItemPropertySet
* ImplGetSvxCharAndParaPropertiesSet()
98 // PropertyMap for character and paragraph properties
99 static const SfxItemPropertyMapEntry aPropMap
[] =
101 SVX_UNOEDIT_CHAR_PROPERTIES
,
102 SVX_UNOEDIT_PARA_PROPERTIES
,
103 SVX_UNOEDIT_NUMBERING_PROPERTIE
,
104 {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS
, &::getCppuType((const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>*)0) , 0, 0},
105 {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS
, &::getCppuType((const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameContainer
>*)0) , 0, 0},
108 static SvxItemPropertySet
aPropSet( aPropMap
);
113 DBG_NAME( AccessibleEditableTextPara
)
115 // --> OD 2006-01-11 #i27138# - add parameter <_pParaManager>
116 AccessibleEditableTextPara::AccessibleEditableTextPara(
117 const uno::Reference
< XAccessible
>& rParent
,
118 const AccessibleParaManager
* _pParaManager
)
119 : AccessibleTextParaInterfaceBase( m_aMutex
),
120 mnParagraphIndex( 0 ),
121 mnIndexInParent( 0 ),
122 mpEditSource( NULL
),
125 // well, that's strictly (UNO) exception safe, though not
126 // really robust. We rely on the fact that this member is
127 // constructed last, and that the constructor body catches
128 // exceptions, thus no chance for exceptions once the Id is
129 // fetched. Nevertheless, normally should employ RAII here...
130 mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient()),
131 // --> OD 2006-01-11 #i27138#
132 mpParaManager( _pParaManager
)
136 DBG_CTOR( AccessibleEditableTextPara
, NULL
);
137 OSL_TRACE( "AccessibleEditableTextPara received ID: %d\n", mnNotifierClientId
);
142 // Create the state set.
143 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper ();
144 mxStateSet
= pStateSet
;
146 // these are always on
147 pStateSet
->AddState( AccessibleStateType::MULTI_LINE
);
148 pStateSet
->AddState( AccessibleStateType::FOCUSABLE
);
149 pStateSet
->AddState( AccessibleStateType::VISIBLE
);
150 pStateSet
->AddState( AccessibleStateType::SHOWING
);
151 pStateSet
->AddState( AccessibleStateType::ENABLED
);
152 pStateSet
->AddState( AccessibleStateType::SENSITIVE
);
154 catch( const uno::Exception
& ) {}
157 AccessibleEditableTextPara::~AccessibleEditableTextPara()
159 DBG_DTOR( AccessibleEditableTextPara
, NULL
);
161 // sign off from event notifier
162 if( getNotifierClientId() != -1 )
166 ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() );
168 OSL_TRACE( "AccessibleEditableTextPara revoked ID: %d\n", mnNotifierClientId
);
171 catch( const uno::Exception
& ) {}
175 ::rtl::OUString
AccessibleEditableTextPara::implGetText()
177 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
179 return GetTextRange( 0, GetTextLen() );
182 ::com::sun::star::lang::Locale
AccessibleEditableTextPara::implGetLocale()
184 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
186 lang::Locale aLocale
;
188 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
189 "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
191 // return locale of first character in the paragraph
192 return SvxLanguageToLocale(aLocale
, GetTextForwarder().GetLanguage( static_cast< USHORT
>( GetParagraphIndex() ), 0 ));
195 void AccessibleEditableTextPara::implGetSelection( sal_Int32
& nStartIndex
, sal_Int32
& nEndIndex
)
197 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
201 if( GetSelection( nStart
, nEnd
) )
203 nStartIndex
= nStart
;
208 // #102234# No exception, just set to 'invalid'
214 void AccessibleEditableTextPara::implGetParagraphBoundary( ::com::sun::star::i18n::Boundary
& rBoundary
, sal_Int32
/*nIndex*/ )
216 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
217 DBG_WARNING( "AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" );
219 rBoundary
.startPos
= 0;
220 rBoundary
.endPos
= GetTextLen();
223 void AccessibleEditableTextPara::implGetLineBoundary( ::com::sun::star::i18n::Boundary
& rBoundary
, sal_Int32 nIndex
)
225 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
227 SvxTextForwarder
& rCacheTF
= GetTextForwarder();
228 const sal_Int32 nParaIndex
= GetParagraphIndex();
230 DBG_ASSERT(nParaIndex
>= 0 && nParaIndex
<= USHRT_MAX
,
231 "AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow");
233 const sal_Int32 nTextLen
= rCacheTF
.GetTextLen( static_cast< USHORT
>( nParaIndex
) );
235 CheckPosition(nIndex
);
237 rBoundary
.startPos
= rBoundary
.endPos
= -1;
239 const USHORT nLineCount
=rCacheTF
.GetLineCount( static_cast< USHORT
>( nParaIndex
) );
241 if( nIndex
== nTextLen
)
243 // #i17014# Special-casing one-behind-the-end character
244 if( nLineCount
<= 1 )
245 rBoundary
.startPos
= 0;
247 rBoundary
.startPos
= nTextLen
- rCacheTF
.GetLineLen( static_cast< USHORT
>( nParaIndex
),
250 rBoundary
.endPos
= nTextLen
;
254 // normal line search
257 for( nLine
=0, nCurIndex
=0; nLine
<nLineCount
; ++nLine
)
259 nCurIndex
+= rCacheTF
.GetLineLen( static_cast< USHORT
>( nParaIndex
), nLine
);
261 if( nCurIndex
> nIndex
)
263 rBoundary
.startPos
= nCurIndex
- rCacheTF
.GetLineLen(static_cast< USHORT
>( nParaIndex
), nLine
);
264 rBoundary
.endPos
= nCurIndex
;
271 int AccessibleEditableTextPara::getNotifierClientId() const
273 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
275 return mnNotifierClientId
;
278 void AccessibleEditableTextPara::SetIndexInParent( sal_Int32 nIndex
)
280 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
282 mnIndexInParent
= nIndex
;
285 sal_Int32
AccessibleEditableTextPara::GetIndexInParent() const
287 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
289 return mnIndexInParent
;
292 void AccessibleEditableTextPara::SetParagraphIndex( sal_Int32 nIndex
)
294 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
296 sal_Int32 nOldIndex
= mnParagraphIndex
;
298 mnParagraphIndex
= nIndex
;
300 WeakBullet::HardRefType
aChild( maImageBullet
.get() );
302 aChild
->SetParagraphIndex(mnParagraphIndex
);
306 if( nOldIndex
!= nIndex
)
313 aOldDesc
<<= getAccessibleDescription();
314 aOldName
<<= getAccessibleName();
316 catch( const uno::Exception
& ) {} // optional behaviour
317 // index and therefore description changed
318 FireEvent( AccessibleEventId::DESCRIPTION_CHANGED
, uno::makeAny( getAccessibleDescription() ), aOldDesc
);
319 FireEvent( AccessibleEventId::NAME_CHANGED
, uno::makeAny( getAccessibleName() ), aOldName
);
322 catch( const uno::Exception
& ) {} // optional behaviour
325 sal_Int32
AccessibleEditableTextPara::GetParagraphIndex() const SAL_THROW((uno::RuntimeException
))
327 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
329 return mnParagraphIndex
;
332 void AccessibleEditableTextPara::Dispose()
334 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
336 int nClientId( getNotifierClientId() );
338 // #108212# drop all references before notifying dispose
340 mnNotifierClientId
= -1;
344 if( nClientId
!= -1 )
348 uno::Reference
< XAccessibleContext
> xThis
= getAccessibleContext();
350 // #106234# Delegate to EventNotifier
351 ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId
, xThis
);
353 OSL_TRACE( "Disposed ID: %d\n", nClientId
);
356 catch( const uno::Exception
& ) {}
360 void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter
* pEditSource
)
362 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
364 mpEditSource
= pEditSource
;
366 WeakBullet::HardRefType
aChild( maImageBullet
.get() );
368 aChild
->SetEditSource(pEditSource
);
373 UnSetState( AccessibleStateType::SHOWING
);
374 UnSetState( AccessibleStateType::VISIBLE
);
375 SetState( AccessibleStateType::INVALID
);
376 SetState( AccessibleStateType::DEFUNC
);
381 // #108900# Init last text content
386 catch( const uno::RuntimeException
& ) {}
389 ESelection
AccessibleEditableTextPara::MakeSelection( sal_Int32 nStartEEIndex
, sal_Int32 nEndEEIndex
)
391 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
394 DBG_ASSERT(nStartEEIndex
>= 0 && nStartEEIndex
<= USHRT_MAX
&&
395 nEndEEIndex
>= 0 && nEndEEIndex
<= USHRT_MAX
&&
396 GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
397 "AccessibleEditableTextPara::MakeSelection: index value overflow");
399 USHORT nParaIndex
= static_cast< USHORT
>( GetParagraphIndex() );
400 return ESelection( nParaIndex
, static_cast< USHORT
>( nStartEEIndex
),
401 nParaIndex
, static_cast< USHORT
>( nEndEEIndex
) );
404 ESelection
AccessibleEditableTextPara::MakeSelection( sal_Int32 nEEIndex
)
406 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
408 return MakeSelection( nEEIndex
, nEEIndex
+1 );
411 ESelection
AccessibleEditableTextPara::MakeCursor( sal_Int32 nEEIndex
)
413 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
415 return MakeSelection( nEEIndex
, nEEIndex
);
418 void AccessibleEditableTextPara::CheckIndex( sal_Int32 nIndex
) SAL_THROW((lang::IndexOutOfBoundsException
, uno::RuntimeException
))
420 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
422 if( nIndex
< 0 || nIndex
>= getCharacterCount() )
423 throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character index out of bounds")),
424 uno::Reference
< uno::XInterface
>
425 ( static_cast< ::cppu::OWeakObject
* > (this) ) ); // disambiguate hierarchy
428 void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex
) SAL_THROW((lang::IndexOutOfBoundsException
, uno::RuntimeException
))
430 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
432 if( nIndex
< 0 || nIndex
> getCharacterCount() )
433 throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character position out of bounds")),
434 uno::Reference
< uno::XInterface
>
435 ( static_cast< ::cppu::OWeakObject
* > (this) ) ); // disambiguate hierarchy
438 void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart
, sal_Int32 nEnd
) SAL_THROW((lang::IndexOutOfBoundsException
, uno::RuntimeException
))
440 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
442 CheckPosition( nStart
);
443 CheckPosition( nEnd
);
446 sal_Bool
AccessibleEditableTextPara::GetSelection( USHORT
& nStartPos
, USHORT
& nEndPos
) SAL_THROW((uno::RuntimeException
))
448 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
450 ESelection aSelection
;
451 USHORT nPara
= static_cast< USHORT
> ( GetParagraphIndex() );
452 if( !GetEditViewForwarder().GetSelection( aSelection
) )
455 if( aSelection
.nStartPara
< aSelection
.nEndPara
)
457 if( aSelection
.nStartPara
> nPara
||
458 aSelection
.nEndPara
< nPara
)
461 if( nPara
== aSelection
.nStartPara
)
462 nStartPos
= aSelection
.nStartPos
;
466 if( nPara
== aSelection
.nEndPara
)
467 nEndPos
= aSelection
.nEndPos
;
469 nEndPos
= GetTextLen();
473 if( aSelection
.nStartPara
< nPara
||
474 aSelection
.nEndPara
> nPara
)
477 if( nPara
== aSelection
.nStartPara
)
478 nStartPos
= aSelection
.nStartPos
;
480 nStartPos
= GetTextLen();
482 if( nPara
== aSelection
.nEndPara
)
483 nEndPos
= aSelection
.nEndPos
;
491 String
AccessibleEditableTextPara::GetText( sal_Int32 nIndex
) SAL_THROW((uno::RuntimeException
))
493 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
495 return GetTextForwarder().GetText( MakeSelection(nIndex
) );
498 String
AccessibleEditableTextPara::GetTextRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) SAL_THROW((uno::RuntimeException
))
500 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
502 return GetTextForwarder().GetText( MakeSelection(nStartIndex
, nEndIndex
) );
505 USHORT
AccessibleEditableTextPara::GetTextLen() const SAL_THROW((uno::RuntimeException
))
507 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
509 return GetTextForwarder().GetTextLen( static_cast< USHORT
>( GetParagraphIndex() ) );
512 sal_Bool
AccessibleEditableTextPara::IsVisible() const
514 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
516 return mpEditSource
? sal_True
: sal_False
;
519 uno::Reference
< XAccessibleText
> AccessibleEditableTextPara::GetParaInterface( sal_Int32 nIndex
)
521 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
523 uno::Reference
< XAccessible
> xParent
= getAccessibleParent();
526 uno::Reference
< XAccessibleContext
> xParentContext
= xParent
->getAccessibleContext();
527 if( xParentContext
.is() )
529 uno::Reference
< XAccessible
> xPara
= xParentContext
->getAccessibleChild( nIndex
);
531 return uno::Reference
< XAccessibleText
> ( xPara
, uno::UNO_QUERY
);
535 return uno::Reference
< XAccessibleText
>();
538 SvxEditSourceAdapter
& AccessibleEditableTextPara::GetEditSource() const SAL_THROW((uno::RuntimeException
))
540 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
543 return *mpEditSource
;
545 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No edit source, object is defunct")),
546 uno::Reference
< uno::XInterface
>
547 ( static_cast< ::cppu::OWeakObject
* >
548 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
551 SvxAccessibleTextAdapter
& AccessibleEditableTextPara::GetTextForwarder() const SAL_THROW((uno::RuntimeException
))
553 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
555 SvxEditSourceAdapter
& rEditSource
= GetEditSource();
556 SvxAccessibleTextAdapter
* pTextForwarder
= rEditSource
.GetTextForwarderAdapter();
558 if( !pTextForwarder
)
559 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch text forwarder, object is defunct")),
560 uno::Reference
< uno::XInterface
>
561 ( static_cast< ::cppu::OWeakObject
* >
562 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
564 if( pTextForwarder
->IsValid() )
565 return *pTextForwarder
;
567 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text forwarder is invalid, object is defunct")),
568 uno::Reference
< uno::XInterface
>
569 ( static_cast< ::cppu::OWeakObject
* >
570 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
573 SvxViewForwarder
& AccessibleEditableTextPara::GetViewForwarder() const SAL_THROW((uno::RuntimeException
))
575 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
577 SvxEditSource
& rEditSource
= GetEditSource();
578 SvxViewForwarder
* pViewForwarder
= rEditSource
.GetViewForwarder();
580 if( !pViewForwarder
)
582 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")),
583 uno::Reference
< uno::XInterface
>
584 ( static_cast< ::cppu::OWeakObject
* >
585 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
588 if( pViewForwarder
->IsValid() )
589 return *pViewForwarder
;
591 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")),
592 uno::Reference
< uno::XInterface
>
593 ( static_cast< ::cppu::OWeakObject
* >
594 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
597 SvxAccessibleTextEditViewAdapter
& AccessibleEditableTextPara::GetEditViewForwarder( sal_Bool bCreate
) const SAL_THROW((uno::RuntimeException
))
599 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
601 SvxEditSourceAdapter
& rEditSource
= GetEditSource();
602 SvxAccessibleTextEditViewAdapter
* pTextEditViewForwarder
= rEditSource
.GetEditViewForwarderAdapter( bCreate
);
604 if( !pTextEditViewForwarder
)
607 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")),
608 uno::Reference
< uno::XInterface
>
609 ( static_cast< ::cppu::OWeakObject
* >
610 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
612 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No view forwarder, object not in edit mode")),
613 uno::Reference
< uno::XInterface
>
614 ( static_cast< ::cppu::OWeakObject
* >
615 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
618 if( pTextEditViewForwarder
->IsValid() )
619 return *pTextEditViewForwarder
;
623 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")),
624 uno::Reference
< uno::XInterface
>
625 ( static_cast< ::cppu::OWeakObject
* >
626 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
628 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object not in edit mode")),
629 uno::Reference
< uno::XInterface
>
630 ( static_cast< ::cppu::OWeakObject
* >
631 ( const_cast< AccessibleEditableTextPara
* > (this) ) ) ); // disambiguate hierarchy
635 sal_Bool
AccessibleEditableTextPara::HaveEditView() const
637 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
639 SvxEditSource
& rEditSource
= GetEditSource();
640 SvxEditViewForwarder
* pViewForwarder
= rEditSource
.GetEditViewForwarder();
642 if( !pViewForwarder
)
645 if( !pViewForwarder
->IsValid() )
651 sal_Bool
AccessibleEditableTextPara::HaveChildren()
653 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
655 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
656 "AccessibleEditableTextPara::HaveChildren: paragraph index value overflow");
658 return GetTextForwarder().HaveImageBullet( static_cast< USHORT
>(GetParagraphIndex()) );
661 sal_Bool
AccessibleEditableTextPara::IsActive() const SAL_THROW((uno::RuntimeException
))
663 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
665 SvxEditSource
& rEditSource
= GetEditSource();
666 SvxEditViewForwarder
* pViewForwarder
= rEditSource
.GetEditViewForwarder();
668 if( !pViewForwarder
)
671 if( pViewForwarder
->IsValid() )
677 Rectangle
AccessibleEditableTextPara::LogicToPixel( const Rectangle
& rRect
, const MapMode
& rMapMode
, SvxViewForwarder
& rForwarder
)
679 // convert to screen coordinates
680 return Rectangle( rForwarder
.LogicToPixel( rRect
.TopLeft(), rMapMode
),
681 rForwarder
.LogicToPixel( rRect
.BottomRight(), rMapMode
) );
684 const Point
& AccessibleEditableTextPara::GetEEOffset() const
686 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
691 void AccessibleEditableTextPara::SetEEOffset( const Point
& rOffset
)
693 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
695 WeakBullet::HardRefType
aChild( maImageBullet
.get() );
697 aChild
->SetEEOffset(rOffset
);
699 maEEOffset
= rOffset
;
702 void AccessibleEditableTextPara::FireEvent(const sal_Int16 nEventId
, const uno::Any
& rNewValue
, const uno::Any
& rOldValue
) const
704 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
706 uno::Reference
< XAccessibleContext
> xThis( const_cast< AccessibleEditableTextPara
* > (this)->getAccessibleContext() );
708 AccessibleEventObject
aEvent(xThis
, nEventId
, rNewValue
, rOldValue
);
710 // #102261# Call global queue for focus events
711 if( nEventId
== AccessibleEventId::STATE_CHANGED
)
712 vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent
);
714 // #106234# Delegate to EventNotifier
715 if( getNotifierClientId() != -1 )
716 ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(),
720 void AccessibleEditableTextPara::GotPropertyEvent( const uno::Any
& rNewValue
, const sal_Int16 nEventId
) const
722 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
724 FireEvent( nEventId
, rNewValue
);
727 void AccessibleEditableTextPara::LostPropertyEvent( const uno::Any
& rOldValue
, const sal_Int16 nEventId
) const
729 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
731 FireEvent( nEventId
, uno::Any(), rOldValue
);
734 bool AccessibleEditableTextPara::HasState( const sal_Int16 nStateId
)
736 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
738 ::utl::AccessibleStateSetHelper
* pStateSet
= static_cast< ::utl::AccessibleStateSetHelper
*>(mxStateSet
.get());
739 if( pStateSet
!= NULL
)
740 return pStateSet
->contains(nStateId
) ? true : false;
745 void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId
)
747 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
749 ::utl::AccessibleStateSetHelper
* pStateSet
= static_cast< ::utl::AccessibleStateSetHelper
*>(mxStateSet
.get());
750 if( pStateSet
!= NULL
&&
751 !pStateSet
->contains(nStateId
) )
753 pStateSet
->AddState( nStateId
);
754 GotPropertyEvent( uno::makeAny( nStateId
), AccessibleEventId::STATE_CHANGED
);
758 void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId
)
760 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
762 ::utl::AccessibleStateSetHelper
* pStateSet
= static_cast< ::utl::AccessibleStateSetHelper
*>(mxStateSet
.get());
763 if( pStateSet
!= NULL
&&
764 pStateSet
->contains(nStateId
) )
766 pStateSet
->RemoveState( nStateId
);
767 LostPropertyEvent( uno::makeAny( nStateId
), AccessibleEventId::STATE_CHANGED
);
771 void AccessibleEditableTextPara::TextChanged()
773 ::rtl::OUString
aCurrentString( OCommonAccessibleText::getText() );
776 if( OCommonAccessibleText::implInitTextChangedEvent( maLastTextString
, aCurrentString
,
777 aDeleted
, aInserted
) )
779 FireEvent( AccessibleEventId::TEXT_CHANGED
, aInserted
, aDeleted
);
780 maLastTextString
= aCurrentString
;
784 sal_Bool
AccessibleEditableTextPara::GetAttributeRun( USHORT
& nStartIndex
, USHORT
& nEndIndex
, sal_Int32 nIndex
)
786 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
788 DBG_ASSERT(nIndex
>= 0 && nIndex
<= USHRT_MAX
,
789 "AccessibleEditableTextPara::GetAttributeRun: index value overflow");
791 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
792 "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
794 return GetTextForwarder().GetAttributeRun( nStartIndex
,
796 static_cast< USHORT
>(GetParagraphIndex()),
797 static_cast< USHORT
>(nIndex
) );
800 uno::Any SAL_CALL
AccessibleEditableTextPara::queryInterface (const uno::Type
& rType
) throw (uno::RuntimeException
)
802 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
806 // must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText
807 if ( rType
== ::getCppuType((uno::Reference
< XAccessibleText
> *)0) )
809 uno::Reference
< XAccessibleText
> aAccText
= static_cast< XAccessibleEditableText
* >(this);
812 else if ( rType
== ::getCppuType((uno::Reference
< XAccessibleEditableText
> *)0) )
814 uno::Reference
< XAccessibleEditableText
> aAccEditText
= this;
815 aRet
<<= aAccEditText
;
819 aRet
= AccessibleTextParaInterfaceBase::queryInterface(rType
);
826 uno::Reference
< XAccessibleContext
> SAL_CALL
AccessibleEditableTextPara::getAccessibleContext() throw (uno::RuntimeException
)
828 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
830 // We implement the XAccessibleContext interface in the same object
831 return uno::Reference
< XAccessibleContext
> ( this );
834 // XAccessibleContext
835 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getAccessibleChildCount() throw (uno::RuntimeException
)
837 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
839 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
841 return HaveChildren() ? 1 : 0;
844 uno::Reference
< XAccessible
> SAL_CALL
AccessibleEditableTextPara::getAccessibleChild( sal_Int32 i
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
846 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
848 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
850 if( !HaveChildren() )
851 throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No childs available")),
852 uno::Reference
< uno::XInterface
>
853 ( static_cast< ::cppu::OWeakObject
* > (this) ) ); // static_cast: disambiguate hierarchy
856 throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid child index")),
857 uno::Reference
< uno::XInterface
>
858 ( static_cast< ::cppu::OWeakObject
* > (this) ) ); // static_cast: disambiguate hierarchy
860 WeakBullet::HardRefType
aChild( maImageBullet
.get() );
864 // there is no hard reference available, create object then
865 AccessibleImageBullet
* pChild
= new AccessibleImageBullet( uno::Reference
< XAccessible
>( this ) );
866 uno::Reference
< XAccessible
> xChild( static_cast< ::cppu::OWeakObject
* > (pChild
), uno::UNO_QUERY
);
869 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Child creation failed")),
870 uno::Reference
< uno::XInterface
>
871 ( static_cast< ::cppu::OWeakObject
* > (this) ) );
873 aChild
= WeakBullet::HardRefType( xChild
, pChild
);
875 aChild
->SetEditSource( &GetEditSource() );
876 aChild
->SetParagraphIndex( GetParagraphIndex() );
877 aChild
->SetIndexInParent( i
);
879 maImageBullet
= aChild
;
882 return aChild
.getRef();
885 uno::Reference
< XAccessible
> SAL_CALL
AccessibleEditableTextPara::getAccessibleParent() throw (uno::RuntimeException
)
887 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
891 DBG_TRACE( "AccessibleEditableTextPara::getAccessibleParent: no frontend set, did somebody forgot to call AccessibleTextHelper::SetEventSource()?");
897 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getAccessibleIndexInParent() throw (uno::RuntimeException
)
899 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
901 return mnIndexInParent
;
904 sal_Int16 SAL_CALL
AccessibleEditableTextPara::getAccessibleRole() throw (uno::RuntimeException
)
906 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
908 return AccessibleRole::PARAGRAPH
;
911 ::rtl::OUString SAL_CALL
AccessibleEditableTextPara::getAccessibleDescription() throw (uno::RuntimeException
)
913 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
915 // ::vos::OGuard aGuard( Application::GetSolarMutex() );
917 return ::rtl::OUString();
920 ::rtl::OUString SAL_CALL
AccessibleEditableTextPara::getAccessibleName() throw (uno::RuntimeException
)
922 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
924 // ::vos::OGuard aGuard( Application::GetSolarMutex() );
926 return ::rtl::OUString();
929 uno::Reference
< XAccessibleRelationSet
> SAL_CALL
AccessibleEditableTextPara::getAccessibleRelationSet() throw (uno::RuntimeException
)
931 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
933 // --> OD 2006-01-11 #i27138# - provide relations CONTENT_FLOWS_FROM
934 // and CONTENT_FLOWS_TO
937 utl::AccessibleRelationSetHelper
* pAccRelSetHelper
=
938 new utl::AccessibleRelationSetHelper();
939 sal_Int32
nMyParaIndex( GetParagraphIndex() );
940 // relation CONTENT_FLOWS_FROM
941 if ( nMyParaIndex
> 0 &&
942 mpParaManager
->IsReferencable( nMyParaIndex
- 1 ) )
944 uno::Sequence
<uno::Reference
<XInterface
> > aSequence(1);
946 mpParaManager
->GetChild( nMyParaIndex
- 1 ).first
.get().getRef();
947 AccessibleRelation
aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM
,
949 pAccRelSetHelper
->AddRelation( aAccRel
);
952 // relation CONTENT_FLOWS_TO
953 if ( (nMyParaIndex
+ 1) < (sal_Int32
)mpParaManager
->GetNum() &&
954 mpParaManager
->IsReferencable( nMyParaIndex
+ 1 ) )
956 uno::Sequence
<uno::Reference
<XInterface
> > aSequence(1);
958 mpParaManager
->GetChild( nMyParaIndex
+ 1 ).first
.get().getRef();
959 AccessibleRelation
aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO
,
961 pAccRelSetHelper
->AddRelation( aAccRel
);
964 return pAccRelSetHelper
;
968 // no relations, therefore empty
969 return uno::Reference
< XAccessibleRelationSet
>();
974 uno::Reference
< XAccessibleStateSet
> SAL_CALL
AccessibleEditableTextPara::getAccessibleStateSet() throw (uno::RuntimeException
)
976 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
978 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
980 // Create a copy of the state set and return it.
981 ::utl::AccessibleStateSetHelper
* pStateSet
= static_cast< ::utl::AccessibleStateSetHelper
*>(mxStateSet
.get());
984 return uno::Reference
<XAccessibleStateSet
>();
986 return uno::Reference
<XAccessibleStateSet
>( new ::utl::AccessibleStateSetHelper (*pStateSet
) );
989 lang::Locale SAL_CALL
AccessibleEditableTextPara::getLocale() throw (IllegalAccessibleComponentStateException
, uno::RuntimeException
)
991 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
993 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
995 return implGetLocale();
998 void SAL_CALL
AccessibleEditableTextPara::addEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
) throw (uno::RuntimeException
)
1000 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1002 if( getNotifierClientId() != -1 )
1003 ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener
);
1006 void SAL_CALL
AccessibleEditableTextPara::removeEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
) throw (uno::RuntimeException
)
1008 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1010 if( getNotifierClientId() != -1 )
1011 ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener
);
1014 // XAccessibleComponent
1015 sal_Bool SAL_CALL
AccessibleEditableTextPara::containsPoint( const awt::Point
& aTmpPoint
) throw (uno::RuntimeException
)
1017 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1019 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1021 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1022 "AccessibleEditableTextPara::contains: index value overflow");
1024 awt::Rectangle aTmpRect
= getBounds();
1025 Rectangle
aRect( Point(aTmpRect
.X
, aTmpRect
.Y
), Size(aTmpRect
.Width
, aTmpRect
.Height
) );
1026 Point
aPoint( aTmpPoint
.X
, aTmpPoint
.Y
);
1028 return aRect
.IsInside( aPoint
);
1031 uno::Reference
< XAccessible
> SAL_CALL
AccessibleEditableTextPara::getAccessibleAtPoint( const awt::Point
& _aPoint
) throw (uno::RuntimeException
)
1033 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1035 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1037 if( HaveChildren() )
1039 // #103862# No longer need to make given position relative
1040 Point
aPoint( _aPoint
.X
, _aPoint
.Y
);
1042 // respect EditEngine offset to surrounding shape/cell
1043 aPoint
-= GetEEOffset();
1045 // convert to EditEngine coordinate system
1046 SvxTextForwarder
& rCacheTF
= GetTextForwarder();
1047 Point
aLogPoint( GetViewForwarder().PixelToLogic( aPoint
, rCacheTF
.GetMapMode() ) );
1049 EBulletInfo aBulletInfo
= rCacheTF
.GetBulletInfo( static_cast< USHORT
> (GetParagraphIndex()) );
1051 if( aBulletInfo
.nParagraph
!= EE_PARA_NOT_FOUND
&&
1052 aBulletInfo
.bVisible
&&
1053 aBulletInfo
.nType
== SVX_NUM_BITMAP
)
1055 Rectangle aRect
= aBulletInfo
.aBounds
;
1057 if( aRect
.IsInside( aLogPoint
) )
1058 return getAccessibleChild(0);
1062 // no children at all, or none at given position
1063 return uno::Reference
< XAccessible
>();
1066 awt::Rectangle SAL_CALL
AccessibleEditableTextPara::getBounds() throw (uno::RuntimeException
)
1068 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1070 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1072 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1073 "AccessibleEditableTextPara::getBounds: index value overflow");
1075 SvxTextForwarder
& rCacheTF
= GetTextForwarder();
1076 Rectangle aRect
= rCacheTF
.GetParaBounds( static_cast< USHORT
>( GetParagraphIndex() ) );
1078 // convert to screen coordinates
1079 Rectangle aScreenRect
= AccessibleEditableTextPara::LogicToPixel( aRect
,
1080 rCacheTF
.GetMapMode(),
1081 GetViewForwarder() );
1083 // offset from shape/cell
1084 Point aOffset
= GetEEOffset();
1086 return awt::Rectangle( aScreenRect
.Left() + aOffset
.X(),
1087 aScreenRect
.Top() + aOffset
.Y(),
1088 aScreenRect
.GetSize().Width(),
1089 aScreenRect
.GetSize().Height() );
1092 awt::Point SAL_CALL
AccessibleEditableTextPara::getLocation( ) throw (uno::RuntimeException
)
1094 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1096 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1098 awt::Rectangle aRect
= getBounds();
1100 return awt::Point( aRect
.X
, aRect
.Y
);
1103 awt::Point SAL_CALL
AccessibleEditableTextPara::getLocationOnScreen( ) throw (uno::RuntimeException
)
1105 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1107 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1109 // relate us to parent
1110 uno::Reference
< XAccessible
> xParent
= getAccessibleParent();
1113 uno::Reference
< XAccessibleComponent
> xParentComponent( xParent
, uno::UNO_QUERY
);
1114 if( xParentComponent
.is() )
1116 awt::Point aRefPoint
= xParentComponent
->getLocationOnScreen();
1117 awt::Point aPoint
= getLocation();
1118 aPoint
.X
+= aRefPoint
.X
;
1119 aPoint
.Y
+= aRefPoint
.Y
;
1125 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot access parent")),
1126 uno::Reference
< uno::XInterface
>
1127 ( static_cast< XAccessible
* > (this) ) ); // disambiguate hierarchy
1130 awt::Size SAL_CALL
AccessibleEditableTextPara::getSize( ) throw (uno::RuntimeException
)
1132 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1134 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1136 awt::Rectangle aRect
= getBounds();
1138 return awt::Size( aRect
.Width
, aRect
.Height
);
1141 void SAL_CALL
AccessibleEditableTextPara::grabFocus( ) throw (uno::RuntimeException
)
1143 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1145 // set cursor to this paragraph
1149 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getForeground( ) throw (::com::sun::star::uno::RuntimeException
)
1151 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1153 // #104444# Added to XAccessibleComponent interface
1154 svtools::ColorConfig aColorConfig
;
1155 UINT32 nColor
= aColorConfig
.GetColorValue( svtools::FONTCOLOR
).nColor
;
1156 return static_cast<sal_Int32
>(nColor
);
1159 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getBackground( ) throw (::com::sun::star::uno::RuntimeException
)
1161 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1163 // #104444# Added to XAccessibleComponent interface
1164 Color
aColor( Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor() );
1166 // the background is transparent
1167 aColor
.SetTransparency( 0xFF);
1169 return static_cast<sal_Int32
>( aColor
.GetColor() );
1173 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getCaretPosition() throw (uno::RuntimeException
)
1175 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1177 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1179 if( !HaveEditView() )
1182 ESelection aSelection
;
1183 if( GetEditViewForwarder().GetSelection( aSelection
) &&
1184 GetParagraphIndex() == aSelection
.nEndPara
)
1186 // caret is always nEndPara,nEndPos
1187 return aSelection
.nEndPos
;
1190 // not within this paragraph
1194 sal_Bool SAL_CALL
AccessibleEditableTextPara::setCaretPosition( sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1196 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1198 return setSelection(nIndex
, nIndex
);
1201 sal_Unicode SAL_CALL
AccessibleEditableTextPara::getCharacter( sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1203 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1205 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1207 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1208 "AccessibleEditableTextPara::getCharacter: index value overflow");
1210 return OCommonAccessibleText::getCharacter( nIndex
);
1213 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
)
1215 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1216 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1218 CheckIndex(nIndex
); // may throw IndexOutOfBoundsException
1220 // get default attribues...
1221 ::comphelper::SequenceAsHashMap
aPropHashMap( getDefaultAttributes( rRequestedAttributes
) );
1223 // ... and override them with the direct attributes from the specific position
1224 uno::Sequence
< beans::PropertyValue
> aRunAttribs( getRunAttributes( nIndex
, rRequestedAttributes
) );
1225 sal_Int32 nRunAttribs
= aRunAttribs
.getLength();
1226 const beans::PropertyValue
*pRunAttrib
= aRunAttribs
.getConstArray();
1227 for (sal_Int32 k
= 0; k
< nRunAttribs
; ++k
)
1229 const beans::PropertyValue
&rRunAttrib
= pRunAttrib
[k
];
1230 aPropHashMap
[ rRunAttrib
.Name
] = rRunAttrib
.Value
; //!! should not only be the value !!
1234 uno::Sequence
< rtl::OUString
> aNames(1);
1235 aNames
.getArray()[0] = rtl::OUString::createFromAscii("CharHeight");
1236 const rtl::OUString
*pNames
= aNames
.getConstArray();
1237 const uno::Sequence
< beans::PropertyValue
> aAttribs( getRunAttributes( nIndex
, aNames
) );
1238 const beans::PropertyValue
*pAttribs
= aAttribs
.getConstArray();
1241 if (aAttribs
.getLength())
1243 uno::Any
aAny( pAttribs
[0].Value
);
1251 // get resulting sequence
1252 uno::Sequence
< beans::PropertyValue
> aRes
;
1253 aPropHashMap
>> aRes
;
1255 // since SequenceAsHashMap ignores property handles and property state
1256 // we have to restore the property state here (property handles are
1257 // of no use to the accessibility API).
1258 sal_Int32 nRes
= aRes
.getLength();
1259 beans::PropertyValue
*pRes
= aRes
.getArray();
1260 for (sal_Int32 i
= 0; i
< nRes
; ++i
)
1262 beans::PropertyValue
&rRes
= pRes
[i
];
1263 sal_Bool bIsDirectVal
= sal_False
;
1264 for (sal_Int32 k
= 0; k
< nRunAttribs
&& !bIsDirectVal
; ++k
)
1266 if (rRes
.Name
== pRunAttrib
[k
].Name
)
1267 bIsDirectVal
= sal_True
;
1270 rRes
.State
= bIsDirectVal
? PropertyState_DIRECT_VALUE
: PropertyState_DEFAULT_VALUE
;
1276 awt::Rectangle SAL_CALL
AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1278 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1280 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1282 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1283 "AccessibleEditableTextPara::getCharacterBounds: index value overflow");
1285 // #108900# Have position semantics now for nIndex, as
1286 // one-past-the-end values are legal, too.
1287 CheckPosition( nIndex
);
1289 SvxTextForwarder
& rCacheTF
= GetTextForwarder();
1290 Rectangle aRect
= rCacheTF
.GetCharBounds( static_cast< USHORT
>( GetParagraphIndex() ), static_cast< USHORT
>( nIndex
) );
1292 // convert to screen
1293 Rectangle aScreenRect
= AccessibleEditableTextPara::LogicToPixel( aRect
,
1294 rCacheTF
.GetMapMode(),
1295 GetViewForwarder() );
1296 // #109864# offset from parent (paragraph), but in screen
1297 // coordinates. This makes sure the internal text offset in
1298 // the outline view forwarder gets cancelled out here
1299 awt::Rectangle
aParaRect( getBounds() );
1300 aScreenRect
.Move( -aParaRect
.X
, -aParaRect
.Y
);
1302 // offset from shape/cell
1303 Point aOffset
= GetEEOffset();
1305 return awt::Rectangle( aScreenRect
.Left() + aOffset
.X(),
1306 aScreenRect
.Top() + aOffset
.Y(),
1307 aScreenRect
.GetSize().Width(),
1308 aScreenRect
.GetSize().Height() );
1311 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getCharacterCount() throw (uno::RuntimeException
)
1313 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1315 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1317 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1318 "AccessibleEditableTextPara::getCharacterCount: index value overflow");
1320 return OCommonAccessibleText::getCharacterCount();
1323 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getIndexAtPoint( const awt::Point
& rPoint
) throw (uno::RuntimeException
)
1325 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1327 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1329 USHORT nPara
, nIndex
;
1331 // offset from surrounding cell/shape
1332 Point
aOffset( GetEEOffset() );
1333 Point
aPoint( rPoint
.X
- aOffset
.X(), rPoint
.Y
- aOffset
.Y() );
1335 // convert to logical coordinates
1336 SvxTextForwarder
& rCacheTF
= GetTextForwarder();
1337 Point
aLogPoint( GetViewForwarder().PixelToLogic( aPoint
, rCacheTF
.GetMapMode() ) );
1339 // re-offset to parent (paragraph)
1340 Rectangle aParaRect
= rCacheTF
.GetParaBounds( static_cast< USHORT
>( GetParagraphIndex() ) );
1341 aLogPoint
.Move( aParaRect
.Left(), aParaRect
.Top() );
1343 if( rCacheTF
.GetIndexAtPoint( aLogPoint
, nPara
, nIndex
) &&
1344 GetParagraphIndex() == nPara
)
1346 // #102259# Double-check if we're _really_ on the given character
1349 awt::Rectangle
aRect1( getCharacterBounds(nIndex
) );
1350 Rectangle
aRect2( aRect1
.X
, aRect1
.Y
,
1351 aRect1
.Width
+ aRect1
.X
, aRect1
.Height
+ aRect1
.Y
);
1352 if( aRect2
.IsInside( Point( rPoint
.X
, rPoint
.Y
) ) )
1357 catch( const lang::IndexOutOfBoundsException
& )
1359 // #103927# Don't throw for invalid nIndex values
1365 // not within our paragraph
1370 ::rtl::OUString SAL_CALL
AccessibleEditableTextPara::getSelectedText() throw (uno::RuntimeException
)
1372 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1374 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1376 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1377 "AccessibleEditableTextPara::getSelectedText: index value overflow");
1379 if( !HaveEditView() )
1380 return ::rtl::OUString();
1382 return OCommonAccessibleText::getSelectedText();
1385 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getSelectionStart() throw (uno::RuntimeException
)
1387 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1389 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1391 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1392 "AccessibleEditableTextPara::getSelectionStart: index value overflow");
1394 if( !HaveEditView() )
1397 return OCommonAccessibleText::getSelectionStart();
1400 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getSelectionEnd() throw (uno::RuntimeException
)
1402 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1404 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1406 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1407 "AccessibleEditableTextPara::getSelectionEnd: index value overflow");
1409 if( !HaveEditView() )
1412 return OCommonAccessibleText::getSelectionEnd();
1415 sal_Bool SAL_CALL
AccessibleEditableTextPara::setSelection( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1417 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1419 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1421 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1422 "AccessibleEditableTextPara::setSelection: paragraph index value overflow");
1424 CheckRange(nStartIndex
, nEndIndex
);
1428 SvxEditViewForwarder
& rCacheVF
= GetEditViewForwarder( sal_True
);
1429 return rCacheVF
.SetSelection( MakeSelection(nStartIndex
, nEndIndex
) );
1431 catch( const uno::RuntimeException
& )
1437 ::rtl::OUString SAL_CALL
AccessibleEditableTextPara::getText() throw (uno::RuntimeException
)
1439 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1441 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1443 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1444 "AccessibleEditableTextPara::getText: paragraph index value overflow");
1446 return OCommonAccessibleText::getText();
1449 ::rtl::OUString SAL_CALL
AccessibleEditableTextPara::getTextRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1451 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1453 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1455 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1456 "AccessibleEditableTextPara::getTextRange: paragraph index value overflow");
1458 return OCommonAccessibleText::getTextRange(nStartIndex
, nEndIndex
);
1461 ::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
)
1463 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1465 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1467 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1468 "AccessibleEditableTextPara::getTextAtIndex: paragraph index value overflow");
1470 ::com::sun::star::accessibility::TextSegment aResult
;
1471 aResult
.SegmentStart
= -1;
1472 aResult
.SegmentEnd
= -1;
1476 // Not yet handled by OCommonAccessibleText. Missing
1477 // implGetAttributeRunBoundary() method there
1478 case AccessibleTextType::ATTRIBUTE_RUN
:
1480 const sal_Int32 nTextLen
= GetTextForwarder().GetTextLen( static_cast< USHORT
>( GetParagraphIndex() ) );
1482 if( nIndex
== nTextLen
)
1484 // #i17014# Special-casing one-behind-the-end character
1485 aResult
.SegmentStart
= aResult
.SegmentEnd
= nTextLen
;
1489 USHORT nStartIndex
, nEndIndex
;
1491 if( GetAttributeRun(nStartIndex
, nEndIndex
, nIndex
) )
1493 aResult
.SegmentText
= GetTextRange(nStartIndex
, nEndIndex
);
1494 aResult
.SegmentStart
= nStartIndex
;
1495 aResult
.SegmentEnd
= nEndIndex
;
1502 aResult
= OCommonAccessibleText::getTextAtIndex( nIndex
, aTextType
);
1504 } /* end of switch( aTextType ) */
1509 ::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
)
1511 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1513 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1515 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1516 "AccessibleEditableTextPara::getTextBeforeIndex: paragraph index value overflow");
1518 ::com::sun::star::accessibility::TextSegment aResult
;
1519 aResult
.SegmentStart
= -1;
1520 aResult
.SegmentEnd
= -1;
1524 // Not yet handled by OCommonAccessibleText. Missing
1525 // implGetAttributeRunBoundary() method there
1526 case AccessibleTextType::ATTRIBUTE_RUN
:
1528 const sal_Int32 nTextLen
= GetTextForwarder().GetTextLen( static_cast< USHORT
>( GetParagraphIndex() ) );
1529 USHORT nStartIndex
, nEndIndex
;
1531 if( nIndex
== nTextLen
)
1533 // #i17014# Special-casing one-behind-the-end character
1535 GetAttributeRun(nStartIndex
, nEndIndex
, nIndex
-1) )
1537 aResult
.SegmentText
= GetTextRange(nStartIndex
, nEndIndex
);
1538 aResult
.SegmentStart
= nStartIndex
;
1539 aResult
.SegmentEnd
= nEndIndex
;
1544 if( GetAttributeRun(nStartIndex
, nEndIndex
, nIndex
) )
1546 // already at the left border? If not, query
1547 // one index further left
1548 if( nStartIndex
> 0 &&
1549 GetAttributeRun(nStartIndex
, nEndIndex
, nStartIndex
-1) )
1551 aResult
.SegmentText
= GetTextRange(nStartIndex
, nEndIndex
);
1552 aResult
.SegmentStart
= nStartIndex
;
1553 aResult
.SegmentEnd
= nEndIndex
;
1561 aResult
= OCommonAccessibleText::getTextBeforeIndex( nIndex
, aTextType
);
1563 } /* end of switch( aTextType ) */
1568 ::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
)
1570 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1572 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1574 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1575 "AccessibleEditableTextPara::getTextBehindIndex: paragraph index value overflow");
1577 ::com::sun::star::accessibility::TextSegment aResult
;
1578 aResult
.SegmentStart
= -1;
1579 aResult
.SegmentEnd
= -1;
1583 case AccessibleTextType::ATTRIBUTE_RUN
:
1585 USHORT nStartIndex
, nEndIndex
;
1587 if( GetAttributeRun(nStartIndex
, nEndIndex
, nIndex
) )
1589 // already at the right border?
1590 if( nEndIndex
< GetTextLen() )
1592 if( GetAttributeRun(nStartIndex
, nEndIndex
, nEndIndex
) )
1594 aResult
.SegmentText
= GetTextRange(nStartIndex
, nEndIndex
);
1595 aResult
.SegmentStart
= nStartIndex
;
1596 aResult
.SegmentEnd
= nEndIndex
;
1604 aResult
= OCommonAccessibleText::getTextBehindIndex( nIndex
, aTextType
);
1606 } /* end of switch( aTextType ) */
1611 sal_Bool SAL_CALL
AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1613 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1615 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1619 SvxEditViewForwarder
& rCacheVF
= GetEditViewForwarder( sal_True
);
1620 #if OSL_DEBUG_LEVEL > 0
1621 SvxAccessibleTextAdapter
& rCacheTF
= GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1624 GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1629 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1630 "AccessibleEditableTextPara::copyText: index value overflow");
1632 CheckRange(nStartIndex
, nEndIndex
);
1634 // save current selection
1635 ESelection aOldSelection
;
1637 rCacheVF
.GetSelection( aOldSelection
);
1638 rCacheVF
.SetSelection( MakeSelection(nStartIndex
, nEndIndex
) );
1639 aRetVal
= rCacheVF
.Copy();
1640 rCacheVF
.SetSelection( aOldSelection
); // restore
1644 catch( const uno::RuntimeException
& )
1650 // XAccessibleEditableText
1651 sal_Bool SAL_CALL
AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1653 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1655 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1659 SvxEditViewForwarder
& rCacheVF
= GetEditViewForwarder( sal_True
);
1660 SvxAccessibleTextAdapter
& rCacheTF
= GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1662 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1663 "AccessibleEditableTextPara::cutText: index value overflow");
1665 CheckRange(nStartIndex
, nEndIndex
);
1667 if( !rCacheTF
.IsEditable( MakeSelection(nStartIndex
, nEndIndex
) ) )
1668 return sal_False
; // non-editable area selected
1670 // don't save selection, might become invalid after cut!
1671 rCacheVF
.SetSelection( MakeSelection(nStartIndex
, nEndIndex
) );
1673 return rCacheVF
.Cut();
1675 catch( const uno::RuntimeException
& )
1681 sal_Bool SAL_CALL
AccessibleEditableTextPara::pasteText( sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1683 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1685 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1689 SvxEditViewForwarder
& rCacheVF
= GetEditViewForwarder( sal_True
);
1690 SvxAccessibleTextAdapter
& rCacheTF
= GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1692 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1693 "AccessibleEditableTextPara::pasteText: index value overflow");
1695 CheckPosition(nIndex
);
1697 if( !rCacheTF
.IsEditable( MakeSelection(nIndex
) ) )
1698 return sal_False
; // non-editable area selected
1700 // #104400# set empty selection (=> cursor) to given index
1701 rCacheVF
.SetSelection( MakeCursor(nIndex
) );
1703 return rCacheVF
.Paste();
1705 catch( const uno::RuntimeException
& )
1711 sal_Bool SAL_CALL
AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1713 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1715 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1719 // #102710# Request edit view when doing changes
1720 // AccessibleEmptyEditSource relies on this behaviour
1721 GetEditViewForwarder( sal_True
);
1722 SvxAccessibleTextAdapter
& rCacheTF
= GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1724 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1725 "AccessibleEditableTextPara::deleteText: index value overflow");
1727 CheckRange(nStartIndex
, nEndIndex
);
1729 if( !rCacheTF
.IsEditable( MakeSelection(nStartIndex
, nEndIndex
) ) )
1730 return sal_False
; // non-editable area selected
1732 sal_Bool bRet
= rCacheTF
.Delete( MakeSelection(nStartIndex
, nEndIndex
) );
1734 GetEditSource().UpdateData();
1738 catch( const uno::RuntimeException
& )
1744 sal_Bool SAL_CALL
AccessibleEditableTextPara::insertText( const ::rtl::OUString
& sText
, sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1746 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1748 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1752 // #102710# Request edit view when doing changes
1753 // AccessibleEmptyEditSource relies on this behaviour
1754 GetEditViewForwarder( sal_True
);
1755 SvxAccessibleTextAdapter
& rCacheTF
= GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1757 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1758 "AccessibleEditableTextPara::insertText: index value overflow");
1760 CheckPosition(nIndex
);
1762 if( !rCacheTF
.IsEditable( MakeSelection(nIndex
) ) )
1763 return sal_False
; // non-editable area selected
1765 // #104400# insert given text at empty selection (=> cursor)
1766 sal_Bool bRet
= rCacheTF
.InsertText( sText
, MakeCursor(nIndex
) );
1768 rCacheTF
.QuickFormatDoc();
1769 GetEditSource().UpdateData();
1773 catch( const uno::RuntimeException
& )
1779 sal_Bool SAL_CALL
AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
, const ::rtl::OUString
& sReplacement
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1781 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1783 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1787 // #102710# Request edit view when doing changes
1788 // AccessibleEmptyEditSource relies on this behaviour
1789 GetEditViewForwarder( sal_True
);
1790 SvxAccessibleTextAdapter
& rCacheTF
= GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1792 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1793 "AccessibleEditableTextPara::replaceText: index value overflow");
1795 CheckRange(nStartIndex
, nEndIndex
);
1797 if( !rCacheTF
.IsEditable( MakeSelection(nStartIndex
, nEndIndex
) ) )
1798 return sal_False
; // non-editable area selected
1800 // insert given text into given range => replace
1801 sal_Bool bRet
= rCacheTF
.InsertText( sReplacement
, MakeSelection(nStartIndex
, nEndIndex
) );
1803 rCacheTF
.QuickFormatDoc();
1804 GetEditSource().UpdateData();
1808 catch( const uno::RuntimeException
& )
1814 sal_Bool SAL_CALL
AccessibleEditableTextPara::setAttributes( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
, const uno::Sequence
< beans::PropertyValue
>& aAttributeSet
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1816 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1818 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1822 // #102710# Request edit view when doing changes
1823 // AccessibleEmptyEditSource relies on this behaviour
1824 GetEditViewForwarder( sal_True
);
1825 SvxAccessibleTextAdapter
& rCacheTF
= GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs
1826 USHORT nPara
= static_cast< USHORT
>( GetParagraphIndex() );
1828 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1829 "AccessibleEditableTextPara::setAttributes: index value overflow");
1831 CheckRange(nStartIndex
, nEndIndex
);
1833 if( !rCacheTF
.IsEditable( MakeSelection(nStartIndex
, nEndIndex
) ) )
1834 return sal_False
; // non-editable area selected
1836 // do the indices span the whole paragraph? Then use the outliner map
1837 // TODO: hold it as a member?
1838 SvxAccessibleTextPropertySet
aPropSet( &GetEditSource(),
1840 rCacheTF
.GetTextLen(nPara
) == nEndIndex
?
1841 ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() :
1842 ImplGetSvxTextPortionSvxPropertySet() );
1844 aPropSet
.SetSelection( MakeSelection(nStartIndex
, nEndIndex
) );
1846 // convert from PropertyValue to Any
1847 sal_Int32 i
, nLength( aAttributeSet
.getLength() );
1848 const beans::PropertyValue
* pPropArray
= aAttributeSet
.getConstArray();
1849 for(i
=0; i
<nLength
; ++i
)
1853 aPropSet
.setPropertyValue(pPropArray
->Name
, pPropArray
->Value
);
1855 catch( const uno::Exception
& )
1857 DBG_ERROR("AccessibleEditableTextPara::setAttributes exception in setPropertyValue");
1863 rCacheTF
.QuickFormatDoc();
1864 GetEditSource().UpdateData();
1868 catch( const uno::RuntimeException
& )
1874 sal_Bool SAL_CALL
AccessibleEditableTextPara::setText( const ::rtl::OUString
& sText
) throw (uno::RuntimeException
)
1876 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1878 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1880 return replaceText(0, getCharacterCount(), sText
);
1883 // XAccessibleTextAttributes
1884 uno::Sequence
< beans::PropertyValue
> SAL_CALL
AccessibleEditableTextPara::getDefaultAttributes(
1885 const uno::Sequence
< ::rtl::OUString
>& rRequestedAttributes
)
1886 throw (uno::RuntimeException
)
1888 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1889 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1891 #if OSL_DEBUG_LEVEL > 0
1892 SvxAccessibleTextAdapter
& rCacheTF
=
1896 #if OSL_DEBUG_LEVEL > 0
1900 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
1901 "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
1903 // get XPropertySetInfo for paragraph attributes and
1904 // character attributes that span all the paragraphs text.
1905 SvxAccessibleTextPropertySet
aPropSet( &GetEditSource(),
1906 ImplGetSvxCharAndParaPropertiesSet() );
1907 aPropSet
.SetSelection( MakeSelection( 0, GetTextLen() ) );
1908 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo
= aPropSet
.getPropertySetInfo();
1909 if (!xPropSetInfo
.is())
1910 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")),
1911 uno::Reference
< uno::XInterface
>
1912 ( static_cast< XAccessible
* > (this) ) ); // disambiguate hierarchy
1914 // build sequence of available properties to check
1915 sal_Int32 nLenReqAttr
= rRequestedAttributes
.getLength();
1916 uno::Sequence
< beans::Property
> aProperties
;
1919 const rtl::OUString
*pRequestedAttributes
= rRequestedAttributes
.getConstArray();
1921 aProperties
.realloc( nLenReqAttr
);
1922 beans::Property
*pProperties
= aProperties
.getArray();
1923 sal_Int32 nCurLen
= 0;
1924 for (sal_Int32 i
= 0; i
< nLenReqAttr
; ++i
)
1926 beans::Property aProp
;
1929 aProp
= xPropSetInfo
->getPropertyByName( pRequestedAttributes
[i
] );
1931 catch (beans::UnknownPropertyException
&)
1935 pProperties
[ nCurLen
++ ] = aProp
;
1937 aProperties
.realloc( nCurLen
);
1940 aProperties
= xPropSetInfo
->getProperties();
1942 sal_Int32 nLength
= aProperties
.getLength();
1943 const beans::Property
*pProperties
= aProperties
.getConstArray();
1945 // build resulting sequence
1946 uno::Sequence
< beans::PropertyValue
> aOutSequence( nLength
);
1947 beans::PropertyValue
* pOutSequence
= aOutSequence
.getArray();
1948 sal_Int32 nOutLen
= 0;
1949 for (sal_Int32 i
= 0; i
< nLength
; ++i
)
1951 // calling implementation functions:
1952 // _getPropertyState and _getPropertyValue (see below) to provide
1953 // the proper paragraph number when retrieving paragraph attributes
1954 PropertyState eState
= aPropSet
._getPropertyState( pProperties
->Name
, mnParagraphIndex
);
1955 if ( eState
== PropertyState_AMBIGUOUS_VALUE
)
1957 OSL_ENSURE( false, "ambiguous property value encountered" );
1960 //if (eState == PropertyState_DIRECT_VALUE)
1961 // per definition all paragraph properties and all character
1962 // properties spanning the whole paragraph should be returned
1963 // and declared as default value
1965 pOutSequence
->Name
= pProperties
->Name
;
1966 pOutSequence
->Handle
= pProperties
->Handle
;
1967 pOutSequence
->Value
= aPropSet
._getPropertyValue( pProperties
->Name
, mnParagraphIndex
);
1968 pOutSequence
->State
= PropertyState_DEFAULT_VALUE
;
1975 aOutSequence
.realloc( nOutLen
);
1977 return aOutSequence
;
1981 uno::Sequence
< beans::PropertyValue
> SAL_CALL
AccessibleEditableTextPara::getRunAttributes(
1983 const uno::Sequence
< ::rtl::OUString
>& rRequestedAttributes
)
1984 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
1986 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
1988 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
1990 #if OSL_DEBUG_LEVEL > 0
1991 SvxAccessibleTextAdapter
& rCacheTF
=
1995 #if OSL_DEBUG_LEVEL > 0
1999 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX
,
2000 "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
2004 SvxAccessibleTextPropertySet
aPropSet( &GetEditSource(),
2005 ImplGetSvxCharAndParaPropertiesSet() );
2006 aPropSet
.SetSelection( MakeSelection( nIndex
) );
2007 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo
= aPropSet
.getPropertySetInfo();
2008 if (!xPropSetInfo
.is())
2009 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")),
2010 uno::Reference
< uno::XInterface
>
2011 ( static_cast< XAccessible
* > (this) ) ); // disambiguate hierarchy
2013 // build sequence of available properties to check
2014 sal_Int32 nLenReqAttr
= rRequestedAttributes
.getLength();
2015 uno::Sequence
< beans::Property
> aProperties
;
2018 const rtl::OUString
*pRequestedAttributes
= rRequestedAttributes
.getConstArray();
2020 aProperties
.realloc( nLenReqAttr
);
2021 beans::Property
*pProperties
= aProperties
.getArray();
2022 sal_Int32 nCurLen
= 0;
2023 for (sal_Int32 i
= 0; i
< nLenReqAttr
; ++i
)
2025 beans::Property aProp
;
2028 aProp
= xPropSetInfo
->getPropertyByName( pRequestedAttributes
[i
] );
2030 catch (beans::UnknownPropertyException
&)
2034 pProperties
[ nCurLen
++ ] = aProp
;
2036 aProperties
.realloc( nCurLen
);
2039 aProperties
= xPropSetInfo
->getProperties();
2041 sal_Int32 nLength
= aProperties
.getLength();
2042 const beans::Property
*pProperties
= aProperties
.getConstArray();
2044 // build resulting sequence
2045 uno::Sequence
< beans::PropertyValue
> aOutSequence( nLength
);
2046 beans::PropertyValue
* pOutSequence
= aOutSequence
.getArray();
2047 sal_Int32 nOutLen
= 0;
2048 for (sal_Int32 i
= 0; i
< nLength
; ++i
)
2050 // calling 'regular' functions that will operate on the selection
2051 PropertyState eState
= aPropSet
.getPropertyState( pProperties
->Name
);
2052 if (eState
== PropertyState_DIRECT_VALUE
)
2054 pOutSequence
->Name
= pProperties
->Name
;
2055 pOutSequence
->Handle
= pProperties
->Handle
;
2056 pOutSequence
->Value
= aPropSet
.getPropertyValue( pProperties
->Name
);
2057 pOutSequence
->State
= eState
;
2064 aOutSequence
.realloc( nOutLen
);
2066 return aOutSequence
;
2069 // XAccessibleMultiLineText
2070 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
2072 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
2074 sal_Int32 nRes
= -1;
2075 sal_Int32 nPara
= GetParagraphIndex();
2077 SvxTextForwarder
&rCacheTF
= GetTextForwarder();
2078 const bool bValidPara
= 0 <= nPara
&& nPara
< rCacheTF
.GetParagraphCount();
2079 DBG_ASSERT( bValidPara
, "getLineNumberAtIndex: current paragraph index out of range" );
2082 // we explicitly allow for the index to point at the character right behind the text
2083 if (0 <= nIndex
&& nIndex
<= rCacheTF
.GetTextLen( static_cast< USHORT
>(nPara
) ))
2084 nRes
= rCacheTF
.GetLineNumberAtIndex( static_cast< USHORT
>(nPara
), static_cast< USHORT
>(nIndex
) );
2086 throw lang::IndexOutOfBoundsException();
2091 // XAccessibleMultiLineText
2092 ::com::sun::star::accessibility::TextSegment SAL_CALL
AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo
) throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
2094 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
2096 ::com::sun::star::accessibility::TextSegment aResult
;
2097 sal_Int32 nPara
= GetParagraphIndex();
2098 SvxTextForwarder
&rCacheTF
= GetTextForwarder();
2099 const bool bValidPara
= 0 <= nPara
&& nPara
< rCacheTF
.GetParagraphCount();
2100 DBG_ASSERT( bValidPara
, "getTextAtLineNumber: current paragraph index out of range" );
2103 if (0 <= nLineNo
&& nLineNo
< rCacheTF
.GetLineCount( static_cast< USHORT
>(nPara
) ))
2105 USHORT nStart
= 0, nEnd
= 0;
2106 rCacheTF
.GetLineBoundaries( nStart
, nEnd
, static_cast< USHORT
>(nPara
), static_cast< USHORT
>(nLineNo
) );
2107 if (nStart
!= 0xFFFF && nEnd
!= 0xFFFF)
2111 aResult
.SegmentText
= getTextRange( nStart
, nEnd
);
2112 aResult
.SegmentStart
= nStart
;
2113 aResult
.SegmentEnd
= nEnd
;
2115 catch (lang::IndexOutOfBoundsException
)
2117 // this is not the exception that should be raised in this function ...
2118 DBG_ASSERT( 0, "unexpected exception" );
2123 throw lang::IndexOutOfBoundsException();
2128 // XAccessibleMultiLineText
2129 ::com::sun::star::accessibility::TextSegment SAL_CALL
AccessibleEditableTextPara::getTextAtLineWithCaret( ) throw (uno::RuntimeException
)
2131 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
2133 ::com::sun::star::accessibility::TextSegment aResult
;
2136 aResult
= getTextAtLineNumber( getNumberOfLineWithCaret() );
2138 catch (lang::IndexOutOfBoundsException
&)
2140 // this one needs to be catched since this interface does not allow for it.
2145 // XAccessibleMultiLineText
2146 sal_Int32 SAL_CALL
AccessibleEditableTextPara::getNumberOfLineWithCaret( ) throw (uno::RuntimeException
)
2148 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
2150 sal_Int32 nRes
= -1;
2153 nRes
= getLineNumberAtIndex( getCaretPosition() );
2155 catch (lang::IndexOutOfBoundsException
&)
2157 // this one needs to be catched since this interface does not allow for it.
2164 ::rtl::OUString SAL_CALL
AccessibleEditableTextPara::getImplementationName (void) throw (uno::RuntimeException
)
2166 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
2168 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("AccessibleEditableTextPara"));
2171 sal_Bool SAL_CALL
AccessibleEditableTextPara::supportsService (const ::rtl::OUString
& sServiceName
) throw (uno::RuntimeException
)
2173 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
2175 // Iterate over all supported service names and return true if on of them
2176 // matches the given name.
2177 uno::Sequence
< ::rtl::OUString
> aSupportedServices (
2178 getSupportedServiceNames ());
2179 for (int i
=0; i
<aSupportedServices
.getLength(); i
++)
2180 if (sServiceName
== aSupportedServices
[i
])
2185 uno::Sequence
< ::rtl::OUString
> SAL_CALL
AccessibleEditableTextPara::getSupportedServiceNames (void) throw (uno::RuntimeException
)
2187 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
2189 const ::rtl::OUString
sServiceName( getServiceName() );
2190 return uno::Sequence
< ::rtl::OUString
> (&sServiceName
, 1);
2194 ::rtl::OUString SAL_CALL
AccessibleEditableTextPara::getServiceName (void) throw (uno::RuntimeException
)
2196 DBG_CHKTHIS( AccessibleEditableTextPara
, NULL
);
2198 // #105185# Using correct service now
2199 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AccessibleParagraphView"));
2202 } // end of namespace accessibility
2204 //------------------------------------------------------------------------