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