Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _ACCMAP_HXX
29 : : #define _ACCMAP_HXX
30 : :
31 : : #include <cppuhelper/weakref.hxx>
32 : : #include <com/sun/star/accessibility/XAccessible.hpp>
33 : : #include <rtl/ref.hxx>
34 : : #include <osl/mutex.hxx>
35 : : #include <svx/IAccessibleViewForwarder.hxx>
36 : : #include <svx/IAccessibleParent.hxx>
37 : : #include <tools/fract.hxx>
38 : :
39 : : #include <vector>
40 : :
41 : : class ViewShell;
42 : : class Rectangle;
43 : : class SwFrm;
44 : : class SwTxtFrm;
45 : : class SwPageFrm;
46 : : class SwAccessibleContext;
47 : : class SwAccessibleContextMap_Impl;
48 : : class SwAccessibleEventList_Impl;
49 : : class SwAccessibleEventMap_Impl;
50 : : class SwShapeList_Impl;
51 : : class SdrObject;
52 : : namespace accessibility {
53 : : class AccessibleShape;
54 : : }
55 : : class SwAccessibleShapeMap_Impl;
56 : : struct SwAccessibleEvent_Impl;
57 : : class SwAccessibleSelectedParas_Impl;
58 : : class SwRect;
59 : : class MapMode;
60 : : class SwAccPreviewData;
61 : : struct PrevwPage;
62 : : class Window;
63 : :
64 : : // real states for events
65 : : #define ACC_STATE_EDITABLE 0x01
66 : : #define ACC_STATE_OPAQUE 0x02
67 : :
68 : : // pseudo states for events
69 : : #define ACC_STATE_TEXT_ATTRIBUTE_CHANGED 0x0200
70 : : #define ACC_STATE_TEXT_SELECTION_CHANGED 0x0100
71 : : #define ACC_STATE_CARET 0x80
72 : : #define ACC_STATE_RELATION_FROM 0x40
73 : : #define ACC_STATE_RELATION_TO 0x20
74 : :
75 : : #define ACC_STATE_RELATION_MASK 0x60
76 : :
77 : : #define ACC_STATE_MASK 0x1F
78 : :
79 : : typedef sal_uInt16 tAccessibleStates;
80 : :
81 : : class SwAccessibleMap : public accessibility::IAccessibleViewForwarder,
82 : : public accessibility::IAccessibleParent
83 : : {
84 : : mutable ::osl::Mutex maMutex;
85 : : ::osl::Mutex maEventMutex;
86 : : SwAccessibleContextMap_Impl *mpFrmMap;
87 : : SwAccessibleShapeMap_Impl *mpShapeMap;
88 : : SwShapeList_Impl *mpShapes;
89 : : SwAccessibleEventList_Impl *mpEvents;
90 : : SwAccessibleEventMap_Impl *mpEventMap;
91 : : // #i27301 data structure to keep information about
92 : : // accessible paragraph, which have a selection.
93 : : SwAccessibleSelectedParas_Impl* mpSelectedParas;
94 : : ViewShell *mpVSh;
95 : : /// for page preview: store preview data, VisArea, and mapping of
96 : : /// preview-to-display coordinates
97 : : SwAccPreviewData* mpPreview;
98 : :
99 : : ::com::sun::star::uno::WeakReference < ::com::sun::star::accessibility::XAccessible > mxCursorContext;
100 : :
101 : : sal_Int32 mnPara;
102 : : sal_Int32 mnFootnote;
103 : : sal_Int32 mnEndnote;
104 : :
105 : :
106 : : sal_Bool mbShapeSelected;
107 : :
108 : : void FireEvent( const SwAccessibleEvent_Impl& rEvent );
109 : :
110 : : void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
111 : :
112 : : void InvalidateCursorPosition(
113 : : const ::com::sun::star::uno::Reference<
114 : : ::com::sun::star::accessibility::XAccessible>& rAcc );
115 : : void DoInvalidateShapeSelection();
116 : : void DoInvalidateShapeFocus();
117 : : void InvalidateShapeSelection();
118 : :
119 : : void _InvalidateRelationSet( const SwFrm* pFrm, sal_Bool bFrom );
120 : :
121 : : ::com::sun::star::uno::Reference<
122 : : ::com::sun::star::accessibility::XAccessible>
123 : : _GetDocumentView( sal_Bool bPagePreview );
124 : :
125 : : /** method to build up a new data structure of the accessible pararaphs,
126 : : which have a selection
127 : :
128 : : Important note: method has to used inside a mutual exclusive section
129 : :
130 : : @author OD
131 : : */
132 : : SwAccessibleSelectedParas_Impl* _BuildSelectedParas();
133 : :
134 : : public:
135 : :
136 : : SwAccessibleMap( ViewShell *pSh );
137 : : ~SwAccessibleMap();
138 : :
139 : : ::com::sun::star::uno::Reference<
140 : : ::com::sun::star::accessibility::XAccessible> GetDocumentView();
141 : :
142 : : ::com::sun::star::uno::Reference<
143 : : ::com::sun::star::accessibility::XAccessible> GetDocumentPreview(
144 : : const std::vector<PrevwPage*>& _rPrevwPages,
145 : : const Fraction& _rScale,
146 : : const SwPageFrm* _pSelectedPageFrm,
147 : : const Size& _rPrevwWinSize );
148 : :
149 : : ::rtl::Reference < SwAccessibleContext > GetContextImpl(
150 : : const SwFrm *pFrm,
151 : : sal_Bool bCreate = sal_True );
152 : : ::com::sun::star::uno::Reference<
153 : : ::com::sun::star::accessibility::XAccessible> GetContext(
154 : : const SwFrm *pFrm,
155 : : sal_Bool bCreate = sal_True );
156 : :
157 : : ::rtl::Reference < ::accessibility::AccessibleShape > GetContextImpl(
158 : : const SdrObject *pObj,
159 : : SwAccessibleContext *pParentImpl,
160 : : sal_Bool bCreate = sal_True );
161 : : ::com::sun::star::uno::Reference<
162 : : ::com::sun::star::accessibility::XAccessible> GetContext(
163 : : const SdrObject *pObj,
164 : : SwAccessibleContext *pParentImpl,
165 : : sal_Bool bCreate = sal_True );
166 : :
167 : 37072 : inline ViewShell* GetShell() const
168 : : {
169 : 37072 : return mpVSh;
170 : : }
171 : :
172 : : const SwRect& GetVisArea() const;
173 : :
174 : : /** get size of a dedicated preview page
175 : :
176 : : @author OD
177 : :
178 : : @param _nPrevwPageNum
179 : : input parameter - physical page number of page visible in the page preview
180 : :
181 : : @return an object of class <Size>
182 : : */
183 : : Size GetPreViewPageSize( sal_uInt16 _nPrevwPageNum ) const;
184 : :
185 : : void RemoveContext( const SwFrm *pFrm );
186 : : void RemoveContext( const SdrObject *pObj );
187 : :
188 : : // Dispose frame and its children if bRecursive is set
189 : : void Dispose( const SwFrm* pFrm,
190 : : const SdrObject* pObj,
191 : : Window* pWindow,
192 : : sal_Bool bRecursive = sal_False );
193 : :
194 : : void InvalidatePosOrSize( const SwFrm* pFrm,
195 : : const SdrObject* pObj,
196 : : Window* pWindow,
197 : : const SwRect& rOldFrm );
198 : :
199 : : void InvalidateContent( const SwFrm *pFrm );
200 : :
201 : : void InvalidateAttr( const SwTxtFrm& rTxtFrm );
202 : :
203 : : void InvalidateCursorPosition( const SwFrm *pFrm );
204 : : void InvalidateFocus();
205 : :
206 : : void SetCursorContext(
207 : : const ::rtl::Reference < SwAccessibleContext >& rCursorContext );
208 : :
209 : : // Invalidate state of whole tree. If an action is open, this call
210 : : // is processed when the last action ends.
211 : : void InvalidateStates( tAccessibleStates _nStates,
212 : : const SwFrm* _pFrm = 0 );
213 : :
214 : : void InvalidateRelationSet( const SwFrm* pMaster, const SwFrm* pFollow );
215 : :
216 : : /** invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph
217 : :
218 : : @author OD
219 : :
220 : : @param _rTxtFrm
221 : : input parameter - reference to paragraph, whose CONTENT_FLOWS_FROM/_TO
222 : : has to be invalidated.
223 : :
224 : : @param _bFrom
225 : : input parameter - boolean indicating, if relation CONTENT_FLOWS_FROM
226 : : (value <true>) or CONTENT_FLOWS_TO (value <false>) has to be invalidated.
227 : : */
228 : : void InvalidateParaFlowRelation( const SwTxtFrm& _rTxtFrm,
229 : : const bool _bFrom );
230 : :
231 : : /** invalidation of text selection of a paragraph
232 : :
233 : : @author OD
234 : : */
235 : : void InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm );
236 : :
237 : : /** invalidation of text selection of all paragraphs
238 : :
239 : : @author OD
240 : : */
241 : : void InvalidateTextSelectionOfAllParas();
242 : :
243 : : sal_Int32 GetChildIndex( const SwFrm& rParentFrm,
244 : : Window& rChild ) const;
245 : :
246 : : // update preview data (and fire events if necessary)
247 : : void UpdatePreview( const std::vector<PrevwPage*>& _rPrevwPages,
248 : : const Fraction& _rScale,
249 : : const SwPageFrm* _pSelectedPageFrm,
250 : : const Size& _rPrevwWinSize );
251 : :
252 : : void InvalidatePreViewSelection( sal_uInt16 nSelPage );
253 : : sal_Bool IsPageSelected( const SwPageFrm *pPageFrm ) const;
254 : :
255 : : void FireEvents();
256 : :
257 : :
258 : : // IAccessibleViewForwarder
259 : :
260 : : virtual sal_Bool IsValid() const;
261 : : virtual Rectangle GetVisibleArea() const;
262 : : virtual Point LogicToPixel (const Point& rPoint) const;
263 : : virtual Size LogicToPixel (const Size& rSize) const;
264 : : virtual Point PixelToLogic (const Point& rPoint) const;
265 : : virtual Size PixelToLogic (const Size& rSize) const;
266 : :
267 : : // IAccessibleParent
268 : : virtual sal_Bool ReplaceChild (
269 : : ::accessibility::AccessibleShape* pCurrentChild,
270 : : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
271 : : const long _nIndex,
272 : : const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
273 : : ) throw (::com::sun::star::uno::RuntimeException);
274 : :
275 : : // additional Core/Pixel conversions for internal use; also works
276 : : // for preview
277 : : Point PixelToCore (const Point& rPoint) const;
278 : : Rectangle CoreToPixel (const Rectangle& rRect) const;
279 : :
280 : : private:
281 : : /** get mapping mode for LogicToPixel and PixelToLogic conversions
282 : :
283 : : Replacement method <PreviewAdjust(..)> by new method <GetMapMode>.
284 : : Method returns mapping mode of current output device and adjusts it,
285 : : if the shell is in page/print preview.
286 : : Necessary, because <PreviewAdjust(..)> changes mapping mode at current
287 : : output device for mapping logic document positions to page preview window
288 : : positions and vice versa and doesn't take care to recover its changes.
289 : :
290 : : @author OD
291 : :
292 : : @param _rPoint
293 : : input parameter - constant reference to point to determine the mapping
294 : : mode adjustments for page/print preview.
295 : :
296 : : @param _orMapMode
297 : : output parameter - reference to the mapping mode, which is determined
298 : : by the method
299 : : */
300 : : void GetMapMode( const Point& _rPoint,
301 : : MapMode& _orMapMode ) const;
302 : : };
303 : : #endif
304 : :
305 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|