From b8ce52aab9459773544f1696cfe6b7b6f171a389 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 12 Mar 2015 08:50:16 +0200 Subject: convert AccessibleStates to enum class Change-Id: Ie0d8c16bb768201e8646c3136d7ceca67e506a3c --- sw/inc/accmap.hxx | 42 +++++++++++++++---------------- sw/source/core/access/acccontext.cxx | 8 +++--- sw/source/core/access/acccontext.hxx | 4 +-- sw/source/core/access/accmap.cxx | 48 ++++++++++++++++++------------------ sw/source/core/view/viewimp.cxx | 4 +-- 5 files changed, 53 insertions(+), 53 deletions(-) (limited to 'sw') diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx index 29dab399a691..d831d95d505c 100644 --- a/sw/inc/accmap.hxx +++ b/sw/inc/accmap.hxx @@ -32,8 +32,9 @@ #include "fesh.hxx" #include #include -class SwAccessibleParagraph; +#include +class SwAccessibleParagraph; class SwViewShell; class Rectangle; class SwFrm; @@ -45,9 +46,7 @@ class SwAccessibleEventList_Impl; class SwAccessibleEventMap_Impl; class SwShapeList_Impl; class SdrObject; -namespace accessibility { - class AccessibleShape; -} +namespace accessibility { class AccessibleShape; } class SwAccessibleShapeMap_Impl; struct SwAccessibleEvent_Impl; class SwAccessibleSelectedParas_Impl; @@ -57,22 +56,23 @@ class SwAccPreviewData; struct PreviewPage; namespace vcl { class Window; } -// real states for events -#define ACC_STATE_EDITABLE 0x01 -#define ACC_STATE_OPAQUE 0x02 - -// pseudo states for events -#define ACC_STATE_TEXT_ATTRIBUTE_CHANGED 0x0200 -#define ACC_STATE_TEXT_SELECTION_CHANGED 0x0100 -#define ACC_STATE_CARET 0x80 -#define ACC_STATE_RELATION_FROM 0x40 -#define ACC_STATE_RELATION_TO 0x20 - -#define ACC_STATE_RELATION_MASK 0x60 - -#define ACC_STATE_MASK 0x1F - -typedef sal_uInt16 tAccessibleStates; +enum class AccessibleStates +{ + NONE = 0x0000, + // real states for events + EDITABLE = 0x0001, + OPAQUE = 0x0002, + // pseudo states for events + TEXT_ATTRIBUTE_CHANGED = 0x0200, + TEXT_SELECTION_CHANGED = 0x0100, + CARET = 0x0080, + RELATION_FROM = 0x0040, + RELATION_TO = 0x0020, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} class SwAccessibleMap : public ::accessibility::IAccessibleViewForwarder, public ::accessibility::IAccessibleParent @@ -212,7 +212,7 @@ public: // Invalidate state of whole tree. If an action is open, this call // is processed when the last action ends. - void InvalidateStates( tAccessibleStates _nStates, + void InvalidateStates( AccessibleStates _nStates, const SwFrm* _pFrm = 0 ); void InvalidateRelationSet( const SwFrm* pMaster, const SwFrm* pFollow ); diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx index 4e9d8ededea6..842152e53085 100644 --- a/sw/source/core/access/acccontext.cxx +++ b/sw/source/core/access/acccontext.cxx @@ -352,7 +352,7 @@ void SwAccessibleContext::ScrolledOut( const SwRect& rOldVisArea ) // #i27301# - use new type definition for <_nStates> void SwAccessibleContext::InvalidateChildrenStates( const SwFrm* _pFrm, - tAccessibleStates _nStates ) + AccessibleStates _nStates ) { const SwAccessibleChildSList aVisList( GetVisArea(), *_pFrm, *(GetMap()) ); @@ -1283,14 +1283,14 @@ void SwAccessibleContext::InvalidateFocus() } // #i27301# - use new type definition for <_nStates> -void SwAccessibleContext::InvalidateStates( tAccessibleStates _nStates ) +void SwAccessibleContext::InvalidateStates( AccessibleStates _nStates ) { if( GetMap() ) { SwViewShell *pVSh = GetMap()->GetShell(); if( pVSh ) { - if( (_nStates & ACC_STATE_EDITABLE) != 0 ) + if( _nStates & AccessibleStates::EDITABLE ) { bool bIsOldEditableState; bool bIsNewEditableState = IsEditable( pVSh ); @@ -1304,7 +1304,7 @@ void SwAccessibleContext::InvalidateStates( tAccessibleStates _nStates ) FireStateChangedEvent( AccessibleStateType::EDITABLE, bIsNewEditableState ); } - if( (_nStates & ACC_STATE_OPAQUE) != 0 ) + if( _nStates & AccessibleStates::OPAQUE ) { bool bIsOldOpaqueState; bool bIsNewOpaqueState = IsOpaque( pVSh ); diff --git a/sw/source/core/access/acccontext.hxx b/sw/source/core/access/acccontext.hxx index 9069e3128f8e..4763f18a486a 100644 --- a/sw/source/core/access/acccontext.hxx +++ b/sw/source/core/access/acccontext.hxx @@ -148,7 +148,7 @@ protected: // SwFrm might belong the current object or to any child or grandchild! // #i27301# - use new type definition for <_nStates> void InvalidateChildrenStates( const SwFrm* _pFrm, - tAccessibleStates _nStates ); + AccessibleStates _nStates ); // Dispose children of the specified SwFrm. The SwFrm might belong to // the current object or to any other child or grandchild. @@ -346,7 +346,7 @@ public: // Check states // #i27301# - use new type definition for <_nStates> - void InvalidateStates( tAccessibleStates _nStates ); + void InvalidateStates( AccessibleStates _nStates ); // the XAccessibleRelationSet may have changed void InvalidateRelation( sal_uInt16 nType ); diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index 16536f3f89df..0428889b7c49 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -344,7 +344,7 @@ private: // the same as xAcc for any other // event type EventType meType; // The event type - tAccessibleStates mnStates; // check states or update caret pos + AccessibleStates mnStates; // check states or update caret pos public: const SwFrm* mpParentFrm; // The object that fires the event @@ -360,7 +360,7 @@ public: : mxAcc( pA ), maFrmOrObj( rFrmOrObj ), meType( eT ), - mnStates( 0 ), + mnStates( AccessibleStates::NONE ), mpParentFrm( nullptr ) {} @@ -368,7 +368,7 @@ public: const SwAccessibleChild& rFrmOrObj ) : maFrmOrObj( rFrmOrObj ), meType( eT ), - mnStates( 0 ), + mnStates( AccessibleStates::NONE ), mpParentFrm( nullptr ) { OSL_ENSURE( SwAccessibleEvent_Impl::DISPOSE == meType, @@ -377,7 +377,7 @@ public: SwAccessibleEvent_Impl( EventType eT ) : meType( eT ), - mnStates( 0 ), + mnStates( AccessibleStates::NONE ), mpParentFrm( nullptr ) { OSL_ENSURE( SwAccessibleEvent_Impl::SHAPE_SELECTION == meType, @@ -392,7 +392,7 @@ public: mxAcc( pA ), maFrmOrObj( rFrmOrObj ), meType( eT ), - mnStates( 0 ), + mnStates( AccessibleStates::NONE ), mpParentFrm( nullptr ) { OSL_ENSURE( SwAccessibleEvent_Impl::CHILD_POS_CHANGED == meType || @@ -403,7 +403,7 @@ public: SwAccessibleEvent_Impl( EventType eT, SwAccessibleContext *pA, const SwAccessibleChild& rFrmOrObj, - const tAccessibleStates _nStates ) + const AccessibleStates _nStates ) : mxAcc( pA ), maFrmOrObj( rFrmOrObj ), meType( eT ), @@ -419,7 +419,7 @@ public: maOldBox( rR ), maFrmOrObj( rFrmOrObj ), meType( eT ), - mnStates( 0 ), + mnStates( AccessibleStates::NONE ), mpParentFrm( pParentFrm ) { OSL_ENSURE( SwAccessibleEvent_Impl::CHILD_POS_CHANGED == meType, @@ -461,39 +461,39 @@ public: } // only used in method - inline void SetStates( tAccessibleStates _nStates ) + inline void SetStates( AccessibleStates _nStates ) { mnStates |= _nStates; } inline bool IsUpdateCursorPos() const { - return (mnStates & ACC_STATE_CARET) != 0; + return bool(mnStates & AccessibleStates::CARET); } inline bool IsInvalidateStates() const { - return (mnStates & ACC_STATE_MASK) != 0; + return bool(mnStates & (AccessibleStates::EDITABLE | AccessibleStates::OPAQUE)); } inline bool IsInvalidateRelation() const { - return (mnStates & ACC_STATE_RELATION_MASK) != 0; + return bool(mnStates & (AccessibleStates::RELATION_FROM | AccessibleStates::RELATION_TO)); } inline bool IsInvalidateTextSelection() const { - return ( mnStates & ACC_STATE_TEXT_SELECTION_CHANGED ) != 0; + return bool( mnStates & AccessibleStates::TEXT_SELECTION_CHANGED ); } inline bool IsInvalidateTextAttrs() const { - return ( mnStates & ACC_STATE_TEXT_ATTRIBUTE_CHANGED ) != 0; + return bool( mnStates & AccessibleStates::TEXT_ATTRIBUTE_CHANGED ); } - inline tAccessibleStates GetStates() const + inline AccessibleStates GetStates() const { - return mnStates & ACC_STATE_MASK; + return mnStates; } - inline tAccessibleStates GetAllStates() const + inline AccessibleStates GetAllStates() const { return mnStates; } @@ -937,12 +937,12 @@ void SwAccessibleMap::FireEvent( const SwAccessibleEvent_Impl& rEvent ) { // both events CONTENT_FLOWS_FROM_RELATION_CHANGED and // CONTENT_FLOWS_TO_RELATION_CHANGED are possible - if ( rEvent.GetAllStates() & ACC_STATE_RELATION_FROM ) + if ( rEvent.GetAllStates() & AccessibleStates::RELATION_FROM ) { xAccImpl->InvalidateRelation( AccessibleEventId::CONTENT_FLOWS_FROM_RELATION_CHANGED ); } - if ( rEvent.GetAllStates() & ACC_STATE_RELATION_TO ) + if ( rEvent.GetAllStates() & AccessibleStates::RELATION_TO ) { xAccImpl->InvalidateRelation( AccessibleEventId::CONTENT_FLOWS_TO_RELATION_CHANGED ); @@ -1082,7 +1082,7 @@ void SwAccessibleMap::InvalidateCursorPosition( SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, SwAccessibleChild(pAccImpl->GetFrm()), - ACC_STATE_CARET ); + AccessibleStates::CARET ); AppendEvent( aEvent ); } else @@ -2570,7 +2570,7 @@ void SwAccessibleMap::InvalidateAttr( const SwTxtFrm& rTxtFrm ) { SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::INVALID_ATTR, pAccImpl, aFrmOrObj ); - aEvent.SetStates( ACC_STATE_TEXT_ATTRIBUTE_CHANGED ); + aEvent.SetStates( AccessibleStates::TEXT_ATTRIBUTE_CHANGED ); AppendEvent( aEvent ); } else @@ -2839,7 +2839,7 @@ void SwAccessibleMap::SetCursorContext( mxCursorContext = xAcc; } -void SwAccessibleMap::InvalidateStates( tAccessibleStates _nStates, +void SwAccessibleMap::InvalidateStates( AccessibleStates _nStates, const SwFrm* _pFrm ) { // Start with the frame or the first upper that is accessible @@ -2899,8 +2899,8 @@ void SwAccessibleMap::_InvalidateRelationSet( const SwFrm* pFrm, SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, SwAccessibleChild(pFrm), ( bFrom - ? ACC_STATE_RELATION_FROM - : ACC_STATE_RELATION_TO ) ); + ? AccessibleStates::RELATION_FROM + : AccessibleStates::RELATION_TO ) ); AppendEvent( aEvent ); } else @@ -2961,7 +2961,7 @@ void SwAccessibleMap::InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm ) SwAccessibleEvent_Impl::CARET_OR_STATES, pAccImpl, SwAccessibleChild( &_rTxtFrm ), - ACC_STATE_TEXT_SELECTION_CHANGED ); + AccessibleStates::TEXT_SELECTION_CHANGED ); AppendEvent( aEvent ); } else diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx index c2f7feefc112..e85e2a0fdc0c 100644 --- a/sw/source/core/view/viewimp.cxx +++ b/sw/source/core/view/viewimp.cxx @@ -337,12 +337,12 @@ void SwViewShellImp::InvalidateAccessibleEditableState( bool bAllShells, for(SwViewShell& rTmp : GetShell()->GetRingContainer()) { if( rTmp.Imp()->IsAccessible() ) - rTmp.Imp()->GetAccessibleMap().InvalidateStates( ACC_STATE_EDITABLE, pFrm ); + rTmp.Imp()->GetAccessibleMap().InvalidateStates( AccessibleStates::EDITABLE, pFrm ); } } else if( IsAccessible() ) { - GetAccessibleMap().InvalidateStates( ACC_STATE_EDITABLE, pFrm ); + GetAccessibleMap().InvalidateStates( AccessibleStates::EDITABLE, pFrm ); } } -- cgit