LCOV - code coverage report
Current view: top level - sw/inc - pagedesc.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 89 0.0 %
Date: 2014-04-14 Functions: 0 59 0.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 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           0 :     SwTwips     GetHeight() const       { return nMaxHeight; }
      56           0 :     sal_uLong           GetLineWidth() const { return nLineWidth; }
      57           0 :     const Color&    GetLineColor() const { return aLineColor;}
      58           0 :     editeng::SvxBorderStyle  GetLineStyle() const { return eLineStyle; }
      59           0 :     const Fraction& GetWidth() const    { return aWidth; }
      60           0 :     SwFtnAdj    GetAdj()    const       { return eAdj; }
      61           0 :     SwTwips     GetTopDist()const       { return nTopDist; }
      62           0 :     SwTwips     GetBottomDist() const   { return nBottomDist; }
      63             : 
      64           0 :     void SetHeight( SwTwips  nNew )     { nMaxHeight = nNew; }
      65           0 :     void SetLineWidth(sal_uLong nSet  )     { nLineWidth = nSet; }
      66           0 :     void SetLineStyle( editeng::SvxBorderStyle eSet )   { eLineStyle = eSet; }
      67           0 :     void SetLineColor(const Color& rCol )  { aLineColor = rCol;}
      68           0 :     void SetWidth( const Fraction &rNew){ aWidth = rNew; }
      69           0 :     void SetAdj   ( SwFtnAdj eNew )     { eAdj = eNew; }
      70           0 :     void SetTopDist   ( SwTwips nNew )  { nTopDist = nNew; }
      71           0 :     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           0 :     OUString GetName() const { return aDescName; }
     165           0 :     void SetName( const OUString& rNewName ) { aDescName = rNewName; }
     166             : 
     167           0 :     sal_Bool GetLandscape() const { return bLandscape; }
     168           0 :     void SetLandscape( sal_Bool bNew ) { bLandscape = bNew; }
     169             : 
     170           0 :     const SvxNumberType &GetNumType() const { return aNumType; }
     171           0 :           void          SetNumType( const SvxNumberType& rNew ) { aNumType = rNew; }
     172             : 
     173           0 :     const SwPageFtnInfo &GetFtnInfo() const { return aFtnInfo; }
     174           0 :           SwPageFtnInfo &GetFtnInfo()       { return aFtnInfo; }
     175           0 :     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           0 :     sal_Bool IsHidden( ) const { return bHidden; }
     185           0 :     void SetHidden( sal_Bool bValue ) { bHidden = bValue; }
     186             : 
     187             :     inline void      SetUseOn( UseOnPage eNew );
     188             :     inline UseOnPage GetUseOn() const;
     189             : 
     190           0 :     void      WriteUseOn( UseOnPage eNew ) { eUse = eNew; }
     191           0 :     UseOnPage ReadUseOn () const { return eUse; }
     192             : 
     193           0 :           SwFrmFmt &GetMaster() { return aMaster; }
     194           0 :           SwFrmFmt &GetLeft()   { return aLeft; }
     195           0 :           SwFrmFmt &GetFirstMaster()   { return m_FirstMaster; }
     196           0 :           SwFrmFmt &GetFirstLeft()   { return m_FirstLeft; }
     197           0 :     const SwFrmFmt &GetMaster() const { return aMaster; }
     198           0 :     const SwFrmFmt &GetLeft()   const { return aLeft; }
     199           0 :     const SwFrmFmt &GetFirstMaster()   const { return m_FirstMaster; }
     200           0 :     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           0 :     sal_uInt16 GetRegHeight() const { return nRegHeight; }
     215           0 :     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           0 :     const SwPageDesc* GetFollow() const { return pFollow; }
     221           0 :           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           0 :     sal_uInt16 GetPoolFmtId() const         { return aMaster.GetPoolFmtId(); }
     229           0 :     void SetPoolFmtId( sal_uInt16 nId )     { aMaster.SetPoolFmtId( nId ); }
     230           0 :     sal_uInt16 GetPoolHelpId() const        { return aMaster.GetPoolHelpId(); }
     231           0 :     void SetPoolHelpId( sal_uInt16 nId )    { aMaster.SetPoolHelpId( nId ); }
     232           0 :     sal_uInt8 GetPoolHlpFileId() const      { return aMaster.GetPoolHlpFileId(); }
     233           0 :     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           0 : inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
     254             : {
     255           0 :     pFollow = pNew ? (SwPageDesc*)pNew : this;
     256           0 : }
     257             : 
     258           0 : inline sal_Bool SwPageDesc::IsHeaderShared() const
     259             : {
     260           0 :     return eUse & nsUseOnPage::PD_HEADERSHARE ? sal_True : sal_False;
     261             : }
     262           0 : inline sal_Bool SwPageDesc::IsFooterShared() const
     263             : {
     264           0 :     return eUse & nsUseOnPage::PD_FOOTERSHARE ? sal_True : sal_False;
     265             : }
     266           0 : inline void SwPageDesc::ChgHeaderShare( sal_Bool bNew )
     267             : {
     268           0 :     if ( bNew )
     269           0 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_HEADERSHARE);
     270             :     else
     271           0 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOHEADERSHARE);
     272           0 : }
     273           0 : inline void SwPageDesc::ChgFooterShare( sal_Bool bNew )
     274             : {
     275           0 :     if ( bNew )
     276           0 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FOOTERSHARE);
     277             :     else
     278           0 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFOOTERSHARE);
     279           0 : }
     280           0 : inline void SwPageDesc::SetUseOn( UseOnPage eNew )
     281             : {
     282           0 :     UseOnPage eTmp = nsUseOnPage::PD_NONE;
     283           0 :     if ( eUse & nsUseOnPage::PD_HEADERSHARE )
     284           0 :         eTmp = nsUseOnPage::PD_HEADERSHARE;
     285           0 :     if ( eUse & nsUseOnPage::PD_FOOTERSHARE )
     286           0 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
     287           0 :     if ( eUse & nsUseOnPage::PD_FIRSTSHARE )
     288           0 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FIRSTSHARE);
     289           0 :     eUse = (UseOnPage) (eTmp | eNew);
     290             : 
     291           0 : }
     292           0 : inline UseOnPage SwPageDesc::GetUseOn() const
     293             : {
     294           0 :     UseOnPage eRet = eUse;
     295           0 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
     296           0 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
     297           0 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFIRSTSHARE);
     298           0 :     return eRet;
     299             : }
     300             : 
     301           0 : inline void SwPageDesc::ResetAllMasterAttr()
     302             : {
     303           0 :     ResetAllAttr( sal_False );
     304           0 : }
     305             : 
     306             : inline void SwPageDesc::ResetAllLeftAttr()
     307             : {
     308             :     ResetAllAttr( sal_True );
     309             : }
     310             : 
     311           0 : inline const SwFrmFmt *SwPageDesc::GetRightFmt(bool const bFirst) const
     312             : {
     313           0 :     return const_cast<SwPageDesc*>(this)->GetRightFmt(bFirst);
     314             : }
     315           0 : inline const SwFrmFmt *SwPageDesc::GetLeftFmt(bool const bFirst) const
     316             : {
     317           0 :     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