Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef SW_ROOTFRM_HXX
20 : #define SW_ROOTFRM_HXX
21 :
22 : #include "layfrm.hxx"
23 :
24 : class SwCntntFrm;
25 : class ViewShell;
26 : class SdrPage;
27 : class SwFrmFmt;
28 : class SwPaM;
29 : class SwCursor;
30 : class SwShellCrsr;
31 : class SwTableCursor;
32 : class SwLayVout;
33 : class SwDestroyList;
34 : class SwCurrShells;
35 : class SwViewOption;
36 : class SwSelectionList;
37 : struct SwPosition;
38 : struct SwCrsrMoveState;
39 :
40 : #define INV_SIZE 1
41 : #define INV_PRTAREA 2
42 : #define INV_POS 4
43 : #define INV_TABLE 8
44 : #define INV_SECTION 16
45 : #define INV_LINENUM 32
46 : #define INV_DIRECTION 64
47 :
48 : #include <vector>
49 :
50 : /// The root element of a Writer document layout.
51 : class SwRootFrm: public SwLayoutFrm
52 : {
53 : //Muss das Superfluous temporaer abschalten.
54 : friend void AdjustSizeChgNotify( SwRootFrm *pRoot );
55 :
56 : //Pflegt pLastPage (Cut() und Paste() vom SwPageFrm
57 : friend inline void SetLastPage( SwPageFrm* );
58 :
59 : // Fuer das Anlegen und Zerstoeren des virtuellen Outputdevice-Managers
60 : friend void _FrmInit(); //erzeugt pVout
61 : friend void _FrmFinit(); //loescht pVout
62 :
63 : // PAGES01
64 : std::vector<SwRect> maPageRects;// returns the current rectangle for each page frame
65 : // the rectangle is extended to the top/bottom/left/right
66 : // for pages located at the outer borders
67 : SwRect maPagesArea; // the area covered by the pages
68 : long mnViewWidth; // the current page layout bases on this view width
69 : sal_uInt16 mnColumns; // the current page layout bases on this number of columns
70 : bool mbBookMode; // the current page layout is in book view
71 : bool mbSidebarChanged; // the notes sidebar state has changed
72 :
73 : bool mbNeedGrammarCheck; // true when sth needs to be checked (not necessarily started yet!)
74 :
75 : static SwLayVout *pVout;
76 : static bool bInPaint; //Schutz gegen doppelte Paints.
77 : static sal_Bool bNoVirDev; //Bei SystemPaints kein virt. Device
78 :
79 : sal_Bool bCheckSuperfluous :1; //Leere Seiten suchen?
80 : sal_Bool bIdleFormat :1; //Idle-Formatierer anwerfen?
81 : sal_Bool bBrowseWidthValid :1; //Ist nBrowseWidth gueltig?
82 : sal_Bool bDummy2 :1; //Unbenutzt
83 : sal_Bool bTurboAllowed :1;
84 : sal_Bool bAssertFlyPages :1; //Ggf. weitere Seiten fuer Flys einfuegen?
85 : sal_Bool bDummy :1; //Unbenutzt
86 : sal_Bool bIsVirtPageNum :1; //gibt es eine virtuelle Seitennummer ?
87 : sal_Bool bIsNewLayout :1; //Layout geladen oder neu erzeugt.
88 : sal_Bool bCallbackActionEnabled:1; //Keine Action in Benachrichtung erwuenscht
89 : //siehe dcontact.cxx, ::Changed()
90 :
91 : //Fuer den BrowseMode. nBrowseWidth ist die Aeussere Kante des am weitesten
92 : //rechts stehenden Objectes. Die rechte Kante der Seiten soll im BrowseMode
93 : //nicht kleiner werden als dieser Wert.
94 : long nBrowseWidth;
95 :
96 : //Wenn nur _ein: CntntFrm zu formatieren ist, so steht dieser in pTurbo.
97 : const SwCntntFrm *pTurbo;
98 :
99 : //Die letzte Seite wollen wir uns nicht immer muehsam zusammensuchen.
100 : SwPageFrm *pLastPage;
101 :
102 : // [ Comment from the original StarOffice checkin ]:
103 : // The root takes care of the shell access. Via the document
104 : // it should be possible to get at the root frame, and thus always
105 : // have access to the shell.
106 : // the pointer pCurrShell is the pointer to any of the shells for
107 : // the document.
108 : // Because sometimes it matters which shell is used, it is necessary to
109 : // know the active shell.
110 : // this is approximated by setting the pointer pCurrShell when a
111 : // shell gets the focus (FEShell). Acditionally the pointer will be
112 : // set temporarily by SwCurrShell typically via SET_CURR_SHELL
113 : // The macro and class can be found in the ViewShell. These object can
114 : // be created nested (also for different kinds of Shells). They are
115 : // collected into the Array pCurrShells.
116 : // Futhermore it can happen that a shell is activated while a curshell
117 : // object is still 'active'. This one will be entered into pWaitingCurrShell
118 : // and will be activated by the last d'tor of CurrShell.
119 : // One other problem is the destruction of a shell while it is active.
120 : // The pointer pCurrShell is then reset to an arbitrary other shell.
121 : // If at the time of the destruction of a shell, which is still referneced
122 : // by a curshell object, that will be cleaned up as well.
123 : friend class CurrShell;
124 : friend void SetShell( ViewShell *pSh );
125 : friend void InitCurrShells( SwRootFrm *pRoot );
126 : ViewShell *pCurrShell;
127 : ViewShell *pWaitingCurrShell;
128 : SwCurrShells *pCurrShells;
129 :
130 : //Eine Page im DrawModel pro Dokument, hat immer die Groesse der Root.
131 : SdrPage *pDrawPage;
132 :
133 : SwDestroyList* pDestroy;
134 :
135 : sal_uInt16 nPhyPageNums; //Anzahl der Seiten.
136 : sal_uInt16 nAccessibleShells; // Number of accessible shells
137 :
138 : void ImplCalcBrowseWidth();
139 : void ImplInvalidateBrowseWidth();
140 :
141 : void _DeleteEmptySct(); // zerstoert ggf. die angemeldeten SectionFrms
142 : void _RemoveFromList( SwSectionFrm* pSct ); // entfernt SectionFrms aus der Delete-Liste
143 :
144 : protected:
145 :
146 : virtual void MakeAll();
147 :
148 : public:
149 :
150 : //MasterObjekte aus der Page entfernen (von den Ctoren gerufen).
151 : static void RemoveMasterObjs( SdrPage *pPg );
152 :
153 : void AllCheckPageDescs() const;//swmod 080226
154 : void AllInvalidateAutoCompleteWords() const;//swmod 080305
155 : void AllAddPaintRect() const;
156 : void AllRemoveFtns() ;//swmod 080305
157 : void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const;//swmod 080307
158 : //Virtuelles Device ausgeben (z.B. wenn Animationen ins Spiel kommen)
159 : static sal_Bool FlushVout();
160 : //Clipping sparen, wenn im Vout eh genau das Cliprechteck ausgegeben wird
161 : static sal_Bool HasSameRect( const SwRect& rRect );
162 :
163 : SwRootFrm( SwFrmFmt*, ViewShell* );
164 : virtual ~SwRootFrm();
165 : void Init(SwFrmFmt*);
166 :
167 139701 : ViewShell *GetCurrShell() const { return pCurrShell; }
168 : void DeRegisterShell( ViewShell *pSh );
169 :
170 : //Start-/EndAction fuer alle Shells auf moeglichst hoeher
171 : //(Shell-Ableitungs-)Ebene aufsetzen. Fuer die StarONE Anbindung, die
172 : //die Shells nicht dirkt kennt.
173 : //Der ChangeLinkd der CrsrShell (UI-Benachrichtigung) wird im EndAllAction
174 : //automatisch gecallt.
175 : void StartAllAction();
176 : void EndAllAction( sal_Bool bVirDev = sal_False );
177 :
178 : // fuer bestimmte UNO-Aktionen (Tabellencursor) ist es notwendig, dass alle Actions
179 : // kurzfristig zurueckgesetzt werden. Dazu muss sich jede ViewShell ihren alten Action-zaehler
180 : // merken
181 : void UnoRemoveAllActions();
182 : void UnoRestoreAllActions();
183 :
184 : const SdrPage* GetDrawPage() const { return pDrawPage; }
185 1924 : SdrPage* GetDrawPage() { return pDrawPage; }
186 1 : void SetDrawPage( SdrPage* pNew ){ pDrawPage = pNew; }
187 :
188 : virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
189 : SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
190 :
191 : virtual void Paint( SwRect const&,
192 : SwPrintData const*const pPrintData = NULL ) const;
193 : virtual SwTwips ShrinkFrm( SwTwips, sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
194 : virtual SwTwips GrowFrm ( SwTwips, sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False );
195 : #ifdef DBG_UTIL
196 : virtual void Cut();
197 : virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
198 : #endif
199 :
200 : virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
201 :
202 : Point GetNextPrevCntntPos( const Point &rPoint, sal_Bool bNext ) const;
203 :
204 : virtual Size ChgSize( const Size& aNewSize );
205 :
206 11694 : void SetIdleFlags() { bIdleFormat = sal_True; }
207 8669 : sal_Bool IsIdleFormat() const { return bIdleFormat; }
208 247 : void ResetIdleFormat() { bIdleFormat = sal_False; }
209 :
210 8669 : bool IsNeedGrammarCheck() const { return mbNeedGrammarCheck; }
211 7072 : void SetNeedGrammarCheck( bool bVal ) { mbNeedGrammarCheck = bVal; }
212 :
213 : //Sorgt dafuer, dass alle gewuenschten Seitengebunden Flys eine Seite finden
214 2 : void SetAssertFlyPages() { bAssertFlyPages = sal_True; }
215 : void AssertFlyPages();
216 2048 : sal_Bool IsAssertFlyPages() { return bAssertFlyPages; }
217 :
218 : //Stellt sicher, dass ab der uebergebenen Seite auf allen Seiten die
219 : //Seitengebundenen Rahmen auf der richtigen Seite (Seitennummer) stehen.
220 : void AssertPageFlys( SwPageFrm * );
221 :
222 : //Saemtlichen Inhalt invalidieren, Size oder PrtArea
223 : void InvalidateAllCntnt( sal_uInt8 nInvalidate = INV_SIZE );
224 :
225 : /** method to invalidate/re-calculate the position of all floating
226 : screen objects (Writer fly frames and drawing objects), which are
227 : anchored to paragraph or to character.
228 :
229 : OD 2004-03-16 #i11860#
230 :
231 : @author OD
232 : */
233 : void InvalidateAllObjPos();
234 :
235 : //Ueberfluessige Seiten entfernen.
236 7 : void SetSuperfluous() { bCheckSuperfluous = sal_True; }
237 2182 : sal_Bool IsSuperfluous() const { return bCheckSuperfluous; }
238 : void RemoveSuperfluous();
239 :
240 : //abfragen/setzen der aktuellen Seite und der Gesamtzahl der Seiten.
241 : //Es wird soweit wie notwendig Formatiert.
242 : sal_uInt16 GetCurrPage( const SwPaM* ) const;
243 : sal_uInt16 SetCurrPage( SwCursor*, sal_uInt16 nPageNum );
244 : Point GetPagePos( sal_uInt16 nPageNum ) const;
245 2734 : sal_uInt16 GetPageNum() const { return nPhyPageNums; }
246 1 : void DecrPhyPageNums() { --nPhyPageNums; }
247 563 : void IncrPhyPageNums() { ++nPhyPageNums; }
248 325 : sal_Bool IsVirtPageNum() const { return bIsVirtPageNum; }
249 : inline void SetVirtPageNum( const sal_Bool bOf ) const;
250 : sal_Bool IsDummyPage( sal_uInt16 nPageNum ) const;
251 :
252 : // Point rPt: The point that should be used to find the page
253 : // Size pSize: If given, we return the (first) page that overlaps with the
254 : // rectangle defined by rPt and pSize
255 : // bool bExtend: Extend each page to the left/right/top/botton up to the
256 : // next page border
257 : const SwPageFrm* GetPageAtPos( const Point& rPt, const Size* pSize = 0, bool bExtend = false ) const;
258 :
259 : //Der Crsr moechte die zu selektierenden Bereiche wissen.
260 : void CalcFrmRects( SwShellCrsr&, sal_Bool bIsTblSel );
261 :
262 : // Calculates the cells included from the current selection
263 : // false: There was no result because of an invalid layout
264 : // true: Everything worked fine.
265 : bool MakeTblCrsrs( SwTableCursor& );
266 :
267 7813 : void DisallowTurbo() const { ((SwRootFrm*)this)->bTurboAllowed = sal_False; }
268 3467 : void ResetTurboFlag() const { ((SwRootFrm*)this)->bTurboAllowed = sal_True; }
269 6977 : sal_Bool IsTurboAllowed() const { return bTurboAllowed; }
270 104 : void SetTurbo( const SwCntntFrm *pCntnt ) { pTurbo = pCntnt; }
271 3511 : void ResetTurbo() { pTurbo = 0; }
272 15953 : const SwCntntFrm *GetTurbo() { return pTurbo; }
273 :
274 : //Fussnotennummern aller Seiten auf den neuesten Stand bringen.
275 : void UpdateFtnNums(); //nur bei Seitenweiser Nummerierung!
276 :
277 : //Alle Fussnoten (nicht etwa die Referenzen) entfernen.
278 : void RemoveFtns( SwPageFrm *pPage = 0, sal_Bool bPageOnly = sal_False,
279 : sal_Bool bEndNotes = sal_False );
280 : void CheckFtnPageDescs( sal_Bool bEndNote );
281 :
282 : const SwPageFrm *GetLastPage() const { return pLastPage; }
283 71 : SwPageFrm *GetLastPage() { return pLastPage; }
284 :
285 703 : static bool IsInPaint() { return bInPaint; }
286 :
287 1210 : static void SetNoVirDev( const sal_Bool bNew ) { bNoVirDev = bNew; }
288 :
289 : inline long GetBrowseWidth() const;
290 : void SetBrowseWidth( long n ) { bBrowseWidthValid = sal_True; nBrowseWidth = n;}
291 : inline void InvalidateBrowseWidth();
292 :
293 478 : sal_Bool IsNewLayout() const { return bIsNewLayout; }
294 76 : void ResetNewLayout() { bIsNewLayout = sal_False;}
295 :
296 : // Hier werden leere SwSectionFrms zur Zerstoerung angemeldet
297 : // und spaeter zerstoert oder wieder abgemeldet
298 : void InsertEmptySct( SwSectionFrm* pDel );
299 4628 : void DeleteEmptySct() { if( pDestroy ) _DeleteEmptySct(); }
300 0 : void RemoveFromList( SwSectionFrm* pSct ) { if( pDestroy ) _RemoveFromList( pSct ); }
301 : #ifdef DBG_UTIL
302 : bool IsInDelList( SwSectionFrm* pSct ) const;
303 : #endif
304 :
305 :
306 5390 : void SetCallbackActionEnabled( sal_Bool b ) { bCallbackActionEnabled = b; }
307 4542 : sal_Bool IsCallbackActionEnabled() const { return bCallbackActionEnabled; }
308 :
309 13746 : sal_Bool IsAnyShellAccessible() const { return nAccessibleShells > 0; }
310 0 : void AddAccessibleShell() { ++nAccessibleShells; }
311 0 : void RemoveAccessibleShell() { --nAccessibleShells; }
312 :
313 : /** get page frame by phyiscal page number
314 :
315 : OD 14.01.2003 #103492#
316 : looping through the lowers, which are page frame, in order to find the
317 : page frame with the given physical page number.
318 : if no page frame is found, 0 is returned.
319 : Note: Empty page frames are also returned.
320 :
321 : @param _nPageNum
322 : input parameter - physical page number of page frame to be searched and
323 : returned.
324 :
325 : @return pointer to the page frame with the given physical page number
326 : */
327 : SwPageFrm* GetPageByPageNum( sal_uInt16 _nPageNum ) const;
328 :
329 : // --> PAGES01
330 : void CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea );
331 : bool IsLeftToRightViewLayout() const;
332 9 : const SwRect& GetPagesArea() const { return maPagesArea; }
333 12 : void SetSidebarChanged() { mbSidebarChanged = true; }
334 : };
335 :
336 0 : inline long SwRootFrm::GetBrowseWidth() const
337 : {
338 0 : if ( !bBrowseWidthValid )
339 0 : ((SwRootFrm*)this)->ImplCalcBrowseWidth();
340 0 : return nBrowseWidth;
341 : }
342 :
343 480 : inline void SwRootFrm::InvalidateBrowseWidth()
344 : {
345 480 : if ( bBrowseWidthValid )
346 0 : ImplInvalidateBrowseWidth();
347 480 : }
348 :
349 0 : inline void SwRootFrm::SetVirtPageNum( const sal_Bool bOf) const
350 : {
351 0 : ((SwRootFrm*)this)->bIsVirtPageNum = bOf;
352 0 : }
353 :
354 : #endif // SW_ROOTFRM_HXX
355 :
356 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|