diff options
Diffstat (limited to 'editeng/source/accessibility/AccessibleEditableTextPara.cxx')
-rw-r--r-- | editeng/source/accessibility/AccessibleEditableTextPara.cxx | 179 |
1 files changed, 67 insertions, 112 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index ac4bbe1ada4d..2f727cb7669d 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -22,10 +22,10 @@ #include <algorithm> -#include <vcl/window.hxx> +#include <utility> #include <vcl/svapp.hxx> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <editeng/flditem.hxx> #include <com/sun/star/uno/Any.hxx> @@ -42,7 +42,6 @@ #include <comphelper/accessibleeventnotifier.hxx> #include <comphelper/sequenceashashmap.hxx> #include <cppuhelper/supportsservice.hxx> -#include <unotools/accessiblestatesethelper.hxx> #include <unotools/accessiblerelationsethelper.hxx> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <vcl/unohelp.hxx> @@ -69,7 +68,6 @@ #include "AccessibleImageBullet.hxx" #include <svtools/colorcfg.hxx> -using namespace std; #include <editeng/editrids.hrc> #include <editeng/eerdll.hxx> #include <editeng/numitem.hxx> @@ -93,10 +91,9 @@ namespace accessibility SVX_UNOEDIT_OUTLINER_PROPERTIES, SVX_UNOEDIT_CHAR_PROPERTIES, SVX_UNOEDIT_PARA_PROPERTIES, - SVX_UNOEDIT_NUMBERING_PROPERTIE, - { u"TextUserDefinedAttributes", EE_CHAR_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, - { u"ParaUserDefinedAttributes", EE_PARA_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, - { u"", 0, css::uno::Type(), 0, 0 } + SVX_UNOEDIT_NUMBERING_PROPERTY, + { u"TextUserDefinedAttributes"_ustr, EE_CHAR_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, + { u"ParaUserDefinedAttributes"_ustr, EE_PARA_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, }; static SvxItemPropertySet aPropSet( aPropMap, EditEngine::GetGlobalItemPool() ); return &aPropSet; @@ -104,14 +101,13 @@ namespace accessibility // #i27138# - add parameter <_pParaManager> AccessibleEditableTextPara::AccessibleEditableTextPara( - const uno::Reference< XAccessible >& rParent, + uno::Reference< XAccessible > xParent, const AccessibleParaManager* _pParaManager ) - : AccessibleTextParaInterfaceBase( m_aMutex ), - mnParagraphIndex( 0 ), + : mnParagraphIndex( 0 ), mnIndexInParent( 0 ), mpEditSource( nullptr ), maEEOffset( 0, 0 ), - mxParent( rParent ), + mxParent(std::move( xParent )), // well, that's strictly (UNO) exception safe, though not // really robust. We rely on the fact that this member is // constructed last, and that the constructor body catches @@ -122,23 +118,16 @@ namespace accessibility mpParaManager( _pParaManager ) { - try - { - // Create the state set. - ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper (); - mxStateSet = pStateSet; + // Create the state set. + mnStateSet = 0; - // these are always on - pStateSet->AddState( AccessibleStateType::MULTI_LINE ); - pStateSet->AddState( AccessibleStateType::FOCUSABLE ); - pStateSet->AddState( AccessibleStateType::VISIBLE ); - pStateSet->AddState( AccessibleStateType::SHOWING ); - pStateSet->AddState( AccessibleStateType::ENABLED ); - pStateSet->AddState( AccessibleStateType::SENSITIVE ); - } - catch (const uno::Exception&) - { - } + // these are always on + mnStateSet |= AccessibleStateType::MULTI_LINE; + mnStateSet |= AccessibleStateType::FOCUSABLE; + mnStateSet |= AccessibleStateType::VISIBLE; + mnStateSet |= AccessibleStateType::SHOWING; + mnStateSet |= AccessibleStateType::ENABLED; + mnStateSet |= AccessibleStateType::SENSITIVE; } AccessibleEditableTextPara::~AccessibleEditableTextPara() @@ -274,8 +263,8 @@ namespace accessibility { } // index and therefore description changed - FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::makeAny( getAccessibleDescription() ), aOldDesc ); - FireEvent( AccessibleEventId::NAME_CHANGED, uno::makeAny( getAccessibleName() ), aOldName ); + FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::Any( getAccessibleDescription() ), aOldDesc ); + FireEvent( AccessibleEventId::NAME_CHANGED, uno::Any( getAccessibleName() ), aOldName ); } } catch (const uno::Exception&) // optional behaviour @@ -362,16 +351,14 @@ namespace accessibility { if( nIndex < 0 || nIndex >= getCharacterCount() ) throw lang::IndexOutOfBoundsException("AccessibleEditableTextPara: character index out of bounds", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy + getXWeak() ); } void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex ) { if( nIndex < 0 || nIndex > getCharacterCount() ) throw lang::IndexOutOfBoundsException("AccessibleEditableTextPara: character position out of bounds", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy + getXWeak() ); } void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd ) @@ -437,9 +424,7 @@ namespace accessibility { if( !mpEditSource ) throw uno::RuntimeException("No edit source, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); return *mpEditSource; } @@ -450,15 +435,11 @@ namespace accessibility if( !pTextForwarder ) throw uno::RuntimeException("Unable to fetch text forwarder, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); if( !pTextForwarder->IsValid() ) throw uno::RuntimeException("Text forwarder is invalid, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); return *pTextForwarder; } @@ -470,16 +451,12 @@ namespace accessibility if( !pViewForwarder ) { throw uno::RuntimeException("Unable to fetch view forwarder, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); } if( !pViewForwarder->IsValid() ) throw uno::RuntimeException("View forwarder is invalid, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); return *pViewForwarder; } @@ -492,14 +469,10 @@ namespace accessibility { if( bCreate ) throw uno::RuntimeException("Unable to fetch view forwarder, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); else throw uno::RuntimeException("No view forwarder, object not in edit mode", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); } if( pTextEditViewForwarder->IsValid() ) @@ -508,14 +481,10 @@ namespace accessibility { if( bCreate ) throw uno::RuntimeException("View forwarder is invalid, object is defunct", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); else throw uno::RuntimeException("View forwarder is invalid, object not in edit mode", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > - ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + const_cast< AccessibleEditableTextPara* > (this)->getXWeak() ); } } @@ -562,11 +531,7 @@ namespace accessibility { uno::Reference < XAccessibleContext > xThis( const_cast< AccessibleEditableTextPara* > (this)->getAccessibleContext() ); - AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue); - - // #102261# Call global queue for focus events - if( nEventId == AccessibleEventId::STATE_CHANGED ) - vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent ); + AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue, -1); // #106234# Delegate to EventNotifier if( getNotifierClientId() != -1 ) @@ -574,25 +539,21 @@ namespace accessibility aEvent ); } - void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId ) + void AccessibleEditableTextPara::SetState( const sal_Int64 nStateId ) { - ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); - if( pStateSet != nullptr && - !pStateSet->contains(nStateId) ) + if( !(mnStateSet & nStateId) ) { - pStateSet->AddState( nStateId ); - FireEvent( AccessibleEventId::STATE_CHANGED, uno::makeAny( nStateId ) ); + mnStateSet |= nStateId; + FireEvent( AccessibleEventId::STATE_CHANGED, uno::Any( nStateId ) ); } } - void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId ) + void AccessibleEditableTextPara::UnSetState( const sal_Int64 nStateId ) { - ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); - if( pStateSet != nullptr && - pStateSet->contains(nStateId) ) + if( mnStateSet & nStateId ) { - pStateSet->RemoveState( nStateId ); - FireEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), uno::makeAny( nStateId ) ); + mnStateSet &= ~nStateId; + FireEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), uno::Any( nStateId ) ); } } @@ -659,26 +620,24 @@ namespace accessibility } // XAccessibleContext - sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount() + sal_Int64 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount() { SolarMutexGuard aGuard; return HaveChildren() ? 1 : 0; } - uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int32 i ) + uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int64 i ) { SolarMutexGuard aGuard; if( !HaveChildren() ) throw lang::IndexOutOfBoundsException("No children available", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy + getXWeak() ); if( i != 0 ) throw lang::IndexOutOfBoundsException("Invalid child index", - uno::Reference< uno::XInterface > - ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy + getXWeak() ); auto aChild( maImageBullet.get() ); @@ -694,7 +653,7 @@ namespace accessibility maImageBullet = aChild; } - return aChild.get(); + return aChild; } uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent() @@ -704,7 +663,7 @@ namespace accessibility return mxParent; } - sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent() + sal_Int64 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent() { return mnIndexInParent; } @@ -770,15 +729,15 @@ namespace accessibility // and CONTENT_FLOWS_TO if ( mpParaManager ) { - utl::AccessibleRelationSetHelper* pAccRelSetHelper = + rtl::Reference<utl::AccessibleRelationSetHelper> pAccRelSetHelper = new utl::AccessibleRelationSetHelper(); sal_Int32 nMyParaIndex( GetParagraphIndex() ); // relation CONTENT_FLOWS_FROM if ( nMyParaIndex > 0 && mpParaManager->IsReferencable( nMyParaIndex - 1 ) ) { - uno::Sequence<uno::Reference<XInterface> > aSequence - { static_cast<cppu::OWeakObject *>(mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().get()) }; + uno::Sequence<uno::Reference<XAccessible>> aSequence + { mpParaManager->GetChild( nMyParaIndex - 1 ).first.get() }; AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM, aSequence ); pAccRelSetHelper->AddRelation( aAccRel ); @@ -788,8 +747,8 @@ namespace accessibility if ( (nMyParaIndex + 1) < mpParaManager->GetNum() && mpParaManager->IsReferencable( nMyParaIndex + 1 ) ) { - uno::Sequence<uno::Reference<XInterface> > aSequence - { static_cast<cppu::OWeakObject *>(mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().get()) }; + uno::Sequence<uno::Reference<XAccessible>> aSequence + { mpParaManager->GetChild( nMyParaIndex + 1 ).first.get() }; AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO, aSequence ); pAccRelSetHelper->AddRelation( aAccRel ); @@ -939,26 +898,23 @@ namespace accessibility return OUString(); } - uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() + sal_Int64 SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() { SolarMutexGuard aGuard; // Create a copy of the state set and return it. - ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); - if( !pStateSet ) - return uno::Reference<XAccessibleStateSet>(); - uno::Reference<XAccessibleStateSet> xParentStates; + sal_Int64 nParentStates = 0; if (getAccessibleParent().is()) { uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); - xParentStates = xParentContext->getAccessibleStateSet(); + nParentStates = xParentContext->getAccessibleStateSet(); } - if (xParentStates.is() && xParentStates->contains(AccessibleStateType::EDITABLE) ) + if (nParentStates & AccessibleStateType::EDITABLE) { - pStateSet->AddState(AccessibleStateType::EDITABLE); + mnStateSet |= AccessibleStateType::EDITABLE; } - return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) ); + return mnStateSet; } lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale() @@ -1004,7 +960,7 @@ namespace accessibility tools::Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), Size(aTmpRect.Width, aTmpRect.Height) ); Point aPoint( aTmpPoint.X, aTmpPoint.Y ); - return aRect.IsInside( aPoint ); + return aRect.Contains( aPoint ); } uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleAtPoint( const awt::Point& _aPoint ) @@ -1031,7 +987,7 @@ namespace accessibility { tools::Rectangle aRect = aBulletInfo.aBounds; - if( aRect.IsInside( aLogPoint ) ) + if( aRect.Contains( aLogPoint ) ) return getAccessibleChild(0); } } @@ -1231,7 +1187,7 @@ namespace accessibility // since SequenceAsHashMap ignores property handles and property state // we have to restore the property state here (property handles are // of no use to the accessibility API). - for (beans::PropertyValue & rRes : aRes) + for (beans::PropertyValue & rRes : asNonConstRange(aRes)) { bool bIsDirectVal = false; for (auto const& rRunAttrib : aRunAttribs) @@ -1249,7 +1205,7 @@ namespace accessibility // NumberingPrefix sal_Int32 nRes = aRes.getLength(); aRes.realloc( nRes + 1 ); - beans::PropertyValue &rRes = aRes[nRes]; + beans::PropertyValue &rRes = aRes.getArray()[nRes]; rRes.Name = "NumberingPrefix"; OUString numStr; if (aBulletInfo.nType != SVX_NUM_CHAR_SPECIAL && aBulletInfo.nType != SVX_NUM_BITMAP) @@ -1263,7 +1219,7 @@ namespace accessibility { nRes = aRes.getLength(); aRes.realloc( nRes + 1 ); - beans::PropertyValue &rResField = aRes[nRes]; + beans::PropertyValue &rResField = aRes.getArray()[nRes]; rResField.Name = "FieldType"; rResField.Value <<= strFieldType.toAsciiLowerCase(); rResField.Handle = -1; @@ -1277,7 +1233,7 @@ namespace accessibility sal_Int32 i = 0; for( i = 0; i < nLength; i++ ) pIndices[i] = i; - sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) ); + std::sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) ); // create sorted sequences according to index array uno::Sequence<beans::PropertyValue> aNewValues( nLength ); beans::PropertyValue* pNewValues = aNewValues.getArray(); @@ -1362,7 +1318,7 @@ namespace accessibility awt::Rectangle aRect1( getCharacterBounds(nIndex) ); tools::Rectangle aRect2( aRect1.X, aRect1.Y, aRect1.Width + aRect1.X, aRect1.Height + aRect1.Y ); - if( aRect2.IsInside( Point( rPoint.X, rPoint.Y ) ) ) + if( aRect2.Contains( Point( rPoint.X, rPoint.Y ) ) ) return nIndex; else return -1; @@ -1527,8 +1483,7 @@ namespace accessibility // NumberingLevel if (rRes.Name == "NumberingLevel") { - const SvxNumBulletItem& rNumBullet = rCacheTF.GetParaAttribs(GetParagraphIndex()).Get(EE_PARA_NUMBULLET); - if(rNumBullet.GetNumRule()->GetLevelCount()==0) + if(rCacheTF.GetParaAttribs(GetParagraphIndex()).Get(EE_PARA_NUMBULLET).GetNumRule().GetLevelCount()==0) { rRes.Value <<= sal_Int16(-1); rRes.Handle = -1; @@ -1923,7 +1878,7 @@ namespace accessibility //while ( preWordStart > 0 && aBoundary.startPos == curWordStart) while ( (preWordStart >= 0 && !bWord ) || ( aBoundary.endPos > curWordStart ) ) - { + { preWordStart--; bWord = implGetWordBoundary( sText, aBoundary, preWordStart ); } @@ -2429,7 +2384,7 @@ namespace accessibility uno::Sequence< beans::PropertyValue > aOutSequence( aProperties.getLength() ); beans::PropertyValue* pOutSequence = aOutSequence.getArray(); sal_Int32 nOutLen = 0; - for (const beans::Property& rProperty : std::as_const(aProperties)) + for (const beans::Property& rProperty : aProperties) { // calling implementation functions: // _getPropertyState and _getPropertyValue (see below) to provide @@ -2515,7 +2470,7 @@ namespace accessibility uno::Sequence< beans::PropertyValue > aOutSequence( aProperties.getLength() ); beans::PropertyValue* pOutSequence = aOutSequence.getArray(); sal_Int32 nOutLen = 0; - for (const beans::Property& rProperty : std::as_const(aProperties)) + for (const beans::Property& rProperty : aProperties) { // calling 'regular' functions that will operate on the selection PropertyState eState = xPropSet->getPropertyState( rProperty.Name ); |