diff options
Diffstat (limited to 'sw/source/core/access/accframebase.cxx')
-rw-r--r-- | sw/source/core/access/accframebase.cxx | 81 |
1 files changed, 36 insertions, 45 deletions
diff --git a/sw/source/core/access/accframebase.cxx b/sw/source/core/access/accframebase.cxx index 6338ee18a5c1..fc94259b5bfd 100644 --- a/sw/source/core/access/accframebase.cxx +++ b/sw/source/core/access/accframebase.cxx @@ -19,8 +19,6 @@ #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp> -#include <unotools/accessiblestatesethelper.hxx> -#include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <vcl/window.hxx> #include <frmfmt.hxx> @@ -58,8 +56,7 @@ bool SwAccessibleFrameBase::IsSelected() return bRet; } -void SwAccessibleFrameBase::GetStates( - ::utl::AccessibleStateSetHelper& rStateSet ) +void SwAccessibleFrameBase::GetStates( sal_Int64& rStateSet ) { SwAccessibleContext::GetStates( rStateSet ); @@ -69,25 +66,25 @@ void SwAccessibleFrameBase::GetStates( if (dynamic_cast<const SwFEShell*>(pVSh)) { // SELECTABLE - rStateSet.AddState(AccessibleStateType::SELECTABLE); + rStateSet |= AccessibleStateType::SELECTABLE; // FOCUSABLE - rStateSet.AddState(AccessibleStateType::FOCUSABLE); + rStateSet |= AccessibleStateType::FOCUSABLE; } // SELECTED and FOCUSED if( IsSelected() ) { - rStateSet.AddState( AccessibleStateType::SELECTED ); + rStateSet |= AccessibleStateType::SELECTED; SAL_WARN_IF(!m_bIsSelected, "sw.a11y", "bSelected out of sync"); ::rtl::Reference < SwAccessibleContext > xThis( this ); GetMap()->SetCursorContext( xThis ); vcl::Window *pWin = GetWindow(); if( pWin && pWin->HasFocus() ) - rStateSet.AddState( AccessibleStateType::FOCUSED ); + rStateSet |= AccessibleStateType::FOCUSED; } if( GetSelectedState() ) - rStateSet.AddState( AccessibleStateType::SELECTED ); + rStateSet |= AccessibleStateType::SELECTED; } SwNodeType SwAccessibleFrameBase::GetNodeType( const SwFlyFrame *pFlyFrame ) @@ -95,7 +92,7 @@ SwNodeType SwAccessibleFrameBase::GetNodeType( const SwFlyFrame *pFlyFrame ) SwNodeType nType = SwNodeType::Text; if( pFlyFrame->Lower() ) { - if( pFlyFrame->Lower()->IsNoTextFrame() ) + if( pFlyFrame->Lower()->IsNoTextFrame() ) { const SwNoTextFrame *const pContentFrame = static_cast<const SwNoTextFrame *>(pFlyFrame->Lower()); @@ -127,8 +124,8 @@ SwAccessibleFrameBase::SwAccessibleFrameBase( m_bIsSelected( false ) { const SwFrameFormat* pFrameFormat = pFlyFrame->GetFormat(); - if(pFrameFormat) - StartListening(const_cast<SwFrameFormat*>(pFrameFormat)->GetNotifier()); + + StartListening(const_cast<SwFrameFormat*>(pFrameFormat)->GetNotifier()); SetName( pFrameFormat->GetName() ); @@ -141,7 +138,7 @@ void SwAccessibleFrameBase::InvalidateCursorPos_() bool bOldSelected; { - osl::MutexGuard aGuard( m_Mutex ); + std::scoped_lock aGuard( m_Mutex ); bOldSelected = m_bIsSelected; m_bIsSelected = bNewSelected; } @@ -188,7 +185,7 @@ void SwAccessibleFrameBase::InvalidateFocus_() bool bSelected; { - osl::MutexGuard aGuard( m_Mutex ); + std::scoped_lock aGuard( m_Mutex ); bSelected = m_bIsSelected; } assert(bSelected && "focus object should be selected"); @@ -199,7 +196,7 @@ void SwAccessibleFrameBase::InvalidateFocus_() bool SwAccessibleFrameBase::HasCursor() { - osl::MutexGuard aGuard( m_Mutex ); + std::scoped_lock aGuard( m_Mutex ); return m_bIsSelected; } @@ -209,34 +206,29 @@ SwAccessibleFrameBase::~SwAccessibleFrameBase() void SwAccessibleFrameBase::Notify(const SfxHint& rHint) { + const SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrame*>(GetFrame()); if(rHint.GetId() == SfxHintId::Dying) { EndListeningAll(); } - else if(auto pLegacyModifyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) + else if (rHint.GetId() == SfxHintId::SwNameChanged && pFlyFrame) { - const sal_uInt16 nWhich = pLegacyModifyHint->GetWhich(); - const SwFlyFrame* pFlyFrame = static_cast<const SwFlyFrame*>(GetFrame()); - if(nWhich == RES_NAME_CHANGED && pFlyFrame) - { - const SwFrameFormat* pFrameFormat = pFlyFrame->GetFormat(); + auto rNameChanged = static_cast<const sw::NameChanged&>(rHint); + const SwFrameFormat* pFrameFormat = pFlyFrame->GetFormat(); - const OUString sOldName( GetName() ); - assert( !pLegacyModifyHint->m_pOld || - static_cast<const SwStringMsgPoolItem *>(pLegacyModifyHint->m_pOld)->GetString() == GetName()); + const OUString sOldName( GetName() ); + assert( rNameChanged.m_sOld == sOldName); - SetName( pFrameFormat->GetName() ); - assert( !pLegacyModifyHint->m_pNew || - static_cast<const SwStringMsgPoolItem *>(pLegacyModifyHint->m_pNew)->GetString() == GetName()); + SetName( pFrameFormat->GetName() ); + assert( rNameChanged.m_sNew == GetName()); - if( sOldName != GetName() ) - { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::NAME_CHANGED; - aEvent.OldValue <<= sOldName; - aEvent.NewValue <<= GetName(); - FireAccessibleEvent( aEvent ); - } + if( sOldName != GetName() ) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::NAME_CHANGED; + aEvent.OldValue <<= sOldName; + aEvent.NewValue <<= GetName(); + FireAccessibleEvent( aEvent ); } } } @@ -257,8 +249,7 @@ SwPaM* SwAccessibleFrameBase::GetCursor() SwCursorShell* pCursorShell = GetCursorShell(); if( pCursorShell != nullptr && !pCursorShell->IsTableMode() ) { - SwFEShell *pFESh = dynamic_cast<const SwFEShell*>( pCursorShell) != nullptr - ? static_cast< SwFEShell * >( pCursorShell ) : nullptr; + SwFEShell *pFESh = dynamic_cast<SwFEShell*>( pCursorShell); if( !pFESh || !(pFESh->IsFrameSelected() || pFESh->IsObjSelected() > 0) ) { @@ -288,14 +279,14 @@ bool SwAccessibleFrameBase::GetSelectedState( ) const SwPosition *pPos = rAnchor.GetContentAnchor(); if( !pPos ) return false; - int nIndex = pPos->nContent.GetIndex(); - if( pPos->nNode.GetNode().GetTextNode() ) + int nIndex = pPos->GetContentIndex(); + if( pPos->GetNode().GetTextNode() ) { SwPaM* pCursor = GetCursor(); if( pCursor != nullptr ) { - const SwTextNode* pNode = pPos->nNode.GetNode().GetTextNode(); - sal_uLong nHere = pNode->GetIndex(); + const SwTextNode* pNode = pPos->GetNode().GetTextNode(); + SwNodeOffset nHere = pNode->GetIndex(); // iterate over ring SwPaM* pRingStart = pCursor; @@ -306,15 +297,15 @@ bool SwAccessibleFrameBase::GetSelectedState( ) { // check whether nHere is 'inside' pCursor SwPosition* pStart = pCursor->Start(); - sal_uLong nStartIndex = pStart->nNode.GetIndex(); + SwNodeOffset nStartIndex = pStart->GetNodeIndex(); SwPosition* pEnd = pCursor->End(); - sal_uLong nEndIndex = pEnd->nNode.GetIndex(); + SwNodeOffset nEndIndex = pEnd->GetNodeIndex(); if( ( nHere >= nStartIndex ) && (nHere <= nEndIndex) ) { if( rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR ) { - if( ((nHere == nStartIndex) && (nIndex >= pStart->nContent.GetIndex())) || (nHere > nStartIndex) ) - if( ((nHere == nEndIndex) && (nIndex < pEnd->nContent.GetIndex())) || (nHere < nEndIndex) ) + if( ((nHere == nStartIndex) && (nIndex >= pStart->GetContentIndex())) || (nHere > nStartIndex) ) + if( ((nHere == nEndIndex) && (nIndex < pEnd->GetContentIndex())) || (nHere < nEndIndex) ) return true; } else if( rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA ) |