LibreOffice Module svx (master) 1
ChildrenManagerImpl.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_SVX_SOURCE_ACCESSIBILITY_CHILDRENMANAGERIMPL_HXX
21#define INCLUDED_SVX_SOURCE_ACCESSIBILITY_CHILDRENMANAGERIMPL_HXX
22
28#include <tools/gen.hxx>
29#include <vector>
30#include <com/sun/star/drawing/XShape.hpp>
31#include <com/sun/star/drawing/XShapes.hpp>
32#include <com/sun/star/document/XEventListener.hpp>
33#include <com/sun/star/view/XSelectionChangeListener.hpp>
34#include <com/sun/star/accessibility/XAccessible.hpp>
35
36namespace accessibility {
37
38class AccessibleShape;
39
40class ChildDescriptor; // See below for declaration.
41typedef ::std::vector<ChildDescriptor> ChildDescriptorListType;
42
43// Re-using MutexOwner class defined in AccessibleContextBase.hxx
44
76 css::document::XEventListener,
77 css::view::XSelectionChangeListener>,
80{
81public:
99 ChildrenManagerImpl (css::uno::Reference<css::accessibility::XAccessible> xParent,
100 css::uno::Reference<css::drawing::XShapes> xShapeList,
101 const AccessibleShapeTreeInfo& rShapeTreeInfo,
102 AccessibleContextBase& rContext);
103
107 virtual ~ChildrenManagerImpl() override;
108
112 void Init();
113
118 sal_Int64 GetChildCount() const noexcept;
119
122 const css::uno::Reference<css::drawing::XShape>& GetChildShape(sal_Int64 nIndex);
136 css::uno::Reference<css::accessibility::XAccessible>
137 GetChild (sal_Int64 nIndex);
138
151 css::uno::Reference<css::accessibility::XAccessible>
152 GetChild (ChildDescriptor& aChildDescriptor,sal_Int32 _nIndex);
153
165 void Update (bool bCreateNewObjectsOnDemand);
166
175 void SetShapeList (const css::uno::Reference<css::drawing::XShapes>& xShapeList);
176
185 void AddAccessibleShape (rtl::Reference<AccessibleShape> const & shape);
186
191
197 void SetInfo (const AccessibleShapeTreeInfo& rShapeTreeInfo);
198
203 void UpdateSelection();
204
211 bool HasFocus() const;
212
217 void RemoveFocus();
218
219 // lang::XEventListener
220 virtual void SAL_CALL
221 disposing (const css::lang::EventObject& rEventObject) override;
222
223 // document::XEventListener
224 virtual void SAL_CALL
225 notifyEvent (const css::document::EventObject& rEventObject) override;
226
227 // view::XSelectionChangeListener
228 virtual void SAL_CALL
229 selectionChanged (const css::lang::EventObject& rEvent) override;
230
231 // IAccessibleViewForwarderListener
243 virtual void ViewForwarderChanged() override;
244
245 // IAccessibleParent
255 virtual bool ReplaceChild (
256 AccessibleShape* pCurrentChild,
257 const css::uno::Reference< css::drawing::XShape >& _rxShape,
258 const tools::Long _nIndex,
259 const AccessibleShapeTreeInfo& _rShapeTreeInfo
260 ) override;
261
262 // Add the impl method for IAccessibleParent interface
264 (css::beans::XPropertySet* pSet) override;
265 virtual css::uno::Reference<css::accessibility::XAccessible>
266 GetAccessibleCaption (const css::uno::Reference<css::drawing::XShape>& xShape) override;
267
268private:
282
287 css::uno::Reference<css::drawing::XShapes> mxShapeList;
288
292 typedef std::vector< rtl::Reference< AccessibleShape> > AccessibleShapeList;
294
300
304 css::uno::Reference<css::accessibility::XAccessible> mxParent;
305
309
314
318 virtual void disposing(std::unique_lock<std::mutex>&) override;
319
320 void impl_dispose();
321
323 ChildrenManagerImpl& operator= (const ChildrenManagerImpl&) = delete;
324
329
340
352 const std::vector<ChildDescriptor*>& rNonVisibleChildren);
353
365
373 static void SendVisibleAreaEvents (ChildDescriptorListType& raChildList);
374
382
387 void AddShape (const css::uno::Reference<css::drawing::XShape>& xShape);
388
393 void RemoveShape (const css::uno::Reference<css::drawing::XShape>& xShape);
394
401 void RegisterAsDisposeListener (const css::uno::Reference<css::drawing::XShape>& xShape);
402
407 void UnregisterAsDisposeListener (const css::uno::Reference<css::drawing::XShape>& xShape);
408};
409
410
422{
423public:
426 css::uno::Reference<css::drawing::XShape> mxShape;
427
433
441 AccessibleShape* GetAccessibleShape() const { return mxAccessibleShape.get(); }
442
447 void setIndexAtAccessibleShape(sal_Int32 _nIndex);
448
456
460 explicit ChildDescriptor (const css::uno::Reference<css::drawing::XShape>& xShape);
461
465 explicit ChildDescriptor (const rtl::Reference<AccessibleShape>& rxAccessibleShape);
466
473 void disposeAccessibleObject (AccessibleContextBase& rParent);
474
479 bool operator == (const ChildDescriptor& aDescriptor) const
480 {
481 return (
482 this == &aDescriptor ||
483 (
484 (mxShape.get() == aDescriptor.mxShape.get() ) &&
485 (mxShape.is() || mxAccessibleShape.get() == aDescriptor.mxAccessibleShape.get())
486 )
487 );
488 }
489
490};
491
492
493} // end of namespace accessibility
494
495#endif
496
497/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class bundles all information that is passed down the tree of accessible shapes so that each sha...
This base class provides a base implementation for all shapes.
A child descriptor holds a reference to a UNO shape and the corresponding accessible object.
AccessibleShape * GetAccessibleShape() const
Return a pointer to the implementation object of the accessible shape of this descriptor.
ChildDescriptor(const css::uno::Reference< css::drawing::XShape > &xShape)
Create a new descriptor for the specified shape with empty reference to accessible object.
css::uno::Reference< css::drawing::XShape > mxShape
Reference to a (partially) visible shape.
bool mbCreateEventPending
This flag is set during the visibility calculation and indicates that at one time in this process an ...
rtl::Reference< AccessibleShape > mxAccessibleShape
The corresponding accessible object.
This class contains the actual implementation of the children manager.
void RemoveShape(const css::uno::Reference< css::drawing::XShape > &xShape)
Remove a single shape.
void CreateAccessibilityObjects(ChildDescriptorListType &raChildList)
If children have to be created immediately and not on demand the create the missing accessible object...
void RemoveNonVisibleChildren(const std::vector< ChildDescriptor * > &rNonVisibleChildren)
From the old list of (former) visible shapes remove those that are not member of the new list.
void AddShape(const css::uno::Reference< css::drawing::XShape > &xShape)
Add a single shape.
ChildrenManagerImpl(css::uno::Reference< css::accessibility::XAccessible > xParent, css::uno::Reference< css::drawing::XShapes > xShapeList, const AccessibleShapeTreeInfo &rShapeTreeInfo, AccessibleContextBase &rContext)
Create a children manager, which manages the children of the given parent.
void UnregisterAsDisposeListener(const css::uno::Reference< css::drawing::XShape > &xShape)
Remove the children manager as dispose listener at the given shape.
virtual ~ChildrenManagerImpl() override
If there still are managed children these are disposed and released.
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &rEvent) override
virtual void SAL_CALL notifyEvent(const css::document::EventObject &rEventObject) override
Listen for new and removed shapes.
void AddAccessibleShape(rtl::Reference< AccessibleShape > const &shape)
Add an accessible shape.
css::uno::Reference< css::drawing::XShapes > mxShapeList
The original list of UNO shapes.
std::vector< rtl::Reference< AccessibleShape > > AccessibleShapeList
This list of additional accessible shapes that can or shall not be created by the shape factory.
void ClearAccessibleShapeList()
Clear the lists of accessible shapes and that of visible accessible shapes.
AccessibleShapeTreeInfo maShapeTreeInfo
Bundle of information passed down the shape tree.
void Init()
Do that part of the initialization that you can not or should not do in the constructor like register...
bool HasFocus() const
Return whether one of the shapes managed by this object has currently the focus.
css::uno::Reference< css::accessibility::XAccessible > GetChild(sal_Int64 nIndex)
Return the requested accessible child or throw and IndexOutOfBoundsException if the given index is in...
AccessibleShape * mpFocusedShape
This member points to the currently focused shape.
std::vector< ChildDescriptor * > MergeAccessibilityInformation(ChildDescriptorListType &raChildList)
Merge the information that is already known about the visible shapes from the old list into the curre...
css::uno::Reference< css::accessibility::XAccessible > mxParent
The parent of the shapes.
AccessibleContextBase & mrContext
Reference to an accessible context object that is used to inform its listeners of new and removed chi...
virtual void ViewForwarderChanged() override
Informs this children manager and its children about a change of one (or more) aspect of the view for...
ChildDescriptorListType maVisibleChildren
This list holds the descriptors of all currently visible shapes and associated accessible object.
void UpdateSelection()
Update the SELECTED and FOCUSED states of all visible children according to the given selection.
virtual AccessibleControlShape * GetAccControlShapeFromModel(css::beans::XPropertySet *pSet) override
void CreateListOfVisibleShapes(ChildDescriptorListType &raChildList)
Three helper functions for the <member>Update</member> method.
const css::uno::Reference< css::drawing::XShape > & GetChildShape(sal_Int64 nIndex)
void RemoveFocus()
When there is a shape that currently has the focus, i.e.
static void SendVisibleAreaEvents(ChildDescriptorListType &raChildList)
If the visible area has changed then send events that signal a change of their bounding boxes for all...
tools::Rectangle maVisibleArea
Rectangle that describes the visible area in which a shape has to lie at least partly,...
sal_Int64 GetChildCount() const noexcept
Return the number of currently visible accessible children.
void Update(bool bCreateNewObjectsOnDemand)
Update the child manager.
virtual void SAL_CALL disposing(const css::lang::EventObject &rEventObject) override
void RegisterAsDisposeListener(const css::uno::Reference< css::drawing::XShape > &xShape)
Add the children manager as dispose listener at the given shape so that the associated accessible obj...
void SetInfo(const AccessibleShapeTreeInfo &rShapeTreeInfo)
Set a new event shape tree info.
virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption(const css::uno::Reference< css::drawing::XShape > &xShape) override
void SetShapeList(const css::uno::Reference< css::drawing::XShapes > &xShapeList)
Set the list of UNO shapes to the given list.
virtual bool ReplaceChild(AccessibleShape *pCurrentChild, const css::uno::Reference< css::drawing::XShape > &_rxShape, const tools::Long _nIndex, const AccessibleShapeTreeInfo &_rShapeTreeInfo) override
Replace the specified child with a replacement.
This interface contains methods missing from the XAccessibleContext interface that allow the modifica...
::std::vector< ChildDescriptor > ChildDescriptorListType
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:29
long Long
uno::Reference< drawing::XShape > const mxShape