1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 #include <cppuhelper/weakref.hxx>
31 #include <com/sun/star/accessibility/XAccessible.hpp>
32 #include <vos/ref.hxx>
33 #include <vos/mutex.hxx>
34 #include <svx/IAccessibleViewForwarder.hxx>
35 #include <svx/IAccessibleParent.hxx>
36 #include <tools/debug.hxx>
37 #include <tools/fract.hxx>
46 class SwAccessibleContext
;
47 class SwAccessibleContextMap_Impl
;
48 class SwAccessibleEventList_Impl
;
49 class SwAccessibleEventMap_Impl
;
50 class SwShapeList_Impl
;
52 namespace accessibility
{
53 class AccessibleShape
;
55 class SwAccessibleShapeMap_Impl
;
56 struct SwAccessibleEvent_Impl
;
57 class SwAccessibleSelectedParas_Impl
;
60 class SwAccPreviewData
;
64 // real states for events
65 #define ACC_STATE_EDITABLE 0x01
66 #define ACC_STATE_OPAQUE 0x02
68 // pseudo states for events
69 // --> OD 2009-01-07 #i88069# - pseudo state for event TEXT_ATTRIBUTE_CHANGED
70 #define ACC_STATE_TEXT_ATTRIBUTE_CHANGED 0x0200
72 // --> OD 2005-12-12 #i27301# - pseudo state for event TEXT_SELECTION_CHANGED
73 #define ACC_STATE_TEXT_SELECTION_CHANGED 0x0100
75 #define ACC_STATE_CARET 0x80
76 #define ACC_STATE_RELATION_FROM 0x40
77 #define ACC_STATE_RELATION_TO 0x20
79 #define ACC_STATE_RELATION_MASK 0x60
81 #define ACC_STATE_MASK 0x1F
83 // --> OD 2005-12-12 #i27301# - introduce type definition of states
84 typedef sal_uInt16 tAccessibleStates
;
87 class SwAccessibleMap
: public accessibility::IAccessibleViewForwarder
,
88 public accessibility::IAccessibleParent
90 mutable ::vos::OMutex maMutex
;
91 ::vos::OMutex maEventMutex
;
92 SwAccessibleContextMap_Impl
*mpFrmMap
;
93 SwAccessibleShapeMap_Impl
*mpShapeMap
;
94 SwShapeList_Impl
*mpShapes
;
95 SwAccessibleEventList_Impl
*mpEvents
;
96 SwAccessibleEventMap_Impl
*mpEventMap
;
97 // --> OD 2005-12-13 #i27301# - data structure to keep information about
98 // accessible paragraph, which have a selection.
99 SwAccessibleSelectedParas_Impl
* mpSelectedParas
;
102 /// for page preview: store preview data, VisArea, and mapping of
103 /// preview-to-display coordinates
104 SwAccPreviewData
* mpPreview
;
106 ::com::sun::star::uno::WeakReference
< ::com::sun::star::accessibility::XAccessible
> mxCursorContext
;
109 sal_Int32 mnFootnote
;
113 sal_Bool mbShapeSelected
;
115 void FireEvent( const SwAccessibleEvent_Impl
& rEvent
);
117 void AppendEvent( const SwAccessibleEvent_Impl
& rEvent
);
119 void InvalidateCursorPosition(
120 const ::com::sun::star::uno::Reference
<
121 ::com::sun::star::accessibility::XAccessible
>& rAcc
);
122 void DoInvalidateShapeSelection();
123 void DoInvalidateShapeFocus();
124 void InvalidateShapeSelection();
126 void _InvalidateRelationSet( const SwFrm
* pFrm
, sal_Bool bFrom
);
128 ::com::sun::star::uno::Reference
<
129 ::com::sun::star::accessibility::XAccessible
>
130 _GetDocumentView( sal_Bool bPagePreview
);
132 /** method to build up a new data structure of the accessible pararaphs,
133 which have a selection
135 OD 2005-12-13 #i27301#
136 Important note: method has to used inside a mutual exclusive section
140 SwAccessibleSelectedParas_Impl
* _BuildSelectedParas();
144 SwAccessibleMap( ViewShell
*pSh
);
147 ::com::sun::star::uno::Reference
<
148 ::com::sun::star::accessibility::XAccessible
> GetDocumentView();
150 // OD 15.01.2003 #103492# - complete re-factoring of method due to new
151 // page/print preview functionality.
152 ::com::sun::star::uno::Reference
<
153 ::com::sun::star::accessibility::XAccessible
> GetDocumentPreview(
154 const std::vector
<PrevwPage
*>& _rPrevwPages
,
155 const Fraction
& _rScale
,
156 const SwPageFrm
* _pSelectedPageFrm
,
157 const Size
& _rPrevwWinSize
);
159 ::vos::ORef
< SwAccessibleContext
> GetContextImpl(
161 sal_Bool bCreate
= sal_True
);
162 ::com::sun::star::uno::Reference
<
163 ::com::sun::star::accessibility::XAccessible
> GetContext(
165 sal_Bool bCreate
= sal_True
);
167 ::vos::ORef
< ::accessibility::AccessibleShape
> GetContextImpl(
168 const SdrObject
*pObj
,
169 SwAccessibleContext
*pParentImpl
,
170 sal_Bool bCreate
= sal_True
);
171 ::com::sun::star::uno::Reference
<
172 ::com::sun::star::accessibility::XAccessible
> GetContext(
173 const SdrObject
*pObj
,
174 SwAccessibleContext
*pParentImpl
,
175 sal_Bool bCreate
= sal_True
);
177 inline ViewShell
* GetShell() const
182 const SwRect
& GetVisArea() const;
184 /** get size of a dedicated preview page
186 OD 15.01.2003 #103492#
187 complete re-factoring of previous method due to new page/print preview
192 @param _nPrevwPageNum
193 input parameter - physical page number of page visible in the page preview
195 @return an object of class <Size>
197 Size
GetPreViewPageSize( sal_uInt16 _nPrevwPageNum
) const;
199 void RemoveContext( const SwFrm
*pFrm
);
200 void RemoveContext( const SdrObject
*pObj
);
202 // Dispose frame and its children if bRecursive is set
203 void Dispose( const SwFrm
* pFrm
,
204 const SdrObject
* pObj
,
206 sal_Bool bRecursive
= sal_False
);
208 void InvalidatePosOrSize( const SwFrm
* pFrm
,
209 const SdrObject
* pObj
,
211 const SwRect
& rOldFrm
);
213 void InvalidateContent( const SwFrm
*pFrm
);
215 // --> OD 2009-01-06 #i88069#
216 void InvalidateAttr( const SwTxtFrm
& rTxtFrm
);
219 void InvalidateCursorPosition( const SwFrm
*pFrm
);
220 void InvalidateFocus();
222 void SetCursorContext(
223 const ::vos::ORef
< SwAccessibleContext
>& rCursorContext
);
225 // Invalidate state of whole tree. If an action is open, this call
226 // is processed when the last action ends.
227 // --> OD 2005-12-12 #i27301# - use new type definition for <_nStates>
228 void InvalidateStates( tAccessibleStates _nStates
,
229 const SwFrm
* _pFrm
= 0 );
231 void InvalidateRelationSet( const SwFrm
* pMaster
, const SwFrm
* pFollow
);
233 /** invalidation CONTENT_FLOWS_FROM/_TO relation of a paragraph
235 OD 2005-12-01 #i27138#
240 input parameter - reference to paragraph, whose CONTENT_FLOWS_FROM/_TO
241 has to be invalidated.
244 input parameter - boolean indicating, if relation CONTENT_FLOWS_FROM
245 (value <true>) or CONTENT_FLOWS_TO (value <false>) has to be invalidated.
247 void InvalidateParaFlowRelation( const SwTxtFrm
& _rTxtFrm
,
250 /** invalidation of text selection of a paragraph
252 OD 2005-12-12 #i27301#
256 void InvalidateParaTextSelection( const SwTxtFrm
& _rTxtFrm
);
258 /** invalidation of text selection of all paragraphs
260 OD 2005-12-13 #i27301#
264 void InvalidateTextSelectionOfAllParas();
266 sal_Int32
GetChildIndex( const SwFrm
& rParentFrm
,
267 Window
& rChild
) const;
269 // update preview data (and fire events if necessary)
270 // OD 15.01.2003 #103492# - complete re-factoring of method due to new
271 // page/print preview functionality.
272 void UpdatePreview( const std::vector
<PrevwPage
*>& _rPrevwPages
,
273 const Fraction
& _rScale
,
274 const SwPageFrm
* _pSelectedPageFrm
,
275 const Size
& _rPrevwWinSize
);
277 void InvalidatePreViewSelection( sal_uInt16 nSelPage
);
278 sal_Bool
IsPageSelected( const SwPageFrm
*pPageFrm
) const;
283 // IAccessibleViewForwarder
285 virtual sal_Bool
IsValid() const;
286 virtual Rectangle
GetVisibleArea() const;
287 virtual Point
LogicToPixel (const Point
& rPoint
) const;
288 virtual Size
LogicToPixel (const Size
& rSize
) const;
289 virtual Point
PixelToLogic (const Point
& rPoint
) const;
290 virtual Size
PixelToLogic (const Size
& rSize
) const;
293 virtual sal_Bool
ReplaceChild (
294 ::accessibility::AccessibleShape
* pCurrentChild
,
295 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
>& _rxShape
,
297 const ::accessibility::AccessibleShapeTreeInfo
& _rShapeTreeInfo
298 ) throw (::com::sun::star::uno::RuntimeException
);
300 // additional Core/Pixel conversions for internal use; also works
302 Point
PixelToCore (const Point
& rPoint
) const;
303 Rectangle
CoreToPixel (const Rectangle
& rRect
) const;
306 /** get mapping mode for LogicToPixel and PixelToLogic conversions
308 OD 15.01.2003 #103492#
309 Replacement method <PreviewAdjust(..)> by new method <GetMapMode>.
310 Method returns mapping mode of current output device and adjusts it,
311 if the shell is in page/print preview.
312 Necessary, because <PreviewAdjust(..)> changes mapping mode at current
313 output device for mapping logic document positions to page preview window
314 positions and vice versa and doesn't take care to recover its changes.
319 input parameter - constant reference to point to determine the mapping
320 mode adjustments for page/print preview.
323 output parameter - reference to the mapping mode, which is determined
326 void GetMapMode( const Point
& _rPoint
,
327 MapMode
& _orMapMode
) const;