LCOV - code coverage report
Current view: top level - sw/source/core/inc - rootfrm.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 47 47 100.0 %
Date: 2012-08-25 Functions: 39 39 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 8 100.0 %

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

Generated by: LCOV version 1.10