LCOV - code coverage report
Current view: top level - sw/inc - fmtclds.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 25 31 80.6 %
Date: 2014-11-03 Functions: 23 29 79.3 %
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_FMTCLDS_HXX
      20             : #define INCLUDED_SW_INC_FMTCLDS_HXX
      21             : 
      22             : #include <editeng/borderline.hxx>
      23             : #include <tools/color.hxx>
      24             : #include <svl/poolitem.hxx>
      25             : #include "swdllapi.h"
      26             : #include <hintids.hxx>
      27             : #include <format.hxx>
      28             : #include <boost/ptr_container/ptr_vector.hpp>
      29             : 
      30             : /// ColumnDescriptor
      31             : class SwColumn
      32             : {
      33             :     sal_uInt16 nWish;   /**< Desired width, borders included.
      34             :                          It is inversely proportional to the ratio of
      35             :                          desired width environment / current width column. */
      36             :     sal_uInt16 nUpper;  ///< Top border.
      37             :     sal_uInt16 nLower;  ///< Bottom border.
      38             :     sal_uInt16 nLeft;   ///< Left border.
      39             :     sal_uInt16 nRight;  ///< Right border.
      40             : 
      41             : public:
      42             :     SwColumn();
      43             : 
      44             :     bool operator==( const SwColumn & ) const;
      45             : 
      46         506 :     void SetWishWidth( sal_uInt16 nNew ) { nWish  = nNew; }
      47             :     void SetUpper( sal_uInt16  nNew ) { nUpper = nNew; }
      48             :     void SetLower( sal_uInt16  nNew ) { nLower = nNew; }
      49         478 :     void SetLeft ( sal_uInt16  nNew ) { nLeft  = nNew; }
      50         478 :     void SetRight( sal_uInt16  nNew ) { nRight = nNew; }
      51             : 
      52        1838 :     sal_uInt16 GetWishWidth() const { return nWish;  }
      53        1020 :     sal_uInt16 GetUpper() const { return nUpper; }
      54        1020 :     sal_uInt16 GetLower() const { return nLower; }
      55        4482 :     sal_uInt16 GetLeft () const { return nLeft; }
      56        4482 :     sal_uInt16 GetRight() const { return nRight; }
      57             : };
      58             : 
      59             : typedef boost::ptr_vector<SwColumn> SwColumns;
      60             : 
      61             : enum SwColLineAdj
      62             : {
      63             :     COLADJ_NONE,
      64             :     COLADJ_TOP,
      65             :     COLADJ_CENTER,
      66             :     COLADJ_BOTTOM
      67             : };
      68             : 
      69             : class SW_DLLPUBLIC SwFmtCol : public SfxPoolItem
      70             : {
      71             :     editeng::SvxBorderStyle m_eLineStyle;     ///< style of the separator line
      72             :     sal_uLong   m_nLineWidth;                 ///< Width of the separator line.
      73             :     Color   m_aLineColor;                     ///< Color of the separator line.
      74             : 
      75             :     sal_uInt16   m_nLineHeight;               /**< Percentile height of lines.
      76             :                                           (Based on height of columns including UL). */
      77             : 
      78             :     SwColLineAdj m_eAdj;                      ///< Line will be adjusted top, centered or bottom.
      79             : 
      80             :     SwColumns   m_aColumns;                   ///< Information concerning the columns.
      81             :     sal_uInt16  m_nWidth;                     ///< Total desired width of all columns.
      82             :     sal_Int16   m_aWidthAdjustValue;
      83             : 
      84             :     bool m_bOrtho;            /**< Only if this flag is set, the setting of GutterWidth will
      85             :                              be accompanied by a "visual rearrangement".
      86             :                              The flag must be reset if widths of columns or borders are changed.
      87             :                              When it is set (again) the visual arrangement is recalculated.
      88             :                              The flag is initially set. */
      89             : 
      90             :     SAL_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct );
      91             : 
      92             : public:
      93             :     SwFmtCol();
      94             :     SwFmtCol( const SwFmtCol& );
      95             :     virtual ~SwFmtCol();
      96             :     //#i120133#
      97         734 :     sal_Int16 GetAdjustValue() const { return m_aWidthAdjustValue; }
      98           0 :     void SetAdjustValue( const sal_Int16& n ) { m_aWidthAdjustValue = n; }
      99             : 
     100             :     SwFmtCol& operator=( const SwFmtCol& );
     101             : 
     102             :     /// "pure virtual methods" of SfxPoolItem
     103             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
     104             :     virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const SAL_OVERRIDE;
     105             :     virtual bool GetPresentation( SfxItemPresentation ePres,
     106             :                                     SfxMapUnit eCoreMetric,
     107             :                                     SfxMapUnit ePresMetric,
     108             :                                     OUString &rText,
     109             :                                     const IntlWrapper* pIntl = 0 ) const SAL_OVERRIDE;
     110             : 
     111             :     virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
     112             :     virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
     113             : 
     114        5838 :     const SwColumns &GetColumns() const { return m_aColumns; }
     115          24 :           SwColumns &GetColumns()       { return m_aColumns; }
     116       36676 :     sal_uInt16           GetNumCols() const { return m_aColumns.size(); }
     117             : 
     118         300 :     editeng::SvxBorderStyle     GetLineStyle() const  { return m_eLineStyle;}
     119        1082 :     sal_uLong           GetLineWidth() const  { return m_nLineWidth;}
     120         300 :     const Color&    GetLineColor() const { return m_aLineColor;}
     121             : 
     122        5692 :     SwColLineAdj     GetLineAdj() const { return m_eAdj; }
     123        5252 :     bool             IsOrtho()    const { return m_bOrtho; }
     124        3810 :     sal_uInt16           GetWishWidth() const { return m_nWidth; }
     125        3350 :     sal_uInt8            GetLineHeight()const { return m_nLineHeight; }
     126             : 
     127             :     /** @return USHRT_MAX if ambiguous.
     128             :      @return smallest width if bMin is true. */
     129             :     sal_uInt16 GetGutterWidth( bool bMin = false ) const;
     130             : 
     131           0 :     void SetLineStyle(editeng::SvxBorderStyle eStyle)        { m_eLineStyle = eStyle;}
     132           0 :     void SetLineWidth(sal_uLong nLWidth)        { m_nLineWidth = nLWidth;}
     133           0 :     void SetLineColor(const Color& rCol )   { m_aLineColor = rCol;}
     134           0 :     void SetLineHeight( sal_uInt8 nNew )     { m_nLineHeight = nNew; }
     135           0 :     void SetLineAdj( SwColLineAdj eNew ){ m_eAdj = eNew; }
     136          12 :     void SetWishWidth( sal_uInt16 nNew )    { m_nWidth = nNew; }
     137             : 
     138             :     /** This function allows to (repeatedly) initialize the columns.
     139             :      The Ortho flag is set automatically. */
     140             :     void Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
     141             : 
     142             :     /** Adjusts borders for columns in aColumns.
     143             :      If flag m_bOrtho is set, columns are visually re-arranged.
     144             :      If the flag is not set, columns widths are not changed and
     145             :      borders are adjusted. */
     146             :     void SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct );
     147             : 
     148             :     /** This too re-arranges columns automatically if flag is set.
     149             :      Only in this case the second parameter is needed and evaluated. */
     150             :     void SetOrtho( bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
     151             : 
     152             :     /// For the reader
     153          12 :     void _SetOrtho( bool bNew ) { m_bOrtho = bNew; }
     154             : 
     155             :     /** Calculates current width of column nCol.
     156             :      The ratio of desired width of this column to return value is
     157             :      proportional to ratio of total desired value to nAct. */
     158             :     sal_uInt16 CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
     159             : 
     160             :     /** As above except that it @return the width of PrtArea -
     161             :      that corresponds to what constitutes the column for the user. */
     162             :     sal_uInt16 CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
     163             : };
     164             : 
     165       12138 : inline const SwFmtCol &SwAttrSet::GetCol(bool bInP) const
     166       12138 :     { return (const SwFmtCol&)Get( RES_COL,bInP); }
     167             : 
     168       11984 : inline const SwFmtCol &SwFmt::GetCol(bool bInP) const
     169       11984 :     { return aSet.GetCol(bInP); }
     170             : 
     171             : #endif
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10