LCOV - code coverage report
Current view: top level - libreoffice/sw/inc - fmtclds.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 29 82.8 %
Date: 2012-12-27 Functions: 22 27 81.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             : #ifndef _FMTCLDS_HXX
      20             : #define _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             :     sal_Bool operator==( const SwColumn & ) const;
      45             : 
      46             : 
      47          20 :     void SetWishWidth( sal_uInt16 nNew ) { nWish  = nNew; }
      48             :     void SetUpper( sal_uInt16  nNew ) { nUpper = nNew; }
      49             :     void SetLower( sal_uInt16  nNew ) { nLower = nNew; }
      50          14 :     void SetLeft ( sal_uInt16  nNew ) { nLeft  = nNew; }
      51          14 :     void SetRight( sal_uInt16  nNew ) { nRight = nNew; }
      52             : 
      53          14 :     sal_uInt16 GetWishWidth() const { return nWish;  }
      54          12 :     sal_uInt16 GetUpper() const { return nUpper; }
      55          12 :     sal_uInt16 GetLower() const { return nLower; }
      56          14 :     sal_uInt16 GetLeft () const { return nLeft; }
      57          14 :     sal_uInt16 GetRight() const { return nRight; }
      58             : };
      59             : 
      60             : typedef boost::ptr_vector<SwColumn> SwColumns;
      61             : 
      62             : enum SwColLineAdj
      63             : {
      64             :     COLADJ_NONE,
      65             :     COLADJ_TOP,
      66             :     COLADJ_CENTER,
      67             :     COLADJ_BOTTOM
      68             : };
      69             : 
      70             : class SW_DLLPUBLIC SwFmtCol : public SfxPoolItem
      71             : {
      72             :     editeng::SvxBorderStyle eLineStyle;     ///< style of the separator line
      73             :     sal_uLong   nLineWidth;                 ///< Width of the separator line.
      74             :     Color   aLineColor;                     ///< Color of the separator line.
      75             : 
      76             :     sal_uInt16   nLineHeight;               /**< Percentile height of lines.
      77             :                                           (Based on height of columns including UL). */
      78             : 
      79             :     SwColLineAdj eAdj;                      ///< Line will be adjusted top, centered or bottom.
      80             : 
      81             :     SwColumns   aColumns;                   ///< Information concerning the columns.
      82             :     sal_uInt16      nWidth;                 ///< Total desired width of all columns.
      83             : 
      84             :     sal_Bool 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             :     SW_DLLPRIVATE void Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct );
      91             : 
      92             : public:
      93             :     SwFmtCol();
      94             :     SwFmtCol( const SwFmtCol& );
      95             :     ~SwFmtCol();
      96             : 
      97             :     SwFmtCol& operator=( const SwFmtCol& );
      98             : 
      99             :     /// "pure virtual methods" of SfxPoolItem
     100             :     virtual int             operator==( const SfxPoolItem& ) const;
     101             :     virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const;
     102             :     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
     103             :                                     SfxMapUnit eCoreMetric,
     104             :                                     SfxMapUnit ePresMetric,
     105             :                                     String &rText,
     106             :                                     const IntlWrapper* pIntl = 0 ) const;
     107             : 
     108             :     virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
     109             :     virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
     110             : 
     111          24 :     const SwColumns &GetColumns() const { return aColumns; }
     112           6 :           SwColumns &GetColumns()       { return aColumns; }
     113         387 :     sal_uInt16           GetNumCols() const { return aColumns.size(); }
     114             : 
     115           1 :     editeng::SvxBorderStyle     GetLineStyle() const  { return eLineStyle;}
     116           1 :     sal_uLong           GetLineWidth() const  { return nLineWidth;}
     117           1 :     const Color&    GetLineColor() const { return aLineColor;}
     118             : 
     119             : 
     120          39 :     SwColLineAdj     GetLineAdj() const { return eAdj; }
     121          33 :     sal_Bool             IsOrtho()    const { return bOrtho; }
     122          37 :     sal_uInt16           GetWishWidth() const { return nWidth; }
     123          32 :     sal_uInt8            GetLineHeight()const { return nLineHeight; }
     124             : 
     125             :     /** @return USHRT_MAX if ambiguous.
     126             :      @return smallest width if bMin is true. */
     127             :     sal_uInt16 GetGutterWidth( sal_Bool bMin = sal_False ) const;
     128             : 
     129           0 :     void SetLineStyle(editeng::SvxBorderStyle eStyle)        { eLineStyle = eStyle;}
     130           0 :     void SetLineWidth(sal_uLong nLWidth)        { nLineWidth = nLWidth;}
     131           0 :     void SetLineColor(const Color& rCol )   { aLineColor = rCol;}
     132           0 :     void SetLineHeight( sal_uInt8 nNew )     { nLineHeight = nNew; }
     133           0 :     void SetLineAdj( SwColLineAdj eNew ){ eAdj = eNew; }
     134           3 :     void SetWishWidth( sal_uInt16 nNew )    { nWidth = nNew; }
     135             : 
     136             :     /** This function allows to (repeatedly) initialize the columns.
     137             :      The Ortho flag is set automatically. */
     138             :     void Init( sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
     139             : 
     140             :     /** Adjusts borders for columns in aColumns.
     141             :      If flag bOrtho is set, columns are visually re-arranged.
     142             :      If the flag is not set, columns widths are not changed and
     143             :      borders are adjusted. */
     144             :     void SetGutterWidth( sal_uInt16 nNew, sal_uInt16 nAct );
     145             : 
     146             :     /** This too re-arranges columns automatically if flag is set.
     147             :      Only in this case the second parameter is needed and evaluated. */
     148             :     void SetOrtho( sal_Bool bNew, sal_uInt16 nGutterWidth, sal_uInt16 nAct );
     149             : 
     150             :     /// For the reader
     151           3 :     void _SetOrtho( sal_Bool bNew ) { bOrtho = bNew; }
     152             : 
     153             :     /** Calculates current width of column nCol.
     154             :      The ratio of desired width of this column to return value is
     155             :      proportional to ratio of total desired value to nAct. */
     156             :     sal_uInt16 CalcColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
     157             : 
     158             :     /** As above except that it @return the width of PrtArea -
     159             :      that corresponds to what constitutes the column for the user. */
     160             :     sal_uInt16 CalcPrtColWidth( sal_uInt16 nCol, sal_uInt16 nAct ) const;
     161             : };
     162             : 
     163         330 : inline const SwFmtCol &SwAttrSet::GetCol(sal_Bool bInP) const
     164         330 :     { return (const SwFmtCol&)Get( RES_COL,bInP); }
     165             : 
     166         330 : inline const SwFmtCol &SwFmt::GetCol(sal_Bool bInP) const
     167         330 :     { return aSet.GetCol(bInP); }
     168             : 
     169             : #endif
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10