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