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 INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
21 :
22 : #include "layfrm.hxx"
23 : #include <viewsh.hxx>
24 : #include <doc.hxx>
25 :
26 : class SwCntntFrm;
27 : class SwViewShell;
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 bTurboAllowed :1;
84 : sal_Bool bAssertFlyPages :1; //Ggf. weitere Seiten fuer Flys einfuegen?
85 : sal_Bool bIsVirtPageNum :1; //gibt es eine virtuelle Seitennummer ?
86 : sal_Bool bIsNewLayout :1; //Layout geladen oder neu erzeugt.
87 : sal_Bool bCallbackActionEnabled:1; //Keine Action in Benachrichtung erwuenscht
88 : //siehe dcontact.cxx, ::Changed()
89 : bool bLayoutFreezed;
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 SwViewShell. 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( SwViewShell *pSh );
125 : friend void InitCurrShells( SwRootFrm *pRoot );
126 : SwViewShell *pCurrShell;
127 : SwViewShell *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() SAL_OVERRIDE;
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;
154 : void AllInvalidateAutoCompleteWords() const;
155 : void AllAddPaintRect() const;
156 : void AllRemoveFtns() ;
157 : void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const;
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*, SwViewShell* );
164 : virtual ~SwRootFrm();
165 : void Init(SwFrmFmt*);
166 :
167 0 : SwViewShell *GetCurrShell() const { return pCurrShell; }
168 : void DeRegisterShell( SwViewShell *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 SwViewShell ihren alten Action-zaehler
180 : // merken
181 : void UnoRemoveAllActions();
182 : void UnoRestoreAllActions();
183 :
184 : const SdrPage* GetDrawPage() const { return pDrawPage; }
185 0 : SdrPage* GetDrawPage() { return pDrawPage; }
186 0 : void SetDrawPage( SdrPage* pNew ){ pDrawPage = pNew; }
187 :
188 : virtual bool GetCrsrOfst( SwPosition *, Point&,
189 : SwCrsrMoveState* = 0, bool bTestBackground = false ) const SAL_OVERRIDE;
190 :
191 : virtual void Paint( SwRect const&,
192 : SwPrintData const*const pPrintData = NULL ) const SAL_OVERRIDE;
193 : virtual SwTwips ShrinkFrm( SwTwips, sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False ) SAL_OVERRIDE;
194 : virtual SwTwips GrowFrm ( SwTwips, sal_Bool bTst = sal_False, sal_Bool bInfo = sal_False ) SAL_OVERRIDE;
195 : #ifdef DBG_UTIL
196 : virtual void Cut() SAL_OVERRIDE;
197 : virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ) SAL_OVERRIDE;
198 : #endif
199 :
200 : virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const SAL_OVERRIDE;
201 :
202 : Point GetNextPrevCntntPos( const Point &rPoint, sal_Bool bNext ) const;
203 :
204 : virtual Size ChgSize( const Size& aNewSize ) SAL_OVERRIDE;
205 :
206 0 : void SetIdleFlags()
207 : {
208 0 : bIdleFormat = sal_True;
209 :
210 0 : SwViewShell* lcl_pCurrShell = GetCurrShell();
211 : // May be NULL if called from SfxBaseModel::dispose
212 : // (this happens in the build test 'rtfexport').
213 0 : if (lcl_pCurrShell != NULL)
214 0 : lcl_pCurrShell->GetDoc()->StartBackgroundJobs();
215 0 : }
216 0 : sal_Bool IsIdleFormat() const { return bIdleFormat; }
217 0 : void ResetIdleFormat() { bIdleFormat = sal_False; }
218 :
219 0 : bool IsNeedGrammarCheck() const { return mbNeedGrammarCheck; }
220 0 : void SetNeedGrammarCheck( bool bVal )
221 : {
222 0 : mbNeedGrammarCheck = bVal;
223 :
224 0 : if ( bVal )
225 : {
226 0 : SwViewShell* lcl_pCurrShell = GetCurrShell();
227 : // May be NULL if called from SfxBaseModel::dispose
228 : // (this happens in the build test 'rtfexport').
229 0 : if (lcl_pCurrShell != NULL)
230 0 : lcl_pCurrShell->GetDoc()->StartBackgroundJobs();
231 : }
232 0 : }
233 :
234 : //Sorgt dafuer, dass alle gewuenschten Seitengebunden Flys eine Seite finden
235 0 : void SetAssertFlyPages() { bAssertFlyPages = sal_True; }
236 : void AssertFlyPages();
237 0 : sal_Bool IsAssertFlyPages() { return bAssertFlyPages; }
238 :
239 : //Stellt sicher, dass ab der uebergebenen Seite auf allen Seiten die
240 : //Seitengebundenen Rahmen auf der richtigen Seite (Seitennummer) stehen.
241 : void AssertPageFlys( SwPageFrm * );
242 :
243 : //Saemtlichen Inhalt invalidieren, Size oder PrtArea
244 : void InvalidateAllCntnt( sal_uInt8 nInvalidate = INV_SIZE );
245 :
246 : /** method to invalidate/re-calculate the position of all floating
247 : screen objects (Writer fly frames and drawing objects), which are
248 : anchored to paragraph or to character.
249 :
250 : OD 2004-03-16 #i11860#
251 : */
252 : void InvalidateAllObjPos();
253 :
254 : //Ueberfluessige Seiten entfernen.
255 0 : void SetSuperfluous() { bCheckSuperfluous = sal_True; }
256 0 : sal_Bool IsSuperfluous() const { return bCheckSuperfluous; }
257 : void RemoveSuperfluous();
258 :
259 : //abfragen/setzen der aktuellen Seite und der Gesamtzahl der Seiten.
260 : //Es wird soweit wie notwendig Formatiert.
261 : sal_uInt16 GetCurrPage( const SwPaM* ) const;
262 : sal_uInt16 SetCurrPage( SwCursor*, sal_uInt16 nPageNum );
263 : Point GetPagePos( sal_uInt16 nPageNum ) const;
264 0 : sal_uInt16 GetPageNum() const { return nPhyPageNums; }
265 0 : void DecrPhyPageNums() { --nPhyPageNums; }
266 0 : void IncrPhyPageNums() { ++nPhyPageNums; }
267 0 : sal_Bool IsVirtPageNum() const { return bIsVirtPageNum; }
268 : inline void SetVirtPageNum( const sal_Bool bOf ) const;
269 : sal_Bool IsDummyPage( sal_uInt16 nPageNum ) const;
270 :
271 : // Point rPt: The point that should be used to find the page
272 : // Size pSize: If given, we return the (first) page that overlaps with the
273 : // rectangle defined by rPt and pSize
274 : // bool bExtend: Extend each page to the left/right/top/botton up to the
275 : // next page border
276 : const SwPageFrm* GetPageAtPos( const Point& rPt, const Size* pSize = 0, bool bExtend = false ) const;
277 :
278 : void CalcFrmRects(
279 : SwShellCrsr&,
280 : const sal_Bool bIsTblSel );
281 :
282 : // Calculates the cells included from the current selection
283 : // false: There was no result because of an invalid layout
284 : // true: Everything worked fine.
285 : bool MakeTblCrsrs( SwTableCursor& );
286 :
287 0 : void DisallowTurbo() const { ((SwRootFrm*)this)->bTurboAllowed = sal_False; }
288 0 : void ResetTurboFlag() const { ((SwRootFrm*)this)->bTurboAllowed = sal_True; }
289 0 : sal_Bool IsTurboAllowed() const { return bTurboAllowed; }
290 0 : void SetTurbo( const SwCntntFrm *pCntnt ) { pTurbo = pCntnt; }
291 0 : void ResetTurbo() { pTurbo = 0; }
292 0 : const SwCntntFrm *GetTurbo() { return pTurbo; }
293 :
294 : //Fussnotennummern aller Seiten auf den neuesten Stand bringen.
295 : void UpdateFtnNums(); //nur bei Seitenweiser Nummerierung!
296 :
297 : //Alle Fussnoten (nicht etwa die Referenzen) entfernen.
298 : void RemoveFtns( SwPageFrm *pPage = 0, sal_Bool bPageOnly = sal_False,
299 : sal_Bool bEndNotes = sal_False );
300 : void CheckFtnPageDescs( sal_Bool bEndNote );
301 :
302 : const SwPageFrm *GetLastPage() const { return pLastPage; }
303 0 : SwPageFrm *GetLastPage() { return pLastPage; }
304 :
305 0 : static bool IsInPaint() { return bInPaint; }
306 :
307 0 : static void SetNoVirDev( const sal_Bool bNew ) { bNoVirDev = bNew; }
308 :
309 : inline long GetBrowseWidth() const;
310 : void SetBrowseWidth( long n ) { bBrowseWidthValid = sal_True; nBrowseWidth = n;}
311 : inline void InvalidateBrowseWidth();
312 :
313 0 : sal_Bool IsNewLayout() const { return bIsNewLayout; }
314 0 : 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 0 : void DeleteEmptySct() { if( pDestroy ) _DeleteEmptySct(); }
320 0 : void RemoveFromList( SwSectionFrm* pSct ) { if( pDestroy ) _RemoveFromList( pSct ); }
321 : #ifdef DBG_UTIL
322 : bool IsInDelList( SwSectionFrm* pSct ) const;
323 : #endif
324 :
325 0 : void SetCallbackActionEnabled( sal_Bool b ) { bCallbackActionEnabled = b; }
326 0 : sal_Bool IsCallbackActionEnabled() const { return bCallbackActionEnabled; }
327 :
328 0 : sal_Bool IsAnyShellAccessible() const { return nAccessibleShells > 0; }
329 0 : void AddAccessibleShell() { ++nAccessibleShells; }
330 0 : void RemoveAccessibleShell() { --nAccessibleShells; }
331 :
332 : /** get page frame by phyiscal page number
333 :
334 : OD 14.01.2003 #103492#
335 : looping through the lowers, which are page frame, in order to find the
336 : page frame with the given physical page number.
337 : if no page frame is found, 0 is returned.
338 : Note: Empty page frames are also returned.
339 :
340 : @param _nPageNum
341 : input parameter - physical page number of page frame to be searched and
342 : returned.
343 :
344 : @return pointer to the page frame with the given physical page number
345 : */
346 : SwPageFrm* GetPageByPageNum( sal_uInt16 _nPageNum ) const;
347 :
348 : void CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea );
349 : bool IsLeftToRightViewLayout() const;
350 0 : const SwRect& GetPagesArea() const { return maPagesArea; }
351 0 : void SetSidebarChanged() { mbSidebarChanged = true; }
352 :
353 0 : bool IsLayoutFreezed() const { return bLayoutFreezed; }
354 0 : void FreezeLayout( bool freeze ) { bLayoutFreezed = freeze; }
355 : };
356 :
357 0 : inline long SwRootFrm::GetBrowseWidth() const
358 : {
359 0 : if ( !bBrowseWidthValid )
360 0 : ((SwRootFrm*)this)->ImplCalcBrowseWidth();
361 0 : return nBrowseWidth;
362 : }
363 :
364 0 : inline void SwRootFrm::InvalidateBrowseWidth()
365 : {
366 0 : if ( bBrowseWidthValid )
367 0 : ImplInvalidateBrowseWidth();
368 0 : }
369 :
370 0 : inline void SwRootFrm::SetVirtPageNum( const sal_Bool bOf) const
371 : {
372 0 : ((SwRootFrm*)this)->bIsVirtPageNum = bOf;
373 0 : }
374 :
375 : #endif // INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
376 :
377 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|