diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-11-18 10:15:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-11-18 11:15:48 +0100 |
commit | efab55fee25c5a2f5a0c491c1ceab721c267af17 (patch) | |
tree | d5f940a88be60d9ad4df818167b3aeea723dc694 | |
parent | ba637bbbd65d71a3956d56f04ce2703b51479700 (diff) |
convert AccessibilityFlowTo to scoped enum
and drop the unused FORSPELLCHECKFLOWTO
Change-Id: I128e84d386c10d001aa63f93b4b6dcb7238a1242
Reviewed-on: https://gerrit.libreoffice.org/83060
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/comphelper/accflowenum.hxx | 10 | ||||
-rw-r--r-- | offapi/com/sun/star/accessibility/XAccessibleGetAccFlowTo.idl | 1 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleDocument.cxx | 101 | ||||
-rw-r--r-- | sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx | 97 | ||||
-rw-r--r-- | svx/source/dialog/srchdlg.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/access/accdoc.cxx | 119 |
6 files changed, 94 insertions, 242 deletions
diff --git a/include/comphelper/accflowenum.hxx b/include/comphelper/accflowenum.hxx index fc6b7ea2d8ec..a5e3b9eb680a 100644 --- a/include/comphelper/accflowenum.hxx +++ b/include/comphelper/accflowenum.hxx @@ -22,11 +22,13 @@ #include <sal/types.h> -enum AccessibilityFlowTo : sal_Int32 +/** + enum for css::accessibility::XAccessibleGetAccFlowTo::getAccFlowTo method +*/ +enum class AccessibilityFlowTo : sal_Int32 { - FORSPELLCHECKFLOWTO = 1, - FORFINDREPLACEFLOWTO_ITEM = 2, - FORFINDREPLACEFLOWTO_RANGE = 3 + ForFindReplaceItem = 2, + ForFindReplaceRange = 3 }; #endif // INCLUDED_COMPHELPER_ACCFLOWENUM_HXX diff --git a/offapi/com/sun/star/accessibility/XAccessibleGetAccFlowTo.idl b/offapi/com/sun/star/accessibility/XAccessibleGetAccFlowTo.idl index 56246775b5cc..0e8f9cd69ae4 100644 --- a/offapi/com/sun/star/accessibility/XAccessibleGetAccFlowTo.idl +++ b/offapi/com/sun/star/accessibility/XAccessibleGetAccFlowTo.idl @@ -28,6 +28,7 @@ module com { module sun { module star { module accessibility { // !!! interface XAccessibleGetAccFlowTo : ::com::sun::star::uno::XInterface { + // @param nType see include/comphelper/accflowenum.hxx sequence<any> getAccFlowTo([in] any aXShape, [in] long nType); }; diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index e10636b5e678..836106cf193e 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -2279,95 +2279,34 @@ css::uno::Sequence< css::uno::Any > ScAccessibleDocument::GetScAccFlowToSequence css::uno::Sequence< css::uno::Any > SAL_CALL ScAccessibleDocument::getAccFlowTo(const css::uno::Any& rAny, sal_Int32 nType) { + AccessibilityFlowTo eType = static_cast<AccessibilityFlowTo>(nType); + +#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG + assert(eType == AccessibilityFlowTo::ForFindReplaceItem || eType == AccessibilityFlowTo::ForFindReplaceRange); +#endif + SolarMutexGuard g; - if (nType == AccessibilityFlowTo::FORSPELLCHECKFLOWTO) + bool bSuccess(false); + rAny >>= bSuccess; + if ( bSuccess ) { - uno::Reference< css::drawing::XShape > xShape; - rAny >>= xShape; - if ( xShape.is() ) + if (eType == AccessibilityFlowTo::ForFindReplaceRange) { - uno::Reference < XAccessible > xAcc = mpChildrenShapes->GetAccessibleCaption(xShape); - uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY ); - if ( xAccSelection.is() ) + uno::Sequence< uno::Any> aSeq = GetScAccFlowToSequence(); + if ( aSeq.hasElements() ) { - if ( xAccSelection->getSelectedAccessibleChildCount() ) - { - uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 ); - if ( xSel.is() ) - { - uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() ); - if ( xSelContext.is() ) - { - //if in sw we find the selected paragraph here - if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) - { - uno::Sequence<uno::Any> aRet( 1 ); - aRet[0] <<= xSel; - return aRet; - } - } - } - } + return aSeq; } } - else - { - if ( getSelectedAccessibleChildCount() ) - { - uno::Reference < XAccessible > xSel = getSelectedAccessibleChild( 0 ); - if ( xSel.is() ) - { - uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() ); - if ( xSelContext.is() ) - { - uno::Reference < XAccessibleSelection > xAccChildSelection( xSel, uno::UNO_QUERY ); - if ( xAccChildSelection.is() ) - { - if ( xAccChildSelection->getSelectedAccessibleChildCount() ) - { - uno::Reference < XAccessible > xChildSel = xAccChildSelection->getSelectedAccessibleChild( 0 ); - if ( xChildSel.is() ) - { - uno::Reference < css::accessibility::XAccessibleContext > xChildSelContext( xChildSel->getAccessibleContext() ); - if ( xChildSelContext.is() && - xChildSelContext->getAccessibleRole() == css::accessibility::AccessibleRole::PARAGRAPH ) - { - uno::Sequence<uno::Any> aRet( 1 ); - aRet[0] <<= xChildSel; - return aRet; - } - } - } - } - } - } - } - } - } - else if (nType == AccessibilityFlowTo::FORFINDREPLACEFLOWTO_ITEM || nType == AccessibilityFlowTo::FORFINDREPLACEFLOWTO_RANGE) - { - bool bSuccess(false); - rAny >>= bSuccess; - if ( bSuccess ) - { - if (nType == AccessibilityFlowTo::FORFINDREPLACEFLOWTO_RANGE) - { - uno::Sequence< uno::Any> aSeq = GetScAccFlowToSequence(); - if ( aSeq.hasElements() ) - { - return aSeq; - } - } - if( mpAccessibleSpreadsheet.is() ) - { - uno::Reference < XAccessible > xFindCellAcc = mpAccessibleSpreadsheet->GetActiveCell(); - // add xFindCellAcc to the return the Sequence - uno::Sequence< uno::Any> aSeq2(1); - aSeq2[0] <<= xFindCellAcc; - return aSeq2; - } + if( mpAccessibleSpreadsheet.is() ) + { + uno::Reference < XAccessible > xFindCellAcc = mpAccessibleSpreadsheet->GetActiveCell(); + // add xFindCellAcc to the return the Sequence + uno::Sequence< uno::Any> aSeq2(1); + aSeq2[0] <<= xFindCellAcc; + return aSeq2; } } uno::Sequence< uno::Any> aEmpty; diff --git a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx index 2e295a0eaf56..ce7c3abad3f6 100644 --- a/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx +++ b/sd/source/ui/accessibility/AccessibleDrawDocumentView.cxx @@ -738,94 +738,55 @@ void SAL_CALL AccessibleDrawDocumentView::disposing() } css::uno::Sequence< css::uno::Any > - SAL_CALL AccessibleDrawDocumentView::getAccFlowTo(const css::uno::Any& rAny, sal_Int32 nType) + SAL_CALL AccessibleDrawDocumentView::getAccFlowTo(const css::uno::Any& /*rAny*/, sal_Int32 nType) { +#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG + AccessibilityFlowTo eType = static_cast<AccessibilityFlowTo>(nType); + assert(eType == AccessibilityFlowTo::ForFindReplaceItem || eType == AccessibilityFlowTo::ForFindReplaceRange); +#else + (void) nType; +#endif + SolarMutexGuard g; - if (nType == AccessibilityFlowTo::FORSPELLCHECKFLOWTO) + sal_Int32 nChildCount = getSelectedAccessibleChildCount(); + if ( nChildCount ) { - uno::Reference< css::drawing::XShape > xShape; - rAny >>= xShape; - if ( mpChildrenManager && xShape.is() ) + uno::Reference < XAccessible > xSel = getSelectedAccessibleChild( 0 ); + if ( xSel.is() ) { - uno::Reference < XAccessible > xAcc = mpChildrenManager->GetChild(xShape); - uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY ); - if ( xAccSelection.is() ) + uno::Reference < XAccessibleSelection > xAccChildSelection( xSel, uno::UNO_QUERY ); + if ( xAccChildSelection.is() ) { - if ( xAccSelection->getSelectedAccessibleChildCount() ) + if ( xAccChildSelection->getSelectedAccessibleChildCount() ) { - uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 ); - if ( xSel.is() ) + uno::Reference < XAccessible > xChildSel = xAccChildSelection->getSelectedAccessibleChild( 0 ); + if ( xChildSel.is() ) { - uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() ); - if ( xSelContext.is() ) + uno::Reference < XAccessibleContext > xChildSelContext( xChildSel->getAccessibleContext() ); + if ( xChildSelContext.is() && + xChildSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) { - //if in sw we find the selected paragraph here - if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) - { - uno::Sequence<uno::Any> aRet( 1 ); - aRet[0] <<= xSel; - return aRet; - } + uno::Sequence<uno::Any> aRet( 1 ); + aRet[0] <<= xChildSel; + return aRet; } } } } - uno::Reference<XAccessible> xPara = GetSelAccContextInTable(); - if ( xPara.is() ) - { - uno::Sequence<uno::Any> aRet( 1 ); - aRet[0] <<= xPara; - return aRet; - } - } - else - { - goto Rt; } } - else if (nType == AccessibilityFlowTo::FORFINDREPLACEFLOWTO_ITEM || nType == AccessibilityFlowTo::FORFINDREPLACEFLOWTO_RANGE) + else { - sal_Int32 nChildCount = getSelectedAccessibleChildCount(); - if ( nChildCount ) - { - uno::Reference < XAccessible > xSel = getSelectedAccessibleChild( 0 ); - if ( xSel.is() ) - { - uno::Reference < XAccessibleSelection > xAccChildSelection( xSel, uno::UNO_QUERY ); - if ( xAccChildSelection.is() ) - { - if ( xAccChildSelection->getSelectedAccessibleChildCount() ) - { - uno::Reference < XAccessible > xChildSel = xAccChildSelection->getSelectedAccessibleChild( 0 ); - if ( xChildSel.is() ) - { - uno::Reference < XAccessibleContext > xChildSelContext( xChildSel->getAccessibleContext() ); - if ( xChildSelContext.is() && - xChildSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) - { - uno::Sequence<uno::Any> aRet( 1 ); - aRet[0] <<= xChildSel; - return aRet; - } - } - } - } - } - } - else + uno::Reference<XAccessible> xPara = GetSelAccContextInTable(); + if ( xPara.is() ) { - uno::Reference<XAccessible> xPara = GetSelAccContextInTable(); - if ( xPara.is() ) - { - uno::Sequence<uno::Any> aRet( 1 ); - aRet[0] <<= xPara; - return aRet; - } + uno::Sequence<uno::Any> aRet( 1 ); + aRet[0] <<= xPara; + return aRet; } } -Rt: css::uno::Sequence< uno::Any> aRet; return aRet; } diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index b971f1f94038..92fa6a1603ee 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -2310,19 +2310,19 @@ void SvxSearchDialog::SetDocWin(vcl::Window* pDocWin, SvxSearchCmd eCommand) But with search/all we do want the new multi-cellselection as the result. */ - AccessibilityFlowTo eFlowTo(AccessibilityFlowTo::FORFINDREPLACEFLOWTO_ITEM); + AccessibilityFlowTo eFlowTo(AccessibilityFlowTo::ForFindReplaceItem); switch (eCommand) { case SvxSearchCmd::FIND: case SvxSearchCmd::REPLACE: - eFlowTo = AccessibilityFlowTo::FORFINDREPLACEFLOWTO_ITEM; + eFlowTo = AccessibilityFlowTo::ForFindReplaceItem; break; case SvxSearchCmd::FIND_ALL: case SvxSearchCmd::REPLACE_ALL: - eFlowTo = AccessibilityFlowTo::FORFINDREPLACEFLOWTO_RANGE; + eFlowTo = AccessibilityFlowTo::ForFindReplaceRange; break; } - uno::Sequence<uno::Any> aAnySeq = xGetAccFlowTo->getAccFlowTo(Any(GetSrchFlag()), eFlowTo); + uno::Sequence<uno::Any> aAnySeq = xGetAccFlowTo->getAccFlowTo(Any(GetSrchFlag()), static_cast<sal_Int32>(eFlowTo)); sal_Int32 nLen = aAnySeq.getLength(); if (nLen) diff --git a/sw/source/core/access/accdoc.cxx b/sw/source/core/access/accdoc.cxx index d62e1878582b..da85ddacc2e0 100644 --- a/sw/source/core/access/accdoc.cxx +++ b/sw/source/core/access/accdoc.cxx @@ -723,8 +723,15 @@ sal_Int32 SAL_CALL SwAccessibleDocument::getBackground() } css::uno::Sequence< css::uno::Any > - SAL_CALL SwAccessibleDocument::getAccFlowTo(const css::uno::Any& rAny, sal_Int32 nType) + SAL_CALL SwAccessibleDocument::getAccFlowTo(const css::uno::Any& /*rAny*/, sal_Int32 nType) { +#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG + AccessibilityFlowTo eType = static_cast<AccessibilityFlowTo>(nType); + assert(eType == AccessibilityFlowTo::ForFindReplaceItem || eType == AccessibilityFlowTo::ForFindReplaceRange); +#else + (void) nType; +#endif + SolarMutexGuard g; SwAccessibleMap* pAccMap = GetMap(); @@ -733,104 +740,46 @@ css::uno::Sequence< css::uno::Any > return uno::Sequence< uno::Any >(); } - if (nType == AccessibilityFlowTo::FORSPELLCHECKFLOWTO) + SwCursorShell* pCursorShell = GetCursorShell(); + if ( pCursorShell ) { - uno::Reference< css::drawing::XShape > xShape; - rAny >>= xShape; - if( xShape.is() ) + SwPaM *_pStartCursor = pCursorShell->GetCursor(), *_pStartCursor2 = _pStartCursor; + std::set<SwFrame*> vFrameList; + do { - SdrObject* pObj = GetSdrObjectFromXShape(xShape); - if( pObj ) + if ( _pStartCursor && _pStartCursor->HasMark() ) { - uno::Reference<XAccessible> xAcc = pAccMap->GetContext(pObj, this, false); - uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY ); - if ( xAccSelection.is() ) + SwContentNode* pContentNode = _pStartCursor->GetContentNode(); + SwFrame *const pFrame = pContentNode + ? pContentNode->getLayoutFrame(pCursorShell->GetLayout(), _pStartCursor->GetPoint()) + : nullptr; + if ( pFrame ) { - try - { - if ( xAccSelection->getSelectedAccessibleChildCount() ) - { - uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 ); - if ( xSel.is() ) - { - uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() ); - if ( xSelContext.is() ) - { - //if in sw we find the selected paragraph here - if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH ) - { - uno::Sequence<uno::Any> aRet( 1 ); - aRet[0] <<= xSel; - return aRet; - } - } - } - } - } - catch ( const css::lang::IndexOutOfBoundsException& ) - { - return uno::Sequence< uno::Any >(); - } - //end of try...catch + vFrameList.insert( pFrame ); } } } - else - { - uno::Reference< XAccessible > xAcc = pAccMap->GetCursorContext(); - SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() ); - if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH ) - { - uno::Sequence< uno::Any > aRet(1); - aRet[0] <<= xAcc; - return aRet; - } - } - } - else if (nType == AccessibilityFlowTo::FORFINDREPLACEFLOWTO_ITEM || nType == AccessibilityFlowTo::FORFINDREPLACEFLOWTO_RANGE) - { - SwCursorShell* pCursorShell = GetCursorShell(); - if ( pCursorShell ) - { - SwPaM *_pStartCursor = pCursorShell->GetCursor(), *_pStartCursor2 = _pStartCursor; - std::set<SwFrame*> vFrameList; - do - { - if ( _pStartCursor && _pStartCursor->HasMark() ) - { - SwContentNode* pContentNode = _pStartCursor->GetContentNode(); - SwFrame *const pFrame = pContentNode - ? pContentNode->getLayoutFrame(pCursorShell->GetLayout(), _pStartCursor->GetPoint()) - : nullptr; - if ( pFrame ) - { - vFrameList.insert( pFrame ); - } - } - } + while( _pStartCursor && ( (_pStartCursor = _pStartCursor->GetNext()) != _pStartCursor2) ); - while( _pStartCursor && ( (_pStartCursor = _pStartCursor->GetNext()) != _pStartCursor2) ); - - if ( !vFrameList.empty() ) + if ( !vFrameList.empty() ) + { + uno::Sequence< uno::Any > aRet(vFrameList.size()); + sal_Int32 nIndex = 0; + for ( const auto& rpFrame : vFrameList ) { - uno::Sequence< uno::Any > aRet(vFrameList.size()); - sal_Int32 nIndex = 0; - for ( const auto& rpFrame : vFrameList ) + uno::Reference< XAccessible > xAcc = pAccMap->GetContext(rpFrame, false); + if ( xAcc.is() ) { - uno::Reference< XAccessible > xAcc = pAccMap->GetContext(rpFrame, false); - if ( xAcc.is() ) + SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() ); + if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH ) { - SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() ); - if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH ) - { - aRet[nIndex] <<= xAcc; - } + aRet[nIndex] <<= xAcc; } - nIndex++; } - aRet.realloc(nIndex); - return aRet; + nIndex++; } + aRet.realloc(nIndex); + return aRet; } } |