LCOV - code coverage report
Current view: top level - sw/source/core/inc - rootfrm.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 59 60 98.3 %
Date: 2014-11-03 Functions: 40 41 97.6 %
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 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             : #include <IDocumentTimerAccess.hxx>
      26             : 
      27             : class SwCntntFrm;
      28             : class SwViewShell;
      29             : class SdrPage;
      30             : class SwFrmFmt;
      31             : class SwPaM;
      32             : class SwCursor;
      33             : class SwShellCrsr;
      34             : class SwTableCursor;
      35             : class SwLayVout;
      36             : class SwDestroyList;
      37             : class SwCurrShells;
      38             : class SwViewOption;
      39             : class SwSelectionList;
      40             : struct SwPosition;
      41             : struct SwCrsrMoveState;
      42             : 
      43             : #define INV_SIZE    1
      44             : #define INV_PRTAREA 2
      45             : #define INV_POS     4
      46             : #define INV_TABLE   8
      47             : #define INV_SECTION 16
      48             : #define INV_LINENUM 32
      49             : #define INV_DIRECTION 64
      50             : 
      51             : #include <vector>
      52             : 
      53             : /// The root element of a Writer document layout.
      54             : class SwRootFrm: public SwLayoutFrm
      55             : {
      56             :     // Needs to disable the Superfluous temporarily
      57             :     friend void AdjustSizeChgNotify( SwRootFrm *pRoot );
      58             : 
      59             :     // Maintains the pLastPage (Cut() and Paste() of SwPageFrm
      60             :     friend inline void SetLastPage( SwPageFrm* );
      61             : 
      62             :     // For creating and destroying of the virtual output device manager
      63             :     friend void _FrmInit(); // Creates pVout
      64             :     friend void _FrmFinit(); // Destroys pVout
      65             : 
      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 margins
      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; // Protection against double Paints
      79             :     static bool           bNoVirDev;// No virt. Device for SystemPaints
      80             : 
      81             :     bool    bCheckSuperfluous   :1; // Search for empty Pages?
      82             :     bool    bIdleFormat         :1; // Trigger Idle Formatter?
      83             :     bool    bBrowseWidthValid   :1; // Is nBrowseWidth valid?
      84             :     bool    bTurboAllowed       :1;
      85             :     bool    bAssertFlyPages     :1; // Insert more Pages for Flys if needed?
      86             :     bool    bIsVirtPageNum      :1; // Do we have a virtual pagenumber?
      87             :     bool    bIsNewLayout        :1; // Layout loaded or newly created
      88             :     bool    bCallbackActionEnabled:1; // No Action in Notification desired
      89             :                                       // @see dcontact.cxx, ::Changed()
      90             :     bool    bLayoutFreezed;
      91             : 
      92             :     /**
      93             :      * For BrowseMode
      94             :      * nBrowseWidth is the outer margin of the object most to the right.
      95             :      * The page's right edge should not be smaller than this value.
      96             :      */
      97             :     long    nBrowseWidth;
      98             : 
      99             :     /// If we only have to format one CntntFrm, its in pTurbo
     100             :     const SwCntntFrm *pTurbo;
     101             : 
     102             :     /// We should not need to always struggle to find the last page, so store it here
     103             :     SwPageFrm *pLastPage;
     104             : 
     105             :     /** [ Comment from the original StarOffice checkin ]:
     106             :      * The root takes care of the shell access. Via the document
     107             :      * it should be possible to get at the root frame, and thus always
     108             :      * have access to the shell.
     109             :      * the pointer pCurrShell is the pointer to any of the shells for
     110             :      * the document.
     111             :      * Because sometimes it matters which shell is used, it is necessary to
     112             :      * know the active shell.
     113             :      * this is approximated by setting the pointer pCurrShell when a
     114             :      * shell gets the focus (FEShell). Acditionally the pointer will be
     115             :      * set temporarily by SwCurrShell typically via  SET_CURR_SHELL
     116             :      * The macro and class can be found in the SwViewShell. These object can
     117             :      * be created nested (also for different kinds of Shells). They are
     118             :      * collected into the Array pCurrShells.
     119             :      * Furthermore it can happen that a shell is activated while a curshell
     120             :      * object is still 'active'. This one will be entered into pWaitingCurrShell
     121             :      * and will be activated by the last d'tor of CurrShell.
     122             :      * One other problem is the destruction of a shell while it is active.
     123             :      * The pointer pCurrShell is then reset to an arbitrary other shell.
     124             :      * If at the time of the destruction of a shell, which is still referneced
     125             :      * by a curshell object, that will be cleaned up as well.
     126             :      */
     127             :     friend class CurrShell;
     128             :     friend void SetShell( SwViewShell *pSh );
     129             :     friend void InitCurrShells( SwRootFrm *pRoot );
     130             :     SwViewShell *pCurrShell;
     131             :     SwViewShell *pWaitingCurrShell;
     132             :     SwCurrShells *pCurrShells;
     133             : 
     134             :     /// One Page per DrawModel per Document; is always the size of the Root
     135             :     SdrPage *pDrawPage;
     136             : 
     137             :     SwDestroyList* pDestroy;
     138             : 
     139             :     sal_uInt16  nPhyPageNums; /// Page count
     140             :     sal_uInt16 nAccessibleShells; // Number of accessible shells
     141             : 
     142             :     void ImplCalcBrowseWidth();
     143             :     void ImplInvalidateBrowseWidth();
     144             : 
     145             :     void _DeleteEmptySct(); // Destroys the registered SectionFrms
     146             :     void _RemoveFromList( SwSectionFrm* pSct ); // Removes SectionFrms from the Delete List
     147             : 
     148             : protected:
     149             : 
     150             :     virtual void MakeAll() SAL_OVERRIDE;
     151             : 
     152             : public:
     153             : 
     154             :     /// Remove MasterObjects from the Page (called by the ctors)
     155             :     static void RemoveMasterObjs( SdrPage *pPg );
     156             : 
     157             :     void AllCheckPageDescs() const;
     158             :     void AllInvalidateAutoCompleteWords() const;
     159             :     void AllAddPaintRect() const;
     160             :     void AllRemoveFtns() ;
     161             :     void AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const;
     162             : 
     163             :     /// Output virtual Device (e.g. for animations)
     164             :     static bool FlushVout();
     165             : 
     166             :     /// Save Clipping if exactly the ClipRect is outputted
     167             :     static bool HasSameRect( const SwRect& rRect );
     168             : 
     169             :     SwRootFrm( SwFrmFmt*, SwViewShell* );
     170             :     virtual ~SwRootFrm();
     171             :     void Init(SwFrmFmt*);
     172             : 
     173     5140574 :     SwViewShell *GetCurrShell() const { return pCurrShell; }
     174             :     void DeRegisterShell( SwViewShell *pSh );
     175             : 
     176             :     /**
     177             :      * Set up Start-/EndAction for all Shells on a as high as possible
     178             :      * (Shell section) level.
     179             :      * For the StarONE binding, which does not know the Shells directly.
     180             :      * The ChangeLinkd of the CrsrShell (UI notifications) is called
     181             :      * automatically in the EndAllAction.
     182             :      */
     183             :     void StartAllAction();
     184             :     void EndAllAction( bool bVirDev = false );
     185             : 
     186             :     /**
     187             :      * Certain UNO Actions (e.g. table cursor) require that all Actions are reset temporarily
     188             :      * In order for that to work, every SwViewShell needs to remember its old Action counter
     189             :      */
     190             :     void UnoRemoveAllActions();
     191             :     void UnoRestoreAllActions();
     192             : 
     193             :     const SdrPage* GetDrawPage() const { return pDrawPage; }
     194       21738 :           SdrPage* GetDrawPage()       { return pDrawPage; }
     195           0 :           void     SetDrawPage( SdrPage* pNew ){ pDrawPage = pNew; }
     196             : 
     197             :     virtual bool  GetCrsrOfst( SwPosition *, Point&,
     198             :                                SwCrsrMoveState* = 0, bool bTestBackground = false ) const SAL_OVERRIDE;
     199             : 
     200             :     virtual void Paint( SwRect const&,
     201             :                         SwPrintData const*const pPrintData = NULL ) const SAL_OVERRIDE;
     202             :     virtual SwTwips ShrinkFrm( SwTwips, bool bTst = false, bool bInfo = false ) SAL_OVERRIDE;
     203             :     virtual SwTwips GrowFrm  ( SwTwips, bool bTst = false, bool bInfo = false ) SAL_OVERRIDE;
     204             : #ifdef DBG_UTIL
     205             :     virtual void Cut() SAL_OVERRIDE;
     206             :     virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 ) SAL_OVERRIDE;
     207             : #endif
     208             : 
     209             :     virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const SAL_OVERRIDE;
     210             : 
     211             :     Point  GetNextPrevCntntPos( const Point &rPoint, bool bNext ) const;
     212             : 
     213             :     virtual Size ChgSize( const Size& aNewSize ) SAL_OVERRIDE;
     214             : 
     215      485754 :     void SetIdleFlags()
     216             :     {
     217      485754 :         bIdleFormat = true;
     218             : 
     219      485754 :         SwViewShell* lcl_pCurrShell = GetCurrShell();
     220             :         // May be NULL if called from SfxBaseModel::dispose
     221             :         // (this happens in the build test 'rtfexport').
     222      485754 :         if (lcl_pCurrShell != NULL)
     223      484736 :             lcl_pCurrShell->GetDoc()->getIDocumentTimerAccess().StartBackgroundJobs();
     224      485754 :     }
     225         777 :     bool IsIdleFormat()  const { return bIdleFormat; }
     226         194 :     void ResetIdleFormat()     { bIdleFormat = false; }
     227             : 
     228         777 :     bool IsNeedGrammarCheck() const         { return mbNeedGrammarCheck; }
     229      309030 :     void SetNeedGrammarCheck( bool bVal )
     230             :     {
     231      309030 :         mbNeedGrammarCheck = bVal;
     232             : 
     233      309030 :         if ( bVal )
     234             :         {
     235      309030 :             SwViewShell* lcl_pCurrShell = GetCurrShell();
     236             :             // May be NULL if called from SfxBaseModel::dispose
     237             :             // (this happens in the build test 'rtfexport').
     238      309030 :             if (lcl_pCurrShell != NULL)
     239      308696 :                 lcl_pCurrShell->GetDoc()->getIDocumentTimerAccess().StartBackgroundJobs();
     240             :         }
     241      309030 :     }
     242             : 
     243             :     /// Makes sure that all requested page-bound Flys find a Page
     244         772 :     void SetAssertFlyPages() { bAssertFlyPages = true; }
     245             :     void AssertFlyPages();
     246       31025 :     bool IsAssertFlyPages()  { return bAssertFlyPages; }
     247             : 
     248             :     /**
     249             :      * Makes sure that, starting from the passed Page, all page-bound Frames
     250             :      * are on the right Page (pagenumber).
     251             :      */
     252             :     void AssertPageFlys( SwPageFrm * );
     253             : 
     254             :     /// Invalidate all Cntnt, Size or PrtArea
     255             :     void InvalidateAllCntnt( sal_uInt8 nInvalidate = INV_SIZE );
     256             : 
     257             :     /**
     258             :      * Invalidate/re-calculate the position of all floating
     259             :      * screen objects (Writer fly frames and drawing objects), which are
     260             :      * anchored to paragraph or to character.
     261             :     */
     262             :     void InvalidateAllObjPos();
     263             : 
     264             :     /// Remove superfluous Pages
     265        2910 :     void SetSuperfluous()      { bCheckSuperfluous = true; }
     266       34419 :     bool IsSuperfluous() const { return bCheckSuperfluous; }
     267             :     void RemoveSuperfluous();
     268             : 
     269             :     /**
     270             :      * Query/set the current Page and the collective Page count
     271             :      * We'll format as much as necessary
     272             :      */
     273             :     sal_uInt16  GetCurrPage( const SwPaM* ) const;
     274             :     sal_uInt16  SetCurrPage( SwCursor*, sal_uInt16 nPageNum );
     275             :     Point   GetPagePos( sal_uInt16 nPageNum ) const;
     276       66069 :     sal_uInt16  GetPageNum() const      { return nPhyPageNums; }
     277         392 :     void    DecrPhyPageNums()       { --nPhyPageNums; }
     278        7532 :     void    IncrPhyPageNums()       { ++nPhyPageNums; }
     279        7743 :     bool    IsVirtPageNum() const   { return bIsVirtPageNum; }
     280             :     inline  void SetVirtPageNum( const bool bOf ) const;
     281             :     bool    IsDummyPage( sal_uInt16 nPageNum ) const;
     282             : 
     283             :     /**
     284             :      * Point rPt: The point that should be used to find the page
     285             :      * Size pSize: If given, we return the (first) page that overlaps with the
     286             :      * rectangle defined by rPt and pSize
     287             :      * bool bExtend: Extend each page to the left/right/top/botton up to the
     288             :      * next page margin
     289             :      */
     290             :     const SwPageFrm* GetPageAtPos( const Point& rPt, const Size* pSize = 0, bool bExtend = false ) const;
     291             : 
     292             :     void CalcFrmRects( SwShellCrsr& );
     293             : 
     294             :     /**
     295             :      * Calculates the cells included from the current selection
     296             :      *
     297             :      * @returns false: There was no result because of an invalid layout
     298             :      * @returns true: Everything worked fine.
     299             :      */
     300             :     bool MakeTblCrsrs( SwTableCursor& );
     301             : 
     302      264800 :     void DisallowTurbo()  const { ((SwRootFrm*)this)->bTurboAllowed = false; }
     303       75610 :     void ResetTurboFlag() const { ((SwRootFrm*)this)->bTurboAllowed = true; }
     304      286481 :     bool IsTurboAllowed() const { return bTurboAllowed; }
     305       10913 :     void SetTurbo( const SwCntntFrm *pCntnt ) { pTurbo = pCntnt; }
     306       78623 :     void ResetTurbo() { pTurbo = 0; }
     307      686700 :     const SwCntntFrm *GetTurbo() { return pTurbo; }
     308             : 
     309             :     /// Update the footernumbers of all Pages
     310             :     void UpdateFtnNums(); // Only for page by page numnbering!
     311             : 
     312             :     /// Remove all footnotes (but no references)
     313             :     void RemoveFtns( SwPageFrm *pPage = 0, bool bPageOnly = false,
     314             :                      bool bEndNotes = false );
     315             :     void CheckFtnPageDescs( bool bEndNote );
     316             : 
     317             :     const SwPageFrm *GetLastPage() const { return pLastPage; }
     318         326 :           SwPageFrm *GetLastPage()       { return pLastPage; }
     319             : 
     320        6795 :     static bool IsInPaint() { return bInPaint; }
     321             : 
     322        5088 :     static void SetNoVirDev( const bool bNew ) { bNoVirDev = bNew; }
     323             : 
     324             :     inline long GetBrowseWidth() const;
     325             :     void SetBrowseWidth( long n ) { bBrowseWidthValid = true; nBrowseWidth = n;}
     326             :     inline void InvalidateBrowseWidth();
     327             : 
     328        4662 :     bool IsNewLayout() const { return bIsNewLayout; }
     329        5316 :     void ResetNewLayout()    { bIsNewLayout = false;}
     330             : 
     331             :     /**
     332             :      * Empty SwSectionFrms are registered here for deletion and
     333             :      * destroyed later on or deregistered.
     334             :      */
     335             :     void InsertEmptySct( SwSectionFrm* pDel );
     336      100077 :     void DeleteEmptySct() { if( pDestroy ) _DeleteEmptySct(); }
     337        1184 :     void RemoveFromList( SwSectionFrm* pSct ) { if( pDestroy ) _RemoveFromList( pSct ); }
     338             : #ifdef DBG_UTIL
     339             :     bool IsInDelList( SwSectionFrm* pSct ) const;
     340             : #endif
     341             : 
     342       89776 :     void SetCallbackActionEnabled( bool b ) { bCallbackActionEnabled = b; }
     343       89935 :     bool IsCallbackActionEnabled() const    { return bCallbackActionEnabled; }
     344             : 
     345      542632 :     bool IsAnyShellAccessible() const { return nAccessibleShells > 0; }
     346          24 :     void AddAccessibleShell() { ++nAccessibleShells; }
     347          24 :     void RemoveAccessibleShell() { --nAccessibleShells; }
     348             : 
     349             :     /**
     350             :      * Get page frame by phyiscal page number
     351             :      * looping through the lowers, which are page frame, in order to find the
     352             :      * page frame with the given physical page number.
     353             :      * if no page frame is found, 0 is returned.
     354             :      * Note: Empty page frames are also returned.
     355             :      *
     356             :      * @param _nPageNum: physical page number of page frame to be searched and
     357             :      *                   returned.
     358             :      *
     359             :      * @return pointer to the page frame with the given physical page number
     360             :     */
     361             :     SwPageFrm* GetPageByPageNum( sal_uInt16 _nPageNum ) const;
     362             : 
     363             :     void CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea );
     364             :     bool IsLeftToRightViewLayout() const;
     365        1075 :     const SwRect& GetPagesArea() const { return maPagesArea; }
     366         318 :     void SetSidebarChanged() { mbSidebarChanged = true; }
     367             : 
     368          54 :     bool IsLayoutFreezed() const { return bLayoutFreezed; }
     369           8 :     void FreezeLayout( bool freeze ) { bLayoutFreezed = freeze; }
     370             : };
     371             : 
     372         196 : inline long SwRootFrm::GetBrowseWidth() const
     373             : {
     374         196 :     if ( !bBrowseWidthValid )
     375         168 :         ((SwRootFrm*)this)->ImplCalcBrowseWidth();
     376         196 :     return nBrowseWidth;
     377             : }
     378             : 
     379        9936 : inline void SwRootFrm::InvalidateBrowseWidth()
     380             : {
     381        9936 :     if ( bBrowseWidthValid )
     382         156 :         ImplInvalidateBrowseWidth();
     383        9936 : }
     384             : 
     385          66 : inline  void SwRootFrm::SetVirtPageNum( const bool bOf) const
     386             : {
     387          66 :     ((SwRootFrm*)this)->bIsVirtPageNum = bOf;
     388          66 : }
     389             : 
     390             : #endif // INCLUDED_SW_SOURCE_CORE_INC_ROOTFRM_HXX
     391             : 
     392             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10