LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/inc - rootfrm.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 45 58 77.6 %
Date: 2012-12-27 Functions: 32 39 82.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10