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 
27 #include <comphelper/compbase.hxx>
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 
36 namespace accessibility {
37 
38 class AccessibleShape;
39 
40 class ChildDescriptor; // See below for declaration.
41 typedef ::std::vector<ChildDescriptor> ChildDescriptorListType;
42 
43 // Re-using MutexOwner class defined in AccessibleContextBase.hxx
44 
76  css::document::XEventListener,
77  css::view::XSelectionChangeListener>,
79  public IAccessibleParent
80 {
81 public:
99  ChildrenManagerImpl (const css::uno::Reference<css::accessibility::XAccessible>& rxParent,
100  const css::uno::Reference<css::drawing::XShapes>& rxShapeList,
101  const AccessibleShapeTreeInfo& rShapeTreeInfo,
102  AccessibleContextBase& rContext);
103 
107  virtual ~ChildrenManagerImpl() override;
108 
112  void Init();
113 
118  tools::Long GetChildCount() const noexcept;
119 
122  css::uno::Reference<css::drawing::XShape> GetChildShape(tools::Long nIndex);
136  css::uno::Reference<css::accessibility::XAccessible>
137  GetChild (tools::Long 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 (css::uno::Reference<css::accessibility::XAccessible> 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 
268 private:
281  ChildDescriptorListType maVisibleChildren;
282 
287  css::uno::Reference<css::drawing::XShapes> mxShapeList;
288 
292  typedef std::vector< css::uno::Reference< css::accessibility::XAccessible> > AccessibleShapeList;
293  AccessibleShapeList maAccessibleShapes;
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 
322  ChildrenManagerImpl (const ChildrenManagerImpl&) = delete;
324 
329 
339  void CreateListOfVisibleShapes (ChildDescriptorListType& raChildList);
340 
352  const ChildDescriptorListType& raNewChildList,
353  ChildDescriptorListType& raOldChildList);
354 
361  void MergeAccessibilityInformation (ChildDescriptorListType& raChildList);
362 
370  static void SendVisibleAreaEvents (ChildDescriptorListType& raChildList);
371 
378  void CreateAccessibilityObjects (ChildDescriptorListType& raChildList);
379 
384  void AddShape (const css::uno::Reference<css::drawing::XShape>& xShape);
385 
390  void RemoveShape (const css::uno::Reference<css::drawing::XShape>& xShape);
391 
398  void RegisterAsDisposeListener (const css::uno::Reference<css::drawing::XShape>& xShape);
399 
404  void UnregisterAsDisposeListener (const css::uno::Reference<css::drawing::XShape>& xShape);
405 };
406 
407 
419 {
420 public:
423  css::uno::Reference<css::drawing::XShape> mxShape;
424 
429  css::uno::Reference<css::accessibility::XAccessible> mxAccessibleShape;
430 
439 
444  void setIndexAtAccessibleShape(sal_Int32 _nIndex);
445 
453 
457  explicit ChildDescriptor (const css::uno::Reference<css::drawing::XShape>& xShape);
458 
462  explicit ChildDescriptor (const css::uno::Reference<css::accessibility::XAccessible>& rxAccessibleShape);
463 
471 
476  bool operator == (const ChildDescriptor& aDescriptor) const
477  {
478  return (
479  this == &aDescriptor ||
480  (
481  (mxShape.get() == aDescriptor.mxShape.get() ) &&
482  (mxShape.is() || mxAccessibleShape.get() == aDescriptor.mxAccessibleShape.get())
483  )
484  );
485  }
486 
487 };
488 
489 
490 } // end of namespace accessibility
491 
492 #endif
493 
494 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A child descriptor holds a reference to a UNO shape and the corresponding accessible object...
void CreateAccessibilityObjects(ChildDescriptorListType &raChildList)
If children have to be created immediately and not on demand the create the missing accessible object...
void RemoveFocus()
When there is a shape that currently has the focus, i.e.
sal_Int32 nIndex
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...
css::uno::Reference< css::accessibility::XAccessible > mxParent
The parent of the shapes.
ChildDescriptorListType maVisibleChildren
This list holds the descriptors of all currently visible shapes and associated accessible object...
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...
tools::Rectangle maVisibleArea
Rectangle that describes the visible area in which a shape has to lie at least partly, to be accessible through this class.
long Long
virtual AccessibleControlShape * GetAccControlShapeFromModel(css::beans::XPropertySet *pSet) override
void disposeAccessibleObject(AccessibleContextBase &rParent)
Dispose the accessible object of this descriptor.
css::uno::Reference< css::drawing::XShapes > mxShapeList
The original list of UNO shapes.
void MergeAccessibilityInformation(ChildDescriptorListType &raChildList)
Merge the information that is already known about the visible shapes from the current list into the n...
static void SendVisibleAreaEvents(ChildDescriptorListType &raChildList)
If the visible area has changed then send events that signal a change of their bounding boxes for all...
ChildDescriptor(const css::uno::Reference< css::drawing::XShape > &xShape)
Create a new descriptor for the specified shape with empty reference to accessible object...
bool mbCreateEventPending
This flag is set during the visibility calculation and indicates that at one time in this process an ...
tools::Long GetChildCount() const noexcept
Return the number of currently visible accessible children.
This interface contains methods missing from the XAccessibleContext interface that allow the modifica...
void Init()
Do that part of the initialization that you can not or should not do in the constructor like register...
void UnregisterAsDisposeListener(const css::uno::Reference< css::drawing::XShape > &xShape)
Remove the children manager as dispose listener at the given shape.
bool operator==(const ChildDescriptor &aDescriptor) const
Compare two child descriptors.
AccessibleShape * GetAccessibleShape() const
Return a pointer to the implementation object of the accessible shape of this descriptor.
void UpdateSelection()
Update the SELECTED and FOCUSED states of all visible children according to the given selection...
void RemoveShape(const css::uno::Reference< css::drawing::XShape > &xShape)
Remove a single shape.
css::uno::Reference< css::drawing::XShape > mxShape
Reference to a (partially) visible shape.
ChildrenManagerImpl(const css::uno::Reference< css::accessibility::XAccessible > &rxParent, const css::uno::Reference< css::drawing::XShapes > &rxShapeList, const AccessibleShapeTreeInfo &rShapeTreeInfo, AccessibleContextBase &rContext)
Create a children manager, which manages the children of the given parent.
void SetInfo(const AccessibleShapeTreeInfo &rShapeTreeInfo)
Set a new event shape tree info.
class SAL_NO_VTABLE XPropertySet
Definition: xmlexchg.hxx:28
AccessibleShapeTreeInfo maShapeTreeInfo
Bundle of information passed down the shape tree.
virtual void SAL_CALL notifyEvent(const css::document::EventObject &rEventObject) override
Listen for new and removed shapes.
bool HasFocus() const
Return whether one of the shapes managed by this object has currently the focus.
void ClearAccessibleShapeList()
Clear the lists of accessible shapes and that of visible accessible shapes.
virtual ~ChildrenManagerImpl() override
If there still are managed children these are disposed and released.
::std::vector< ChildDescriptor > ChildDescriptorListType
This base class provides a base implementation for all shapes.
css::uno::Reference< css::drawing::XShape > GetChildShape(tools::Long nIndex)
void AddAccessibleShape(css::uno::Reference< css::accessibility::XAccessible > const &shape)
Add an accessible shape.
virtual void SAL_CALL disposing(const css::lang::EventObject &rEventObject) override
std::vector< css::uno::Reference< css::accessibility::XAccessible > > AccessibleShapeList
This list of additional accessible shapes that can or shall not be created by the shape factory...
AccessibleShape * mpFocusedShape
This member points to the currently focused shape.
void SetShapeList(const css::uno::Reference< css::drawing::XShapes > &xShapeList)
Set the list of UNO shapes to the given list.
ChildrenManagerImpl & operator=(const ChildrenManagerImpl &)=delete
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.
void RemoveNonVisibleChildren(const ChildDescriptorListType &raNewChildList, ChildDescriptorListType &raOldChildList)
From the old list of (former) visible shapes remove those that are not member of the new list...
css::uno::Reference< css::accessibility::XAccessible > mxAccessibleShape
The corresponding accessible object.
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &rEvent) override
void Update(bool bCreateNewObjectsOnDemand)
Update the child manager.
void setIndexAtAccessibleShape(sal_Int32 _nIndex)
set the index _nIndex at the accessible shape
void AddShape(const css::uno::Reference< css::drawing::XShape > &xShape)
Add a single shape.
This class contains the actual implementation of the children manager.
css::uno::Reference< css::accessibility::XAccessible > GetChild(tools::Long nIndex)
Return the requested accessible child or throw and IndexOutOfBoundsException if the given index is in...
void CreateListOfVisibleShapes(ChildDescriptorListType &raChildList)
Three helper functions for the Update method.
virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption(const css::uno::Reference< css::drawing::XShape > &xShape) override
This class bundles all information that is passed down the tree of accessible shapes so that each sha...