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 <cppuhelper/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 
75  : public MutexOwner,
76  public cppu::WeakComponentImplHelper<
77  css::document::XEventListener,
78  css::view::XSelectionChangeListener>,
80  public IAccessibleParent
81 {
82 public:
100  ChildrenManagerImpl (const css::uno::Reference<css::accessibility::XAccessible>& rxParent,
101  const css::uno::Reference<css::drawing::XShapes>& rxShapeList,
102  const AccessibleShapeTreeInfo& rShapeTreeInfo,
103  AccessibleContextBase& rContext);
104 
108  virtual ~ChildrenManagerImpl() override;
109 
113  void Init();
114 
119  tools::Long GetChildCount() const throw ();
120 
123  css::uno::Reference<css::drawing::XShape> GetChildShape(tools::Long nIndex);
137  css::uno::Reference<css::accessibility::XAccessible>
138  GetChild (tools::Long nIndex);
139 
152  css::uno::Reference<css::accessibility::XAccessible>
153  GetChild (ChildDescriptor& aChildDescriptor,sal_Int32 _nIndex);
154 
166  void Update (bool bCreateNewObjectsOnDemand);
167 
176  void SetShapeList (const css::uno::Reference<css::drawing::XShapes>& xShapeList);
177 
186  void AddAccessibleShape (css::uno::Reference<css::accessibility::XAccessible> const & shape);
187 
192 
198  void SetInfo (const AccessibleShapeTreeInfo& rShapeTreeInfo);
199 
204  void UpdateSelection();
205 
212  bool HasFocus() const;
213 
218  void RemoveFocus();
219 
220  // lang::XEventListener
221  virtual void SAL_CALL
222  disposing (const css::lang::EventObject& rEventObject) override;
223 
224  // document::XEventListener
225  virtual void SAL_CALL
226  notifyEvent (const css::document::EventObject& rEventObject) override;
227 
228  // view::XSelectionChangeListener
229  virtual void SAL_CALL
230  selectionChanged (const css::lang::EventObject& rEvent) override;
231 
232  // IAccessibleViewForwarderListener
244  virtual void ViewForwarderChanged() override;
245 
246  // IAccessibleParent
256  virtual bool ReplaceChild (
257  AccessibleShape* pCurrentChild,
258  const css::uno::Reference< css::drawing::XShape >& _rxShape,
259  const tools::Long _nIndex,
260  const AccessibleShapeTreeInfo& _rShapeTreeInfo
261  ) override;
262 
263  // Add the impl method for IAccessibleParent interface
265  (css::beans::XPropertySet* pSet) override;
266  virtual css::uno::Reference<css::accessibility::XAccessible>
267  GetAccessibleCaption (const css::uno::Reference<css::drawing::XShape>& xShape) override;
268 
269 private:
282  ChildDescriptorListType maVisibleChildren;
283 
288  css::uno::Reference<css::drawing::XShapes> mxShapeList;
289 
293  typedef std::vector< css::uno::Reference< css::accessibility::XAccessible> > AccessibleShapeList;
294  AccessibleShapeList maAccessibleShapes;
295 
301 
305  css::uno::Reference<css::accessibility::XAccessible> mxParent;
306 
310 
315 
319  virtual void SAL_CALL disposing() override;
320 
321  void impl_dispose();
322 
323  ChildrenManagerImpl (const ChildrenManagerImpl&) = delete;
325 
330 
340  void CreateListOfVisibleShapes (ChildDescriptorListType& raChildList);
341 
353  const ChildDescriptorListType& raNewChildList,
354  ChildDescriptorListType& raOldChildList);
355 
362  void MergeAccessibilityInformation (ChildDescriptorListType& raChildList);
363 
371  static void SendVisibleAreaEvents (ChildDescriptorListType& raChildList);
372 
379  void CreateAccessibilityObjects (ChildDescriptorListType& raChildList);
380 
385  void AddShape (const css::uno::Reference<css::drawing::XShape>& xShape);
386 
391  void RemoveShape (const css::uno::Reference<css::drawing::XShape>& xShape);
392 
399  void RegisterAsDisposeListener (const css::uno::Reference<css::drawing::XShape>& xShape);
400 
405  void UnregisterAsDisposeListener (const css::uno::Reference<css::drawing::XShape>& xShape);
406 };
407 
408 
420 {
421 public:
424  css::uno::Reference<css::drawing::XShape> mxShape;
425 
430  css::uno::Reference<css::accessibility::XAccessible> mxAccessibleShape;
431 
440 
445  void setIndexAtAccessibleShape(sal_Int32 _nIndex);
446 
454 
458  explicit ChildDescriptor (const css::uno::Reference<css::drawing::XShape>& xShape);
459 
463  explicit ChildDescriptor (const css::uno::Reference<css::accessibility::XAccessible>& rxAccessibleShape);
464 
472 
477  bool operator == (const ChildDescriptor& aDescriptor) const
478  {
479  return (
480  this == &aDescriptor ||
481  (
482  (mxShape.get() == aDescriptor.mxShape.get() ) &&
483  (mxShape.is() || mxAccessibleShape.get() == aDescriptor.mxAccessibleShape.get())
484  )
485  );
486  }
487 
488 };
489 
490 
491 } // end of namespace accessibility
492 
493 #endif
494 
495 /* 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 ...
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.
tools::Long GetChildCount() const
Return the number of currently visible accessible children.
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.
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.
virtual void SAL_CALL disposing() override
This method is called from the component helper base class while disposing.
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...