xref: /AOO41X/main/sw/source/core/inc/viewimp.hxx (revision 4d7c9de063a797b8b4f3d45e3561e82ad1f8ef1f)
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     */
IsStopPrt()123     sal_Bool IsStopPrt() { return bStopPrt; }
124 
125     /**
126        Resets signal for stopping printing.
127 
128     */
ResetStopPrt()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 
GetShell() const188     const ViewShell *GetShell() const { return pSh; }
GetShell()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();
SetFirstVisPageInvalid()196     void SetFirstVisPageInvalid() { bFirstPageInvalid = sal_True; }
197 
198     sal_Bool AddPaintRect( const SwRect &rRect );
GetRegion()199     SwRegionRects *GetRegion()      { return pRegion; }
200     void DelRegion();
201 
202     // neues Interface fuer StarView Drawing
HasDrawView() const203     inline sal_Bool HasDrawView()       const { return 0 != pDrawView; }
GetDrawView()204           SwDrawView* GetDrawView()       { return pDrawView; }
GetDrawView() const205     const SwDrawView* GetDrawView() const { return pDrawView; }
GetPageView()206           SdrPageView*GetPageView()       { return pSdrPageView; }
GetPageView() const207     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
IsAction() const237     sal_Bool  IsAction() const                   { return pLayAct  != 0; }
IsIdleAction() const238     sal_Bool  IsIdleAction() const               { return pIdleAct != 0; }
GetLayAction()239           SwLayAction &GetLayAction()        { return *pLayAct; }
GetLayAction() const240     const SwLayAction &GetLayAction() const  { return *pLayAct; }
GetIdleAction()241           SwLayIdle   &GetIdleAction()       { return *pIdleAct;}
GetIdleAction() const242     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 
SetRestoreActions(sal_uInt16 nSet)252     void    SetRestoreActions(sal_uInt16 nSet){nRestoreActions = nSet;}
GetRestoreActions() const253     sal_uInt16  GetRestoreActions() const{return nRestoreActions;}
254 
255     // OD 12.12.2002 #103492#
256     void InitPagePreviewLayout();
257 
258     // OD 12.12.2002 #103492#
PagePreviewLayout()259     inline SwPagePreviewLayout* PagePreviewLayout()
260     {
261         return mpPgPrevwLayout;
262     }
263 
264     // Is this view accessible?
IsAccessible() const265     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     void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage);
290     void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection);
291     void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn);
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 
GetFirstVisPage()321 inline SwPageFrm *SwViewImp::GetFirstVisPage()
322 {
323     if ( bFirstPageInvalid )
324         SetFirstVisPage();
325     return pFirstVisPage;
326 }
327 
GetFirstVisPage() const328 inline const SwPageFrm *SwViewImp::GetFirstVisPage() const
329 {
330     if ( bFirstPageInvalid )
331         ((SwViewImp*)this)->SetFirstVisPage();
332     return pFirstVisPage;
333 }
334 
GetAccessibleMap()335 inline SwAccessibleMap& SwViewImp::GetAccessibleMap()
336 {
337     if( !pAccMap )
338         CreateAccessibleMap();
339 
340     return *pAccMap;
341 }
342 
DisposeAccessibleFrm(const SwFrm * pFrm,sal_Bool bRecursive)343 inline void SwViewImp::DisposeAccessibleFrm( const SwFrm *pFrm,
344                                sal_Bool bRecursive )
345 {
346     DisposeAccessible( pFrm, 0, bRecursive );
347 }
348 
DisposeAccessibleObj(const SdrObject * pObj)349 inline void SwViewImp::DisposeAccessibleObj( const SdrObject *pObj )
350 {
351     DisposeAccessible( 0, pObj, sal_False );
352 }
353 
MoveAccessibleFrm(const SwFrm * pFrm,const SwRect & rOldFrm)354 inline void SwViewImp::MoveAccessibleFrm( const SwFrm *pFrm,
355                                           const SwRect& rOldFrm )
356 {
357     MoveAccessible( pFrm, 0, rOldFrm );
358 }
359 
AddAccessibleFrm(const SwFrm * pFrm)360 inline void SwViewImp::AddAccessibleFrm( const SwFrm *pFrm )
361 {
362     SwRect aEmptyRect;
363     MoveAccessible( pFrm, 0, aEmptyRect );
364 }
365 
AddAccessibleObj(const SdrObject * pObj)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