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 ::osl::Mutex maEventMutex;
93 std::unique_ptr<SwAccessibleContextMap_Impl> mpFrameMap;
94 std::unique_ptr<SwAccessibleShapeMap_Impl> mpShapeMap;
96 std::unique_ptr<SwAccessibleEventList_Impl> mpEvents;
97 std::unique_ptr<SwAccessibleEventMap_Impl> mpEventMap;
98
99 // Para Container for InvalidateCursorPosition
102
103 // #i27301 data structure to keep information about
104 // accessible paragraph, which have a selection.
105 std::unique_ptr<SwAccessibleSelectedParas_Impl> mpSelectedParas;
109 std::unique_ptr<SwAccPreviewData> mpPreview;
110
111 css::uno::WeakReference < css::accessibility::XAccessible > mxCursorContext;
112
114
115 void FireEvent( const SwAccessibleEvent_Impl& rEvent );
116
117 void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
118
119 void InvalidateCursorPosition( const css::uno::Reference<css::accessibility::XAccessible>& rAcc );
120 void DoInvalidateShapeSelection(bool bInvalidateFocusMode = false);
121
123
124 //mpSelectedFrameMap contains the old selected objects.
125 std::unique_ptr<SwAccessibleContextMap_Impl> mpSelectedFrameMap;
126
127 OUString maDocName;
128
129 //InvalidateShapeInParaSelection() method is responsible for the updating the selected states of the objects.
131
132 void InvalidateRelationSet_( const SwFrame* pFrame, bool bFrom );
133
134 css::uno::Reference<css::accessibility::XAccessible>
135 GetDocumentView_( bool bPagePreview );
136
142 std::unique_ptr<SwAccessibleSelectedParas_Impl> BuildSelectedParas();
143
144public:
145
147 virtual ~SwAccessibleMap() override;
148
149 css::uno::Reference<css::accessibility::XAccessible> GetDocumentView();
150
151 css::uno::Reference<css::accessibility::XAccessible> GetDocumentPreview(
152 const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
153 const Fraction& _rScale,
154 const SwPageFrame* _pSelectedPageFrame,
155 const Size& _rPreviewWinSize );
156
158 const SwFrame *pFrame,
159 bool bCreate = true );
160 css::uno::Reference<css::accessibility::XAccessible> GetContext(
161 const SwFrame *pFrame,
162 bool bCreate = true );
163
165 const SdrObject *pObj,
166 SwAccessibleContext *pParentImpl,
167 bool bCreate = true );
168 css::uno::Reference<css::accessibility::XAccessible> GetContext(
169 const SdrObject *pObj,
170 SwAccessibleContext *pParentImpl,
171 bool bCreate = true );
172
174 {
175 return mpVSh;
176 }
177 static bool IsInSameLevel(const SdrObject* pObj, const SwFEShell* pFESh);
178 void AddShapeContext(const SdrObject *pObj,
179 css::uno::Reference < css::accessibility::XAccessible > const & xAccShape);
180
181 void AddGroupContext(const SdrObject *pParentObj,
182 css::uno::Reference < css::accessibility::XAccessible > const & xAccParent);
183 void RemoveGroupContext(const SdrObject *pParentObj);
184
185 const SwRect& GetVisArea() const;
186
194 Size GetPreviewPageSize( sal_uInt16 _nPreviewPageNum ) const;
195
196 void RemoveContext( const SwFrame *pFrame );
197 void RemoveContext( const SdrObject *pObj );
198
199 // Dispose frame and its children if bRecursive is set
200 void A11yDispose( const SwFrame* pFrame,
201 const SdrObject* pObj,
202 vcl::Window* pWindow,
203 bool bRecursive = false,
204 bool bCanSkipInvisible = true );
205
206 void InvalidatePosOrSize( const SwFrame* pFrame,
207 const SdrObject* pObj,
208 vcl::Window* pWindow,
209 const SwRect& rOldFrame );
210
211 void InvalidateContent( const SwFrame *pFrame );
212
213 void InvalidateAttr( const SwTextFrame& rTextFrame );
214
215 void InvalidateCursorPosition( const SwFrame *pFrame );
216 void InvalidateFocus();
217 void SetCursorContext(
218 const ::rtl::Reference < SwAccessibleContext >& rCursorContext );
219
220 // Invalidate state of whole tree. If an action is open, this call
221 // is processed when the last action ends.
222 void InvalidateEditableStates( const SwFrame* _pFrame );
223
224 void InvalidateRelationSet( const SwFrame* pMaster, const SwFrame* pFollow );
225
236 void InvalidateParaFlowRelation( const SwTextFrame& _rTextFrame,
237 const bool _bFrom );
238
240 void InvalidateParaTextSelection( const SwTextFrame& _rTextFrame );
241
244
245 sal_Int32 GetChildIndex( const SwFrame& rParentFrame,
246 vcl::Window& rChild ) const;
247
248 // update preview data (and fire events if necessary)
249 void UpdatePreview( const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
250 const Fraction& _rScale,
251 const SwPageFrame* _pSelectedPageFrame,
252 const Size& _rPreviewWinSize );
253
254 void InvalidatePreviewSelection( sal_uInt16 nSelPage );
255 bool IsPageSelected( const SwPageFrame *pPageFrame ) const;
256
257 void FireEvents();
258
259 const OUString& GetDocName() const { return maDocName; }
260
261 // IAccessibleViewForwarder
262
263 virtual tools::Rectangle GetVisibleArea() const override;
264 virtual Point LogicToPixel (const Point& rPoint) const override;
265 virtual Size LogicToPixel (const Size& rSize) const override;
266
267 // IAccessibleParent
268 virtual bool ReplaceChild (
270 const css::uno::Reference< css::drawing::XShape >& _rxShape,
271 const tools::Long _nIndex,
272 const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
273 ) override;
274 virtual ::accessibility::AccessibleControlShape* GetAccControlShapeFromModel
275 (css::beans::XPropertySet* pSet) override;
276 virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption (
277 const css::uno::Reference< css::drawing::XShape > & xShape) override;
278
279 // additional Core/Pixel conversions for internal use; also works
280 // for preview
281 Point PixelToCore (const Point& rPoint) const;
282 tools::Rectangle CoreToPixel (const SwRect& rRect) const;
283
284 // is there a known accessibility impl cached for the frame
285 bool Contains(const SwFrame *pFrame) const;
286
287private:
305 void GetMapMode( const Point& _rPoint,
306 MapMode& _orMapMode ) const;
307public:
308 virtual bool IsDocumentSelAll() override;
309};
310#endif
311
312/* 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:2994
std::unique_ptr< SwAccessibleShapeMap_Impl > mpShapeMap
Definition: accmap.hxx:94
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:2812
const OUString & GetDocName() const
Definition: accmap.hxx:259
o3tl::sorted_vector< SwAccessibleParagraph * > m_setParaAdd
Definition: accmap.hxx:100
void InvalidateShapeInParaSelection()
Definition: accmap.cxx:1145
tools::Rectangle CoreToPixel(const SwRect &rRect) const
Definition: accmap.cxx:3174
void InvalidatePosOrSize(const SwFrame *pFrame, const SdrObject *pObj, vcl::Window *pWindow, const SwRect &rOldFrame)
Definition: accmap.cxx:2280
std::unique_ptr< SwAccessibleSelectedParas_Impl > mpSelectedParas
Definition: accmap.hxx:105
SwViewShell * mpVSh
Definition: accmap.hxx:106
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:3221
std::unique_ptr< SwAccessibleContextMap_Impl > mpFrameMap
Definition: accmap.hxx:93
std::unique_ptr< SwAccessibleEventMap_Impl > mpEventMap
Definition: accmap.hxx:97
void UpdatePreview(const std::vector< std::unique_ptr< PreviewPage > > &_rPreviewPages, const Fraction &_rScale, const SwPageFrame *_pSelectedPageFrame, const Size &_rPreviewWinSize)
Definition: accmap.cxx:2904
void InvalidateParaTextSelection(const SwTextFrame &_rTextFrame)
invalidation of text selection of a paragraph
Definition: accmap.cxx:2827
void InvalidateCursorPosition(const css::uno::Reference< css::accessibility::XAccessible > &rAcc)
void InvalidatePreviewSelection(sal_uInt16 nSelPage)
Definition: accmap.cxx:2940
void InvalidateRelationSet_(const SwFrame *pFrame, bool bFrom)
Definition: accmap.cxx:2767
void FireEvent(const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:898
::osl::Mutex maEventMutex
Definition: accmap.hxx:92
virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessibleCaption(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: accmap.cxx:3124
bool Contains(const SwFrame *pFrame) const
Definition: accmap.cxx:2149
void InvalidateEditableStates(const SwFrame *_pFrame)
Definition: accmap.cxx:2740
o3tl::sorted_vector< SwAccessibleParagraph * > m_setParaRemove
Definition: accmap.hxx:101
SwAccessibleMap(SwViewShell *pSh)
Definition: accmap.cxx:1642
void SetCursorContext(const ::rtl::Reference< SwAccessibleContext > &rCursorContext)
Definition: accmap.cxx:2732
void GetMapMode(const Point &_rPoint, MapMode &_orMapMode) const
get mapping mode for LogicToPixel and PixelToLogic conversions
Definition: accmap.cxx:3198
SwShapeList_Impl mvShapes
Definition: accmap.hxx:95
css::uno::WeakReference< css::accessibility::XAccessible > mxCursorContext
Definition: accmap.hxx:111
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:3028
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:2154
void RemoveGroupContext(const SdrObject *pParentObj)
Definition: accmap.cxx:2002
virtual bool IsDocumentSelAll() override
Definition: accmap.cxx:3417
void InvalidateAttr(const SwTextFrame &rTextFrame)
Definition: accmap.cxx:2451
virtual ~SwAccessibleMap() override
Definition: accmap.cxx:1650
std::unique_ptr< SwAccPreviewData > mpPreview
for page preview: store preview data, VisArea, and mapping of preview-to-display coordinates
Definition: accmap.hxx:109
std::unique_ptr< SwAccessibleEventList_Impl > mpEvents
Definition: accmap.hxx:96
sal_Int32 GetChildIndex(const SwFrame &rParentFrame, vcl::Window &rChild) const
Definition: accmap.cxx:2869
OUString maDocName
Definition: accmap.hxx:127
bool mbShapeSelected
Definition: accmap.hxx:113
css::uno::Reference< css::accessibility::XAccessible > GetDocumentView_(bool bPagePreview)
Definition: accmap.cxx:1709
void InvalidateContent(const SwFrame *pFrame)
Definition: accmap.cxx:2415
Size GetPreviewPageSize(sal_uInt16 _nPreviewPageNum) const
get size of a dedicated preview page
Definition: accmap.cxx:3210
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:1774
Point PixelToCore(const Point &rPoint) const
Definition: accmap.cxx:3129
void InvalidateShapeSelection()
Definition: accmap.cxx:1126
css::uno::Reference< css::accessibility::XAccessible > GetDocumentView()
Definition: accmap.cxx:1769
void DoInvalidateShapeSelection(bool bInvalidateFocusMode=false)
Definition: accmap.cxx:1480
::rtl::Reference< SwAccessibleContext > GetContextImpl(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1914
virtual ::accessibility::AccessibleControlShape * GetAccControlShapeFromModel(css::beans::XPropertySet *pSet) override
Definition: accmap.cxx:3100
void FireEvents()
Definition: accmap.cxx:2970
void InvalidateFocus()
Definition: accmap.cxx:2702
void AppendEvent(const SwAccessibleEvent_Impl &rEvent)
Definition: accmap.cxx:980
void InvalidateParaFlowRelation(const SwTextFrame &_rTextFrame, const bool _bFrom)
invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph
Definition: accmap.cxx:2820
const SwRect & GetVisArea() const
Definition: accmap.cxx:3408
void RemoveContext(const SwFrame *pFrame)
Definition: accmap.cxx:2082
void InvalidateTextSelectionOfAllParas()
invalidation of text selection of all paragraphs
Definition: accmap.cxx:3309
bool IsPageSelected(const SwPageFrame *pPageFrame) const
Definition: accmap.cxx:2965
std::unique_ptr< SwAccessibleContextMap_Impl > mpSelectedFrameMap
Definition: accmap.hxx:125
css::uno::Reference< css::accessibility::XAccessible > GetContext(const SwFrame *pFrame, bool bCreate=true)
Definition: accmap.cxx:1789
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:3001
SwViewShell * GetShell() const
Definition: accmap.hxx:173
Base class of the Writer layout elements.
Definition: frame.hxx:315
A page of the document layout.
Definition: pagefrm.hxx:60
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:168
NONE
long Long
data structure for a preview page in the current preview layout
Definition: prevwpage.hxx:31
#define OPAQUE
@ TEXT_SELECTION_CHANGED