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