LCOV - code coverage report
Current view: top level - sw/inc - pagedesc.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 88 90 97.8 %
Date: 2014-11-03 Functions: 58 60 96.7 %
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      159740 :     SwTwips     GetHeight() const       { return nMaxHeight; }
      56         430 :     sal_uLong           GetLineWidth() const { return nLineWidth; }
      57          84 :     const Color&    GetLineColor() const { return aLineColor;}
      58          16 :     editeng::SvxBorderStyle  GetLineStyle() const { return eLineStyle; }
      59      152350 :     const Fraction& GetWidth() const    { return aWidth; }
      60      144272 :     SwFtnAdj    GetAdj()    const       { return eAdj; }
      61      144600 :     SwTwips     GetTopDist()const       { return nTopDist; }
      62      144580 :     SwTwips     GetBottomDist() const   { return nBottomDist; }
      63             : 
      64         574 :     void SetHeight( SwTwips  nNew )     { nMaxHeight = nNew; }
      65         834 :     void SetLineWidth(sal_uLong nSet  )     { nLineWidth = nSet; }
      66          10 :     void SetLineStyle( editeng::SvxBorderStyle eSet )   { eLineStyle = eSet; }
      67         674 :     void SetLineColor(const Color& rCol )  { aLineColor = rCol;}
      68        4584 :     void SetWidth( const Fraction &rNew){ aWidth = rNew; }
      69         674 :     void SetAdj   ( SwFtnAdj eNew )     { eAdj = eNew; }
      70         834 :     void SetTopDist   ( SwTwips nNew )  { nTopDist = nNew; }
      71         834 :     void SetBottomDist( SwTwips nNew )  { nBottomDist = nNew; }
      72             : 
      73             :     SwPageFtnInfo();
      74             :     SwPageFtnInfo( const SwPageFtnInfo& );
      75             :     SwPageFtnInfo& operator=( const SwPageFtnInfo& );
      76             : 
      77             :     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             :     bool        bLandscape;
     147             :     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( 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      162916 :     OUString GetName() const { return aDescName; }
     165      139295 :     bool HasName( const OUString& rThisName ) { return aDescName == rThisName; }
     166           8 :     void SetName( const OUString& rNewName ) { aDescName = rNewName; }
     167             : 
     168       62532 :     bool GetLandscape() const { return bLandscape; }
     169       32854 :     void SetLandscape( bool bNew ) { bLandscape = bNew; }
     170             : 
     171       76522 :     const SvxNumberType &GetNumType() const { return aNumType; }
     172       21334 :           void          SetNumType( const SvxNumberType& rNew ) { aNumType = rNew; }
     173             : 
     174       63952 :     const SwPageFtnInfo &GetFtnInfo() const { return aFtnInfo; }
     175       29948 :           SwPageFtnInfo &GetFtnInfo()       { return aFtnInfo; }
     176       14664 :     void  SetFtnInfo( const SwPageFtnInfo &rNew ) { aFtnInfo = rNew; }
     177             : 
     178             :     inline bool IsHeaderShared() const;
     179             :     inline bool IsFooterShared() const;
     180             :     inline void ChgHeaderShare( bool bNew );
     181             :     inline void ChgFooterShare( bool bNew );
     182             :     bool IsFirstShared() const;
     183             :     void ChgFirstShare( bool bNew );
     184             : 
     185       12016 :     bool IsHidden( ) const { return bHidden; }
     186         678 :     void SetHidden( bool bValue ) { bHidden = bValue; }
     187             : 
     188             :     inline void      SetUseOn( UseOnPage eNew );
     189             :     inline UseOnPage GetUseOn() const;
     190             : 
     191         220 :     void      WriteUseOn( UseOnPage eNew ) { eUse = eNew; }
     192       38462 :     UseOnPage ReadUseOn () const { return eUse; }
     193             : 
     194      241526 :           SwFrmFmt &GetMaster() { return aMaster; }
     195      166700 :           SwFrmFmt &GetLeft()   { return aLeft; }
     196      127970 :           SwFrmFmt &GetFirstMaster()   { return m_FirstMaster; }
     197      112168 :           SwFrmFmt &GetFirstLeft()   { return m_FirstLeft; }
     198      163635 :     const SwFrmFmt &GetMaster() const { return aMaster; }
     199       49936 :     const SwFrmFmt &GetLeft()   const { return aLeft; }
     200       34612 :     const SwFrmFmt &GetFirstMaster()   const { return m_FirstMaster; }
     201       33326 :     const SwFrmFmt &GetFirstLeft()   const { return m_FirstLeft; }
     202             : 
     203             :     /** Reset all attrs of the format but keep the ones a pagedesc
     204             :        cannot live without. */
     205             :     inline void ResetAllMasterAttr();
     206             :     inline void ResetAllLeftAttr();
     207             : 
     208             :     /** Layout uses the following methods to obtain a format in order
     209             :        to be able to create a page. */
     210             :            SwFrmFmt *GetRightFmt(bool const bFirst = false);
     211             :     inline const SwFrmFmt *GetRightFmt(bool const bFirst = false) const;
     212             :            SwFrmFmt *GetLeftFmt(bool const bFirst = false);
     213             :     inline const SwFrmFmt *GetLeftFmt(bool const bFirst = false) const;
     214             : 
     215       11220 :     sal_uInt16 GetRegHeight() const { return nRegHeight; }
     216       11220 :     sal_uInt16 GetRegAscent() const { return nRegAscent; }
     217           0 :     void SetRegHeight( sal_uInt16 nNew ){ nRegHeight = nNew; }
     218           0 :     void SetRegAscent( sal_uInt16 nNew ){ nRegAscent = nNew; }
     219             : 
     220             :     inline void SetFollow( const SwPageDesc* pNew );
     221      152356 :     const SwPageDesc* GetFollow() const { return pFollow; }
     222       46090 :           SwPageDesc* GetFollow() { return pFollow; }
     223             : 
     224             :     void SetRegisterFmtColl( const SwTxtFmtColl* rFmt );
     225             :     const SwTxtFmtColl* GetRegisterFmtColl() const;
     226             :     void RegisterChange();
     227             : 
     228             :     /// Query and set PoolFormat-Id.
     229      233152 :     sal_uInt16 GetPoolFmtId() const         { return aMaster.GetPoolFmtId(); }
     230       16442 :     void SetPoolFmtId( sal_uInt16 nId )     { aMaster.SetPoolFmtId( nId ); }
     231       45406 :     sal_uInt16 GetPoolHelpId() const        { return aMaster.GetPoolHelpId(); }
     232       10594 :     void SetPoolHelpId( sal_uInt16 nId )    { aMaster.SetPoolHelpId( nId ); }
     233       34812 :     sal_uInt8 GetPoolHlpFileId() const      { return aMaster.GetPoolHlpFileId(); }
     234       10594 :     void SetPoolHlpFileId( sal_uInt8 nId )  { aMaster.SetPoolHlpFileId( nId ); }
     235             : 
     236             :     /// Query information from Client.
     237             :     virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;
     238             : 
     239             :     const SwFrmFmt* GetPageFmtOfNode( const SwNode& rNd,
     240             :                                     bool bCheckForThisPgDc = true ) const;
     241             :     bool IsFollowNextPageOfNode( const SwNode& rNd ) const;
     242             : 
     243             :     /// Given a SwNode return the pagedesc in use at that location.
     244             :     static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd);
     245             : 
     246             :     static SwPageDesc* GetByName(SwDoc& rDoc, const OUString& rName);
     247             : 
     248             :     SwPageDesc& operator=( const SwPageDesc& );
     249             : 
     250             :     SwPageDesc( const SwPageDesc& );
     251             :     virtual ~SwPageDesc();
     252             : };
     253             : 
     254        3082 : inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
     255             : {
     256        3082 :     pFollow = pNew ? (SwPageDesc*)pNew : this;
     257        3082 : }
     258             : 
     259       44742 : inline bool SwPageDesc::IsHeaderShared() const
     260             : {
     261       44742 :     return eUse & nsUseOnPage::PD_HEADERSHARE ? sal_True : sal_False;
     262             : }
     263       42042 : inline bool SwPageDesc::IsFooterShared() const
     264             : {
     265       42042 :     return eUse & nsUseOnPage::PD_FOOTERSHARE ? sal_True : sal_False;
     266             : }
     267       16090 : inline void SwPageDesc::ChgHeaderShare( bool bNew )
     268             : {
     269       16090 :     if ( bNew )
     270       14770 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_HEADERSHARE);
     271             :     else
     272        1320 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOHEADERSHARE);
     273       16090 : }
     274       14560 : inline void SwPageDesc::ChgFooterShare( bool bNew )
     275             : {
     276       14560 :     if ( bNew )
     277       13904 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FOOTERSHARE);
     278             :     else
     279         656 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFOOTERSHARE);
     280       14560 : }
     281       17132 : inline void SwPageDesc::SetUseOn( UseOnPage eNew )
     282             : {
     283       17132 :     UseOnPage eTmp = nsUseOnPage::PD_NONE;
     284       17132 :     if ( eUse & nsUseOnPage::PD_HEADERSHARE )
     285       16564 :         eTmp = nsUseOnPage::PD_HEADERSHARE;
     286       17132 :     if ( eUse & nsUseOnPage::PD_FOOTERSHARE )
     287       16886 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
     288       17132 :     if ( eUse & nsUseOnPage::PD_FIRSTSHARE )
     289       17040 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FIRSTSHARE);
     290       17132 :     eUse = (UseOnPage) (eTmp | eNew);
     291             : 
     292       17132 : }
     293       62633 : inline UseOnPage SwPageDesc::GetUseOn() const
     294             : {
     295       62633 :     UseOnPage eRet = eUse;
     296       62633 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
     297       62633 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
     298       62633 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFIRSTSHARE);
     299       62633 :     return eRet;
     300             : }
     301             : 
     302         670 : inline void SwPageDesc::ResetAllMasterAttr()
     303             : {
     304         670 :     ResetAllAttr( false );
     305         670 : }
     306             : 
     307             : inline void SwPageDesc::ResetAllLeftAttr()
     308             : {
     309             :     ResetAllAttr( true );
     310             : }
     311             : 
     312        1964 : inline const SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst) const
     313             : {
     314        1964 :     return const_cast<SwPageDesc*>(this)->GetRightFmt(bFirst);
     315             : }
     316        1956 : inline const SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst) const
     317             : {
     318        1956 :     return const_cast<SwPageDesc*>(this)->GetLeftFmt(bFirst);
     319             : }
     320             : 
     321             : class SwPageDescExt
     322             : {
     323             :     SwPageDesc aPageDesc;
     324             :     SwDoc * pDoc;
     325             :     OUString sFollow;
     326             : 
     327             :     void SetPageDesc(const SwPageDesc & aPageDesc);
     328             : 
     329             : public:
     330             :     SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
     331             :     SwPageDescExt(const SwPageDescExt & rSrc);
     332             :     ~SwPageDescExt();
     333             : 
     334             :     SwPageDescExt & operator = (const SwPageDescExt & rSrc);
     335             :     SwPageDescExt & operator = (const SwPageDesc & rSrc);
     336             : 
     337             :     OUString GetName() const;
     338             : 
     339             :     operator SwPageDesc() const; // #i7983#
     340             : };
     341             : 
     342             : #endif // INCLUDED_SW_INC_PAGEDESC_HXX
     343             : 
     344             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10