LCOV - code coverage report
Current view: top level - sw/inc - fmtclds.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 25 31 80.6 %
Date: 2015-06-13 12:38:46 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         263 :     void SetWishWidth( sal_uInt16 nNew ) { nWish  = nNew; }
      47             :     void SetUpper( sal_uInt16  nNew ) { nUpper = nNew; }
      48             :     void SetLower( sal_uInt16  nNew ) { nLower = nNew; }
      49         249 :     void SetLeft ( sal_uInt16  nNew ) { nLeft  = nNew; }
      50         249 :     void SetRight( sal_uInt16  nNew ) { nRight = nNew; }
      51             : 
      52         913 :     sal_uInt16 GetWishWidth() const { return nWish;  }
      53         485 :     sal_uInt16 GetUpper() const { return nUpper; }
      54         485 :     sal_uInt16 GetLower() const { return nLower; }
      55        2381 :     sal_uInt16 GetLeft () const { return nLeft; }
      56        2381 :     sal_uInt16 GetRight() const { return nRight; }
      57             : 
      58             :     void dumpAsXml(struct _xmlTextWriter* pWriter) const;
      59             : };
      60             : 
      61             : typedef boost::ptr_vector<SwColumn> SwColumns;
      62             : 
      63             : enum SwColLineAdj
      64             : {
      65             :     COLADJ_NONE,
      66             :     COLADJ_TOP,
      67             :     COLADJ_CENTER,
      68             :     COLADJ_BOTTOM
      69             : };
      70             : 
      71             : class SW_DLLPUBLIC SwFormatCol : public SfxPoolItem
      72             : {
      73             :     editeng::SvxBorderStyle m_eLineStyle;     ///< style of the separator line
      74             :     sal_uLong   m_nLineWidth;                 ///< Width of the separator line.
      75             :     Color   m_aLineColor;                     ///< Color of the separator line.
      76             : 
      77             :     sal_uInt16   m_nLineHeight;               /**< Percentile height of lines.
      78             :                                           (Based on height of columns including UL). */
      79             : 
      80             :     SwColLineAdj m_eAdj;                      ///< Line will be adjusted top, centered or bottom.
      81             : 
      82             :     SwColumns   m_aColumns;                   ///< Information concerning the columns.
      83             :     sal_uInt16  m_nWidth;                     ///< Total desired width of all columns.
      84             :     sal_Int16   m_aWidthAdjustValue;
      85             : 
      86             :     bool m_bOrtho;            /**< Only if this flag is set, the setting of GutterWidth will
      87             :                              be accompanied by a "visual rearrangement".
      88             :                              The flag must be reset if widths of columns or borders are changed.
      89             :                              When it is set (again) the visual arrangement is recalculated.
      90             :                              The flag is initially set. */
      91             : 
      92             :     SAL_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct );
      93             : 
      94             : public:
      95             :     SwFormatCol();
      96             :     SwFormatCol( const SwFormatCol& );
      97             :     virtual ~SwFormatCol();
      98             :     //#i120133#
      99         503 :     sal_Int16 GetAdjustValue() const { return m_aWidthAdjustValue; }
     100           0 :     void SetAdjustValue( const sal_Int16& n ) { m_aWidthAdjustValue = n; }
     101             : 
     102             :     SwFormatCol& operator=( const SwFormatCol& );
     103             : 
     104             :     /// "pure virtual methods" of SfxPoolItem
     105             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
     106             :     virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const SAL_OVERRIDE;
     107             :     virtual bool GetPresentation( SfxItemPresentation ePres,
     108             :                                     SfxMapUnit eCoreMetric,
     109             :                                     SfxMapUnit ePresMetric,
     110             :                                     OUString &rText,
     111             :                                     const IntlWrapper* pIntl = 0 ) const SAL_OVERRIDE;
     112             : 
     113             :     virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
     114             :     virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
     115             : 
     116        3148 :     const SwColumns &GetColumns() const { return m_aColumns; }
     117          12 :           SwColumns &GetColumns()       { return m_aColumns; }
     118       21605 :     sal_uInt16           GetNumCols() const { return m_aColumns.size(); }
     119             : 
     120         190 :     editeng::SvxBorderStyle     GetLineStyle() const  { return m_eLineStyle;}
     121         579 :     sal_uLong           GetLineWidth() const  { return m_nLineWidth;}
     122         190 :     const Color&    GetLineColor() const { return m_aLineColor;}
     123             : 
     124        3675 :     SwColLineAdj     GetLineAdj() const { return m_eAdj; }
     125        3359 :     bool             IsOrtho()    const { return m_bOrtho; }
     126        2650 :     sal_uInt16           GetWishWidth() const { return m_nWidth; }
     127        2462 :     sal_uInt8            GetLineHeight()const { return m_nLineHeight; }
     128             : 
     129             :     /** @return USHRT_MAX if ambiguous.
     130             :      @return smallest width if bMin is true. */
     131             :     sal_uInt16 GetGutterWidth( bool bMin = false ) const;
     132             : 
     133           0 :     void SetLineStyle(editeng::SvxBorderStyle eStyle)        { m_eLineStyle = eStyle;}
     134           0 :     void SetLineWidth(sal_uLong nLWidth)        { m_nLineWidth = nLWidth;}
     135           0 :     void SetLineColor(const Color& rCol )   { m_aLineColor = rCol;}
     136           0 :     void SetLineHeight( sal_uInt8 nNew )     { m_nLineHeight = nNew; }
     137           0 :     void SetLineAdj( SwColLineAdj eNew ){ m_eAdj = eNew; }
     138           6 :     void SetWishWidth( sal_uInt16 nNew )    { m_nWidth = nNew; }
     139             : 
     140             :     /** This function allows to (repeatedly) initialize the columns.
     141             :      The Ortho flag is set automatically. */
     142             :     void Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
     143             : 
     144             :     /** Adjusts borders for columns in aColumns.
     145             :      If flag m_bOrtho is set, columns are visually re-arranged.
     146             :      If the flag is not set, columns widths are not changed and
     147             :      borders are adjusted. */
     148             :     void SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct );
     149             : 
     150             :     /** This too re-arranges columns automatically if flag is set.
     151             :      Only in this case the second parameter is needed and evaluated. */
     152             :     void SetOrtho( bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
     153             : 
     154             :     /// For the reader
     155           6 :     void _SetOrtho( bool bNew ) { m_bOrtho = bNew; }
     156             : 
     157             :     /** Calculates current width of column nCol.
     158             :      The ratio of desired width of this column to return value is
     159             :      proportional to ratio of total desired value to nAct. */
     160             :     sal_uInt16 CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
     161             : 
     162             :     /** As above except that it @return the width of PrtArea -
     163             :      that corresponds to what constitutes the column for the user. */
     164             :     sal_uInt16 CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
     165             : 
     166             :     void dumpAsXml(struct _xmlTextWriter* pWriter) const SAL_OVERRIDE;
     167             : };
     168             : 
     169        7679 : inline const SwFormatCol &SwAttrSet::GetCol(bool bInP) const
     170        7679 :     { return static_cast<const SwFormatCol&>(Get( RES_COL,bInP)); }
     171             : 
     172        7595 : inline const SwFormatCol &SwFormat::GetCol(bool bInP) const
     173        7595 :     { return m_aSet.GetCol(bInP); }
     174             : 
     175             : #endif
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11