LCOV - code coverage report
Current view: top level - sw/inc - pagedesc.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 84 88 95.5 %
Date: 2012-08-25 Functions: 56 58 96.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 24 58.3 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : #ifndef _PAGEDESC_HXX
      29                 :            : #define _PAGEDESC_HXX
      30                 :            : 
      31                 :            : #include <tools/fract.hxx>
      32                 :            : #include <tools/color.hxx>
      33                 :            : #include <tools/string.hxx>
      34                 :            : #include "swdllapi.h"
      35                 :            : #include <swtypes.hxx>  // For SwTwips.
      36                 :            : #include <frmfmt.hxx>
      37                 :            : #include <editeng/numitem.hxx>
      38                 :            : #include <editeng/borderline.hxx>
      39                 :            : 
      40                 :            : class SfxPoolItem;
      41                 :            : class SwTxtFmtColl;
      42                 :            : class SwNode;
      43                 :            : 
      44                 :            : // Separator line adjustment.
      45                 :            : enum SwFtnAdj
      46                 :            : {
      47                 :            :     FTNADJ_LEFT,
      48                 :            :     FTNADJ_CENTER,
      49                 :            :     FTNADJ_RIGHT
      50                 :            : };
      51                 :            : 
      52                 :            : // Footnote information.
      53                 :            : class SW_DLLPUBLIC SwPageFtnInfo
      54                 :            : {
      55                 :            :     SwTwips     nMaxHeight;     //maximum height of the footnote area.
      56                 :            :     sal_uLong   nLineWidth;     //width of separator line
      57                 :            :     editeng::SvxBorderStyle eLineStyle;  // Style of the separator line
      58                 :            :     Color       aLineColor;     //color of the separator line
      59                 :            :     Fraction    aWidth;         //percentage width of the separator line.
      60                 :            :     SwFtnAdj    eAdj;           //line adjustment.
      61                 :            :     SwTwips     nTopDist;       //distance between body and separator.
      62                 :            :     SwTwips     nBottomDist;    //distance between separator and first footnote
      63                 :            : 
      64                 :            : public:
      65                 :      15630 :     SwTwips     GetHeight() const       { return nMaxHeight; }
      66                 :        188 :     sal_uLong           GetLineWidth() const { return nLineWidth; }
      67                 :         28 :     const Color&    GetLineColor() const { return aLineColor;}
      68                 :         28 :     editeng::SvxBorderStyle  GetLineStyle() const { return eLineStyle; }
      69                 :      13954 :     const Fraction& GetWidth() const    { return aWidth; }
      70                 :      13954 :     SwFtnAdj    GetAdj()    const       { return eAdj; }
      71                 :      14120 :     SwTwips     GetTopDist()const       { return nTopDist; }
      72                 :      14109 :     SwTwips     GetBottomDist() const   { return nBottomDist; }
      73                 :            : 
      74                 :        119 :     void SetHeight( SwTwips  nNew )     { nMaxHeight = nNew; }
      75                 :        141 :     void SetLineWidth(sal_uLong nSet  )     { nLineWidth = nSet; }
      76                 :        238 :     void SetLineStyle( editeng::SvxBorderStyle eSet )   { eLineStyle = eSet; }
      77                 :        119 :     void SetLineColor(const Color& rCol )  { aLineColor = rCol;}
      78                 :        119 :     void SetWidth( const Fraction &rNew){ aWidth = rNew; }
      79                 :        119 :     void SetAdj   ( SwFtnAdj eNew )     { eAdj = eNew; }
      80                 :        141 :     void SetTopDist   ( SwTwips nNew )  { nTopDist = nNew; }
      81                 :        141 :     void SetBottomDist( SwTwips nNew )  { nBottomDist = nNew; }
      82                 :            : 
      83                 :            :     SwPageFtnInfo();
      84                 :            :     SwPageFtnInfo( const SwPageFtnInfo& );
      85                 :            :     SwPageFtnInfo& operator=( const SwPageFtnInfo& );
      86                 :            : 
      87                 :            :     sal_Bool operator ==( const SwPageFtnInfo& ) const;
      88                 :            : };
      89                 :            : 
      90                 :            : /*
      91                 :            :  *  Use of UseOnPage (eUse) and of FrmFmts
      92                 :            :  *
      93                 :            :  *  RIGHT   - aMaster only for right hand (odd) pages, left hand (even) pages
      94                 :            :  *            always empty.
      95                 :            :  *  LEFT    - aLeft for left-hand pages, right-hand pages always empty.
      96                 :            :  *            aLeft is a copy of master.
      97                 :            :  *  ALL     - aMaster for right hand pages, aLeft for left hand pages.
      98                 :            :  *          - aLeft is a copy of master.
      99                 :            :  * MIRROR   - aMaster for right hand pages, aLeft for left hand pagers.
     100                 :            :  *            aLeft is a copy of master, margins are mirrored.
     101                 :            :  *
     102                 :            :  * UI works exclusively on master! aLeft is adjusted on Chg at document
     103                 :            :  * according to eUse.
     104                 :            :  *
     105                 :            :  * In order to simplify the work of the filters some more values are placed
     106                 :            :  * into eUse:
     107                 :            :  *
     108                 :            :  * HEADERSHARE - Content of header is equal on left and right hand pages.
     109                 :            :  * FOOTERSHARE - Content of footer is equal on left and right hand pages.
     110                 :            :  *
     111                 :            :  * The values are masked out in the respective getter and setter methods.
     112                 :            :  * Access to complete eUse including the information on header and footer
     113                 :            :  * via ReadUseOn(), WriteUseOn() (fuer Filter und CopyCTor)!
     114                 :            :  *
     115                 :            :  * The Frmformats for header/footer are adjusted by the UI according to
     116                 :            :  * the attributes for header and footer at master (height, margin, back-
     117                 :            :  * ground ...)
     118                 :            :  * Header/footer for left hand pages are copied or mirrored (Chg at
     119                 :            :  * document).
     120                 :            :  * The respective attribute for content is cared for automatically on Chg at
     121                 :            :  * document (contents are created or removed according to SHARE-information).
     122                 :            :  */
     123                 :            : 
     124                 :            : typedef sal_uInt16 UseOnPage;
     125                 :            : namespace nsUseOnPage
     126                 :            : {
     127                 :            :     const UseOnPage PD_NONE           = 0x0000; // For internal use only.
     128                 :            :     const UseOnPage PD_LEFT           = 0x0001;
     129                 :            :     const UseOnPage PD_RIGHT          = 0x0002;
     130                 :            :     const UseOnPage PD_FIRST          = 0x0004;
     131                 :            :     const UseOnPage PD_ALL            = 0x0007;
     132                 :            :     const UseOnPage PD_MIRROR         = 0x000F;
     133                 :            :     const UseOnPage PD_HEADERSHARE    = 0x0040;
     134                 :            :     const UseOnPage PD_FOOTERSHARE    = 0x0080;
     135                 :            :     const UseOnPage PD_NOHEADERSHARE  = 0xFFBF; // For internal use only.
     136                 :            :     const UseOnPage PD_NOFOOTERSHARE  = 0xFF7F; // For internal use only.
     137                 :            :     const UseOnPage PD_FIRSTSHARE = 0x0100;
     138                 :            :     const UseOnPage PD_NOFIRSTSHARE = 0xFEFF;
     139                 :            : }
     140                 :            : 
     141                 :            : class SW_DLLPUBLIC SwPageDesc : public SwModify
     142                 :            : {
     143                 :            :     friend class SwDoc;
     144                 :            : 
     145                 :            :     String      aDescName;
     146                 :            :     SvxNumberType   aNumType;
     147                 :            :     SwFrmFmt    aMaster;
     148                 :            :     SwFrmFmt    aLeft;
     149                 :            :     SwFrmFmt    aFirst;
     150                 :            :     SwDepend    aDepend;    // Because of grid alignment (Registerhaltigkeit).
     151                 :            :     SwPageDesc *pFollow;
     152                 :            :     sal_uInt16  nRegHeight; // Sentence spacing and fontascent of style.
     153                 :            :     sal_uInt16  nRegAscent; // For grid alignment (Registerhaltigkeit).
     154                 :            :     UseOnPage   eUse;
     155                 :            :     sal_Bool        bLandscape;
     156                 :            : 
     157                 :            :     // Footnote information.
     158                 :            :     SwPageFtnInfo aFtnInfo;
     159                 :            : 
     160                 :            :     // Called for mirroring of Chg (doc).
     161                 :            :     // No adjustment at any other place.
     162                 :            :     SW_DLLPRIVATE void Mirror();
     163                 :            : 
     164                 :            :     SW_DLLPRIVATE void ResetAllAttr( sal_Bool bLeft );
     165                 :            : 
     166                 :            :     SW_DLLPRIVATE SwPageDesc(const String&, SwFrmFmt*, SwDoc *pDc );
     167                 :            : 
     168                 :            : protected:
     169                 :            :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue );
     170                 :            : 
     171                 :            : public:
     172                 :      37075 :     const String &GetName() const { return aDescName; }
     173                 :         14 :           void    SetName( const String& rNewName ) { aDescName = rNewName; }
     174                 :            : 
     175                 :       6690 :     sal_Bool GetLandscape() const { return bLandscape; }
     176                 :       3536 :     void SetLandscape( sal_Bool bNew ) { bLandscape = bNew; }
     177                 :            : 
     178                 :       9155 :     const SvxNumberType &GetNumType() const { return aNumType; }
     179                 :       2224 :           void          SetNumType( const SvxNumberType& rNew ) { aNumType = rNew; }
     180                 :            : 
     181                 :       6279 :     const SwPageFtnInfo &GetFtnInfo() const { return aFtnInfo; }
     182                 :       3702 :           SwPageFtnInfo &GetFtnInfo()       { return aFtnInfo; }
     183                 :       1027 :     void  SetFtnInfo( const SwPageFtnInfo &rNew ) { aFtnInfo = rNew; }
     184                 :            : 
     185                 :            :     inline sal_Bool IsHeaderShared() const;
     186                 :            :     inline sal_Bool IsFooterShared() const;
     187                 :            :     inline void ChgHeaderShare( sal_Bool bNew );
     188                 :            :     inline void ChgFooterShare( sal_Bool bNew );
     189                 :            :     sal_Bool IsFirstShared() const;
     190                 :            :     void ChgFirstShare( sal_Bool bNew );
     191                 :            : 
     192                 :            :     inline void      SetUseOn( UseOnPage eNew );
     193                 :            :     inline UseOnPage GetUseOn() const;
     194                 :            : 
     195                 :        218 :     void      WriteUseOn( UseOnPage eNew ) { eUse = eNew; }
     196                 :       3141 :     UseOnPage ReadUseOn () const { return eUse; }
     197                 :            : 
     198                 :      29658 :           SwFrmFmt &GetMaster() { return aMaster; }
     199                 :      16486 :           SwFrmFmt &GetLeft()   { return aLeft; }
     200                 :      10962 :           SwFrmFmt &GetFirst()   { return aFirst; }
     201                 :      14091 :     const SwFrmFmt &GetMaster() const { return aMaster; }
     202                 :       3661 :     const SwFrmFmt &GetLeft()   const { return aLeft; }
     203                 :       4075 :     const SwFrmFmt &GetFirst()   const { return aFirst; }
     204                 :            : 
     205                 :            :     // Reset all attrs of the format but keep the ones a pagedesc
     206                 :            :     // cannot live without.
     207                 :            :     inline void ResetAllMasterAttr();
     208                 :            :     inline void ResetAllLeftAttr();
     209                 :            : 
     210                 :            :     // Layout uses the following methods to obtain a format in order
     211                 :            :     // to be able to create a page.
     212                 :            :     inline SwFrmFmt *GetRightFmt();
     213                 :            :     inline const SwFrmFmt *GetRightFmt() const;
     214                 :            :     inline SwFrmFmt *GetLeftFmt();
     215                 :            :     inline const SwFrmFmt *GetLeftFmt() const;
     216                 :            :     inline SwFrmFmt *GetFirstFmt();
     217                 :            :     inline const SwFrmFmt *GetFirstFmt() const;
     218                 :            : 
     219                 :        993 :     sal_uInt16 GetRegHeight() const { return nRegHeight; }
     220                 :        993 :     sal_uInt16 GetRegAscent() const { return nRegAscent; }
     221                 :          0 :     void SetRegHeight( sal_uInt16 nNew ){ nRegHeight = nNew; }
     222                 :          0 :     void SetRegAscent( sal_uInt16 nNew ){ nRegAscent = nNew; }
     223                 :            : 
     224                 :            :     inline void SetFollow( const SwPageDesc* pNew );
     225                 :      20285 :     const SwPageDesc* GetFollow() const { return pFollow; }
     226                 :       3742 :           SwPageDesc* GetFollow() { return pFollow; }
     227                 :            : 
     228                 :            :     void SetRegisterFmtColl( const SwTxtFmtColl* rFmt );
     229                 :            :     const SwTxtFmtColl* GetRegisterFmtColl() const;
     230                 :            :     void RegisterChange();
     231                 :            : 
     232                 :            :     // Query and set PoolFormat-Id.
     233                 :      19905 :     sal_uInt16 GetPoolFmtId() const         { return aMaster.GetPoolFmtId(); }
     234                 :       2738 :     void SetPoolFmtId( sal_uInt16 nId )     { aMaster.SetPoolFmtId( nId ); }
     235                 :       6759 :     sal_uInt16 GetPoolHelpId() const        { return aMaster.GetPoolHelpId(); }
     236                 :        959 :     void SetPoolHelpId( sal_uInt16 nId )    { aMaster.SetPoolHelpId( nId ); }
     237                 :       5806 :     sal_uInt8 GetPoolHlpFileId() const      { return aMaster.GetPoolHlpFileId(); }
     238                 :        959 :     void SetPoolHlpFileId( sal_uInt8 nId )  { aMaster.SetPoolHlpFileId( nId ); }
     239                 :            : 
     240                 :            :     // Query information from Client.
     241                 :            :     virtual sal_Bool GetInfo( SfxPoolItem& ) const;
     242                 :            : 
     243                 :            :     const SwFrmFmt* GetPageFmtOfNode( const SwNode& rNd,
     244                 :            :                                     sal_Bool bCheckForThisPgDc = sal_True ) const;
     245                 :            :     sal_Bool IsFollowNextPageOfNode( const SwNode& rNd ) const;
     246                 :            : 
     247                 :            :     //Given a SwNode return the pagedesc in use at that location.
     248                 :            :     static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd);
     249                 :            : 
     250                 :            :     SwPageDesc& operator=( const SwPageDesc& );
     251                 :            : 
     252                 :            :     SwPageDesc( const SwPageDesc& );
     253                 :            :     ~SwPageDesc();
     254                 :            : };
     255                 :            : 
     256                 :        559 : inline void SwPageDesc::SetFollow( const SwPageDesc* pNew )
     257                 :            : {
     258         [ +  + ]:        559 :     pFollow = pNew ? (SwPageDesc*)pNew : this;
     259                 :        559 : }
     260                 :            : 
     261                 :       4071 : inline sal_Bool SwPageDesc::IsHeaderShared() const
     262                 :            : {
     263         [ +  - ]:       4071 :     return eUse & nsUseOnPage::PD_HEADERSHARE ? sal_True : sal_False;
     264                 :            : }
     265                 :       3947 : inline sal_Bool SwPageDesc::IsFooterShared() const
     266                 :            : {
     267         [ +  - ]:       3947 :     return eUse & nsUseOnPage::PD_FOOTERSHARE ? sal_True : sal_False;
     268                 :            : }
     269                 :       1422 : inline void SwPageDesc::ChgHeaderShare( sal_Bool bNew )
     270                 :            : {
     271         [ +  - ]:       1422 :     if ( bNew )
     272                 :       1422 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_HEADERSHARE);
     273                 :            :     else
     274                 :          0 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOHEADERSHARE);
     275                 :       1422 : }
     276                 :       1367 : inline void SwPageDesc::ChgFooterShare( sal_Bool bNew )
     277                 :            : {
     278         [ +  - ]:       1367 :     if ( bNew )
     279                 :       1367 :         eUse = (UseOnPage) (eUse | nsUseOnPage::PD_FOOTERSHARE);
     280                 :            :     else
     281                 :          0 :         eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFOOTERSHARE);
     282                 :       1367 : }
     283                 :       2859 : inline void SwPageDesc::SetUseOn( UseOnPage eNew )
     284                 :            : {
     285                 :       2859 :     UseOnPage eTmp = nsUseOnPage::PD_NONE;
     286         [ +  - ]:       2859 :     if ( eUse & nsUseOnPage::PD_HEADERSHARE )
     287                 :       2859 :         eTmp = nsUseOnPage::PD_HEADERSHARE;
     288         [ +  - ]:       2859 :     if ( eUse & nsUseOnPage::PD_FOOTERSHARE )
     289                 :       2859 :         eTmp = (UseOnPage) (eTmp | nsUseOnPage::PD_FOOTERSHARE);
     290                 :       2859 :     eUse = (UseOnPage) (eTmp | eNew);
     291                 :            : 
     292                 :       2859 : }
     293                 :       7452 : inline UseOnPage SwPageDesc::GetUseOn() const
     294                 :            : {
     295                 :       7452 :     UseOnPage eRet = eUse;
     296                 :       7452 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOHEADERSHARE);
     297                 :       7452 :     eRet = (UseOnPage) (eRet & nsUseOnPage::PD_NOFOOTERSHARE);
     298                 :       7452 :     return eRet;
     299                 :            : }
     300                 :            : 
     301                 :        121 : inline void SwPageDesc::ResetAllMasterAttr()
     302                 :            : {
     303                 :        121 :     ResetAllAttr( sal_False );
     304                 :        121 : }
     305                 :            : 
     306                 :            : inline void SwPageDesc::ResetAllLeftAttr()
     307                 :            : {
     308                 :            :     ResetAllAttr( sal_True );
     309                 :            : }
     310                 :            : 
     311                 :        282 : inline SwFrmFmt *SwPageDesc::GetRightFmt()
     312                 :            : {
     313         [ +  + ]:        282 :     return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
     314                 :            : }
     315                 :        169 : inline const SwFrmFmt *SwPageDesc::GetRightFmt() const
     316                 :            : {
     317         [ +  - ]:        169 :     return nsUseOnPage::PD_RIGHT & eUse ? &aMaster : 0;
     318                 :            : }
     319                 :        168 : inline SwFrmFmt *SwPageDesc::GetLeftFmt()
     320                 :            : {
     321         [ +  - ]:        168 :     return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
     322                 :            : }
     323                 :        169 : inline const SwFrmFmt *SwPageDesc::GetLeftFmt() const
     324                 :            : {
     325         [ +  - ]:        169 :     return nsUseOnPage::PD_LEFT & eUse ? &aLeft : 0;
     326                 :            : }
     327                 :       1285 : inline SwFrmFmt *SwPageDesc::GetFirstFmt()
     328                 :            : {
     329         [ +  - ]:       1285 :     return nsUseOnPage::PD_FIRST & eUse ? &aFirst : 0;
     330                 :            : }
     331                 :            : inline const SwFrmFmt *SwPageDesc::GetFirstFmt() const
     332                 :            : {
     333                 :            :     return nsUseOnPage::PD_FIRST & eUse ? &aFirst : 0;
     334                 :            : }
     335                 :            : 
     336                 :            : class SwPageDescExt
     337                 :            : {
     338                 :            :     SwPageDesc aPageDesc;
     339                 :            :     SwDoc * pDoc;
     340                 :            :     String sFollow;
     341                 :            : 
     342                 :            :     void SetPageDesc(const SwPageDesc & aPageDesc);
     343                 :            : 
     344                 :            : public:
     345                 :            :     SwPageDescExt(const SwPageDesc & rPageDesc, SwDoc * pDoc);
     346                 :            :     SwPageDescExt(const SwPageDescExt & rSrc);
     347                 :            :     ~SwPageDescExt();
     348                 :            : 
     349                 :            :     SwPageDescExt & operator = (const SwPageDescExt & rSrc);
     350                 :            :     SwPageDescExt & operator = (const SwPageDesc & rSrc);
     351                 :            : 
     352                 :            :     const String & GetName() const;
     353                 :            : 
     354                 :            :     operator SwPageDesc() const; // #i7983#
     355                 :            : };
     356                 :            : 
     357                 :            : 
     358                 :            : SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName);
     359                 :            : 
     360                 :            : #endif  //_PAGEDESC_HXX
     361                 :            : 
     362                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10