LCOV - code coverage report
Current view: top level - include/editeng - boxitem.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 26 92.3 %
Date: 2015-06-13 12:38:46 Functions: 19 21 90.5 %
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             : #include <o3tl/typed_flags_set.hxx>
      28             : 
      29             : 
      30             : // class SvxBoxItem ------------------------------------------------------
      31             : 
      32             : /*  [Description]
      33             : 
      34             :     This item describes a border attribute
      35             :     (all four edges and the inward distance)
      36             : */
      37             : enum class SvxBoxItemLine
      38             : {
      39             :     TOP, BOTTOM, LEFT, RIGHT, LAST = RIGHT
      40             : };
      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     3467919 :     const   editeng::SvxBorderLine* GetTop()    const { return pTop; }
      91     3365443 :     const   editeng::SvxBorderLine* GetBottom() const { return pBottom; }
      92     3281342 :     const   editeng::SvxBorderLine* GetLeft()   const { return pLeft; }
      93     3224569 :     const   editeng::SvxBorderLine* GetRight()  const { return pRight; }
      94             : 
      95             :     const   editeng::SvxBorderLine* GetLine( SvxBoxItemLine nLine ) const;
      96             : 
      97             :     //The Pointers are being copied!
      98             :     void    SetLine( const editeng::SvxBorderLine* pNew, SvxBoxItemLine nLine );
      99             : 
     100             :     sal_uInt16  GetDistance( SvxBoxItemLine nLine ) const;
     101             :     sal_uInt16  GetDistance() const;
     102             : 
     103             :     void    SetDistance( sal_uInt16 nNew, SvxBoxItemLine 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( SvxBoxItemLine 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        7040 : inline void SvxBoxItem::SetDistance( sal_uInt16 nNew )
     115             : {
     116        7040 :     nTopDist = nBottomDist = nLeftDist = nRightDist = nNew;
     117        7040 : }
     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             : enum class SvxBoxInfoItemLine
     130             : {
     131             :     HORI, VERT, LAST = VERT
     132             : };
     133             : 
     134             : enum class SvxBoxInfoItemValidFlags
     135             : {
     136             :     NONE          = 0x00,
     137             :     TOP           = 0x01,
     138             :     BOTTOM        = 0x02,
     139             :     LEFT          = 0x04,
     140             :     RIGHT         = 0x08,
     141             :     HORI          = 0x10,
     142             :     VERT          = 0x20,
     143             :     DISTANCE      = 0x40,
     144             :     DISABLE       = 0x80,
     145             :     ALL           = 0xff
     146             : };
     147             : namespace o3tl
     148             : {
     149             :     template<> struct typed_flags<SvxBoxInfoItemValidFlags> : is_typed_flags<SvxBoxInfoItemValidFlags, 0xff> {};
     150             : }
     151             : 
     152             : class EDITENG_DLLPUBLIC SvxBoxInfoItem : public SfxPoolItem
     153             : {
     154             :     editeng::SvxBorderLine* pHori;   //inner horizontal Line
     155             :     editeng::SvxBorderLine* pVert;   //inner vertical Line
     156             : 
     157             :     bool                mbEnableHor;   /// true = Enable inner horizontal line.
     158             :     bool                mbEnableVer;   /// true = Enable inner vertical line.
     159             : 
     160             :     /*
     161             :      Currently only for StarWriter: distance inward from SvxBoxItem. If the
     162             :      distance is requested, then the field for the distance from the dialog be
     163             :      activated. nDefDist is regarded as a default value. If any line is
     164             :      turned on or will be turned on it must this distance be set to default.
     165             :      bMinDist indicates whether the user can go below this value or not.
     166             :      With NDIST is the current distance from the app transported back and
     167             :      forth to the dialogue.
     168             :     */
     169             : 
     170             :     bool        bDist      :1;  // TRUE, Unlock Distance.
     171             :     bool        bMinDist   :1;  // TRUE, Going below minimum Distance is prohibited
     172             : 
     173             :     SvxBoxInfoItemValidFlags nValidFlags;
     174             :     sal_uInt16  nDefDist;       // The default or minimum distance.
     175             : 
     176             : public:
     177             :     TYPEINFO_OVERRIDE();
     178             : 
     179             :     explicit SvxBoxInfoItem( const sal_uInt16 nId );
     180             :     SvxBoxInfoItem( const SvxBoxInfoItem &rCpy );
     181             :     virtual ~SvxBoxInfoItem();
     182             :     SvxBoxInfoItem &operator=( const SvxBoxInfoItem &rCpy );
     183             : 
     184             :     // "pure virtual Methods" from SfxPoolItem
     185             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
     186             :     virtual bool            GetPresentation( SfxItemPresentation ePres,
     187             :                                     SfxMapUnit eCoreMetric,
     188             :                                     SfxMapUnit ePresMetric,
     189             :                                     OUString &rText, const IntlWrapper * = 0 ) const SAL_OVERRIDE;
     190             :     virtual bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
     191             :     virtual bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
     192             : 
     193             :     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
     194             :     virtual SfxPoolItem*    Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
     195             :     virtual SvStream&       Store(SvStream &, sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
     196             :     virtual bool            ScaleMetrics( long nMult, long nDiv ) SAL_OVERRIDE;
     197             :     virtual bool            HasMetrics() const SAL_OVERRIDE;
     198             : 
     199      879279 :     const editeng::SvxBorderLine*   GetHori() const { return pHori; }
     200      879301 :     const editeng::SvxBorderLine*   GetVert() const { return pVert; }
     201             : 
     202             :     //The Pointers are being copied!
     203             :     void                    SetLine( const editeng::SvxBorderLine* pNew, SvxBoxInfoItemLine nLine );
     204             : 
     205          31 :     bool                    IsTable() const             { return mbEnableHor && mbEnableVer; }
     206      299266 :     void                    SetTable( bool bNew )       { mbEnableHor = mbEnableVer = bNew; }
     207             : 
     208           0 :     inline bool             IsHorEnabled() const { return mbEnableHor; }
     209          60 :     inline void             EnableHor( bool bEnable ) { mbEnableHor = bEnable; }
     210           0 :     inline bool             IsVerEnabled() const { return mbEnableVer; }
     211          60 :     inline void             EnableVer( bool bEnable ) { mbEnableVer = bEnable; }
     212             : 
     213      877663 :     bool                    IsDist() const              { return bDist; }
     214      299260 :     void                    SetDist( bool bNew )        { bDist = bNew; }
     215      877663 :     bool                    IsMinDist() const           { return bMinDist; }
     216      291577 :     void                    SetMinDist( bool bNew )     { bMinDist = bNew; }
     217      877661 :     sal_uInt16              GetDefDist() const            { return nDefDist; }
     218      289479 :     void                    SetDefDist( sal_uInt16 nNew ) { nDefDist = nNew; }
     219             : 
     220       17940 :     bool                    IsValid( SvxBoxInfoItemValidFlags nValid ) const
     221       17940 :                                 { return bool( nValidFlags & nValid ); }
     222      302947 :     void                    SetValid( SvxBoxInfoItemValidFlags nValid, bool bValid = true )
     223      300022 :                                 { bValid ? ( nValidFlags |= nValid )
     224      602969 :                                          : ( nValidFlags &= ~nValid ); }
     225             :     void                    ResetFlags();
     226             : };
     227             : #endif
     228             : 
     229             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11