LCOV - code coverage report
Current view: top level - sw/inc - pagedesc.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 87 89 97.8 %
Date: 2014-04-11 Functions: 57 59 96.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_INC_PAGEDESC_HXX
      20             : #define INCLUDED_SW_INC_PAGEDESC_HXX
      21             : 
      22             : #include <tools/fract.hxx>
      23             : #include <tools/color.hxx>
      24             : #include "swdllapi.h"
      25             : #include <swtypes.hxx>
      26             : #include <frmfmt.hxx>
      27             : #include <editeng/numitem.hxx>
      28             : #include <editeng/borderline.hxx>
      29             : 
      30             : class SfxPoolItem;
      31             : class SwTxtFmtColl;
      32             : class SwNode;
      33             : 
      34             : /// Separator line adjustment.
      35             : enum SwFtnAdj
      36             : {
      37             :     FTNADJ_LEFT,
      38             :     FTNADJ_CENTER,
      39             :     FTNADJ_RIGHT
      40             : };
      41             : 
      42             : /// Footnote information.
      43             : class SW_DLLPUBLIC SwPageFtnInfo
      44             : {
      45             :     SwTwips     nMaxHeight;              ///< maximum height of the footnote area.
      46             :     sal_uLong   nLineWidth;              ///< width of separator line
      47             :     editeng::SvxBorderStyle eLineStyle;  ///< Style of the separator line
      48             :     Color       aLineColor;              ///< color of the separator line
      49             :     Fraction    aWidth;                  ///< percentage width of the separator line.
      50             :     SwFtnAdj    eAdj;                    ///< line adjustment.
      51             :     SwTwips     nTopDist;                ///< distance between body and separator.
      52             :     SwTwips     nBottomDist;             ///< distance between separator and first footnote
      53             : 
      54             : public:
      55       47117 :     SwTwips     GetHeight() const       { return nMaxHeight; }
      56         171 :     sal_uLong           GetLineWidth() const { return nLineWidth; }
      57          26 :     const Color&    GetLineColor() const { return aLineColor;}
      58          26 :     editeng::SvxBorderStyle  GetLineStyle() const { return eLineStyle; }
      59       44126 :     const Fraction& GetWidth() const    { return aWidth; }
      60       41410 :     SwFtnAdj    GetAdj()    const       { return eAdj; }
      61       41571 :     SwTwips     GetTopDist()const       { return nTopDist; }
      62       41566 :     SwTwips     GetBottomDist() const   { return nBottomDist; }
      63             : 
      64         213 :     void SetHeight( SwTwips  nNew )     { nMaxHeight = nNew; }
      65         233 :     void SetLineWidth(sal_uLong nSet  )     { nLineWidth = nSet; }
      66         426 :     void SetLineStyle( editeng::SvxBorderStyle eSet )   { eLineStyle = eSet; }
      67         213 :     void SetLineColor(const Color& rCol )  { aLineColor = rCol;}
      68        1521 :     void SetWidth( const Fraction &rNew){ aWidth = rNew; }
      69         213 :     void SetAdj   ( SwFtnAdj eNew )     { eAdj = eNew; }
      70         233 :     void SetTopDist   ( SwTwips nNew )  { nTopDist = nNew; }
      71         233 :     void SetBottomDist( SwTwips nNew )  { nBottomDist = nNew; }
      72             : 
      73             :     SwPageFtnInfo();
      74             :     SwPageFtnInfo( const SwPageFtnInfo& );
      75             :     SwPageFtnInfo& operator=( const SwPageFtnInfo& );
      76             : 
      77             :     sal_Bool operator ==( const SwPageFtnInfo& ) const;
      78             : };
      79             : 
      80             : /*
      81             :  *  Use of UseOnPage (eUse) and of FrmFmts
      82             :  *
      83             :  *  RIGHT   - aMaster only for right hand (odd) pages, left hand (even) pages
      84             :  *            always empty.
      85             :  *  LEFT    - aLeft for left-hand pages, right-hand pages always empty.
      86             :  *            aLeft is a copy of master.
      87             :  *  ALL     - aMaster for right hand pages, aLeft for left hand pages.
      88             :  *          - aLeft is a copy of master.
      89             :  * MIRROR   - aMaster for right hand pages, aLeft for left hand pagers.
      90             :  *            aLeft is a copy of master, margins are mirrored.
      91             :  *
      92             :  * UI works exclusively on master! aLeft is adjusted on Chg at document
      93             :  * according to eUse.
      94             :  *
      95             :  * In order to simplify the work of the filters some more values are placed
      96             :  * into eUse:
      97             :  *
      98             :  * HEADERSHARE - Content of header is equal on left and right hand pages.
      99             :  * FOOTERSHARE - Content of footer is equal on left and right hand pages.
     100             :  *
     101             :  * The values are masked out in the respective getter and setter methods.
     102             :  * Access to complete eUse including the information on header and footer
     103             :  * via ReadUseOn(), WriteUseOn() (fuer Filter und CopyCTor)!
     104             :  *
     105             :  * The Frmformats for header/footer are adjusted by the UI according to
     106             :  * the attributes for header and footer at master (height, margin, back-
     107             :  * ground ...)
     108             :  * Header/footer for left hand pages are copied or mirrored (Chg at
     109             :  * document).
     110             :  * The respective attribute for content is cared for automatically on Chg at
     111             :  * document (contents are created or removed according to SHARE-information).
     112             :  */
     113             : 
     114             : typedef sal_uInt16 UseOnPage;
     115             : namespace nsUseOnPage
     116             : {
     117             :     const UseOnPage PD_NONE           = 0x0000; ///< For internal use only.
     118             :     const UseOnPage PD_LEFT           = 0x0001;
     119             :     const UseOnPage PD_RIGHT          = 0x0002;
     120             :     const UseOnPage PD_ALL            = 0x0003;
     121             :     const UseOnPage PD_MIRROR         = 0x0007;
     122             :     const UseOnPage PD_HEADERSHARE    = 0x0040;
     123             :     const UseOnPage PD_FOOTERSHARE    = 0x0080;
     124             :     const UseOnPage PD_NOHEADERSHARE  = 0xFFBF; ///< For internal use only.
     125             :     const UseOnPage PD_NOFOOTERSHARE  = 0xFF7F; ///< For internal use only.
     126             :     const UseOnPage PD_FIRSTSHARE = 0x0100;
     127             :     const UseOnPage PD_NOFIRSTSHARE = 0xFEFF;
     128             : }
     129             : 
     130             : class SW_DLLPUBLIC SwPageDesc : public SwModify
     131             : {
     132             :     friend class SwDoc;
     133             : 
     134             :     OUString    aDescName;
     135             :     SvxNumberType   aNumType;
     136             :     SwFrmFmt    aMaster;
     137             :     SwFrmFmt    aLeft;
     138             :     // FIXME epicycles growing here - page margins need to be stored differently
     139             :     SwFrmFmt    m_FirstMaster;
     140             :     SwFrmFmt    m_FirstLeft;
     141             :     SwDepend    aDepend;    ///< Because of grid alignment (Registerhaltigkeit).
     142             :     SwPageDesc *pFollow;
     143             :     sal_uInt16  nRegHeight; ///< Sentence spacing and fontascent of style.
     144             :     sal_uInt16  nRegAscent; ///< For grid alignment (Registerhaltigkeit).
     145             :     UseOnPage   eUse;
     146             :     sal_Bool        bLandscape;
     147             :     sal_Bool    bHidden;
     148             : 
     149             :     /// Footnote information.
     150             :     SwPageFtnInfo aFtnInfo;
     151             : 
     152             :     /** Called for mirroring of Chg (doc).
     153             :        No adjustment at any other place. */
     154             :     SAL_DLLPRIVATE void Mirror();
     155             : 
     156             :     SAL_DLLPRIVATE void ResetAllAttr( sal_Bool bLeft );
     157             : 
     158             :     SAL_DLLPRIVATE SwPageDesc(const OUString&, SwFrmFmt*, SwDoc *pDc );
     159             : 
     160             : protected:
     161             :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue ) SAL_OVERRIDE;
     162             : 
     163             : public:
     164      132390 :     OUString GetName() const { return aDescName; }
     165           4 :     void SetName( const OUString& rNewName ) { aDescName = rNewName; }
     166             : 
     167       18714 :     sal_Bool GetLandscape() const { return bLandscape; }
     168       10204 :     void SetLandscape( sal_Bool bNew ) { bLandscape = bNew; }
     169             : 
     170       23428 :     const SvxNumberType &GetNumType() const { return aNumType; }
     171        6620 :           void          SetNumType( const SvxNumberType& rNew ) { aNumType = rNew; }
     172             : 
     173       19347 :     const SwPageFtnInfo &GetFtnInfo() const { return aFtnInfo; }
     174        9525 :           SwPageFtnInfo &GetFtnInfo()       { return aFtnInfo; }
     175        4719 :     void  SetFtnInfo( const SwPageFtnInfo &rNew ) { aFtnInfo = rNew; }
     176             : 
     177             :     inline sal_Bool IsHeaderShared() const;
     178             :     inline sal_Bool IsFooterShared() const;
     179             :     inline void ChgHeaderShare( sal_Bool bNew );
     180             :     inline void ChgFooterShare( sal_Bool bNew );
     181             :     sal_Bool IsFirstShared() const;
     182             :     void ChgFirstShare( sal_Bool bNew );
     183             : 
     184        3674 :     sal_Bool IsHidden( ) const { return bHidden; }
     185         214 :     void SetHidden( sal_Bool bValue ) { bHidden = bValue; }
     186             : 
     187             :     inline void      SetUseOn( UseOnPage eNew );
     188             :     inline UseOnPage GetUseOn() const;
     189             : 
     190          85 :     void      WriteUseOn( UseOnPage eNew ) { eUse = eNew; }
     191       12162 :     UseOnPage ReadUseOn () const { return eUse; }
     192             : 
     193       76233 :           SwFrmFmt &GetMaster() { return aMaster; }
     194       52671 :           SwFrmFmt &GetLeft()   { return aLeft; }
     195       34647 :           SwFrmFmt &GetFirstMaster()   { return m_FirstMaster; }
     196       29184 :           SwFrmFmt &GetFirstLeft()   { return m_FirstLeft; }
     197       51076 :     const SwFrmFmt &GetMaster() const { return aMaster; }
     198       15495 :     const SwFrmFmt &GetLeft()   const { return aLeft; }
     199        7442 :     const SwFrmFmt &GetFirstMaster()   const { return m_FirstMaster; }
     200        7011 :     const SwFrmFmt &GetFirstLeft()   const { return m_FirstLeft; }
     201             : 
     202             :     /** Reset all attrs of the format but keep the ones a pagedesc
     203             :        cannot live without. */
     204             :     inline void ResetAllMasterAttr();
     205             :     inline void ResetAllLeftAttr();
     206             : 
     207             :     /** Layout uses the following methods to obtain a format in order
     208             :        to be able to create a page. */
     209             :            SwFrmFmt *GetRightFmt(bool const bFirst = false);
     210             :     inline const SwFrmFmt *GetRightFmt(bool const bFirst = false) const;
     211             :            SwFrmFmt *GetLeftFmt(bool const bFirst = false);
     212             :     inline const SwFrmFmt *GetLeftFmt(bool const bFirst = false) const;
     213             : 
     214        3432 :     sal_uInt16 GetRegHeight() const { return nRegHeight; }
     215        3432 :     sal_uInt16 GetRegAscent() const { return nRegAscent; }
     216           0 :     void SetRegHeight( sal_uInt16 nNew ){ nRegHeight = nNew; }
     217           0 :     void SetRegAscent( sal_uInt16 nNew ){ nRegAscent = nNew; }
     218             : 
     219             :     inline void SetFollow( const SwPageDesc* pNew );
     220       55413 :     const SwPageDesc* GetFollow() const { return pFollow; }
     221       14461 :           SwPageDesc* GetFollow() { return pFollow; }
     222             : 
     223             :     void SetRegisterFmtColl( const SwTxtFmtColl* rFmt );
     224             :     const SwTxtFmtColl* GetRegisterFmtColl() const;
     225             :     void RegisterChange();
     226             : 
     227             :     /// Query and set PoolFormat-Id.
     228       88295 :     sal_uInt16 GetPoolFmtId() const         { return aMaster.GetPoolFmtId(); }
     229        5374 :     void SetPoolFmtId( sal_uInt16 nId )     { aMaster.SetPoolFmtId( nId ); }
     230       18845 :     sal_uInt16 GetPoolHelpId() const        { return aMaster.GetPoolHelpId(); }
     231        3277 :     void SetPoolHelpId( sal_uInt16 nId )    { aMaster.SetPoolHelpId( nId ); }
     232       15568 :     sal_uInt8 GetPoolHlpFileId() const      { return aMaster.GetPoolHlpFileId(); }
     233        3277 :     void SetPoolHlpFileId( sal_uInt8 nId )  { aMaster.SetPoolHlpFileId( nId ); }
     234             : 
     235             :     /// Query information from Client.
     236             :     virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
     237             : 
     238             :     const SwFrmFmt* GetPageFmtOfNode( const SwNode& rNd,
     239             :                                     sal_Bool bCheckForThisPgDc = sal_True ) const;
     240             :     sal_Bool IsFollowNextPageOfNode( const SwNode& rNd ) const;
     241             : 
     242             :     /// Given a SwNode return the pagedesc in use at that location.
     243             :     static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd);
     244             : 
     245             :     static SwPageDesc* GetByName(SwDoc& rDoc, const OUString& rName);
     246             : 
     247             :     SwPageDesc& operator=( const SwPageDesc& );
     248             : 
     249             :     SwPageDesc( const SwPageDesc& );
     250             :     virtual ~SwPageDesc();
     251             : };
     252             : 
     253         957 : inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
     254             : {
     255         957 :     pFollow = pNew ? (SwPageDesc*)pNew : this;
     256         957 : }
     257             : 
     258       13366 : inline sal_Bool SwPageDesc::IsHeaderShared() const
     259             : {
     260       13366 :     return eUse & nsUseOnPage::PD_HEADERSHARE ? sal_True : sal_False;
     261             : }
     262       12986 : inline sal_Bool SwPageDesc::IsFooterShared() const
     263             : {
     264       12986 :     return eUse & nsUseOnPage::PD_FOOTERSHARE ? sal_True : sal_False;
     265             : }
     266        4855 : inline void SwPageDesc::ChgHeaderShare( sal_Bool bNew )
     267             : {
     268        4855 :     if ( bNew )
     269        4629 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_HEADERSHARE);
     270             :     else
     271         226 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOHEADERSHARE);
     272        4855 : }
     273        4556 : inline void SwPageDesc::ChgFooterShare( sal_Bool bNew )
     274             : {
     275        4556 :     if ( bNew )
     276        4406 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FOOTERSHARE);
     277             :     else
     278         150 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFOOTERSHARE);
     279        4556 : }
     280        5608 : inline void SwPageDesc::SetUseOn( UseOnPage eNew )
     281             : {
     282        5608 :     UseOnPage eTmp = nsUseOnPage::PD_NONE;
     283        5608 :     if ( eUse & nsUseOnPage::PD_HEADERSHARE )
     284        5517 :         eTmp = nsUseOnPage::PD_HEADERSHARE;
     285        5608 :     if ( eUse & nsUseOnPage::PD_FOOTERSHARE )
     286        5554 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
     287        5608 :     if ( eUse & nsUseOnPage::PD_FIRSTSHARE )
     288        5559 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FIRSTSHARE);
     289        5608 :     eUse = (UseOnPage) (eTmp | eNew);
     290             : 
     291        5608 : }
     292       18577 : inline UseOnPage SwPageDesc::GetUseOn() const
     293             : {
     294       18577 :     UseOnPage eRet = eUse;
     295       18577 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
     296       18577 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
     297       18577 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFIRSTSHARE);
     298       18577 :     return eRet;
     299             : }
     300             : 
     301         215 : inline void SwPageDesc::ResetAllMasterAttr()
     302             : {
     303         215 :     ResetAllAttr( sal_False );
     304         215 : }
     305             : 
     306             : inline void SwPageDesc::ResetAllLeftAttr()
     307             : {
     308             :     ResetAllAttr( sal_True );
     309             : }
     310             : 
     311         907 : inline const SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst) const
     312             : {
     313         907 :     return const_cast<SwPageDesc*>(this)->GetRightFmt(bFirst);
     314             : }
     315         903 : inline const SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst) const
     316             : {
     317         903 :     return const_cast<SwPageDesc*>(this)->GetLeftFmt(bFirst);
     318             : }
     319             : 
     320             : class SwPageDescExt
     321             : {
     322             :     SwPageDesc aPageDesc;
     323             :     SwDoc * pDoc;
     324             :     OUString sFollow;
     325             : 
     326             :     void SetPageDesc(const SwPageDesc & aPageDesc);
     327             : 
     328             : public:
     329             :     SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
     330             :     SwPageDescExt(const SwPageDescExt & rSrc);
     331             :     ~SwPageDescExt();
     332             : 
     333             :     SwPageDescExt & operator = (const SwPageDescExt & rSrc);
     334             :     SwPageDescExt & operator = (const SwPageDesc & rSrc);
     335             : 
     336             :     OUString GetName() const;
     337             : 
     338             :     operator SwPageDesc() const; // #i7983#
     339             : };
     340             : 
     341             : #endif // INCLUDED_SW_INC_PAGEDESC_HXX
     342             : 
     343             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10