1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewimp.hxx,v $
10 * $Revision: 1.36.214.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include <vcl/timer.hxx>
34 #include <tools/color.hxx>
36 // OD 25.06.2003 #108784#
37 #include <svx/svdtypes.hxx>
39 #include <tools/string.hxx>
41 #include "swtypes.hxx"
56 struct SdrPaintProcRec
;
57 class SwAccessibleMap
;
60 // OD 12.12.2002 #103492#
61 class SwPagePreviewLayout
;
62 // OD 15.01.2003 #103492#
63 #ifndef _PREVWPAGE_HXX
64 #include <prevwpage.hxx>
66 // OD 15.01.2003 #103492#
68 // --> OD 2005-12-01 #i27138#
74 friend class ViewShell
;
76 friend class SwLayAction
; //Lay- und IdleAction tragen sich ein und aus.
77 friend class SwLayIdle
;
79 // OD 12.12.2002 #103492# - for paint of page preview
80 friend class SwPagePreviewLayout
;
82 ViewShell
*pSh
; //Falls jemand einen Imp durchreicht und doch
83 //mal eine ViewShell braucht hier die
84 //Rueckwaertsverkettung.
86 SwDrawView
*pDrawView
; //Unsere DrawView
87 SdrPageView
*pSdrPageView
; //Genau eine Seite fuer unsere DrawView
89 SwPageFrm
*pFirstVisPage
;//Zeigt immer auf die erste sichtbare Seite.
90 SwRegionRects
*pRegion
; //Sammler fuer Paintrects aus der LayAction.
91 SwScrollAreas
*pScrollRects
; //Sammler fuer Scrollrects aus der LayAction.
92 SwScrollAreas
*pScrolledArea
;//Sammler der gescrollten Rechtecke.
94 SwLayAction
*pLayAct
; //Ist gesetzt wenn ein Action-Objekt existiert
95 //Wird vom SwLayAction-CTor ein- und vom DTor
97 SwLayIdle
*pIdleAct
; //Analog zur SwLayAction fuer SwLayIdle.
99 SwAccessibleMap
*pAccMap
; // Accessible Wrappers
101 mutable const SdrObject
* pSdrObjCached
;
102 mutable String sSdrObjCachedComment
;
104 AutoTimer aScrollTimer
; //Fuer das Aufraeumen nach dem Scrollen.
106 BOOL bFirstPageInvalid
:1; //Pointer auf erste Seite ungueltig?
107 BOOL bNextScroll
:1; //Scroll in der folgenden EndAction erlaubt?
108 BOOL bScroll
:1; //Scroll in der aktuellen EndAction erlaubt?
109 BOOL bScrolled
:1; //Wurde gescrolled? Dann im Idle aufraeumen.
111 //BOOL bResetXorVisibility:1; //StartAction/EndAction
112 //HMHBOOL bShowHdlPaint :1; //LockPaint/UnlockPaint
113 BOOL bResetHdlHiddenPaint
:1;// -- "" --
114 BOOL bPaintInScroll
:1; //Paint (Update() im ScrollHdl der ViewShell
116 BOOL bSmoothUpdate
:1; //Meber fuer SmoothScroll
118 BOOL bStopPrt
:1; // Stop Printing
120 USHORT nRestoreActions
; //Die Anzahl der zu restaurierenden Actions (UNO)
123 // OD 12.12.2002 #103492#
124 SwPagePreviewLayout
* mpPgPrevwLayout
;
127 Signal whether to stop printing.
129 @param _useless just to fit macro
131 DECL_LINK(SetStopPrt
, void * _useless
= NULL
);
134 Returns if printer shall be stopped.
136 @retval TRUE The printer shall be stopped.
139 BOOL
IsStopPrt() { return bStopPrt
; }
142 Resets signal for stopping printing.
145 void ResetStopPrt() { bStopPrt
= FALSE
; }
147 void SetFirstVisPage(); //Neue Ermittlung der ersten sichtbaren Seite
149 void ResetNextScroll() { bNextScroll
= FALSE
; }
150 void SetNextScroll() { bNextScroll
= TRUE
; }
151 void SetScroll() { bScroll
= TRUE
; }
152 void ResetScrolled() { bScrolled
= FALSE
; }
153 void SetScrolled() { bScrolled
= TRUE
; }
155 SwScrollAreas
*GetScrollRects() { return pScrollRects
; }
156 void FlushScrolledArea();
157 BOOL
_FlushScrolledArea( SwRect
& rRect
);
158 BOOL
FlushScrolledArea( SwRect
& rRect
)
159 { if( !pScrolledArea
) return FALSE
; return _FlushScrolledArea( rRect
); }
160 void _ScrolledRect( const SwRect
& rRect
, long nOffs
);
161 void ScrolledRect( const SwRect
& rRect
, long nOffs
)
162 { if( pScrolledArea
) _ScrolledRect( rRect
, nOffs
); }
164 void StartAction(); //Henkel Anzeigen und verstecken.
165 void EndAction(); //gerufen von ViewShell::ImplXXXAction
166 void LockPaint(); //dito, gerufen von ViewShell::ImplLockPaint
171 SwAccessibleMap
*CreateAccessibleMap();
173 /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
175 OD 2005-12-01 #i27138#
176 implementation for wrapper method
177 <ViewShell::InvalidateAccessibleParaFlowRelation(..)>
182 input parameter - paragraph frame, for which the relation CONTENT_FLOWS_FROM
183 has to be invalidated.
184 If NULL, no CONTENT_FLOWS_FROM relation has to be invalidated
187 input parameter - paragraph frame, for which the relation CONTENT_FLOWS_TO
188 has to be invalidated.
189 If NULL, no CONTENT_FLOWS_TO relation has to be invalidated
191 void _InvalidateAccessibleParaFlowRelation( const SwTxtFrm
* _pFromTxtFrm
,
192 const SwTxtFrm
* _pToTxtFrm
);
194 /** invalidate text selection for paragraphs
196 OD 2005-12-12 #i27301#
197 implementation for wrapper method
198 <ViewShell::InvalidateAccessibleParaTextSelection(..)>
202 void _InvalidateAccessibleParaTextSelection();
204 /** invalidate attributes for paragraphs
206 OD 2009-01-06 #i88069#
207 implementation for wrapper method
208 <ViewShell::InvalidateAccessibleParaAttrs(..)>
212 void _InvalidateAccessibleParaAttrs( const SwTxtFrm
& rTxtFrm
);
215 SwViewImp( ViewShell
* );
217 void Init( const SwViewOption
* ); //nur fuer ViewShell::Init()
219 const ViewShell
*GetShell() const { return pSh
; }
220 ViewShell
*GetShell() { return pSh
; }
222 Color
GetRetoucheColor() const;
224 //Verwaltung zur ersten sichtbaren Seite
225 inline const SwPageFrm
*GetFirstVisPage() const;
226 inline SwPageFrm
*GetFirstVisPage();
227 void SetFirstVisPageInvalid() { bFirstPageInvalid
= TRUE
; }
229 //SS'en fuer Paint- und Scrollrects.
230 BOOL
AddPaintRect( const SwRect
&rRect
);
231 void AddScrollRect( const SwFrm
*pFrm
, const SwRect
&rRect
, long nOffs
);
232 void MoveScrollArea();
233 SwRegionRects
*GetRegion() { return pRegion
; }
234 void DelRegions(); //Loescht Scroll- und PaintRects
236 //Handler fuer das Refresh von gescrollten Bereichen (Korrektur des
237 //Alignments). Ruft das Refresh mit der ScrolledArea.
238 //RefreshScrolledArea kann z.B. beim Setzen des Crsr genutzt werden, es
239 //wird nur der Anteil des Rect refreshed, der mit der ScrolledArea
240 //ueberlappt. Das 'reingereichte Rechteck wird veraendert!
241 void RestartScrollTimer() { aScrollTimer
.Start(); }
242 DECL_LINK( RefreshScrolledHdl
, Timer
* );
243 void _RefreshScrolledArea( const SwRect
&rRect
);
244 void RefreshScrolledArea( SwRect
&rRect
);
246 //Wird vom Layout ggf. waehrend einer Action gerufen, wenn der
247 //Verdacht besteht, dass es etwas drunter und drueber geht.
248 void ResetScroll() { bScroll
= FALSE
; }
250 BOOL
IsNextScroll() const { return bNextScroll
; }
251 BOOL
IsScroll() const { return bScroll
; }
252 BOOL
IsScrolled() const { return bScrolled
; }
254 BOOL
IsPaintInScroll() const { return bPaintInScroll
; }
256 // neues Interface fuer StarView Drawing
257 inline BOOL
HasDrawView() const { return 0 != pDrawView
; }
258 SwDrawView
* GetDrawView() { return pDrawView
; }
259 const SwDrawView
* GetDrawView() const { return pDrawView
; }
260 SdrPageView
*GetPageView() { return pSdrPageView
; }
261 const SdrPageView
*GetPageView() const { return pSdrPageView
; }
264 // OD 29.08.2002 #102450#
265 // add 3rd parameter <const Color* pPageBackgrdColor> for setting this
266 // color as the background color at the outliner of the draw view
267 // for painting layers <hell> and <heaven>
268 // OD 09.12.2002 #103045# - add 4th parameter for the horizontal text
269 // direction of the page in order to set the default horizontal text
270 // direction at the outliner of the draw view for painting layers <hell>
272 // OD 25.06.2003 #108784# - correct type of 1st parameter
273 void PaintLayer ( const SdrLayerID _nLayerID
,
274 const SwRect
& _rRect
,
275 const Color
* _pPageBackgrdColor
= 0,
276 const bool _bIsPageRightToLeft
= false ) const;
278 //wird als Link an die DrawEngine uebergeben, entscheidet was wie
279 //gepaintet wird oder nicht.
281 //DECL_LINK( PaintDispatcher, SdrPaintProcRec * );
284 BOOL
IsDragPossible( const Point
&rPoint
);
285 void NotifySizeChg( const Size
&rNewSz
);
287 //SS Fuer die Lay- bzw. IdleAction und verwandtes
288 BOOL
IsAction() const { return pLayAct
!= 0; }
289 BOOL
IsIdleAction() const { return pIdleAct
!= 0; }
290 SwLayAction
&GetLayAction() { return *pLayAct
; }
291 const SwLayAction
&GetLayAction() const { return *pLayAct
; }
292 SwLayIdle
&GetIdleAction() { return *pIdleAct
;}
293 const SwLayIdle
&GetIdleAction() const { return *pIdleAct
;}
295 //Wenn eine Aktion laueft wird diese gebeten zu pruefen ob es
296 //an der zeit ist den WaitCrsr einzuschalten.
297 void CheckWaitCrsr();
298 BOOL
IsCalcLayoutProgress() const; //Fragt die LayAction wenn vorhanden.
299 //TRUE wenn eine LayAction laeuft, dort wird dann auch das Flag fuer
300 //ExpressionFields gesetzt.
301 BOOL
IsUpdateExpFlds();
303 void SetRestoreActions(USHORT nSet
){nRestoreActions
= nSet
;}
304 USHORT
GetRestoreActions() const{return nRestoreActions
;}
306 // OD 12.12.2002 #103492#
307 void InitPagePreviewLayout();
309 // OD 12.12.2002 #103492#
310 inline SwPagePreviewLayout
* PagePreviewLayout()
312 return mpPgPrevwLayout
;
315 // Is this view accessible?
316 sal_Bool
IsAccessible() const { return pAccMap
!= 0; }
318 inline SwAccessibleMap
& GetAccessibleMap();
320 // Update (this) accessible view
321 void UpdateAccessible();
323 // Remove a frame from the accessible view
324 void DisposeAccessible( const SwFrm
*pFrm
, const SdrObject
*pObj
,
325 sal_Bool bRecursive
);
326 inline void DisposeAccessibleFrm( const SwFrm
*pFrm
,
327 sal_Bool bRecursive
=sal_False
);
328 inline void DisposeAccessibleObj( const SdrObject
*pObj
);
330 // Move a frame's position in the accessible view
331 void MoveAccessible( const SwFrm
*pFrm
, const SdrObject
*pObj
,
332 const SwRect
& rOldFrm
);
333 inline void MoveAccessibleFrm( const SwFrm
*pFrm
, const SwRect
& rOldFrm
);
335 // Add a frame in the accessible view
336 inline void AddAccessibleFrm( const SwFrm
*pFrm
);
338 inline void AddAccessibleObj( const SdrObject
*pObj
);
340 // Invalidate accessible frame's frame's content
341 void InvalidateAccessibleFrmContent( const SwFrm
*pFrm
);
343 // Invalidate accessible frame's cursor position
344 void InvalidateAccessibleCursorPosition( const SwFrm
*pFrm
);
346 // Invalidate editable state for all accessible frames
347 void InvalidateAccessibleEditableState( sal_Bool bAllShells
=sal_True
,
348 const SwFrm
*pFrm
=0 );
350 // Invalidate frame's relation set (for chained frames)
351 void InvalidateAccessibleRelationSet( const SwFlyFrm
*pMaster
,
352 const SwFlyFrm
*pFollow
);
354 // update data for accessible preview
355 // OD 15.01.2003 #103492# - change method signature due to new page preview
357 void UpdateAccessiblePreview( const std::vector
<PrevwPage
*>& _rPrevwPages
,
358 const Fraction
& _rScale
,
359 const SwPageFrm
* _pSelectedPageFrm
,
360 const Size
& _rPrevwWinSize
);
362 void InvalidateAccessiblePreViewSelection( sal_uInt16 nSelPage
);
364 // Fire all accessible events that have been collected so far
365 void FireAccessibleEvents();
368 //Kann auf dem Stack angelegt werden, wenn etwas ausgegeben oder
369 //gescrolled wird. Handles und sontiges vom Drawing werden im CTor
370 //gehidet und im DTor wieder sichtbar gemacht.
371 //AW 06-Sep99: Hiding of handles is no longer necessary, removed
377 // SwSaveHdl( SwViewImp *pImp );
382 inline SwPageFrm
*SwViewImp::GetFirstVisPage()
384 if ( bFirstPageInvalid
)
386 return pFirstVisPage
;
389 inline const SwPageFrm
*SwViewImp::GetFirstVisPage() const
391 if ( bFirstPageInvalid
)
392 ((SwViewImp
*)this)->SetFirstVisPage();
393 return pFirstVisPage
;
396 inline SwAccessibleMap
& SwViewImp::GetAccessibleMap()
399 CreateAccessibleMap();
404 inline void SwViewImp::DisposeAccessibleFrm( const SwFrm
*pFrm
,
405 sal_Bool bRecursive
)
407 DisposeAccessible( pFrm
, 0, bRecursive
);
410 inline void SwViewImp::DisposeAccessibleObj( const SdrObject
*pObj
)
412 DisposeAccessible( 0, pObj
, sal_False
);
415 inline void SwViewImp::MoveAccessibleFrm( const SwFrm
*pFrm
,
416 const SwRect
& rOldFrm
)
418 MoveAccessible( pFrm
, 0, rOldFrm
);
421 inline void SwViewImp::AddAccessibleFrm( const SwFrm
*pFrm
)
424 MoveAccessible( pFrm
, 0, aEmptyRect
);
427 inline void SwViewImp::AddAccessibleObj( const SdrObject
*pObj
)
430 MoveAccessible( 0, pObj
, aEmptyRect
);
432 #endif //_VIEWIMP_HXX