20#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
32#include <com/sun/star/uno/Reference.hxx>
33#include <com/sun/star/accessibility/AccessibleStateType.hpp>
34#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
41using ::com::sun::star::accessibility::XAccessible;
42using ::com::sun::star::accessibility::XAccessibleContext;
43using ::com::sun::star::accessibility::XAccessibleSelection;
57 OSL_ENSURE( pViewShell !=
nullptr,
58 "No view shell? Then what are you looking at?" );
67 Reference < XAccessibleContext > xThis( &
m_rContext );
68 Reference < XAccessibleSelection >xSelThis( xThis, UNO_QUERY );
69 lang::IndexOutOfBoundsException aExcept(
70 "index out of bounds",
77 sal_Int64 nChildIndex )
87 if( !aChild.IsValid() )
94 const SdrObject *pObj = aChild.GetDrawObject();
106 Reference< XAccessible > xAcc;
107 if ( aChild.GetSwFrame() )
109 xAcc = pMap->
GetContext( aChild.GetSwFrame(),
false );
111 else if ( aChild.GetDrawObject() )
113 xAcc = pMap->
GetContext( aChild.GetDrawObject(), pContext,
false );
118 Reference< XAccessibleContext > pRContext = xAcc->getAccessibleContext();
121 sal_Int64 nRStateSet = pRContext->getAccessibleStateSet();
122 if(nRStateSet & AccessibleStateType::SELECTED)
129 sal_Int64 nChildIndex )
139 if( !aChild.IsValid() )
146 if ( aChild.GetSwFrame() !=
nullptr )
148 bRet = (pFEShell->GetSelectedFlyFrame() == aChild.GetSwFrame());
150 else if ( aChild.GetDrawObject() )
152 bRet = pFEShell->IsObjSelected( *aChild.GetDrawObject() );
176 std::list< SwAccessibleChild > aChildren;
179 for(
const SwAccessibleChild& rChild : aChildren )
181 const SdrObject* pObj = rChild.GetDrawObject();
182 const SwFrame* pFrame = rChild.GetSwFrame();
183 if( pObj && !(pFrame !=
nullptr && pFEShell->
IsObjSelected()) )
201 const SwFlyFrame* pFlyFrame = pFEShell->GetSelectedFlyFrame();
208 const size_t nSelObjs = pFEShell->IsObjSelected();
211 std::list< SwAccessibleChild > aChildren;
214 for(
const SwAccessibleChild& rChild : aChildren )
216 if( rChild.GetDrawObject() && !rChild.GetSwFrame() &&
219 pFEShell->IsObjSelected( *rChild.GetDrawObject() ) )
232 std::list< SwAccessibleChild > aChildren;
234 nCount =
static_cast<sal_Int32
>(std::count_if(aChildren.begin(), aChildren.end(),
235 [
this](
const SwAccessibleChild& aChild) { return lcl_getSelectedState(aChild, &m_rContext, m_rContext.GetMap()); }));
242 sal_Int64 nSelectedChildIndex )
254 SwAccessibleChild aChild;
258 if( 0 == nSelectedChildIndex )
270 if( rAnchor.
GetAnchorId() == RndStdIds::FLY_AS_CHAR )
285 std::list< SwAccessibleChild > aChildren;
288 for(
const SwAccessibleChild& rChild : aChildren )
290 if( rChild.GetDrawObject() && !rChild.GetSwFrame() &&
295 if( 0 == nSelectedChildIndex )
298 --nSelectedChildIndex;
300 if (aChild.IsValid())
305 if( !aChild.IsValid() )
309 Reference< XAccessible > xChild;
310 if( aChild.GetSwFrame() )
314 if( xChildImpl.is() )
317 xChild = xChildImpl.get();
320 else if ( aChild.GetDrawObject() )
325 if( xChildImpl.is() )
326 xChild = xChildImpl.get();
333 sal_Int64 nChildIndex )
337 if( nChildIndex < 0 ||
static bool lcl_getSelectedState(const SwAccessibleChild &aChild, SwAccessibleContext *pContext, SwAccessibleMap *pMap)
SwAccessibleMap * GetMap()
bool Select(SwPaM *pPaM, SdrObject *pObj, bool bAdd)
bool IsInPagePreview() const
static void GetChildren(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame &rFrame, std::list< sw::access::SwAccessibleChild > &rChildren, bool bInPagePreview)
static sal_Int32 GetChildCount(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame *pFrame, bool bInPagePreviewr)
static sw::access::SwAccessibleChild GetChild(SwAccessibleMap &rAccMap, const SwRect &rVisArea, const SwFrame &rFrame, sal_Int32 &rPos, bool bInPagePreview)
const SwFrame * GetFrame() const
const SwFrame * GetParent() const
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
SwViewShell * GetShell() const
SwAccessibleContext & m_rContext
the context on which this helper works
void throwIndexOutOfBoundsException()
SwAccessibleSelectionHelper(SwAccessibleContext &rContext)
bool isAccessibleChildSelected(sal_Int64 nChildIndex)
void selectAccessibleChild(sal_Int64 nChildIndex)
SwFEShell * GetFEShell()
get FE-Shell
void selectAllAccessibleChildren()
css::uno::Reference< css::accessibility::XAccessible > getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex)
void deselectAccessibleChild(sal_Int64 nChildIndex)
sal_Int64 getSelectedAccessibleChildCount()
SwFlyFrame * GetSelectedFlyFrame() const
size_t IsObjSelected() const
general base class for all free-flowing frames
virtual const SwFlyFrameFormat * GetFormat() const override
Base class of the Writer layout elements.
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
const Reference< XComponentContext > & m_rContext