diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-01 11:25:59 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-01 17:47:56 +0200 |
commit | 5ba7e1586f03b8227f9c5a09d0b85587412ee2ae (patch) | |
tree | 065ce65a9a9aaaf80f5f2b8d7a987576ab2656a3 | |
parent | 8e0a3ee310fa361ffee5b4f4c86a4c19512ebf7d (diff) |
wina11y: Use enum class for navigation direction
Switch the `DM_NIR` enum to an enum class
`NavigationDirection` and move it to MAccessible.{h,cxx}
which is the only place where it's used.
The param name of "flags" previously used in
CMAccessible::GetNavigateChildForDM was misleading,
as any of the values can only be handled exclusively.
Change-Id: I39d8d6afc5c8c845b3aa0add7bd314501f4c91b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174320
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
-rw-r--r-- | winaccessibility/source/UAccCOM/MAccessible.cxx | 27 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/MAccessible.h | 3 | ||||
-rw-r--r-- | winaccessibility/source/UAccCOM/acccommon.h | 7 |
3 files changed, 19 insertions, 18 deletions
diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 8763b48dd3a3..814f13c1ea7d 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -88,6 +88,13 @@ enum class XInterfaceType { XI_ATTRIBUTE }; +enum class NavigationDirection { + FIRST_CHILD, + LAST_CHILD, + NEXT_CHILD, + PREVIOUS_CHILD, +}; + template <class Interface> bool queryXInterface(XAccessible* pXAcc, XInterface** ppXI) { @@ -1315,10 +1322,10 @@ IMAccessible* CMAccessible::GetChildInterface(long dChildID)//for test /** * for descendantmanager circumstance,provide child interface when navigate * @param varCur, the current child. -* @param flags, the navigation direction. +* @param eDirection, the navigation direction. * @return IMAccessible*, the child of the end up node. */ -IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) +IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, NavigationDirection eDirection) { XAccessibleContext* pXContext = GetContextByXAcc(m_xAccessible.get()); @@ -1334,16 +1341,16 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) } Reference<XAccessible> pRChildXAcc; - switch(flags) + switch(eDirection) { - case DM_FIRSTCHILD: + case NavigationDirection::FIRST_CHILD: pRChildXAcc = pXContext->getAccessibleChild(0); break; - case DM_LASTCHILD: + case NavigationDirection::LAST_CHILD: pRChildXAcc = pXContext->getAccessibleChild(count-1); break; - case DM_NEXTCHILD: - case DM_PREVCHILD: + case NavigationDirection::NEXT_CHILD: + case NavigationDirection::PREVIOUS_CHILD: { IMAccessible* pCurChild = GetChildInterface(varCur.lVal); if(pCurChild==nullptr) @@ -1361,7 +1368,7 @@ IMAccessible* CMAccessible::GetNavigateChildForDM(VARIANT varCur, short flags) { return nullptr; } - const sal_Int64 delta = (flags == DM_NEXTCHILD) ? 1 : -1; + const sal_Int64 delta = (eDirection == NavigationDirection::NEXT_CHILD) ? 1 : -1; //currently, getAccessibleIndexInParent is error in UNO for //some kind of List,such as ValueSet, the index will be less 1 than //what should be, need to fix UNO code @@ -1411,7 +1418,7 @@ HRESULT CMAccessible::GetFirstChild(VARIANT varStart,VARIANT* pvarEndUpAt) return E_INVALIDARG; } - pvarEndUpAt->pdispVal = GetNavigateChildForDM(varStart, DM_FIRSTCHILD); + pvarEndUpAt->pdispVal = GetNavigateChildForDM(varStart, NavigationDirection::FIRST_CHILD); if(pvarEndUpAt->pdispVal) { pvarEndUpAt->pdispVal->AddRef(); @@ -1448,7 +1455,7 @@ HRESULT CMAccessible::GetLastChild(VARIANT varStart,VARIANT* pvarEndUpAt) return E_INVALIDARG; } - pvarEndUpAt->pdispVal = GetNavigateChildForDM(varStart, DM_LASTCHILD); + pvarEndUpAt->pdispVal = GetNavigateChildForDM(varStart, NavigationDirection::LAST_CHILD); if(pvarEndUpAt->pdispVal) { pvarEndUpAt->pdispVal->AddRef(); diff --git a/winaccessibility/source/UAccCOM/MAccessible.h b/winaccessibility/source/UAccCOM/MAccessible.h index 7bd2153bf344..2a4f792fd88a 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.h +++ b/winaccessibility/source/UAccCOM/MAccessible.h @@ -33,6 +33,7 @@ namespace { enum class XInterfaceType; +enum class NavigationDirection; } /** @@ -183,7 +184,7 @@ private: // the helper methods in order to implement the above public methods IMAccessible* GetChildInterface(long dChildIndex);//notice here the parameter is child index,not child id - IMAccessible* GetNavigateChildForDM(VARIANT varCur,short flags);//for descendant manage + IMAccessible* GetNavigateChildForDM(VARIANT varCur, NavigationDirection eDirection); HRESULT GetFirstChild(VARIANT varStart,VARIANT* pvarEndUpAt);//for accNavigate implementation HRESULT GetLastChild(VARIANT varStart,VARIANT* pvarEndUpAt);//for accNavigate implementation HRESULT GetNextSibling(VARIANT varStart,VARIANT* pvarEndUpAt);//for accNavigate implementation diff --git a/winaccessibility/source/UAccCOM/acccommon.h b/winaccessibility/source/UAccCOM/acccommon.h index d0ce6200614b..0de27ea9c794 100644 --- a/winaccessibility/source/UAccCOM/acccommon.h +++ b/winaccessibility/source/UAccCOM/acccommon.h @@ -46,13 +46,6 @@ struct ltComp } }; -enum DM_NIR { - DM_FIRSTCHILD = 0x00, - DM_LASTCHILD = 0x01, - DM_NEXTCHILD = 0x02, - DM_PREVCHILD = 0x03 -}; - template<typename T, typename Ifc> HRESULT createInstance(REFIID iid, Ifc ** ppIfc) { |