xref: /aoo42x/main/sw/inc/accmap.hxx (revision 1d2dbeb0)
1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _ACCMAP_HXX
24cdf0e10cSrcweir #define _ACCMAP_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
27cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
28cdf0e10cSrcweir #include <vos/ref.hxx>
29cdf0e10cSrcweir #include <vos/mutex.hxx>
30cdf0e10cSrcweir #include <svx/IAccessibleViewForwarder.hxx>
31cdf0e10cSrcweir #include <svx/IAccessibleParent.hxx>
32cdf0e10cSrcweir #include <tools/debug.hxx>
33cdf0e10cSrcweir #include <tools/fract.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <vector>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class ViewShell;
38cdf0e10cSrcweir class Rectangle;
39cdf0e10cSrcweir class SwFrm;
40cdf0e10cSrcweir class SwTxtFrm;
41cdf0e10cSrcweir class SwPageFrm;
42cdf0e10cSrcweir class SwAccessibleContext;
43cdf0e10cSrcweir class SwAccessibleContextMap_Impl;
44cdf0e10cSrcweir class SwAccessibleEventList_Impl;
45cdf0e10cSrcweir class SwAccessibleEventMap_Impl;
46cdf0e10cSrcweir class SwShapeList_Impl;
47cdf0e10cSrcweir class SdrObject;
48cdf0e10cSrcweir namespace accessibility {
49cdf0e10cSrcweir     class AccessibleShape;
50cdf0e10cSrcweir }
51cdf0e10cSrcweir class SwAccessibleShapeMap_Impl;
52cdf0e10cSrcweir struct SwAccessibleEvent_Impl;
53cdf0e10cSrcweir class SwAccessibleSelectedParas_Impl;
54cdf0e10cSrcweir class SwRect;
55cdf0e10cSrcweir class MapMode;
56cdf0e10cSrcweir class SwAccPreviewData;
57cdf0e10cSrcweir struct PrevwPage;
58cdf0e10cSrcweir class Window;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // real states for events
61cdf0e10cSrcweir #define ACC_STATE_EDITABLE 0x01
62cdf0e10cSrcweir #define ACC_STATE_OPAQUE 0x02
63cdf0e10cSrcweir 
64cdf0e10cSrcweir // pseudo states for events
65cdf0e10cSrcweir // --> OD 2009-01-07 #i88069# - pseudo state for event TEXT_ATTRIBUTE_CHANGED
66cdf0e10cSrcweir #define ACC_STATE_TEXT_ATTRIBUTE_CHANGED 0x0200
67cdf0e10cSrcweir // <--
68cdf0e10cSrcweir // --> OD 2005-12-12 #i27301# - pseudo state for event TEXT_SELECTION_CHANGED
69cdf0e10cSrcweir #define ACC_STATE_TEXT_SELECTION_CHANGED 0x0100
70cdf0e10cSrcweir // <--
71cdf0e10cSrcweir #define ACC_STATE_CARET 0x80
72cdf0e10cSrcweir #define ACC_STATE_RELATION_FROM 0x40
73cdf0e10cSrcweir #define ACC_STATE_RELATION_TO 0x20
74cdf0e10cSrcweir 
75cdf0e10cSrcweir #define ACC_STATE_RELATION_MASK 0x60
76cdf0e10cSrcweir 
77cdf0e10cSrcweir #define ACC_STATE_MASK 0x1F
78cdf0e10cSrcweir 
79cdf0e10cSrcweir // --> OD 2005-12-12 #i27301# - introduce type definition of states
80cdf0e10cSrcweir typedef sal_uInt16 tAccessibleStates;
81cdf0e10cSrcweir // <--
82cdf0e10cSrcweir 
83cdf0e10cSrcweir class SwAccessibleMap : public accessibility::IAccessibleViewForwarder,
84cdf0e10cSrcweir 						public accessibility::IAccessibleParent
85cdf0e10cSrcweir {
86cdf0e10cSrcweir     mutable ::vos::OMutex maMutex;
87cdf0e10cSrcweir 	::vos::OMutex maEventMutex;
88cdf0e10cSrcweir 	SwAccessibleContextMap_Impl *mpFrmMap;
89cdf0e10cSrcweir 	SwAccessibleShapeMap_Impl *mpShapeMap;
90cdf0e10cSrcweir 	SwShapeList_Impl *mpShapes;
91cdf0e10cSrcweir 	SwAccessibleEventList_Impl *mpEvents;
92cdf0e10cSrcweir 	SwAccessibleEventMap_Impl *mpEventMap;
93cdf0e10cSrcweir     // --> OD 2005-12-13 #i27301# - data structure to keep information about
94cdf0e10cSrcweir     // accessible paragraph, which have a selection.
95cdf0e10cSrcweir     SwAccessibleSelectedParas_Impl* mpSelectedParas;
96cdf0e10cSrcweir     // <--
97cdf0e10cSrcweir     ViewShell *mpVSh;
98cdf0e10cSrcweir     /// for page preview: store preview data, VisArea, and mapping of
99cdf0e10cSrcweir     /// preview-to-display coordinates
100cdf0e10cSrcweir     SwAccPreviewData* mpPreview;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	::com::sun::star::uno::WeakReference < ::com::sun::star::accessibility::XAccessible > mxCursorContext;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	sal_Int32 mnPara;
105cdf0e10cSrcweir 	sal_Int32 mnFootnote;
106cdf0e10cSrcweir 	sal_Int32 mnEndnote;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	sal_Bool mbShapeSelected;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	void FireEvent( const SwAccessibleEvent_Impl& rEvent );
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	void InvalidateCursorPosition(
116cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference<
117cdf0e10cSrcweir 			::com::sun::star::accessibility::XAccessible>& rAcc );
118cdf0e10cSrcweir 	void DoInvalidateShapeSelection();
119cdf0e10cSrcweir 	void DoInvalidateShapeFocus();
120cdf0e10cSrcweir 	void InvalidateShapeSelection();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     void _InvalidateRelationSet( const SwFrm* pFrm, sal_Bool bFrom );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
125cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessible>
126cdf0e10cSrcweir             _GetDocumentView( sal_Bool bPagePreview );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     /** method to build up a new data structure of the accessible pararaphs,
129cdf0e10cSrcweir         which have a selection
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         OD 2005-12-13 #i27301#
132cdf0e10cSrcweir         Important note: method has to used inside a mutual exclusive section
133cdf0e10cSrcweir 
134cdf0e10cSrcweir         @author OD
135cdf0e10cSrcweir     */
136cdf0e10cSrcweir     SwAccessibleSelectedParas_Impl* _BuildSelectedParas();
137cdf0e10cSrcweir 
138cdf0e10cSrcweir public:
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	SwAccessibleMap( ViewShell *pSh );
141cdf0e10cSrcweir 	~SwAccessibleMap();
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
144cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessible> GetDocumentView();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     // OD 15.01.2003 #103492# - complete re-factoring of method due to new
147cdf0e10cSrcweir     // page/print preview functionality.
148cdf0e10cSrcweir     ::com::sun::star::uno::Reference<
149cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible> GetDocumentPreview(
150cdf0e10cSrcweir                             const std::vector<PrevwPage*>& _rPrevwPages,
151cdf0e10cSrcweir                             const Fraction&  _rScale,
152cdf0e10cSrcweir                             const SwPageFrm* _pSelectedPageFrm,
153cdf0e10cSrcweir                             const Size&      _rPrevwWinSize );
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	::vos::ORef < SwAccessibleContext > GetContextImpl(
156cdf0e10cSrcweir 									 			const SwFrm *pFrm,
157cdf0e10cSrcweir 												sal_Bool bCreate = sal_True );
158cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
159cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessible> GetContext(
160cdf0e10cSrcweir 									 			const SwFrm *pFrm,
161cdf0e10cSrcweir 												sal_Bool bCreate = sal_True );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	::vos::ORef < ::accessibility::AccessibleShape > GetContextImpl(
164cdf0e10cSrcweir 										const SdrObject *pObj,
165cdf0e10cSrcweir 										SwAccessibleContext *pParentImpl,
166cdf0e10cSrcweir 										sal_Bool bCreate = sal_True );
167cdf0e10cSrcweir 	::com::sun::star::uno::Reference<
168cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessible> GetContext(
169cdf0e10cSrcweir 										const SdrObject *pObj,
170cdf0e10cSrcweir 										SwAccessibleContext *pParentImpl,
171cdf0e10cSrcweir 										sal_Bool bCreate = sal_True );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     inline ViewShell* GetShell() const
174cdf0e10cSrcweir     {
175cdf0e10cSrcweir         return mpVSh;
176cdf0e10cSrcweir     }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     const SwRect& GetVisArea() const;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     /** get size of a dedicated preview page
181cdf0e10cSrcweir 
182cdf0e10cSrcweir         OD 15.01.2003 #103492#
183cdf0e10cSrcweir         complete re-factoring of previous method due to new page/print preview
184cdf0e10cSrcweir         functionality.
185cdf0e10cSrcweir 
186cdf0e10cSrcweir         @author OD
187cdf0e10cSrcweir 
188cdf0e10cSrcweir         @param _nPrevwPageNum
189cdf0e10cSrcweir         input parameter - physical page number of page visible in the page preview
190cdf0e10cSrcweir 
191cdf0e10cSrcweir         @return an object of class <Size>
192cdf0e10cSrcweir     */
193cdf0e10cSrcweir     Size GetPreViewPageSize( sal_uInt16 _nPrevwPageNum ) const;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	void RemoveContext( const SwFrm *pFrm );
196cdf0e10cSrcweir 	void RemoveContext( const SdrObject *pObj );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	// Dispose frame and its children if bRecursive is set
199cdf0e10cSrcweir     void Dispose( const SwFrm* pFrm,
200cdf0e10cSrcweir                   const SdrObject* pObj,
201cdf0e10cSrcweir                   Window* pWindow,
202cdf0e10cSrcweir                   sal_Bool bRecursive = sal_False );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     void InvalidatePosOrSize( const SwFrm* pFrm,
205cdf0e10cSrcweir                               const SdrObject* pObj,
206cdf0e10cSrcweir                               Window* pWindow,
207cdf0e10cSrcweir 							  const SwRect& rOldFrm );
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	void InvalidateContent( const SwFrm *pFrm );
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     // --> OD 2009-01-06 #i88069#
212cdf0e10cSrcweir     void InvalidateAttr( const SwTxtFrm& rTxtFrm );
213cdf0e10cSrcweir     // <--
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	void InvalidateCursorPosition( const SwFrm *pFrm );
216cdf0e10cSrcweir 	void InvalidateFocus();
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	void SetCursorContext(
219cdf0e10cSrcweir 		const ::vos::ORef < SwAccessibleContext >& rCursorContext );
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 	// Invalidate state of whole tree. If an action is open, this call
222cdf0e10cSrcweir 	// is processed when the last action ends.
223cdf0e10cSrcweir     // --> OD 2005-12-12 #i27301# - use new type definition for <_nStates>
224cdf0e10cSrcweir     void InvalidateStates( tAccessibleStates _nStates,
225cdf0e10cSrcweir                            const SwFrm* _pFrm = 0 );
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     void InvalidateRelationSet( const SwFrm* pMaster, const SwFrm* pFollow );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     /** invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph
230cdf0e10cSrcweir 
231cdf0e10cSrcweir         OD 2005-12-01 #i27138#
232cdf0e10cSrcweir 
233cdf0e10cSrcweir         @author OD
234cdf0e10cSrcweir 
235cdf0e10cSrcweir         @param _rTxtFrm
236cdf0e10cSrcweir         input parameter - reference to paragraph, whose CONTENT_FLOWS_FROM/_TO
237cdf0e10cSrcweir         has to be invalidated.
238cdf0e10cSrcweir 
239cdf0e10cSrcweir         @param _bFrom
240cdf0e10cSrcweir         input parameter - boolean indicating, if relation CONTENT_FLOWS_FROM
241cdf0e10cSrcweir         (value <true>) or CONTENT_FLOWS_TO (value <false>) has to be invalidated.
242cdf0e10cSrcweir     */
243cdf0e10cSrcweir     void InvalidateParaFlowRelation( const SwTxtFrm& _rTxtFrm,
244cdf0e10cSrcweir                                      const bool _bFrom );
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     /** invalidation of text selection of a paragraph
247cdf0e10cSrcweir 
248cdf0e10cSrcweir         OD 2005-12-12 #i27301#
249cdf0e10cSrcweir 
250cdf0e10cSrcweir         @author OD
251cdf0e10cSrcweir     */
252cdf0e10cSrcweir     void InvalidateParaTextSelection( const SwTxtFrm& _rTxtFrm );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     /** invalidation of text selection of all paragraphs
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         OD 2005-12-13 #i27301#
257cdf0e10cSrcweir 
258cdf0e10cSrcweir         @author OD
259cdf0e10cSrcweir     */
260cdf0e10cSrcweir     void InvalidateTextSelectionOfAllParas();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     sal_Int32 GetChildIndex( const SwFrm& rParentFrm,
263cdf0e10cSrcweir                              Window& rChild ) const;
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     // update preview data (and fire events if necessary)
266cdf0e10cSrcweir     // OD 15.01.2003 #103492# - complete re-factoring of method due to new
267cdf0e10cSrcweir     // page/print preview functionality.
268cdf0e10cSrcweir     void UpdatePreview( const std::vector<PrevwPage*>& _rPrevwPages,
269cdf0e10cSrcweir                         const Fraction&  _rScale,
270cdf0e10cSrcweir                         const SwPageFrm* _pSelectedPageFrm,
271cdf0e10cSrcweir                         const Size&      _rPrevwWinSize );
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     void InvalidatePreViewSelection( sal_uInt16 nSelPage );
274cdf0e10cSrcweir 	sal_Bool IsPageSelected( const SwPageFrm *pPageFrm ) const;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	void FireEvents();
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 	// IAccessibleViewForwarder
280cdf0e10cSrcweir 
281cdf0e10cSrcweir 	virtual sal_Bool IsValid() const;
282cdf0e10cSrcweir     virtual Rectangle GetVisibleArea() const;
283cdf0e10cSrcweir     virtual Point LogicToPixel (const Point& rPoint) const;
284cdf0e10cSrcweir     virtual Size LogicToPixel (const Size& rSize) const;
285cdf0e10cSrcweir     virtual Point PixelToLogic (const Point& rPoint) const;
286cdf0e10cSrcweir     virtual Size PixelToLogic (const Size& rSize) const;
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 	// IAccessibleParent
289cdf0e10cSrcweir     virtual sal_Bool ReplaceChild (
290cdf0e10cSrcweir         ::accessibility::AccessibleShape* pCurrentChild,
291cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
292cdf0e10cSrcweir 		const long _nIndex,
293cdf0e10cSrcweir 		const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
294cdf0e10cSrcweir 	)	throw (::com::sun::star::uno::RuntimeException);
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     // additional Core/Pixel conversions for internal use; also works
297cdf0e10cSrcweir     // for preview
298cdf0e10cSrcweir     Point PixelToCore (const Point& rPoint) const;
299cdf0e10cSrcweir     Rectangle CoreToPixel (const Rectangle& rRect) const;
300cdf0e10cSrcweir 
301cdf0e10cSrcweir private:
302cdf0e10cSrcweir     /** get mapping mode for LogicToPixel and PixelToLogic conversions
303cdf0e10cSrcweir 
304cdf0e10cSrcweir         OD 15.01.2003 #103492#
305cdf0e10cSrcweir         Replacement method <PreviewAdjust(..)> by new method <GetMapMode>.
306cdf0e10cSrcweir         Method returns mapping mode of current output device and adjusts it,
307cdf0e10cSrcweir         if the shell is in page/print preview.
308cdf0e10cSrcweir         Necessary, because <PreviewAdjust(..)> changes mapping mode at current
309cdf0e10cSrcweir         output device for mapping logic document positions to page preview window
310cdf0e10cSrcweir         positions and vice versa and doesn't take care to recover its changes.
311cdf0e10cSrcweir 
312cdf0e10cSrcweir         @author OD
313cdf0e10cSrcweir 
314cdf0e10cSrcweir         @param _rPoint
315cdf0e10cSrcweir         input parameter - constant reference to point to determine the mapping
316cdf0e10cSrcweir         mode adjustments for page/print preview.
317cdf0e10cSrcweir 
318cdf0e10cSrcweir         @param _orMapMode
319cdf0e10cSrcweir         output parameter - reference to the mapping mode, which is determined
320cdf0e10cSrcweir         by the method
321cdf0e10cSrcweir     */
322cdf0e10cSrcweir     void GetMapMode( const Point& _rPoint,
323cdf0e10cSrcweir                      MapMode&     _orMapMode ) const;
324cdf0e10cSrcweir };
325cdf0e10cSrcweir #endif
326