LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/inc - pagefrm.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 87 95 91.6 %
Date: 2012-12-27 Functions: 45 50 90.0 %
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 _PAGEFRM_HXX
      20             : #define _PAGEFRM_HXX
      21             : 
      22             : #include <viewsh.hxx>
      23             : #include "ftnboss.hxx"
      24             : #include <tools/mempool.hxx>
      25             : 
      26             : #include <SidebarWindowsTypes.hxx>
      27             : 
      28             : class SwFlyFrm;
      29             : class SwFlyFrmFmt;
      30             : class SwPageDesc;
      31             : class SwCntntFrm;
      32             : struct SwPosition;
      33             : struct SwCrsrMoveState;
      34             : class SwAttrSetChg;
      35             : class Font;
      36             : 
      37             : // #i28701# - replaced by class <SwSortedObjs>
      38             : class SwSortedObjs;
      39             : // #i28701#
      40             : class SwAnchoredObject;
      41             : 
      42             : enum SwPageChg
      43             : {
      44             :     CHG_NEWPAGE,
      45             :     CHG_CUTPAGE,
      46             :     CHG_CHGPAGE
      47             : };
      48             : 
      49             : /// A page of the document layout.
      50             : class SwPageFrm: public SwFtnBossFrm
      51             : {
      52             :     friend class SwFrm;
      53             : 
      54             :     // #i28701# - use <SwSortedObjs>
      55             :     SwSortedObjs *pSortedObjs;
      56             : 
      57             :     SwPageDesc *pDesc;      //PageDesc der die Seite beschreibt.
      58             : 
      59             :     sal_uInt16  nPhyPageNum;        //Physikalische Seitennummer.
      60             : 
      61             :     sal_Bool bInvalidCntnt      :1;
      62             :     sal_Bool bInvalidLayout     :1;
      63             :     sal_Bool bInvalidFlyCntnt   :1;
      64             :     sal_Bool bInvalidFlyLayout  :1;
      65             :     sal_Bool bInvalidFlyInCnt   :1;
      66             :     sal_Bool bFtnPage           :1; //Diese Seite ist fuer Dokumentende-Fussnoten.
      67             :     sal_Bool bEmptyPage         :1; //Dies ist eine explizite Leerseite
      68             :     sal_Bool bEndNotePage       :1; //'Fussnotenseite' fuer Endnoten
      69             :     sal_Bool bInvalidSpelling   :1; //Das Online-Spelling ist gefordert
      70             :     sal_Bool bInvalidSmartTags :1;  //checking for smarttags is needed  // SMARTTAGS
      71             :     sal_Bool bInvalidAutoCmplWrds :1; //Auto-Complete Wordliste aktualisieren
      72             :     sal_Bool bInvalidWordCount  :1;
      73             :     sal_Bool bHasGrid           :1; // Grid for Asian layout
      74             : 
      75             :     // #i28701# - boolean, indicating that layout of page frame
      76             :     // is in progress.
      77             :     bool mbLayoutInProgress;
      78             : 
      79             :     static const sal_Int8 mnShadowPxWidth;
      80             : 
      81             :     void _UpdateAttr( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
      82             :                       SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );
      83             : 
      84             :     // Anpassen der max. Fussnotenhoehen in den einzelnen Spalten
      85             :     void SetColMaxFtnHeight();
      86             : 
      87             :     /** determine rectangle for horizontal page shadow
      88             : 
      89             :         #i9719#
      90             : 
      91             :         @param _rPageRect
      92             :         input parameter - constant instance reference of the page rectangle.
      93             :         Generally, it's the frame area of the page, but for empty pages in print
      94             :         preview, this parameter is useful.
      95             : 
      96             :         @param _pViewShell
      97             :         input parameter - instance of the view shell, for which the rectangle
      98             :         has to be generated.
      99             : 
     100             :         @param _orBottomShadowRect
     101             :         output parameter - instance reference of the bottom shadow rectangle for
     102             :         the given page rectangle
     103             :     */
     104             : 
     105             :     static void GetHorizontalShadowRect( const SwRect& _rPageRect,
     106             :                                      const ViewShell*    _pViewShell,
     107             :                                      SwRect&       _orBottomShadowRect,
     108             :                                      bool bPaintLeftShadow,
     109             :                                      bool bPaintRightShadow,
     110             :                                      bool bRightSidebar );
     111             : 
     112             : protected:
     113             :     virtual void MakeAll();
     114             :     virtual void Modify( const SfxPoolItem*, const SfxPoolItem* );
     115             : 
     116             : public:
     117         343 :     DECL_FIXEDMEMPOOL_NEWDEL(SwPageFrm)
     118             : 
     119             :     SwPageFrm( SwFrmFmt*, SwFrm*, SwPageDesc* );
     120             :     ~SwPageFrm();
     121             : 
     122             :     //public, damit die ViewShell beim Umschalten vom BrowseMode darauf
     123             :     //zugreifen kann.
     124             :     void PrepareHeader();   //Kopf-/Fusszeilen anlegen/entfernen.
     125             :     void PrepareFooter();
     126             : 
     127        5322 :     const SwSortedObjs  *GetSortedObjs() const  { return pSortedObjs; }
     128        6841 :           SwSortedObjs  *GetSortedObjs()          { return pSortedObjs; }
     129             : 
     130             :     // #i28701# - new methods to append/remove drawing objects
     131             :     void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
     132             :     void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
     133             : 
     134             :     void AppendFlyToPage( SwFlyFrm *pNew );
     135             :     void RemoveFlyFromPage( SwFlyFrm *pToRemove );
     136             :     void MoveFly( SwFlyFrm *pToMove, SwPageFrm *pDest );//optimiertes Remove/Append
     137             : 
     138             :     void  SetPageDesc( SwPageDesc *, SwFrmFmt * );
     139         330 :           SwPageDesc *GetPageDesc() { return pDesc; }
     140         227 :     const SwPageDesc *GetPageDesc() const { return pDesc; }
     141             :           SwPageDesc *FindPageDesc();
     142             : 
     143             :                  SwCntntFrm  *FindLastBodyCntnt();
     144             :     inline       SwCntntFrm  *FindFirstBodyCntnt();
     145             :     inline const SwCntntFrm  *FindFirstBodyCntnt() const;
     146             :     inline const SwCntntFrm  *FindLastBodyCntnt() const;
     147             : 
     148             :     SwRect GetBoundRect() const;
     149             : 
     150             :     //Spezialisiertes GetCntntPos() fuer Felder in Rahmen.
     151             :     void GetCntntPosition( const Point &rPt, SwPosition &rPos ) const;
     152             : 
     153       12106 :     sal_Bool IsEmptyPage() const { return bEmptyPage; } //explizite Leerseite.
     154             : 
     155             :     void    UpdateFtnNum();
     156             : 
     157             :     //Immer nach dem Paste rufen. Erzeugt die Seitengeb. Rahmen und Formatiert
     158             :     //generischen Inhalt.
     159             :     void PreparePage( sal_Bool bFtn );
     160             : 
     161             :     //Schickt an alle ContentFrames ein Prepare wg. geaenderter Registervorlage
     162             :     void PrepareRegisterChg();
     163             : 
     164             :     // #i50432# - adjust method description and synopsis.
     165             :     // Appends a fly frame - the given one or a new one - at the page frame.
     166             :     // Needed for <Modify> and <MakeFrms>
     167             :     // - return value not needed any more
     168             :     // - second parameter is of type <SwFlyFrmFmt*>
     169             :     // - third parameter only needed for assertion, but calling method assures
     170             :     //   this assertion. Thus, delete it.
     171             :     void PlaceFly( SwFlyFrm* pFly, SwFlyFrmFmt* pFmt );
     172             : 
     173             :     virtual sal_Bool GetCrsrOfst( SwPosition *, Point&,
     174             :                               SwCrsrMoveState* = 0, bool bTestBackground = false ) const;
     175             :         // erfrage vom Client Informationen
     176             :     virtual bool GetInfo( SfxPoolItem& ) const;
     177             : 
     178             :     virtual void Cut();
     179             :     virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );
     180             :     virtual void  CheckDirection( sal_Bool bVert );
     181             :     void CheckGrid( sal_Bool bInvalidate );
     182             :     void PaintGrid( OutputDevice* pOut, SwRect &rRect ) const;
     183        8350 :     sal_Bool HasGrid() const { return bHasGrid; }
     184             : 
     185             :     void PaintDecorators( ) const;
     186             :     virtual void PaintSubsidiaryLines( const SwPageFrm*, const SwRect& ) const;
     187             :     virtual void PaintBreak() const;
     188             : 
     189             :     //Zeilennummern usw malen
     190             :     void RefreshExtraData( const SwRect & ) const;
     191             : 
     192             :     //Hilfslinien malen.
     193             :     void RefreshSubsidiary( const SwRect& ) const;
     194             : 
     195             :     //Fussnotenschnittstelle
     196         707 :     sal_Bool IsFtnPage() const                                  { return bFtnPage; }
     197          10 :     sal_Bool IsEndNotePage() const                              { return bEndNotePage; }
     198         268 :     void SetFtnPage( sal_Bool b )                               { bFtnPage = b; }
     199           0 :     void SetEndNotePage( sal_Bool b )                           { bEndNotePage = b; }
     200             : 
     201        4222 :     inline  sal_uInt16 GetPhyPageNum() const        { return nPhyPageNum;}
     202         268 :     inline  void SetPhyPageNum( sal_uInt16 nNum )   { nPhyPageNum = nNum;}
     203           0 :     inline  void DecrPhyPageNum()               { --nPhyPageNum;     }
     204           1 :     inline  void IncrPhyPageNum()               { ++nPhyPageNum;     }
     205             : 
     206             :     //Validieren, invalidieren und abfragen des Status der Seite.
     207             :     //Layout/Cntnt und jeweils Fly/nicht Fly werden getrennt betrachtet.
     208             :     inline void InvalidateFlyLayout() const;
     209             :     inline void InvalidateFlyCntnt() const;
     210             :     inline void InvalidateFlyInCnt() const;
     211             :     inline void InvalidateLayout() const;
     212             :     inline void InvalidateCntnt() const;
     213             :     inline void InvalidateSpelling() const;
     214             :     inline void InvalidateSmartTags() const;
     215             :     inline void InvalidateAutoCompleteWords() const;
     216             :     inline void InvalidateWordCount() const;
     217             :     inline void ValidateFlyLayout() const;
     218             :     inline void ValidateFlyCntnt() const;
     219             :     inline void ValidateFlyInCnt() const;
     220             :     inline void ValidateLayout() const;
     221             :     inline void ValidateCntnt() const;
     222             :     inline void ValidateSpelling()  const;
     223             :     inline void ValidateSmartTags() const;        // SMARTTAGS
     224             :     inline void ValidateAutoCompleteWords() const;
     225             :     inline void ValidateWordCount() const;
     226             :     inline sal_Bool IsInvalid() const;
     227             :     inline sal_Bool IsInvalidFly() const;
     228             :     sal_Bool IsRightShadowNeeded() const;
     229             :     sal_Bool IsLeftShadowNeeded() const;
     230         389 :     sal_Bool IsInvalidFlyLayout() const { return bInvalidFlyLayout; }
     231         389 :     sal_Bool IsInvalidFlyCntnt() const { return bInvalidFlyCntnt; }
     232         389 :     sal_Bool IsInvalidFlyInCnt() const { return bInvalidFlyInCnt; }
     233        1345 :     sal_Bool IsInvalidLayout() const { return bInvalidLayout; }
     234         630 :     sal_Bool IsInvalidCntnt() const { return (bInvalidCntnt || bInvalidFlyInCnt); }
     235         389 :     sal_Bool IsInvalidSpelling() const { return bInvalidSpelling; }
     236           0 :     sal_Bool IsInvalidSmartTags() const { return bInvalidSmartTags; }   // SMARTTAGS
     237         388 :     sal_Bool IsInvalidAutoCompleteWords() const { return bInvalidAutoCmplWrds; }
     238         388 :     sal_Bool IsInvalidWordCount() const { return bInvalidWordCount; }
     239             : 
     240             :     /** SwPageFrm::GetDrawBackgrdColor
     241             : 
     242             :         determine the color, that is respectively will be drawn as background
     243             :         for the page frame.
     244             : 
     245             :         @return reference to an instance of class Color
     246             :     */
     247             :     const Color& GetDrawBackgrdColor() const;
     248             : 
     249             :     /** paint margin area of a page
     250             : 
     251             :         implement paint of margin area; margin area will be painted for a
     252             :         view shell with a window and if the document is not in online layout.
     253             : 
     254             :         @param _rOutputRect
     255             :         input parameter - constant instance reference of the rectangle, for
     256             :         which an output has to be generated.
     257             : 
     258             :         @param _pViewShell
     259             :         input parameter - instance of the view shell, on which the output
     260             :         has to be generated.
     261             :     */
     262             :     void PaintMarginArea( const SwRect& _rOutputRect,
     263             :                           ViewShell* _pViewShell ) const;
     264             : 
     265             :     /** paint page border and shadow
     266             : 
     267             :         #i9719#
     268             :         implement paint of page border and shadow
     269             : 
     270             :         @param _rPageRect
     271             :         input parameter - constant instance reference of the page rectangle.
     272             :         Generally, it's the frame area of the page, but for empty pages in print
     273             :         preview, this parameter is useful.
     274             : 
     275             :         @param _pViewShell
     276             :         input parameter - instance of the view shell, on which the output
     277             :         has to be generated.
     278             : 
     279             :         @param bPaintRightShadow
     280             :         Should we paint shadow on the right or not (used in book mode)
     281             : 
     282             :         @param bFullBottomShadow
     283             :         Should we have a bottom shadow of the same size as the pages or
     284             :         not (for right pages in book mode in a LTR environment).
     285             : 
     286             :         @param bRightSidebar
     287             :         Is the note sidebar on the right or not (used to adjust the
     288             :         shadow with & position).
     289             :     */
     290             :     static void PaintBorderAndShadow( const SwRect& _rPageRect,
     291             :                                       const ViewShell*    _pViewShell,
     292             :                                       bool bPaintLeftShadow,
     293             :                                       bool bPaintRightShadow,
     294             :                                       bool bRightSidebar );
     295             : 
     296             :     /** get bound rectangle of border and shadow for repaints
     297             : 
     298             :         #i9719#
     299             : 
     300             :         @param _rPageRect
     301             :         input parameter - constant instance reference of the page rectangle.
     302             :         Generally, it's the frame area of the page, but for empty pages in print
     303             :         preview, this parameter is useful.
     304             : 
     305             :         @param _pViewShell
     306             :         input parameter - instance of the view shell, for which the rectangle
     307             :         has to be generated.
     308             : 
     309             :         @param _orBorderAndShadowBoundRect
     310             :         output parameter - instance reference of the bounded border and shadow
     311             :         rectangle for the given page rectangle
     312             :     */
     313             :     static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
     314             :                                              const ViewShell*    _pViewShell,
     315             :                                              SwRect& _orBorderAndShadowBoundRect,
     316             :                                              const bool bLeftShadow,
     317             :                                              const bool bRightShadow,
     318             :                                              const bool bRightSidebar
     319             :                                             );
     320             : 
     321             :     static void PaintNotesSidebar(const SwRect& _rPageRect, ViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
     322             :     static void PaintNotesSidebarArrows(const Point &aMiddleFirst, const Point &aMiddleSecond, ViewShell* _pViewShell, const Color aColorUp, const Color aColorDown);
     323             :     /**
     324             :         asks the page on which side a margin should be shown, e.g for notes
     325             :         returns true for left side, false for right side
     326             :     */
     327             :     sw::sidebarwindows::SidebarPosition SidebarPosition() const;
     328             : 
     329             :     virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
     330             : 
     331             :     inline sal_Int8 ShadowPxWidth() const
     332             :     {
     333             :         return mnShadowPxWidth;
     334             :     }
     335             : 
     336             :     const SwRect PrtWithoutHeaderAndFooter() const;
     337             : 
     338             :     // #i28701#
     339           2 :     inline bool IsLayoutInProgress() const
     340             :     {
     341           2 :         return mbLayoutInProgress;
     342             :     }
     343         430 :     inline void SetLayoutInProgress( const bool _bLayoutInProgress )
     344             :     {
     345         430 :         mbLayoutInProgress = _bLayoutInProgress;
     346         430 :     }
     347             : 
     348             :     // in case this is am empty page, this function returns the 'reference' page
     349             :     const SwPageFrm& GetFormatPage() const;
     350             : 
     351             :     /// If in header or footer area, it also indicates the exact area in rControl.
     352             :     bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
     353             : 
     354             :     // return font used to paint the "empty page" string
     355             :     static const Font& GetEmptyPageFont();
     356             : 
     357             :     static SwTwips GetSidebarBorderWidth( const ViewShell* );
     358             : };
     359             : 
     360        1114 : inline SwCntntFrm *SwPageFrm::FindFirstBodyCntnt()
     361             : {
     362        1114 :     SwLayoutFrm *pBody = FindBodyCont();
     363        1114 :     return pBody ? pBody->ContainsCntnt() : 0;
     364             : }
     365           8 : inline const SwCntntFrm *SwPageFrm::FindFirstBodyCntnt() const
     366             : {
     367           8 :     const SwLayoutFrm *pBody = FindBodyCont();
     368           8 :     return pBody ? pBody->ContainsCntnt() : 0;
     369             : }
     370           0 : inline const SwCntntFrm *SwPageFrm::FindLastBodyCntnt() const
     371             : {
     372           0 :     return ((SwPageFrm*)this)->FindLastBodyCntnt();
     373             : }
     374         172 : inline void SwPageFrm::InvalidateFlyLayout() const
     375             : {
     376         172 :     ((SwPageFrm*)this)->bInvalidFlyLayout = sal_True;
     377         172 : }
     378         124 : inline void SwPageFrm::InvalidateFlyCntnt() const
     379             : {
     380         124 :     ((SwPageFrm*)this)->bInvalidFlyCntnt = sal_True;
     381         124 : }
     382         891 : inline void SwPageFrm::InvalidateFlyInCnt() const
     383             : {
     384         891 :     ((SwPageFrm*)this)->bInvalidFlyInCnt = sal_True;
     385         891 : }
     386        1506 : inline void SwPageFrm::InvalidateLayout() const
     387             : {
     388        1506 :     ((SwPageFrm*)this)->bInvalidLayout = sal_True;
     389        1506 : }
     390        2709 : inline void SwPageFrm::InvalidateCntnt() const
     391             : {
     392        2709 :     ((SwPageFrm*)this)->bInvalidCntnt = sal_True;
     393        2709 : }
     394         465 : inline void SwPageFrm::InvalidateSpelling() const
     395             : {
     396         465 :     ((SwPageFrm*)this)->bInvalidSpelling = sal_True;
     397         465 : }
     398             : // SMARTTAGS
     399         465 : inline void    SwPageFrm::InvalidateSmartTags() const
     400             : {
     401         465 :    ((SwPageFrm*)this)->bInvalidSmartTags = sal_True;
     402         465 : }
     403         465 : inline void SwPageFrm::InvalidateAutoCompleteWords() const
     404             : {
     405         465 :     ((SwPageFrm*)this)->bInvalidAutoCmplWrds = sal_True;
     406         465 : }
     407         465 : inline void SwPageFrm::InvalidateWordCount() const
     408             : {
     409         465 :     ((SwPageFrm*)this)->bInvalidWordCount = sal_True;
     410         465 : }
     411         605 : inline void SwPageFrm::ValidateFlyLayout() const
     412             : {
     413         605 :     ((SwPageFrm*)this)->bInvalidFlyLayout = sal_False;
     414         605 : }
     415         605 : inline void SwPageFrm::ValidateFlyCntnt() const
     416             : {
     417         605 :     ((SwPageFrm*)this)->bInvalidFlyCntnt = sal_False;
     418         605 : }
     419         239 : inline void SwPageFrm::ValidateFlyInCnt() const
     420             : {
     421         239 :     ((SwPageFrm*)this)->bInvalidFlyInCnt = sal_False;
     422         239 : }
     423         224 : inline void SwPageFrm::ValidateLayout() const
     424             : {
     425         224 :     ((SwPageFrm*)this)->bInvalidLayout = sal_False;
     426         224 : }
     427         239 : inline void SwPageFrm::ValidateCntnt() const
     428             : {
     429         239 :     ((SwPageFrm*)this)->bInvalidCntnt = sal_False;
     430         239 : }
     431         486 : inline void SwPageFrm::ValidateSpelling() const
     432             : {
     433         486 :     ((SwPageFrm*)this)->bInvalidSpelling = sal_False;
     434         486 : }
     435             : // SMARTTAGS
     436           0 : inline void    SwPageFrm::ValidateSmartTags() const
     437             : {
     438           0 :    ((SwPageFrm*)this)->bInvalidSmartTags = sal_False;
     439           0 : }
     440         486 : inline void SwPageFrm::ValidateAutoCompleteWords() const
     441             : {
     442         486 :     ((SwPageFrm*)this)->bInvalidAutoCmplWrds = sal_False;
     443         486 : }
     444         101 : inline void SwPageFrm::ValidateWordCount() const
     445             : {
     446         101 :     ((SwPageFrm*)this)->bInvalidWordCount = sal_False;
     447         101 : }
     448             : 
     449        3236 : inline sal_Bool SwPageFrm::IsInvalid() const
     450             : {
     451        3236 :     return (bInvalidCntnt || bInvalidLayout || bInvalidFlyInCnt);
     452             : }
     453        1881 : inline sal_Bool SwPageFrm::IsInvalidFly() const
     454             : {
     455        1881 :     return bInvalidFlyLayout || bInvalidFlyCntnt;
     456             : }
     457             : 
     458             : #define GETGRID( pPage ) const SwTextGridItem *pGrid = NULL; \
     459             :  {if( pPage && pPage->HasGrid() && GRID_NONE==(pGrid=(SwTextGridItem*)&pPage->\
     460             :      GetPageDesc()->GetMaster().GetFmtAttr(RES_TEXTGRID))->GetGridType() ) \
     461             :     pGrid = NULL;}
     462             : 
     463             : #define GETGRIDWIDTH( pGrid , pDoc )  pDoc->IsSquaredPageMode() ? \
     464             :     pGrid->GetBaseHeight(): pGrid->GetBaseWidth()
     465             : 
     466             : 
     467             : 
     468             : #endif  //_PAGEFRM_HXX
     469             : 
     470             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10