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
23#include <rtl/ref.hxx>
24#include <osl/mutex.hxx>
27
30
31#include <vector>
32#include <memory>
34
36class SwViewShell;
37class SwFrame;
38class SwTextFrame;
39class SwPageFrame;
44class SdrObject;
45namespace accessibility { class AccessibleShape; }
49class SwRect;
50class MapMode;
52class SwFEShell;
53class Fraction;
54struct PreviewPage;
55namespace vcl { class Window; }
56namespace com::sun::star::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::SwClientNotify. 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.
68using SwShapeList_Impl = std::vector<css::uno::Reference<css::drawing::XShape>>;
69
71{
72 NONE = 0x0000,
73 // real states for events
74 EDITABLE = 0x0001,
75 OPAQUE = 0x0002,
76 // pseudo states for events
79 CARET = 0x0080,
80 RELATION_FROM = 0x0040,
81 RELATION_TO = 0x0020,
82};
83namespace 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
100 // Para Container for InvalidateCursorPosition
103
104 // #i27301 data structure to keep information about
105 // accessible paragraph, which have a selection.
106 std::unique_ptr<SwAccessibleSelectedParas_Impl> mpSelectedParas;
110 std::unique_ptr<SwAccPreviewData> mpPreview;
111
112 css::uno::WeakReference < css::accessibility::XAccessible > mxCursorContext;
113
115
116 void FireEvent( const SwAccessibleEvent_Impl& rEvent );
117
118 void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
119
120 void InvalidateCursorPosition( const css::uno::Reference<css::accessibility::XAccessible>& rAcc );
121 void DoInvalidateShapeSelection(bool bInvalidateFocusMode = false);
122
124
125 //mpSelectedFrameMap contains the old selected objects.
126 std::unique_ptr<SwAccessibleContextMap_Impl> mpSelectedFrameMap;
127
128 OUString maDocName;
129
130 //InvalidateShapeInParaSelection() method is responsible for the updating the selected states of the objects.
132
133 void InvalidateRelationSet_( const SwFrame* pFrame, bool bFrom );
134
135 css::uno::Reference<css::accessibility::XAccessible>
136 GetDocumentView_( bool bPagePreview );
137
143 std::unique_ptr<SwAccessibleSelectedParas_Impl> BuildSelectedParas();
144
145public:
146
148 virtual ~SwAccessibleMap() override;
149
150 css::uno::Reference<css::accessibility::XAccessible> GetDocumentView();
151
152 css::uno::Reference<css::accessibility::XAccessible> GetDocumentPreview(
153 const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
154 const Fraction& _rScale,
155 const SwPageFrame* _pSelectedPageFrame,
156 const Size& _rPreviewWinSize );
157
159 const SwFrame *pFrame,
160 bool bCreate = true );
161 css::uno::Reference<css::accessibility::XAccessible> GetContext(
162 const SwFrame *pFrame,
163 bool bCreate = true );
164
166 const SdrObject *pObj,
167 SwAccessibleContext *pParentImpl,
168 bool bCreate = true );
169 css::uno::Reference<css::accessibility::XAccessible> GetContext(
170 const SdrObject *pObj,
171 SwAccessibleContext *pParentImpl,
172 bool bCreate = true );
173
175 {
176 return mpVSh;
177 }
178 static bool IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh);
179 void AddShapeContext(const SdrObject *pObj,
180 css::uno::Reference < css::accessibility::XAccessible > const & xAccShape);
181
182 void AddGroupContext(const SdrObject *pParentObj,
183 css::uno::Reference < css::accessibility::XAccessible > const & xAccParent);
184 void RemoveGroupContext(const SdrObject *pParentObj);
185
186 const SwRect& GetVisArea() const;
187
195 Size GetPreviewPageSize( sal_uInt16 _nPreviewPageNum ) const;
196
197 void RemoveContext( const SwFrame *pFrame );
198 void RemoveContext( const SdrObject *pObj );
199
200 // Dispose frame and its children if bRecursive is set
201 void A11yDispose( const SwFrame* pFrame,
202 const SdrObject* pObj,
203 vcl::Window* pWindow,
204 bool bRecursive = false,
205 bool bCanSkipInvisible = true );
206
207 void InvalidatePosOrSize( const SwFrame* pFrame,
208 const SdrObject* pObj,
209 vcl::Window* pWindow,
210 const SwRect& rOldFrame );
211
212 void InvalidateContent( const SwFrame *pFrame );
213
214 void InvalidateAttr( const SwTextFrame& rTextFrame );
215
216 void InvalidateCursorPosition( const SwFrame *pFrame );
217 void InvalidateFocus();
218 void SetCursorContext(
219 const ::rtl::Reference < SwAccessibleContext >& rCursorContext );
220
221 // Invalidate state of whole tree. If an action is open, this call
222 // is processed when the last action ends.
223 void InvalidateEditableStates( const SwFrame* _pFrame );
224
225 void InvalidateRelationSet( const SwFrame* pMaster, const SwFrame* pFollow );
226
237 void InvalidateParaFlowRelation( const SwTextFrame& _rTextFrame,
238 const bool _bFrom );
239
241 void InvalidateParaTextSelection( const SwTextFrame& _rTextFrame );
242
245
246 sal_Int32 GetChildIndex( const SwFrame& rParentFrame,
247 vcl::Window& rChild ) const;
248
249 // update preview data (and fire events if necessary)
250 void UpdatePreview( const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
251 const Fraction& _rScale,
252 const SwPageFrame* _pSelectedPageFrame,
253 const Size& _rPreviewWinSize );
254
255 void InvalidatePreviewSelection( sal_uInt16 nSelPage );
256 bool IsPageSelected( const SwPageFrame *pPageFrame ) const;
257
258 void FireEvents();
259
260 const OUString& GetDocName() const { return maDocName; }
261
262 // IAccessibleViewForwarder
263
264 virtual tools::Rectangle GetVisibleArea() const override;
265 virtual Point LogicToPixel (const Point& rPoint) const override;
266 virtual Size LogicToPixel (const Size& rSize) const override;
267
268 // IAccessibleParent
269 virtual bool ReplaceChild (
271 const css::uno::Reference< css::drawing::XShape >& _rxShape,
272 const tools::Long _nIndex,
273 const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
274 ) override;
275 virtual ::accessibility::AccessibleControlShape* GetAccControlShapeFromModel
276 (css::beans::XPropertySet* pSet) override;
277 virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption (
278 const css::uno::Reference< css::drawing::XShape > & xShape) override;
279
280 // additional Core/Pixel conversions for internal use; also works
281 // for preview
282 Point PixelToCore (const Point& rPoint) const;
283 tools::Rectangle CoreToPixel (const SwRect& rRect) const;
284
285 // is there a known accessibility impl cached for the frame
286 bool Contains(const SwFrame *pFrame) const;
287
288private:
306 void GetMapMode( const Point& _rPoint,
307 MapMode& _orMapMode ) const;
308public:
309 virtual bool IsDocumentSelAll() override;
310};
311#endif
312
313/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AccessibleStates
Definition: accmap.hxx:71
std::vector< css::uno::Reference< css::drawing::XShape > > SwShapeList_Impl
Definition: accmap.hxx:68
virtual tools::Rectangle GetVisibleArea() const override
Definition: accmap.cxx:3006
std::unique_ptr< SwAccessibleShapeMap_Impl > mpShapeMap
Definition: accmap.hxx:95
void AddShapeContext(const SdrObject *pObj, css::uno::Reference< css::accessibility::XAccessible > const &xAccShape)
Definition: accmap.cxx:1991
void InvalidateRelationSet(const SwFrame *pMaster, const SwFrame *pFollow)
Definition: accmap.cxx:2810
const OUString & GetDocName() const
Definition: accmap.hxx:260
o3tl::sorted_vector< SwAccessibleParagraph * > m_setParaAdd
Definition: accmap.hxx:101
void InvalidateShapeInParaSelection()
Definition: accmap.cxx:1131
tools::Rectangle CoreToPixel(const SwRect &rRect) const
Definition: accmap.cxx:3191
void InvalidatePosOrSize(const SwFrame *pFrame, const SdrObject *pObj, vcl::Window *pWindow, const SwRect &rOldFrame)
Definition: accmap.cxx:2272
std::unique_ptr< SwAccessibleSelectedParas_Impl > mpSelectedParas
Definition: accmap.hxx:106
SwViewShell * mpVSh
Definition: accmap.hxx:107
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:3238
std::unique_ptr< SwAccessibleContextMap_Impl > mpFrameMap
Definition: accmap.hxx:94
std::unique_ptr< SwAccessibleEventMap_Impl > mpEventMap
Definition: accmap.hxx:98
mutable::osl::Mutex maMutex
Definition: accmap.hxx:92
void UpdatePreview(const std::vector< std::unique_ptr< PreviewPage > > &_rPreviewPages, const Fraction &_rScale, const SwPageFrame *_pSelectedPageFrame, const Size &_rPreviewWinSize)
Definition: accmap.cxx:2905
void InvalidateParaTextSelection(const SwTextFrame &_rTextFrame)
invalidation of text selection of a paragraph
Definition: accmap.cxx:2825
void InvalidateCursorPosition(const css::uno::Reference< css::accessibility::XAccessible > &rAcc)
void InvalidatePreviewSelection(sal_uInt16 nSelPage)
Definition: accmap.cxx:2945
void InvalidateRelationSet_(const SwFrame *pFrame, bool bFrom)
Definition: accmap.cxx:2763
void FireEvent(const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:891
::osl::Mutex maEventMutex
Definition: accmap.hxx:93
virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: accmap.cxx:3141
bool Contains(const SwFrame *pFrame) const
Definition: accmap.cxx:2141
void InvalidateEditableStates(const SwFrame *_pFrame)
Definition: accmap.cxx:2736
o3tl::sorted_vector< SwAccessibleParagraph * > m_setParaRemove
Definition: accmap.hxx:102
SwAccessibleMap(SwViewShell *pSh)
Definition: accmap.cxx:1630
void SetCursorContext(const ::rtl::Reference< SwAccessibleContext > &rCursorContext)
Definition: accmap.cxx:2728
void GetMapMode(const Point &_rPoint, MapMode &_orMapMode) const
get mapping mode for LogicToPixel and PixelToLogic conversions
Definition: accmap.cxx:3215
SwShapeList_Impl mvShapes
Definition: accmap.hxx:96
css::uno::WeakReference< css::accessibility::XAccessible > mxCursorContext
Definition: accmap.hxx:112
virtual bool ReplaceChild(::accessibility::AccessibleShape *pCurrentChild, const css::uno::Reference< css::drawing::XShape > &_rxShape, const tools::Long _nIndex, const ::accessibility::AccessibleShapeTreeInfo &_rShapeTreeInfo) override
Definition: accmap.cxx:3040
static bool IsInSameLevel(const SdrObject *pObj, const SwFEShell *pFESh)
Definition: accmap.cxx:1984
void A11yDispose(const SwFrame *pFrame, const SdrObject *pObj, vcl::Window *pWindow, bool bRecursive=false, bool bCanSkipInvisible=true)
Definition: accmap.cxx:2146
void RemoveGroupContext(const SdrObject *pParentObj)
Definition: accmap.cxx:2003
virtual bool IsDocumentSelAll() override
Definition: accmap.cxx:3435
void InvalidateAttr(const SwTextFrame &rTextFrame)
Definition: accmap.cxx:2447
virtual ~SwAccessibleMap() override
Definition: accmap.cxx:1638
std::unique_ptr< SwAccPreviewData > mpPreview
for page preview: store preview data, VisArea, and mapping of preview-to-display coordinates
Definition: accmap.hxx:110
std::unique_ptr< SwAccessibleEventList_Impl > mpEvents
Definition: accmap.hxx:97
sal_Int32 GetChildIndex(const SwFrame &rParentFrame, vcl::Window &rChild) const
Definition: accmap.cxx:2869
OUString maDocName
Definition: accmap.hxx:128
bool mbShapeSelected
Definition: accmap.hxx:114
css::uno::Reference< css::accessibility::XAccessible > GetDocumentView_(bool bPagePreview)
Definition: accmap.cxx:1702
void InvalidateContent(const SwFrame *pFrame)
Definition: accmap.cxx:2409
Size GetPreviewPageSize(sal_uInt16 _nPreviewPageNum) const
get size of a dedicated preview page
Definition: accmap.cxx:3227
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:1769
Point PixelToCore(const Point &rPoint) const
Definition: accmap.cxx:3146
void InvalidateShapeSelection()
Definition: accmap.cxx:1112
css::uno::Reference< css::accessibility::XAccessible > GetDocumentView()
Definition: accmap.cxx:1764
void DoInvalidateShapeSelection(bool bInvalidateFocusMode=false)
Definition: accmap.cxx:1467
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1912
virtual ::accessibility::AccessibleControlShape * GetAccControlShapeFromModel(css::beans::XPropertySet *pSet) override
Definition: accmap.cxx:3117
void FireEvents()
Definition: accmap.cxx:2979
void InvalidateFocus()
Definition: accmap.cxx:2695
void AppendEvent(const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:973
void InvalidateParaFlowRelation(const SwTextFrame &_rTextFrame, const bool _bFrom)
invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph
Definition: accmap.cxx:2818
const SwRect & GetVisArea() const
Definition: accmap.cxx:3426
void RemoveContext(const SwFrame *pFrame)
Definition: accmap.cxx:2081
void InvalidateTextSelectionOfAllParas()
invalidation of text selection of all paragraphs
Definition: accmap.cxx:3327
bool IsPageSelected(const SwPageFrame *pPageFrame) const
Definition: accmap.cxx:2974
std::unique_ptr< SwAccessibleContextMap_Impl > mpSelectedFrameMap
Definition: accmap.hxx:126
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1784
void AddGroupContext(const SdrObject *pParentObj, css::uno::Reference< css::accessibility::XAccessible > const &xAccParent)
Definition: accmap.cxx:2025
virtual Point LogicToPixel(const Point &rPoint) const override
Definition: accmap.cxx:3013
SwViewShell * GetShell() const
Definition: accmap.hxx:174
Base class of the Writer layout elements.
Definition: frame.hxx:315
A page of the document layout.
Definition: pagefrm.hxx:58
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:163
NONE
long Long
data structure for a preview page in the current preview layout
Definition: prevwpage.hxx:31
#define OPAQUE
@ TEXT_SELECTION_CHANGED