xref: /aoo42x/main/sw/source/core/inc/viewimp.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 #ifndef SW_VIEWIMP_HXX
28 #define SW_VIEWIMP_HXX
29 
30 #include <vector>
31 
32 #include <vcl/timer.hxx>
33 #include <tools/color.hxx>
34 
35 // OD 25.06.2003 #108784#
36 #include <svx/svdtypes.hxx>
37 
38 #include <tools/string.hxx>
39 
40 #include <swtypes.hxx>
41 #include <swrect.hxx>
42 
43 class ViewShell;
44 class SwFlyFrm;
45 class SwViewOption;
46 class SwRegionRects;
47 class SwFrm;
48 class SwLayAction;
49 class SwLayIdle;
50 class SwDrawView;
51 class SdrPageView;
52 class SwPageFrm;
53 class SwRegionRects;
54 struct SdrPaintProcRec;
55 class SwAccessibleMap;
56 class SdrObject;
57 class Fraction;
58 class SwPrintData;
59 class SwPagePreviewLayout;
60 struct PrevwPage;
61 class SwTxtFrm;
62 // --> OD #i76669#
63 namespace sdr { namespace contact {
64         class ViewObjectContactRedirector;
65 } }
66 // <--
67 
68 class SwViewImp
69 {
70 	friend class ViewShell;
71 
72 	friend class SwLayAction;	//Lay- und IdleAction tragen sich ein und aus.
73 	friend class SwLayIdle;
74 
75     // OD 12.12.2002 #103492# - for paint of page preview
76     friend class SwPagePreviewLayout;
77 
78 	ViewShell *pSh;				//Falls jemand einen Imp durchreicht und doch
79 								//mal eine ViewShell braucht hier die
80 								//Rueckwaertsverkettung.
81 
82 	SwDrawView  *pDrawView;		//Unsere DrawView
83 	SdrPageView *pSdrPageView;	//Genau eine Seite fuer unsere DrawView
84 
85 	SwPageFrm	  *pFirstVisPage;//Zeigt immer auf die erste sichtbare Seite.
86     SwRegionRects *pRegion;      //Sammler fuer Paintrects aus der LayAction.
87 
88 	SwLayAction	  *pLayAct;		 //Ist gesetzt wenn ein Action-Objekt existiert
89 								 //Wird vom SwLayAction-CTor ein- und vom DTor
90 								 //ausgetragen.
91 	SwLayIdle	  *pIdleAct;	 //Analog zur SwLayAction fuer SwLayIdle.
92 
93 	SwAccessibleMap	*pAccMap;		// Accessible Wrappers
94 
95     mutable const SdrObject * pSdrObjCached;
96     mutable String sSdrObjCachedComment;
97 
98 	sal_Bool bFirstPageInvalid	:1;	//Pointer auf erste Seite ungueltig?
99 
100 	//sal_Bool bResetXorVisibility:1; //StartAction/EndAction
101 	//HMHBOOL bShowHdlPaint		:1; //LockPaint/UnlockPaint
102 	sal_Bool bResetHdlHiddenPaint:1;//  -- "" --
103 
104 	sal_Bool bSmoothUpdate		:1;	//Meber fuer SmoothScroll
105 	sal_Bool bStopSmooth		:1;
106 	sal_Bool bStopPrt           :1; // Stop Printing
107 
108     sal_uInt16 nRestoreActions  ; //Die Anzahl der zu restaurierenden Actions (UNO)
109 	SwRect aSmoothRect;
110 
111     // OD 12.12.2002 #103492#
112     SwPagePreviewLayout* mpPgPrevwLayout;
113 
114     /**
115 		Signal whether to stop printing.
116 
117 		@param _useless just to fit macro
118 	*/
119 	DECL_LINK(SetStopPrt, void * _useless = NULL);
120 
121 	/**
122 	   Returns if printer shall be stopped.
123 
124 	   @retval sal_True The printer shall be stopped.
125 	   @retval sal_False else
126 	*/
127 	sal_Bool IsStopPrt() { return bStopPrt; }
128 
129 	/**
130 	   Resets signal for stopping printing.
131 
132 	*/
133 	void ResetStopPrt() { bStopPrt = sal_False; }
134 
135 	void SetFirstVisPage();		//Neue Ermittlung der ersten sichtbaren Seite
136 
137 	void StartAction();			//Henkel Anzeigen und verstecken.
138 	void EndAction();			//gerufen von ViewShell::ImplXXXAction
139 	void LockPaint();			//dito, gerufen von ViewShell::ImplLockPaint
140 	void UnlockPaint();
141 
142 private:
143 
144 	SwAccessibleMap *CreateAccessibleMap();
145 
146     /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
147 
148         OD 2005-12-01 #i27138#
149         implementation for wrapper method
150         <ViewShell::InvalidateAccessibleParaFlowRelation(..)>
151 
152         @author OD
153 
154         @param _pFromTxtFrm
155         input parameter - paragraph frame, for which the relation CONTENT_FLOWS_FROM
156         has to be invalidated.
157         If NULL, no CONTENT_FLOWS_FROM relation has to be invalidated
158 
159         @param _pToTxtFrm
160         input parameter - paragraph frame, for which the relation CONTENT_FLOWS_TO
161         has to be invalidated.
162         If NULL, no CONTENT_FLOWS_TO relation has to be invalidated
163     */
164     void _InvalidateAccessibleParaFlowRelation( const SwTxtFrm* _pFromTxtFrm,
165                                                 const SwTxtFrm* _pToTxtFrm );
166 
167     /** invalidate text selection for paragraphs
168 
169         OD 2005-12-12 #i27301#
170         implementation for wrapper method
171         <ViewShell::InvalidateAccessibleParaTextSelection(..)>
172 
173         @author OD
174     */
175     void _InvalidateAccessibleParaTextSelection();
176 
177     /** invalidate attributes for paragraphs and paragraph's characters
178 
179         OD 2009-01-06 #i88069#
180         implementation for wrapper method
181         <ViewShell::InvalidateAccessibleParaAttrs(..)>
182 
183         @author OD
184     */
185     void _InvalidateAccessibleParaAttrs( const SwTxtFrm& rTxtFrm );
186 
187 public:
188     SwViewImp( ViewShell * );
189 	~SwViewImp();
190 	void Init( const SwViewOption * );			//nur fuer ViewShell::Init()
191 
192 	const ViewShell *GetShell() const { return pSh; }
193 		  ViewShell *GetShell()		  { return pSh; }
194 
195 	Color GetRetoucheColor() const;
196 
197 	//Verwaltung zur ersten sichtbaren Seite
198 	inline const SwPageFrm *GetFirstVisPage() const;
199 	inline		 SwPageFrm *GetFirstVisPage();
200 	void SetFirstVisPageInvalid() { bFirstPageInvalid = sal_True; }
201 
202 	sal_Bool AddPaintRect( const SwRect &rRect );
203 	SwRegionRects *GetRegion()		{ return pRegion; }
204     void DelRegion();
205 
206 	// neues Interface fuer StarView Drawing
207 	inline sal_Bool HasDrawView()       const { return 0 != pDrawView; }
208 		  SwDrawView* GetDrawView() 	  { return pDrawView; }
209 	const SwDrawView* GetDrawView() const { return pDrawView; }
210 		  SdrPageView*GetPageView() 	  { return pSdrPageView; }
211 	const SdrPageView*GetPageView() const { return pSdrPageView; }
212 	void MakeDrawView();
213 
214     // OD 29.08.2002 #102450#
215     // add 3rd parameter <const Color* pPageBackgrdColor> for setting this
216     // color as the background color at the outliner of the draw view
217     // for painting layers <hell> and <heaven>
218     // OD 09.12.2002 #103045# - add 4th parameter for the horizontal text
219     // direction of the page in order to set the default horizontal text
220     // direction at the outliner of the draw view for painting layers <hell>
221     // and <heaven>.
222     // OD 25.06.2003 #108784# - correct type of 1st parameter
223     // OD #i76669# - added parameter <pRedirector>
224     void   PaintLayer( const SdrLayerID _nLayerID,
225                        SwPrintData const*const pPrintData,
226                        const SwRect& _rRect,
227                        const Color* _pPageBackgrdColor = 0,
228                        const bool _bIsPageRightToLeft = false,
229                        sdr::contact::ViewObjectContactRedirector* pRedirector = 0 ) const;
230 
231 	//wird als Link an die DrawEngine uebergeben, entscheidet was wie
232 	//gepaintet wird oder nicht.
233 	//#110094#-3
234     //DECL_LINK( PaintDispatcher, SdrPaintProcRec * );
235 
236 	// Interface Drawing
237 	sal_Bool IsDragPossible( const Point &rPoint );
238 	void NotifySizeChg( const Size &rNewSz );
239 
240 	//SS Fuer die Lay- bzw. IdleAction und verwandtes
241 	sal_Bool  IsAction() const 					 { return pLayAct  != 0; }
242 	sal_Bool  IsIdleAction() const				 { return pIdleAct != 0; }
243 		  SwLayAction &GetLayAction()		 { return *pLayAct; }
244 	const SwLayAction &GetLayAction() const  { return *pLayAct; }
245 		  SwLayIdle	  &GetIdleAction()		 { return *pIdleAct;}
246 	const SwLayIdle   &GetIdleAction() const { return *pIdleAct;}
247 
248 	//Wenn eine Aktion laueft wird diese gebeten zu pruefen ob es
249 	//an der zeit ist den WaitCrsr einzuschalten.
250 	void CheckWaitCrsr();
251 	sal_Bool IsCalcLayoutProgress() const;	//Fragt die LayAction wenn vorhanden.
252 	//sal_True wenn eine LayAction laeuft, dort wird dann auch das Flag fuer
253 	//ExpressionFields gesetzt.
254 	sal_Bool IsUpdateExpFlds();
255 
256 	void	SetRestoreActions(sal_uInt16 nSet){nRestoreActions = nSet;}
257 	sal_uInt16 	GetRestoreActions() const{return nRestoreActions;}
258 
259     // OD 12.12.2002 #103492#
260     void InitPagePreviewLayout();
261 
262     // OD 12.12.2002 #103492#
263     inline SwPagePreviewLayout* PagePreviewLayout()
264     {
265         return mpPgPrevwLayout;
266     }
267 
268 	// Is this view accessible?
269 	sal_Bool IsAccessible() const { return pAccMap != 0; }
270 
271 	inline SwAccessibleMap& GetAccessibleMap();
272 
273 	// Update (this) accessible view
274 	void UpdateAccessible();
275 
276 	// Remove a frame from the accessible view
277 	void DisposeAccessible( const SwFrm *pFrm, const SdrObject *pObj,
278 							sal_Bool bRecursive );
279 	inline void DisposeAccessibleFrm( const SwFrm *pFrm,
280 							   sal_Bool bRecursive=sal_False );
281 	inline void DisposeAccessibleObj( const SdrObject *pObj );
282 
283 	// Move a frame's position in the accessible view
284 	void MoveAccessible( const SwFrm *pFrm, const SdrObject *pObj,
285 						 const SwRect& rOldFrm );
286 	inline void MoveAccessibleFrm( const SwFrm *pFrm, const SwRect& rOldFrm );
287 
288 	// Add a frame in the accessible view
289 	inline void AddAccessibleFrm( const SwFrm *pFrm );
290 
291 	inline void AddAccessibleObj( const SdrObject *pObj );
292 
293 	// Invalidate accessible frame's frame's content
294 	void InvalidateAccessibleFrmContent( const SwFrm *pFrm );
295 
296 	// Invalidate accessible frame's cursor position
297 	void InvalidateAccessibleCursorPosition( const SwFrm *pFrm );
298 
299 	// Invalidate editable state for all accessible frames
300 	void InvalidateAccessibleEditableState( sal_Bool bAllShells=sal_True,
301 		   									const SwFrm *pFrm=0 );
302 
303 	// Invalidate frame's relation set (for chained frames)
304 	void InvalidateAccessibleRelationSet( const SwFlyFrm *pMaster,
305                                           const SwFlyFrm *pFollow );
306 
307     // update data for accessible preview
308     // OD 15.01.2003 #103492# - change method signature due to new page preview
309     // functionality
310     void UpdateAccessiblePreview( const std::vector<PrevwPage*>& _rPrevwPages,
311                                   const Fraction&  _rScale,
312                                   const SwPageFrm* _pSelectedPageFrm,
313                                   const Size&      _rPrevwWinSize );
314 
315     void InvalidateAccessiblePreViewSelection( sal_uInt16 nSelPage );
316 
317 	// Fire all accessible events that have been collected so far
318 	void FireAccessibleEvents();
319 };
320 
321 inline SwPageFrm *SwViewImp::GetFirstVisPage()
322 {
323 	if ( bFirstPageInvalid )
324 		SetFirstVisPage();
325 	return pFirstVisPage;
326 }
327 
328 inline const SwPageFrm *SwViewImp::GetFirstVisPage() const
329 {
330 	if ( bFirstPageInvalid )
331 		((SwViewImp*)this)->SetFirstVisPage();
332 	return pFirstVisPage;
333 }
334 
335 inline SwAccessibleMap& SwViewImp::GetAccessibleMap()
336 {
337 	if( !pAccMap )
338 		CreateAccessibleMap();
339 
340 	return *pAccMap;
341 }
342 
343 inline void SwViewImp::DisposeAccessibleFrm( const SwFrm *pFrm,
344 							   sal_Bool bRecursive )
345 {
346 	DisposeAccessible( pFrm, 0, bRecursive );
347 }
348 
349 inline void SwViewImp::DisposeAccessibleObj( const SdrObject *pObj )
350 {
351 	DisposeAccessible( 0, pObj, sal_False );
352 }
353 
354 inline void SwViewImp::MoveAccessibleFrm( const SwFrm *pFrm,
355 										  const SwRect& rOldFrm )
356 {
357 	MoveAccessible( pFrm, 0, rOldFrm );
358 }
359 
360 inline void SwViewImp::AddAccessibleFrm( const SwFrm *pFrm )
361 {
362 	SwRect aEmptyRect;
363 	MoveAccessible( pFrm, 0, aEmptyRect );
364 }
365 
366 inline void SwViewImp::AddAccessibleObj( const SdrObject *pObj )
367 {
368 	SwRect aEmptyRect;
369 	MoveAccessible( 0, pObj, aEmptyRect );
370 }
371 #endif // SW_VIEWIMP_HXX
372 
373