LCOV - code coverage report
Current view: top level - libreoffice/sw/inc - pagedesc.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 90 94 95.7 %
Date: 2012-12-27 Functions: 58 61 95.1 %
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 _PAGEDESC_HXX
      20             : #define _PAGEDESC_HXX
      21             : 
      22             : #include <tools/fract.hxx>
      23             : #include <tools/color.hxx>
      24             : #include <tools/string.hxx>
      25             : #include "swdllapi.h"
      26             : #include <swtypes.hxx>  ///< For SwTwips.
      27             : #include <frmfmt.hxx>
      28             : #include <editeng/numitem.hxx>
      29             : #include <editeng/borderline.hxx>
      30             : 
      31             : class SfxPoolItem;
      32             : class SwTxtFmtColl;
      33             : class SwNode;
      34             : 
      35             : /// Separator line adjustment.
      36             : enum SwFtnAdj
      37             : {
      38             :     FTNADJ_LEFT,
      39             :     FTNADJ_CENTER,
      40             :     FTNADJ_RIGHT
      41             : };
      42             : 
      43             : /// Footnote information.
      44             : class SW_DLLPUBLIC SwPageFtnInfo
      45             : {
      46             :     SwTwips     nMaxHeight;              ///< maximum height of the footnote area.
      47             :     sal_uLong   nLineWidth;              ///< width of separator line
      48             :     editeng::SvxBorderStyle eLineStyle;  ///< Style of the separator line
      49             :     Color       aLineColor;              ///< color of the separator line
      50             :     Fraction    aWidth;                  ///< percentage width of the separator line.
      51             :     SwFtnAdj    eAdj;                    ///< line adjustment.
      52             :     SwTwips     nTopDist;                ///< distance between body and separator.
      53             :     SwTwips     nBottomDist;             ///< distance between separator and first footnote
      54             : 
      55             : public:
      56        5639 :     SwTwips     GetHeight() const       { return nMaxHeight; }
      57          14 :     sal_uLong           GetLineWidth() const { return nLineWidth; }
      58           4 :     const Color&    GetLineColor() const { return aLineColor;}
      59           4 :     editeng::SvxBorderStyle  GetLineStyle() const { return eLineStyle; }
      60        5311 :     const Fraction& GetWidth() const    { return aWidth; }
      61        5311 :     SwFtnAdj    GetAdj()    const       { return eAdj; }
      62        5325 :     SwTwips     GetTopDist()const       { return nTopDist; }
      63        5325 :     SwTwips     GetBottomDist() const   { return nBottomDist; }
      64             : 
      65          28 :     void SetHeight( SwTwips  nNew )     { nMaxHeight = nNew; }
      66          29 :     void SetLineWidth(sal_uLong nSet  )     { nLineWidth = nSet; }
      67          56 :     void SetLineStyle( editeng::SvxBorderStyle eSet )   { eLineStyle = eSet; }
      68          28 :     void SetLineColor(const Color& rCol )  { aLineColor = rCol;}
      69          28 :     void SetWidth( const Fraction &rNew){ aWidth = rNew; }
      70          28 :     void SetAdj   ( SwFtnAdj eNew )     { eAdj = eNew; }
      71          29 :     void SetTopDist   ( SwTwips nNew )  { nTopDist = nNew; }
      72          29 :     void SetBottomDist( SwTwips nNew )  { nBottomDist = nNew; }
      73             : 
      74             :     SwPageFtnInfo();
      75             :     SwPageFtnInfo( const SwPageFtnInfo& );
      76             :     SwPageFtnInfo& operator=( const SwPageFtnInfo& );
      77             : 
      78             :     sal_Bool operator ==( const SwPageFtnInfo& ) const;
      79             : };
      80             : 
      81             : /*
      82             :  *  Use of UseOnPage (eUse) and of FrmFmts
      83             :  *
      84             :  *  RIGHT   - aMaster only for right hand (odd) pages, left hand (even) pages
      85             :  *            always empty.
      86             :  *  LEFT    - aLeft for left-hand pages, right-hand pages always empty.
      87             :  *            aLeft is a copy of master.
      88             :  *  ALL     - aMaster for right hand pages, aLeft for left hand pages.
      89             :  *          - aLeft is a copy of master.
      90             :  * MIRROR   - aMaster for right hand pages, aLeft for left hand pagers.
      91             :  *            aLeft is a copy of master, margins are mirrored.
      92             :  *
      93             :  * UI works exclusively on master! aLeft is adjusted on Chg at document
      94             :  * according to eUse.
      95             :  *
      96             :  * In order to simplify the work of the filters some more values are placed
      97             :  * into eUse:
      98             :  *
      99             :  * HEADERSHARE - Content of header is equal on left and right hand pages.
     100             :  * FOOTERSHARE - Content of footer is equal on left and right hand pages.
     101             :  *
     102             :  * The values are masked out in the respective getter and setter methods.
     103             :  * Access to complete eUse including the information on header and footer
     104             :  * via ReadUseOn(), WriteUseOn() (fuer Filter und CopyCTor)!
     105             :  *
     106             :  * The Frmformats for header/footer are adjusted by the UI according to
     107             :  * the attributes for header and footer at master (height, margin, back-
     108             :  * ground ...)
     109             :  * Header/footer for left hand pages are copied or mirrored (Chg at
     110             :  * document).
     111             :  * The respective attribute for content is cared for automatically on Chg at
     112             :  * document (contents are created or removed according to SHARE-information).
     113             :  */
     114             : 
     115             : typedef sal_uInt16 UseOnPage;
     116             : namespace nsUseOnPage
     117             : {
     118             :     const UseOnPage PD_NONE           = 0x0000; ///< For internal use only.
     119             :     const UseOnPage PD_LEFT           = 0x0001;
     120             :     const UseOnPage PD_RIGHT          = 0x0002;
     121             :     const UseOnPage PD_FIRST          = 0x0004;
     122             :     const UseOnPage PD_ALL            = 0x0007;
     123             :     const UseOnPage PD_MIRROR         = 0x000F;
     124             :     const UseOnPage PD_HEADERSHARE    = 0x0040;
     125             :     const UseOnPage PD_FOOTERSHARE    = 0x0080;
     126             :     const UseOnPage PD_NOHEADERSHARE  = 0xFFBF; ///< For internal use only.
     127             :     const UseOnPage PD_NOFOOTERSHARE  = 0xFF7F; ///< For internal use only.
     128             :     const UseOnPage PD_FIRSTSHARE = 0x0100;
     129             :     const UseOnPage PD_NOFIRSTSHARE = 0xFEFF;
     130             : }
     131             : 
     132             : class SW_DLLPUBLIC SwPageDesc : public SwModify
     133             : {
     134             :     friend class SwDoc;
     135             : 
     136             :     String      aDescName;
     137             :     SvxNumberType   aNumType;
     138             :     SwFrmFmt    aMaster;
     139             :     SwFrmFmt    aLeft;
     140             :     SwFrmFmt    aFirst;
     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             :     SW_DLLPRIVATE void Mirror();
     155             : 
     156             :     SW_DLLPRIVATE void ResetAllAttr( sal_Bool bLeft );
     157             : 
     158             :     SW_DLLPRIVATE SwPageDesc(const String&, SwFrmFmt*, SwDoc *pDc );
     159             : 
     160             : protected:
     161             :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue );
     162             : 
     163             : public:
     164       12760 :     const String &GetName() const { return aDescName; }
     165           2 :           void    SetName( const String& rNewName ) { aDescName = rNewName; }
     166             : 
     167        2653 :     sal_Bool GetLandscape() const { return bLandscape; }
     168        1452 :     void SetLandscape( sal_Bool bNew ) { bLandscape = bNew; }
     169             : 
     170        3076 :     const SvxNumberType &GetNumType() const { return aNumType; }
     171         945 :           void          SetNumType( const SvxNumberType& rNew ) { aNumType = rNew; }
     172             : 
     173        2472 :     const SwPageFtnInfo &GetFtnInfo() const { return aFtnInfo; }
     174        1187 :           SwPageFtnInfo &GetFtnInfo()       { return aFtnInfo; }
     175         418 :     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         484 :     sal_Bool IsHidden( ) const { return bHidden; }
     185          28 :     void SetHidden( sal_Bool bValue ) { bHidden = bValue; }
     186             : 
     187             :     inline void      SetUseOn( UseOnPage eNew );
     188             :     inline UseOnPage GetUseOn() const;
     189             : 
     190          82 :     void      WriteUseOn( UseOnPage eNew ) { eUse = eNew; }
     191        1336 :     UseOnPage ReadUseOn () const { return eUse; }
     192             : 
     193       11115 :           SwFrmFmt &GetMaster() { return aMaster; }
     194        5165 :           SwFrmFmt &GetLeft()   { return aLeft; }
     195        4082 :           SwFrmFmt &GetFirst()   { return aFirst; }
     196        4998 :     const SwFrmFmt &GetMaster() const { return aMaster; }
     197        1537 :     const SwFrmFmt &GetLeft()   const { return aLeft; }
     198         986 :     const SwFrmFmt &GetFirst()   const { return aFirst; }
     199             : 
     200             :     /** Reset all attrs of the format but keep the ones a pagedesc
     201             :        cannot live without. */
     202             :     inline void ResetAllMasterAttr();
     203             :     inline void ResetAllLeftAttr();
     204             : 
     205             :     /** Layout uses the following methods to obtain a format in order
     206             :        to be able to create a page. */
     207             :     inline SwFrmFmt *GetRightFmt();
     208             :     inline const SwFrmFmt *GetRightFmt() const;
     209             :     inline SwFrmFmt *GetLeftFmt();
     210             :     inline const SwFrmFmt *GetLeftFmt() const;
     211             :     inline SwFrmFmt *GetFirstFmt();
     212             :     inline const SwFrmFmt *GetFirstFmt() const;
     213             : 
     214         415 :     sal_uInt16 GetRegHeight() const { return nRegHeight; }
     215         415 :     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        7957 :     const SwPageDesc* GetFollow() const { return pFollow; }
     221        1191 :           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        7205 :     sal_uInt16 GetPoolFmtId() const         { return aMaster.GetPoolFmtId(); }
     229         745 :     void SetPoolFmtId( sal_uInt16 nId )     { aMaster.SetPoolFmtId( nId ); }
     230        2652 :     sal_uInt16 GetPoolHelpId() const        { return aMaster.GetPoolHelpId(); }
     231         413 :     void SetPoolHelpId( sal_uInt16 nId )    { aMaster.SetPoolHelpId( nId ); }
     232        2241 :     sal_uInt8 GetPoolHlpFileId() const      { return aMaster.GetPoolHlpFileId(); }
     233         413 :     void SetPoolHlpFileId( sal_uInt8 nId )  { aMaster.SetPoolHlpFileId( nId ); }
     234             : 
     235             :     /// Query information from Client.
     236             :     virtual bool GetInfo( SfxPoolItem& ) const;
     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             :     SwPageDesc& operator=( const SwPageDesc& );
     246             : 
     247             :     SwPageDesc( const SwPageDesc& );
     248             :     ~SwPageDesc();
     249             : };
     250             : 
     251         187 : inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
     252             : {
     253         187 :     pFollow = pNew ? (SwPageDesc*)pNew : this;
     254         187 : }
     255             : 
     256        1743 : inline sal_Bool SwPageDesc::IsHeaderShared() const
     257             : {
     258        1743 :     return eUse & nsUseOnPage::PD_HEADERSHARE ? sal_True : sal_False;
     259             : }
     260        1670 : inline sal_Bool SwPageDesc::IsFooterShared() const
     261             : {
     262        1670 :     return eUse & nsUseOnPage::PD_FOOTERSHARE ? sal_True : sal_False;
     263             : }
     264         597 : inline void SwPageDesc::ChgHeaderShare( sal_Bool bNew )
     265             : {
     266         597 :     if ( bNew )
     267         549 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_HEADERSHARE);
     268             :     else
     269          48 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOHEADERSHARE);
     270         597 : }
     271         563 : inline void SwPageDesc::ChgFooterShare( sal_Bool bNew )
     272             : {
     273         563 :     if ( bNew )
     274         531 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FOOTERSHARE);
     275             :     else
     276          32 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFOOTERSHARE);
     277         563 : }
     278         787 : inline void SwPageDesc::SetUseOn( UseOnPage eNew )
     279             : {
     280         787 :     UseOnPage eTmp = nsUseOnPage::PD_NONE;
     281         787 :     if ( eUse & nsUseOnPage::PD_HEADERSHARE )
     282         763 :         eTmp = nsUseOnPage::PD_HEADERSHARE;
     283         787 :     if ( eUse & nsUseOnPage::PD_FOOTERSHARE )
     284         771 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
     285         787 :     if ( eUse & nsUseOnPage::PD_FIRSTSHARE )
     286         759 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FIRSTSHARE);
     287         787 :     eUse = (UseOnPage) (eTmp | eNew);
     288             : 
     289         787 : }
     290        2766 : inline UseOnPage SwPageDesc::GetUseOn() const
     291             : {
     292        2766 :     UseOnPage eRet = eUse;
     293        2766 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
     294        2766 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
     295        2766 :     return eRet;
     296             : }
     297             : 
     298          28 : inline void SwPageDesc::ResetAllMasterAttr()
     299             : {
     300          28 :     ResetAllAttr( sal_False );
     301          28 : }
     302             : 
     303             : inline void SwPageDesc::ResetAllLeftAttr()
     304             : {
     305             :     ResetAllAttr( sal_True );
     306             : }
     307             : 
     308           8 : inline SwFrmFmt *SwPageDesc::GetRightFmt()
     309             : {
     310           8 :     return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
     311             : }
     312           2 : inline const SwFrmFmt *SwPageDesc::GetRightFmt() const
     313             : {
     314           2 :     return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
     315             : }
     316          13 : inline SwFrmFmt *SwPageDesc::GetLeftFmt()
     317             : {
     318          13 :     return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
     319             : }
     320           2 : inline const SwFrmFmt *SwPageDesc::GetLeftFmt() const
     321             : {
     322           2 :     return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
     323             : }
     324         256 : inline SwFrmFmt *SwPageDesc::GetFirstFmt()
     325             : {
     326         256 :     return nsUseOnPage::PD_FIRST & eUse ? &aFirst : 0;
     327             : }
     328           0 : inline const SwFrmFmt *SwPageDesc::GetFirstFmt() const
     329             : {
     330           0 :     return nsUseOnPage::PD_FIRST & eUse ? &aFirst : 0;
     331             : }
     332             : 
     333             : class SwPageDescExt
     334             : {
     335             :     SwPageDesc aPageDesc;
     336             :     SwDoc * pDoc;
     337             :     String sFollow;
     338             : 
     339             :     void SetPageDesc(const SwPageDesc & aPageDesc);
     340             : 
     341             : public:
     342             :     SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
     343             :     SwPageDescExt(const SwPageDescExt & rSrc);
     344             :     ~SwPageDescExt();
     345             : 
     346             :     SwPageDescExt & operator = (const SwPageDescExt & rSrc);
     347             :     SwPageDescExt & operator = (const SwPageDesc & rSrc);
     348             : 
     349             :     const String & GetName() const;
     350             : 
     351             :     operator SwPageDesc() const; // #i7983#
     352             : };
     353             : 
     354             : 
     355             : SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName);
     356             : 
     357             : #endif  //_PAGEDESC_HXX
     358             : 
     359             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10