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