xref: /trunk/main/sw/source/core/inc/rootfrm.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_ROOTFRM_HXX
28 #define SW_ROOTFRM_HXX
29 
30 #include "layfrm.hxx"
31 
32 class SwCntntFrm;
33 class ViewShell;
34 class SdrPage;
35 class SwFrmFmt;
36 class SwPaM;
37 class SwCursor;
38 class SwShellCrsr;
39 class SwTableCursor;
40 class SwLayVout;
41 class SwDestroyList;
42 class SwCurrShells;
43 class SwViewOption;
44 class SwSelectionList;
45 struct SwPosition;
46 struct SwCrsrMoveState;
47 
48 #define HACK_TABLEMODE_INIT         0
49 #define HACK_TABLEMODE_LOCKLINES    1
50 #define HACK_TABLEMODE_PAINTLINES   2
51 #define HACK_TABLEMODE_UNLOCKLINES  3
52 #define HACK_TABLEMODE_EXIT         4
53 
54 #define INV_SIZE    1
55 #define INV_PRTAREA 2
56 #define INV_POS     4
57 #define INV_TABLE   8
58 #define INV_SECTION 16
59 #define INV_LINENUM 32
60 #define INV_DIRECTION 64
61 
62 #include <vector>
63 
64 class SwRootFrm: public SwLayoutFrm
65 {
66     //Muss das Superfluous temporaer abschalten.
67     friend void AdjustSizeChgNotify( SwRootFrm *pRoot );
68 
69     //Pflegt pLastPage (Cut() und Paste() vom SwPageFrm
70     friend inline void SetLastPage( SwPageFrm* );
71 
72     // Fuer das Anlegen und Zerstoeren des virtuellen Outputdevice-Managers
73     friend void _FrmInit();     //erzeugt pVout
74     friend void _FrmFinit();    //loescht pVout
75 
76     // PAGES01
77     std::vector<SwRect> maPageRects;// returns the current rectangle for each page frame
78                                     // the rectangle is extended to the top/bottom/left/right
79                                     // for pages located at the outer borders
80     SwRect  maPagesArea;            // the area covered by the pages
81     long    mnViewWidth;            // the current page layout bases on this view width
82     sal_uInt16  mnColumns;              // the current page layout bases on this number of columns
83     bool    mbBookMode;             // the current page layout is in book view
84     bool    mbSidebarChanged;       // the notes sidebar state has changed
85     // <--
86 
87     bool    mbNeedGrammarCheck;     // true when sth needs to be checked (not necessarily started yet!)
88 
89     static SwLayVout     *pVout;
90     static sal_Bool           bInPaint;     //Schutz gegen doppelte Paints.
91     static sal_Bool           bNoVirDev;    //Bei SystemPaints kein virt. Device
92 
93     sal_Bool    bCheckSuperfluous   :1; //Leere Seiten suchen?
94     sal_Bool    bIdleFormat         :1; //Idle-Formatierer anwerfen?
95     sal_Bool    bBrowseWidthValid   :1; //Ist nBrowseWidth gueltig?
96     sal_Bool    bDummy2             :1; //Unbenutzt
97     sal_Bool    bTurboAllowed       :1;
98     sal_Bool    bAssertFlyPages     :1; //Ggf. weitere Seiten fuer Flys einfuegen?
99     sal_Bool    bDummy              :1; //Unbenutzt
100     sal_Bool    bIsVirtPageNum      :1; //gibt es eine virtuelle Seitennummer ?
101     sal_Bool    bIsNewLayout        :1; //Layout geladen oder neu erzeugt.
102     sal_Bool    bCallbackActionEnabled:1; //Keine Action in Benachrichtung erwuenscht
103                                     //siehe dcontact.cxx, ::Changed()
104 
105     //Fuer den BrowseMode. nBrowseWidth ist die Aeussere Kante des am weitesten
106     //rechts stehenden Objectes. Die rechte Kante der Seiten soll im BrowseMode
107     //nicht kleiner werden als dieser Wert.
108     long    nBrowseWidth;
109 
110     //Wenn nur _ein: CntntFrm zu formatieren ist, so steht dieser in pTurbo.
111     const SwCntntFrm *pTurbo;
112 
113     //Die letzte Seite wollen wir uns nicht immer muehsam zusammensuchen.
114     SwPageFrm *pLastPage;
115 
116     //Die Root kuemmert sich nun auch um den Shell-Zugriff. Ueber das Dokument
117     //sollte man auch immer an die Root herankommen und somit auch immer
118     //einen Zugriff auf die Shell haben.
119     //Der Pointer pCurrShell ist der Pointer auf irgendeine der Shells fuer
120     //das Dokument
121     //Da es durchaus nicht immer egal ist, auf welcher Shell gearbeitet wird,
122     //ist es notwendig die aktive Shell zu kennen. Das wird dadurch angenaehert,
123     //dass der Pointer pCurrShell immer dann umgesetzt wird, wenn eine
124     //Shell den Fokus erhaelt (FEShell). Zusaetzlich wird der Pointer
125     //Temporaer von SwCurrShell umgesetzt, dieses wird typischerweise
126     //ueber das Macro SET_CURR_SHELL erledigt. Makro + Klasse sind in der
127     //ViewShell zu finden. Diese Objekte koennen auch verschachtelt (auch fuer
128     //unterschiedliche Shells) erzeugt werden. Sie werden im Array pCurrShells
129     //gesammelt.
130     //Weiterhin kann es noch vorkommen, dass eine Shell aktiviert wird,
131     //waehrend noch ein CurrShell-Objekt "aktiv" ist. Dieses wird dann in
132     //pWaitingCurrShell eingetragen und vom letzten DTor der CurrShell
133     //"aktiviert".
134     //Ein weiteres Problem ist dass Zerstoeren einer Shell waehrend sie aktiv
135     //ist. Der Pointer pCurrShell wird dann auf eine beliebige andere Shell
136     //umgesetzt.
137     //Wenn zum Zeitpunkt der zerstoerung einer Shell diese noch in irgendwelchen
138     //CurrShell-Objekten referenziert wird, so wird auch dies aufgeklart.
139     friend class CurrShell;
140     friend void SetShell( ViewShell *pSh );
141     friend void InitCurrShells( SwRootFrm *pRoot );
142     ViewShell *pCurrShell;
143     ViewShell *pWaitingCurrShell;
144     SwCurrShells *pCurrShells;
145 
146     //Eine Page im DrawModel pro Dokument, hat immer die Groesse der Root.
147     SdrPage *pDrawPage;
148 
149     SwDestroyList* pDestroy;
150 
151     sal_uInt16  nPhyPageNums;           //Anzahl der Seiten.
152     sal_uInt16 nAccessibleShells;   // Number of accessible shells
153 
154     void ImplCalcBrowseWidth();
155     void ImplInvalidateBrowseWidth();
156 
157     void _DeleteEmptySct(); // zerstoert ggf. die angemeldeten SectionFrms
158     void _RemoveFromList( SwSectionFrm* pSct ); // entfernt SectionFrms aus der Delete-Liste
159 
160 protected:
161 
162     virtual void MakeAll();
163 
164 public:
165 
166     //MasterObjekte aus der Page entfernen (von den Ctoren gerufen).
167     static void RemoveMasterObjs( SdrPage *pPg );
168 
169     void AllCheckPageDescs() const;//swmod 080226
170     void AllInvalidateAutoCompleteWords() const;//swmod 080305
171     void AllAddPaintRect() const;
172     void AllRemoveFtns() ;//swmod 080305
173     void AllInvalidateSmartTagsOrSpelling(sal_Bool bSmartTags) const;//swmod 080307
174     //Virtuelles Device ausgeben (z.B. wenn Animationen ins Spiel kommen)
175     static sal_Bool FlushVout();
176     //Clipping sparen, wenn im Vout eh genau das Cliprechteck ausgegeben wird
177     static sal_Bool HasSameRect( const SwRect& rRect );
178 
179     SwRootFrm( SwFrmFmt*, ViewShell* );
180     ~SwRootFrm();
181     void Init(SwFrmFmt*);
182 
183     ViewShell *GetCurrShell() const { return pCurrShell; }
184     void DeRegisterShell( ViewShell *pSh );
185 
186     //Start-/EndAction fuer alle Shells auf moeglichst hoeher
187     //(Shell-Ableitungs-)Ebene aufsetzen. Fuer die StarONE Anbindung, die
188     //die Shells nicht dirkt kennt.
189     //Der ChangeLinkd der CrsrShell (UI-Benachrichtigung) wird im EndAllAction
190     //automatisch gecallt.
191     void StartAllAction();
192     void EndAllAction( sal_Bool bVirDev = sal_False );
193 
194     // fuer bestimmte UNO-Aktionen (Tabellencursor) ist es notwendig, dass alle Actions
195     // kurzfristig zurueckgesetzt werden. Dazu muss sich jede ViewShell ihren alten Action-zaehler
196     // merken
197     void UnoRemoveAllActions();
198     void UnoRestoreAllActions();
199 
200     const SdrPage* GetDrawPage() const { return pDrawPage; }
201           SdrPage* GetDrawPage()       { return pDrawPage; }
202           void     SetDrawPage( SdrPage* pNew ){ pDrawPage = pNew; }
203 
204     virtual sal_Bool  GetCrsrOfst( SwPosition *, Point&,
205                                SwCrsrMoveState* = 0 ) const;
206 
207     virtual void Paint( SwRect const&,
208                         SwPrintData const*const pPrintData = NULL ) const;
209     virtual SwTwips ShrinkFrm( SwTwips, sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
210     virtual SwTwips GrowFrm  ( SwTwips, sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
211 #ifdef DBG_UTIL
212     virtual void Cut();
213     virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
214 #endif
215 
216     virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
217 
218     Point  GetNextPrevCntntPos( const Point &rPoint, sal_Bool bNext ) const;
219 
220     virtual Size ChgSize( const Size& aNewSize );
221 
222     void SetIdleFlags() { bIdleFormat = sal_True; }
223     sal_Bool IsIdleFormat()  const { return bIdleFormat; }
224     void ResetIdleFormat()     { bIdleFormat = sal_False; }
225 
226     bool IsNeedGrammarCheck() const         { return mbNeedGrammarCheck; }
227     void SetNeedGrammarCheck( bool bVal )   { mbNeedGrammarCheck = bVal; }
228 
229     //Sorgt dafuer, dass alle gewuenschten Seitengebunden Flys eine Seite finden
230     void SetAssertFlyPages() { bAssertFlyPages = sal_True; }
231     void AssertFlyPages();
232     sal_Bool IsAssertFlyPages()  { return bAssertFlyPages; }
233 
234     //Stellt sicher, dass ab der uebergebenen Seite auf allen Seiten die
235     //Seitengebundenen Rahmen auf der richtigen Seite (Seitennummer) stehen.
236     void AssertPageFlys( SwPageFrm * );
237 
238     //Saemtlichen Inhalt invalidieren, Size oder PrtArea
239     void InvalidateAllCntnt( sal_uInt8 nInvalidate = INV_SIZE );
240 
241     /** method to invalidate/re-calculate the position of all floating
242         screen objects (Writer fly frames and drawing objects), which are
243         anchored to paragraph or to character.
244 
245         OD 2004-03-16 #i11860#
246 
247         @author OD
248     */
249     void InvalidateAllObjPos();
250 
251     //Ueberfluessige Seiten entfernen.
252     void SetSuperfluous()      { bCheckSuperfluous = sal_True; }
253     sal_Bool IsSuperfluous() const { return bCheckSuperfluous; }
254     void RemoveSuperfluous();
255 
256     //abfragen/setzen der aktuellen Seite und der Gesamtzahl der Seiten.
257     //Es wird soweit wie notwendig Formatiert.
258     sal_uInt16  GetCurrPage( const SwPaM* ) const;
259     sal_uInt16  SetCurrPage( SwCursor*, sal_uInt16 nPageNum );
260     Point   GetPagePos( sal_uInt16 nPageNum ) const;
261     sal_uInt16  GetPageNum() const      { return nPhyPageNums; }
262     void    DecrPhyPageNums()       { --nPhyPageNums; }
263     void    IncrPhyPageNums()       { ++nPhyPageNums; }
264     sal_Bool    IsVirtPageNum() const   { return bIsVirtPageNum; }
265     inline  void SetVirtPageNum( const sal_Bool bOf ) const;
266     sal_Bool    IsDummyPage( sal_uInt16 nPageNum ) const;
267 
268     // Point rPt: The point that should be used to find the page
269     // Size pSize: If given, we return the (first) page that overlaps with the
270     // rectangle defined by rPt and pSize
271     // bool bExtend: Extend each page to the left/right/top/botton up to the
272     // next page border
273     const SwPageFrm* GetPageAtPos( const Point& rPt, const Size* pSize = 0, bool bExtend = false ) const;
274 
275     //Der Crsr moechte die zu selektierenden Bereiche wissen.
276     void CalcFrmRects( SwShellCrsr&, sal_Bool bIsTblSel );
277 
278     // Calculates the cells included from the current selection
279     // false: There was no result because of an invalid layout
280     // true: Everything worked fine.
281     bool MakeTblCrsrs( SwTableCursor& );
282 
283     void DisallowTurbo()  const { ((SwRootFrm*)this)->bTurboAllowed = sal_False; }
284     void ResetTurboFlag() const { ((SwRootFrm*)this)->bTurboAllowed = sal_True; }
285     sal_Bool IsTurboAllowed() const { return bTurboAllowed; }
286     void SetTurbo( const SwCntntFrm *pCntnt ) { pTurbo = pCntnt; }
287     void ResetTurbo() { pTurbo = 0; }
288     const SwCntntFrm *GetTurbo() { return pTurbo; }
289 
290     //Fussnotennummern aller Seiten auf den neuesten Stand bringen.
291     void UpdateFtnNums();           //nur bei Seitenweiser Nummerierung!
292 
293     //Alle Fussnoten (nicht etwa die Referenzen) entfernen.
294     void RemoveFtns( SwPageFrm *pPage = 0, sal_Bool bPageOnly = sal_False,
295                      sal_Bool bEndNotes = sal_False );
296     void CheckFtnPageDescs( sal_Bool bEndNote );
297 
298     const SwPageFrm *GetLastPage() const { return pLastPage; }
299           SwPageFrm *GetLastPage()       { return pLastPage; }
300 
301     static sal_Bool IsInPaint() { return bInPaint; }
302 
303     static void SetNoVirDev( const sal_Bool bNew ) { bNoVirDev = bNew; }
304 
305     inline long GetBrowseWidth() const;
306     void SetBrowseWidth( long n ) { bBrowseWidthValid = sal_True; nBrowseWidth = n;}
307     inline void InvalidateBrowseWidth();
308 
309 #ifdef LONG_TABLE_HACK
310     void HackPrepareLongTblPaint( int nMode );
311 #endif
312 
313     sal_Bool IsNewLayout() const { return bIsNewLayout; }
314     void ResetNewLayout()    { bIsNewLayout = sal_False;}
315 
316     // Hier werden leere SwSectionFrms zur Zerstoerung angemeldet
317     // und spaeter zerstoert oder wieder abgemeldet
318     void InsertEmptySct( SwSectionFrm* pDel );
319     void DeleteEmptySct() { if( pDestroy ) _DeleteEmptySct(); }
320     void RemoveFromList( SwSectionFrm* pSct ) { if( pDestroy ) _RemoveFromList( pSct ); }
321 #ifdef DBG_UTIL
322     // Wird zur Zeit nur fuer ASSERTs benutzt:
323     sal_Bool IsInDelList( SwSectionFrm* pSct ) const; // Ist der SectionFrm in der Liste enthalten?
324 #endif
325 
326 
327     void SetCallbackActionEnabled( sal_Bool b ) { bCallbackActionEnabled = b; }
328     sal_Bool IsCallbackActionEnabled() const    { return bCallbackActionEnabled; }
329 
330     sal_Bool IsAnyShellAccessible() const { return nAccessibleShells > 0; }
331     void AddAccessibleShell() { ++nAccessibleShells; }
332     void RemoveAccessibleShell() { --nAccessibleShells; }
333 
334     /** get page frame by phyiscal page number
335 
336         OD 14.01.2003 #103492#
337         looping through the lowers, which are page frame, in order to find the
338         page frame with the given physical page number.
339         if no page frame is found, 0 is returned.
340         Note: Empty page frames are also returned.
341 
342         @param _nPageNum
343         input parameter - physical page number of page frame to be searched and
344         returned.
345 
346         @return pointer to the page frame with the given physical page number
347     */
348     SwPageFrm* GetPageByPageNum( sal_uInt16 _nPageNum ) const;
349 
350     // --> PAGES01
351     void CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea );
352     bool IsLeftToRightViewLayout() const;
353     const SwRect& GetPagesArea() const { return maPagesArea; }
354     void SetSidebarChanged() { mbSidebarChanged = true; }
355     // <--
356 };
357 
358 inline long SwRootFrm::GetBrowseWidth() const
359 {
360     if ( !bBrowseWidthValid )
361         ((SwRootFrm*)this)->ImplCalcBrowseWidth();
362     return nBrowseWidth;
363 }
364 
365 inline void SwRootFrm::InvalidateBrowseWidth()
366 {
367     if ( bBrowseWidthValid )
368         ImplInvalidateBrowseWidth();
369 }
370 
371 inline  void SwRootFrm::SetVirtPageNum( const sal_Bool bOf) const
372 {
373     ((SwRootFrm*)this)->bIsVirtPageNum = bOf;
374 }
375 
376 #endif  // SW_ROOTFRM_HXX
377 
378