LCOV - code coverage report
Current view: top level - include/editeng - boxitem.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 22 25 88.0 %
Date: 2014-11-03 Functions: 18 21 85.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             : 
      20             : #ifndef INCLUDED_EDITENG_BOXITEM_HXX
      21             : #define INCLUDED_EDITENG_BOXITEM_HXX
      22             : 
      23             : #include <svl/poolitem.hxx>
      24             : #include <editeng/borderline.hxx>
      25             : #include <editeng/editengdllapi.h>
      26             : #include <com/sun/star/table/BorderLine2.hpp>
      27             : 
      28             : 
      29             : // class SvxBoxItem ------------------------------------------------------
      30             : 
      31             : /*  [Description]
      32             : 
      33             :     This item describes a border attribute
      34             :     (all four edges and the inward distance)
      35             : */
      36             : 
      37             : #define BOX_LINE_TOP    ((sal_uInt16)0)
      38             : #define BOX_LINE_BOTTOM ((sal_uInt16)1)
      39             : #define BOX_LINE_LEFT   ((sal_uInt16)2)
      40             : #define BOX_LINE_RIGHT  ((sal_uInt16)3)
      41             : 
      42             : /**
      43             : This version causes SvxBoxItem to store the 4 cell spacing distances separately
      44             : when serializing to stream.
      45             : */
      46             : #define BOX_4DISTS_VERSION ((sal_uInt16)1)
      47             : /**
      48             : This version causes SvxBoxItem to store the styles for its border lines when
      49             : serializing to stream.
      50             : */
      51             : #define BOX_BORDER_STYLE_VERSION ((sal_uInt16)2)
      52             : 
      53             : class EDITENG_DLLPUBLIC SvxBoxItem : public SfxPoolItem
      54             : {
      55             :     editeng::SvxBorderLine  *pTop,
      56             :                             *pBottom,
      57             :                             *pLeft,
      58             :                             *pRight;
      59             :     sal_uInt16      nTopDist,
      60             :                     nBottomDist,
      61             :                     nLeftDist,
      62             :                     nRightDist;
      63             : 
      64             : public:
      65             :     TYPEINFO_OVERRIDE();
      66             : 
      67             :     explicit SvxBoxItem( const sal_uInt16 nId );
      68             :     SvxBoxItem( const SvxBoxItem &rCpy );
      69             :     virtual ~SvxBoxItem();
      70             :     SvxBoxItem &operator=( const SvxBoxItem& rBox );
      71             : 
      72             :     // "pure virtual Methods" from SfxPoolItem
      73             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
      74             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
      75             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
      76             : 
      77             :     virtual bool GetPresentation( SfxItemPresentation ePres,
      78             :                                     SfxMapUnit eCoreMetric,
      79             :                                     SfxMapUnit ePresMetric,
      80             :                                     OUString &rText, const IntlWrapper * = 0 ) const SAL_OVERRIDE;
      81             : 
      82             :     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
      83             :     virtual SfxPoolItem*     Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
      84             :     virtual SvStream&        Store(SvStream &, sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
      85             :     virtual sal_uInt16           GetVersion( sal_uInt16 nFileVersion ) const SAL_OVERRIDE;
      86             : 
      87             :     virtual bool             ScaleMetrics( long nMult, long nDiv ) SAL_OVERRIDE;
      88             :     virtual bool             HasMetrics() const SAL_OVERRIDE;
      89             : 
      90     6687995 :     const   editeng::SvxBorderLine* GetTop()    const { return pTop; }
      91     6490221 :     const   editeng::SvxBorderLine* GetBottom() const { return pBottom; }
      92     6383976 :     const   editeng::SvxBorderLine* GetLeft()   const { return pLeft; }
      93     6277440 :     const   editeng::SvxBorderLine* GetRight()  const { return pRight; }
      94             : 
      95             :     const   editeng::SvxBorderLine* GetLine( sal_uInt16 nLine ) const;
      96             : 
      97             :     //The Pointers are being copied!
      98             :     void    SetLine( const editeng::SvxBorderLine* pNew, sal_uInt16 nLine );
      99             : 
     100             :     sal_uInt16  GetDistance( sal_uInt16 nLine ) const;
     101             :     sal_uInt16  GetDistance() const;
     102             : 
     103             :     void    SetDistance( sal_uInt16 nNew, sal_uInt16 nLine );
     104             :     inline void SetDistance( sal_uInt16 nNew );
     105             : 
     106             :     // Line width plus Space plus inward distance
     107             :     // bIgnoreLine = TRUE -> Also return distance, when no Line is set
     108             :     sal_uInt16  CalcLineSpace( sal_uInt16 nLine, bool bIgnoreLine = false ) const;
     109             :     static com::sun::star::table::BorderLine2 SvxLineToLine( const editeng::SvxBorderLine* pLine, bool bConvert );
     110             :     static bool LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, editeng::SvxBorderLine& rSvxLine, bool bConvert);
     111             :     static bool LineToSvxLine(const ::com::sun::star::table::BorderLine2& rLine, editeng::SvxBorderLine& rSvxLine, bool bConvert);
     112             : };
     113             : 
     114       11166 : inline void SvxBoxItem::SetDistance( sal_uInt16 nNew )
     115             : {
     116       11166 :     nTopDist = nBottomDist = nLeftDist = nRightDist = nNew;
     117       11166 : }
     118             : 
     119             : // class SvxBoxInfoItem --------------------------------------------------
     120             : 
     121             : /*  [Description]
     122             : 
     123             :     Another item for the border. This item has only limited functionality.
     124             :     On one hand, the general Dialog is told by the item which options it
     125             :     should offer. On the other hand, this attribute  may be used to
     126             :     transported the borderline for the inner horizontal and vertical lines.
     127             : */
     128             : 
     129             : #define BOXINFO_LINE_HORI   ((sal_uInt16)0)
     130             : #define BOXINFO_LINE_VERT   ((sal_uInt16)1)
     131             : 
     132             : #define VALID_TOP           0x01
     133             : #define VALID_BOTTOM        0x02
     134             : #define VALID_LEFT          0x04
     135             : #define VALID_RIGHT         0x08
     136             : #define VALID_HORI          0x10
     137             : #define VALID_VERT          0x20
     138             : #define VALID_DISTANCE      0x40
     139             : #define VALID_DISABLE       0x80
     140             : 
     141             : class EDITENG_DLLPUBLIC SvxBoxInfoItem : public SfxPoolItem
     142             : {
     143             :     editeng::SvxBorderLine* pHori;   //inner horizontal Line
     144             :     editeng::SvxBorderLine* pVert;   //inner vertical Line
     145             : 
     146             :     bool                mbEnableHor;   /// true = Enable inner horizontal line.
     147             :     bool                mbEnableVer;   /// true = Enable inner vertical line.
     148             : 
     149             :     /*
     150             :      Currently only for StarWriter: distance inward from SvxBoxItem. If the
     151             :      distance is requested, then the field for the distance from the dialog be
     152             :      activated. nDefDist is regarded as a default value. If any line is
     153             :      turned on or will be turned on it must this distance be set to default.
     154             :      bMinDist indicates whether the user can go below this value or not.
     155             :      With NDIST is the current distance from the app transported back and
     156             :      forth to the dialogue.
     157             :     */
     158             : 
     159             :     bool        bDist      :1;  // TRUE, Unlock Distance.
     160             :     bool        bMinDist   :1;  // TRUE, Going below minimum Distance is prohibited
     161             : 
     162             :     sal_uInt8   nValidFlags;    // 0000 0000
     163             :                                 // 0000 0001 VALID_TOP
     164             :                                 // 0000 0010 VALID_BOTTOM
     165             :                                 // 0000 0100 VALID_LEFT
     166             :                                 // 0000 1000 VALID_RIGHT
     167             :                                 // 0001 0000 VALID_HORI
     168             :                                 // 0010 0000 VALID_VERT
     169             :                                 // 0100 0000 VALID_DIST
     170             :                                 // 1000 0000 VALID_DISABLE
     171             : 
     172             :     sal_uInt16  nDefDist;       // The default or minimum distance.
     173             : 
     174             : public:
     175             :     TYPEINFO_OVERRIDE();
     176             : 
     177             :     explicit SvxBoxInfoItem( const sal_uInt16 nId );
     178             :     SvxBoxInfoItem( const SvxBoxInfoItem &rCpy );
     179             :     virtual ~SvxBoxInfoItem();
     180             :     SvxBoxInfoItem &operator=( const SvxBoxInfoItem &rCpy );
     181             : 
     182             :     // "pure virtual Methods" from SfxPoolItem
     183             :     virtual bool             operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
     184             :     virtual bool GetPresentation( SfxItemPresentation ePres,
     185             :                                     SfxMapUnit eCoreMetric,
     186             :                                     SfxMapUnit ePresMetric,
     187             :                                     OUString &rText, const IntlWrapper * = 0 ) const SAL_OVERRIDE;
     188             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
     189             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
     190             : 
     191             :     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
     192             :     virtual SfxPoolItem*    Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
     193             :     virtual SvStream&       Store(SvStream &, sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
     194             :     virtual bool             ScaleMetrics( long nMult, long nDiv ) SAL_OVERRIDE;
     195             :     virtual bool             HasMetrics() const SAL_OVERRIDE;
     196             : 
     197     1432616 :     const editeng::SvxBorderLine*   GetHori() const { return pHori; }
     198     1432502 :     const editeng::SvxBorderLine*   GetVert() const { return pVert; }
     199             : 
     200             :     //The Pointers are being copied!
     201             :     void                    SetLine( const editeng::SvxBorderLine* pNew, sal_uInt16 nLine );
     202             : 
     203           0 :     bool    IsTable() const             { return mbEnableHor && mbEnableVer; }
     204      440628 :     void    SetTable( bool bNew )       { mbEnableHor = mbEnableVer = bNew; }
     205             : 
     206           0 :     inline bool         IsHorEnabled() const { return mbEnableHor; }
     207          88 :     inline void         EnableHor( bool bEnable ) { mbEnableHor = bEnable; }
     208           0 :     inline bool         IsVerEnabled() const { return mbEnableVer; }
     209          88 :     inline void         EnableVer( bool bEnable ) { mbEnableVer = bEnable; }
     210             : 
     211     1430536 :     bool    IsDist() const              { return bDist; }
     212      440616 :     void    SetDist( bool bNew )        { bDist = bNew; }
     213     1430536 :     bool    IsMinDist() const           { return bMinDist; }
     214      428356 :     void    SetMinDist( bool bNew )     { bMinDist = bNew; }
     215     1430532 :     sal_uInt16  GetDefDist() const          { return nDefDist; }
     216      425446 :     void    SetDefDist( sal_uInt16 nNew )   { nDefDist = nNew; }
     217             : 
     218       29616 :     bool                    IsValid( sal_uInt8 nValid ) const
     219       29616 :                                 { return ( nValidFlags & nValid ) == nValid; }
     220      447828 :     void                    SetValid( sal_uInt8 nValid, bool bValid = true )
     221             :                                 { bValid ? ( nValidFlags |= nValid )
     222      447828 :                                          : ( nValidFlags &= ~nValid ); }
     223             :     void                    ResetFlags();
     224             : };
     225             : #endif
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10