LibreOffice Module sw (master)  1
accmap.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 #ifndef INCLUDED_SW_INC_ACCMAP_HXX
20 #define INCLUDED_SW_INC_ACCMAP_HXX
21 
22 #include <cppuhelper/weakref.hxx>
23 #include <rtl/ref.hxx>
24 #include <osl/mutex.hxx>
27 
29 #include <o3tl/typed_flags_set.hxx>
30 
31 #include <vector>
32 #include <memory>
33 #include <set>
34 
36 class SwViewShell;
37 class SwFrame;
38 class SwTextFrame;
39 class SwPageFrame;
44 class SdrObject;
45 namespace accessibility { class AccessibleShape; }
49 class SwRect;
50 class MapMode;
51 class SwAccPreviewData;
52 class SwFEShell;
53 class Fraction;
54 struct PreviewPage;
55 namespace vcl { class Window; }
56 namespace com { namespace sun { namespace star { namespace accessibility { class XAccessible; } } } }
57 
58 // The shape list is filled if an accessible shape is destroyed. It
59 // simply keeps a reference to the accessible shape's XShape. These
60 // references are destroyed within the EndAction when firing events.
61 // There are two reason for this. First of all, a new accessible shape
62 // for the XShape might be created soon. It's then cheaper if the XShape
63 // still exists. The other reason are situations where an accessible shape
64 // is destroyed within an SwFrameFormat::Modify. In this case, destroying
65 // the XShape at the same time (indirectly by destroying the accessible
66 // shape) leads to an assert, because a client of the Modify is destroyed
67 // within a Modify call.
68 using SwShapeList_Impl = std::vector<css::uno::Reference<css::drawing::XShape>>;
69 
70 enum class AccessibleStates
71 {
72  NONE = 0x0000,
73  // real states for events
74  EDITABLE = 0x0001,
75  OPAQUE = 0x0002,
76  // pseudo states for events
77  TEXT_ATTRIBUTE_CHANGED = 0x0200,
78  TEXT_SELECTION_CHANGED = 0x0100,
79  CARET = 0x0080,
80  RELATION_FROM = 0x0040,
81  RELATION_TO = 0x0020,
82 };
83 namespace o3tl
84 {
85  template<> struct typed_flags<AccessibleStates> : is_typed_flags<AccessibleStates, 0x3e3> {};
86 }
87 
90  , public std::enable_shared_from_this<SwAccessibleMap>
91 {
92  mutable ::osl::Mutex maMutex;
93  ::osl::Mutex maEventMutex;
94  std::unique_ptr<SwAccessibleContextMap_Impl> mpFrameMap;
95  std::unique_ptr<SwAccessibleShapeMap_Impl> mpShapeMap;
97  std::unique_ptr<SwAccessibleEventList_Impl> mpEvents;
98  std::unique_ptr<SwAccessibleEventMap_Impl> mpEventMap;
99  // #i27301 data structure to keep information about
100  // accessible paragraph, which have a selection.
101  std::unique_ptr<SwAccessibleSelectedParas_Impl> mpSelectedParas;
105  std::unique_ptr<SwAccPreviewData> mpPreview;
106 
107  css::uno::WeakReference < css::accessibility::XAccessible > mxCursorContext;
108 
110 
111  void FireEvent( const SwAccessibleEvent_Impl& rEvent );
112 
113  void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
114 
115  void InvalidateCursorPosition( const css::uno::Reference<css::accessibility::XAccessible>& rAcc );
116  void DoInvalidateShapeSelection(bool bInvalidateFocusMode = false);
117 
119 
120  //mpSelectedFrameMap contains the old selected objects.
121  std::unique_ptr<SwAccessibleContextMap_Impl> mpSeletedFrameMap;
122 
123  OUString const maDocName;
124 
125  //InvalidateShapeInParaSelection() method is responsible for the updating the selected states of the objects.
127 
128  void InvalidateRelationSet_( const SwFrame* pFrame, bool bFrom );
129 
130  css::uno::Reference<css::accessibility::XAccessible>
131  GetDocumentView_( bool bPagePreview );
132 
138  std::unique_ptr<SwAccessibleSelectedParas_Impl> BuildSelectedParas();
139 
140 public:
141 
143  virtual ~SwAccessibleMap() override;
144 
145  css::uno::Reference<css::accessibility::XAccessible> GetDocumentView();
146 
147  css::uno::Reference<css::accessibility::XAccessible> GetDocumentPreview(
148  const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
149  const Fraction& _rScale,
150  const SwPageFrame* _pSelectedPageFrame,
151  const Size& _rPreviewWinSize );
152 
154  const SwFrame *pFrame,
155  bool bCreate = true );
156  css::uno::Reference<css::accessibility::XAccessible> GetContext(
157  const SwFrame *pFrame,
158  bool bCreate = true );
159 
161  const SdrObject *pObj,
162  SwAccessibleContext *pParentImpl,
163  bool bCreate = true );
164  css::uno::Reference<css::accessibility::XAccessible> GetContext(
165  const SdrObject *pObj,
166  SwAccessibleContext *pParentImpl,
167  bool bCreate = true );
168 
170  {
171  return mpVSh;
172  }
173  static bool IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh);
174  void AddShapeContext(const SdrObject *pObj,
175  css::uno::Reference < css::accessibility::XAccessible > const & xAccShape);
176 
177  void AddGroupContext(const SdrObject *pParentObj,
178  css::uno::Reference < css::accessibility::XAccessible > const & xAccParent);
179  void RemoveGroupContext(const SdrObject *pParentObj);
180 
181  const SwRect& GetVisArea() const;
182 
190  Size GetPreviewPageSize( sal_uInt16 _nPreviewPageNum ) const;
191 
192  void RemoveContext( const SwFrame *pFrame );
193  void RemoveContext( const SdrObject *pObj );
194 
195  // Dispose frame and its children if bRecursive is set
196  void A11yDispose( const SwFrame* pFrame,
197  const SdrObject* pObj,
198  vcl::Window* pWindow,
199  bool bRecursive = false,
200  bool bCanSkipInvisible = true );
201 
202  void InvalidatePosOrSize( const SwFrame* pFrame,
203  const SdrObject* pObj,
204  vcl::Window* pWindow,
205  const SwRect& rOldFrame );
206 
207  void InvalidateContent( const SwFrame *pFrame );
208 
209  void InvalidateAttr( const SwTextFrame& rTextFrame );
210 
211  void InvalidateCursorPosition( const SwFrame *pFrame );
212  void InvalidateFocus();
213  void SetCursorContext(
214  const ::rtl::Reference < SwAccessibleContext >& rCursorContext );
215 
216  // Invalidate state of whole tree. If an action is open, this call
217  // is processed when the last action ends.
218  void InvalidateEditableStates( const SwFrame* _pFrame );
219 
220  void InvalidateRelationSet( const SwFrame* pMaster, const SwFrame* pFollow );
221 
232  void InvalidateParaFlowRelation( const SwTextFrame& _rTextFrame,
233  const bool _bFrom );
234 
236  void InvalidateParaTextSelection( const SwTextFrame& _rTextFrame );
237 
240 
241  sal_Int32 GetChildIndex( const SwFrame& rParentFrame,
242  vcl::Window& rChild ) const;
243 
244  // update preview data (and fire events if necessary)
245  void UpdatePreview( const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
246  const Fraction& _rScale,
247  const SwPageFrame* _pSelectedPageFrame,
248  const Size& _rPreviewWinSize );
249 
250  void InvalidatePreviewSelection( sal_uInt16 nSelPage );
251  bool IsPageSelected( const SwPageFrame *pPageFrame ) const;
252 
253  void FireEvents();
254 
255  const OUString& GetDocName() const { return maDocName; }
256 
257  // IAccessibleViewForwarder
258 
259  virtual tools::Rectangle GetVisibleArea() const override;
260  virtual Point LogicToPixel (const Point& rPoint) const override;
261  virtual Size LogicToPixel (const Size& rSize) const override;
262 
263  // IAccessibleParent
264  virtual bool ReplaceChild (
265  ::accessibility::AccessibleShape* pCurrentChild,
266  const css::uno::Reference< css::drawing::XShape >& _rxShape,
267  const long _nIndex,
268  const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
269  ) override;
270  virtual ::accessibility::AccessibleControlShape* GetAccControlShapeFromModel
271  (css::beans::XPropertySet* pSet) override;
272  virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption (
273  const css::uno::Reference< css::drawing::XShape > & xShape) override;
274 
275  // additional Core/Pixel conversions for internal use; also works
276  // for preview
277  Point PixelToCore (const Point& rPoint) const;
278  tools::Rectangle CoreToPixel (const tools::Rectangle& rRect) const;
279 
280  // is there a known accessibility impl cached for the frame
281  bool Contains(const SwFrame *pFrame) const;
282 
283 private:
301  void GetMapMode( const Point& _rPoint,
302  MapMode& _orMapMode ) const;
303 public:
304  virtual bool IsDocumentSelAll() override;
305 
306  const css::uno::WeakReference < css::accessibility::XAccessible >&
307  GetCursorContext() const { return mxCursorContext; }
308 
309  //Para Container for InvalidateCursorPosition
310  typedef std::set< SwAccessibleParagraph* > SET_PARA;
311  SET_PARA m_setParaAdd;
312  SET_PARA m_setParaRemove;
313 };
314 #endif
315 
316 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
data structure for a preview page in the current preview layout
Definition: prevwpage.hxx:30
Base class of the Writer layout elements.
Definition: frame.hxx:295
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
void InvalidateRelationSet(const SwFrame *pMaster, const SwFrame *pFollow)
Definition: accmap.cxx:2874
std::unique_ptr< SwAccessibleContextMap_Impl > mpFrameMap
Definition: accmap.hxx:94
void InvalidateContent(const SwFrame *pFrame)
Definition: accmap.cxx:2473
virtual tools::Rectangle GetVisibleArea() const override
Definition: accmap.cxx:3070
virtual bool IsDocumentSelAll() override
Definition: accmap.cxx:3509
void RemoveContext(const SwFrame *pFrame)
Definition: accmap.cxx:2145
OUString const maDocName
Definition: accmap.hxx:123
sal_Int32 GetChildIndex(const SwFrame &rParentFrame, vcl::Window &rChild) const
Definition: accmap.cxx:2933
std::unique_ptr< SwAccessibleEventList_Impl > mpEvents
Definition: accmap.hxx:97
SET_PARA m_setParaAdd
Definition: accmap.hxx:311
void InvalidateShapeSelection()
Definition: accmap.cxx:1122
virtual ::accessibility::AccessibleControlShape * GetAccControlShapeFromModel(css::beans::XPropertySet *pSet) override
Definition: accmap.cxx:3189
SwViewShell * mpVSh
Definition: accmap.hxx:102
::osl::Mutex maEventMutex
Definition: accmap.hxx:93
void FireEvents()
Definition: accmap.cxx:3043
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
std::vector< css::uno::Reference< css::drawing::XShape >> SwShapeList_Impl
Definition: accmap.hxx:68
void InvalidatePreviewSelection(sal_uInt16 nSelPage)
Definition: accmap.cxx:3009
mutable::osl::Mutex maMutex
Definition: accmap.hxx:92
void InvalidatePosOrSize(const SwFrame *pFrame, const SdrObject *pObj, vcl::Window *pWindow, const SwRect &rOldFrame)
Definition: accmap.cxx:2336
SwViewShell * GetShell() const
Definition: accmap.hxx:169
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1976
static bool IsInSameLevel(const SdrObject *pObj, const SwFEShell *pFESh)
Definition: accmap.cxx:2048
css::uno::Reference< css::accessibility::XAccessible > GetDocumentPreview(const std::vector< std::unique_ptr< PreviewPage >> &_rPreviewPages, const Fraction &_rScale, const SwPageFrame *_pSelectedPageFrame, const Size &_rPreviewWinSize)
Definition: accmap.cxx:1833
Point PixelToCore(const Point &rPoint) const
Definition: accmap.cxx:3218
void AddShapeContext(const SdrObject *pObj, css::uno::Reference< css::accessibility::XAccessible > const &xAccShape)
Definition: accmap.cxx:2055
void InvalidateParaTextSelection(const SwTextFrame &_rTextFrame)
invalidation of text selection of a paragraph
Definition: accmap.cxx:2889
void FireEvent(const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:901
std::unique_ptr< SwAccessibleEventMap_Impl > mpEventMap
Definition: accmap.hxx:98
virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: accmap.cxx:3213
css::uno::Reference< css::accessibility::XAccessible > GetDocumentView()
Definition: accmap.cxx:1828
Size GetPreviewPageSize(sal_uInt16 _nPreviewPageNum) const
get size of a dedicated preview page
Definition: accmap.cxx:3299
void InvalidateCursorPosition(const css::uno::Reference< css::accessibility::XAccessible > &rAcc)
css::uno::Reference< css::accessibility::XAccessible > GetDocumentView_(bool bPagePreview)
Definition: accmap.cxx:1766
tools::Rectangle CoreToPixel(const tools::Rectangle &rRect) const
Definition: accmap.cxx:3263
const css::uno::WeakReference< css::accessibility::XAccessible > & GetCursorContext() const
Definition: accmap.hxx:307
void GetMapMode(const Point &_rPoint, MapMode &_orMapMode) const
get mapping mode for LogicToPixel and PixelToLogic conversions
Definition: accmap.cxx:3287
const SwRect & GetVisArea() const
Definition: accmap.cxx:3500
virtual ~SwAccessibleMap() override
Definition: accmap.cxx:1702
A page of the document layout.
Definition: pagefrm.hxx:40
void InvalidateFocus()
Definition: accmap.cxx:2759
std::unique_ptr< SwAccessibleShapeMap_Impl > mpShapeMap
Definition: accmap.hxx:95
void A11yDispose(const SwFrame *pFrame, const SdrObject *pObj, vcl::Window *pWindow, bool bRecursive=false, bool bCanSkipInvisible=true)
Definition: accmap.cxx:2210
void AddGroupContext(const SdrObject *pParentObj, css::uno::Reference< css::accessibility::XAccessible > const &xAccParent)
Definition: accmap.cxx:2089
void InvalidateRelationSet_(const SwFrame *pFrame, bool bFrom)
Definition: accmap.cxx:2827
void InvalidateShapeInParaSelection()
Definition: accmap.cxx:1141
void InvalidateAttr(const SwTextFrame &rTextFrame)
Definition: accmap.cxx:2511
virtual bool ReplaceChild(::accessibility::AccessibleShape *pCurrentChild, const css::uno::Reference< css::drawing::XShape > &_rxShape, const long _nIndex, const ::accessibility::AccessibleShapeTreeInfo &_rShapeTreeInfo) override
Definition: accmap.cxx:3112
void InvalidateEditableStates(const SwFrame *_pFrame)
Definition: accmap.cxx:2800
void UpdatePreview(const std::vector< std::unique_ptr< PreviewPage >> &_rPreviewPages, const Fraction &_rScale, const SwPageFrame *_pSelectedPageFrame, const Size &_rPreviewWinSize)
Definition: accmap.cxx:2969
std::unique_ptr< SwAccessibleSelectedParas_Impl > BuildSelectedParas()
method to build up a new data structure of the accessible paragraphs, which have a selection ...
Definition: accmap.cxx:3310
bool Contains(const SwFrame *pFrame) const
Definition: accmap.cxx:2205
virtual Point LogicToPixel(const Point &rPoint) const override
Definition: accmap.cxx:3079
void InvalidateParaFlowRelation(const SwTextFrame &_rTextFrame, const bool _bFrom)
invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph
Definition: accmap.cxx:2882
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1848
const OUString & GetDocName() const
Definition: accmap.hxx:255
SET_PARA m_setParaRemove
Definition: accmap.hxx:312
void SetCursorContext(const ::rtl::Reference< SwAccessibleContext > &rCursorContext)
Definition: accmap.cxx:2792
bool IsPageSelected(const SwPageFrame *pPageFrame) const
Definition: accmap.cxx:3038
std::unique_ptr< SwAccPreviewData > mpPreview
for page preview: store preview data, VisArea, and mapping of preview-to-display coordinates ...
Definition: accmap.hxx:105
SwShapeList_Impl mvShapes
Definition: accmap.hxx:96
std::set< SwAccessibleParagraph * > SET_PARA
Definition: accmap.hxx:310
void InvalidateTextSelectionOfAllParas()
invalidation of text selection of all paragraphs
Definition: accmap.cxx:3399
std::unique_ptr< SwAccessibleContextMap_Impl > mpSeletedFrameMap
Definition: accmap.hxx:121
void RemoveGroupContext(const SdrObject *pParentObj)
Definition: accmap.cxx:2067
void DoInvalidateShapeSelection(bool bInvalidateFocusMode=false)
Definition: accmap.cxx:1483
AccessibleStates
Definition: accmap.hxx:70
bool mbShapeSelected
Definition: accmap.hxx:109
void AppendEvent(const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:983
css::uno::WeakReference< css::accessibility::XAccessible > mxCursorContext
Definition: accmap.hxx:107
std::unique_ptr< SwAccessibleSelectedParas_Impl > mpSelectedParas
Definition: accmap.hxx:101
SwAccessibleMap(SwViewShell *pSh)
Definition: accmap.cxx:1694