LCOV - code coverage report
Current view: top level - include/editeng - borderline.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 12 100.0 %
Date: 2015-06-13 12:38:46 Functions: 9 9 100.0 %
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_BORDERLINE_HXX
      21             : #define INCLUDED_EDITENG_BORDERLINE_HXX
      22             : 
      23             : #include <com/sun/star/table/BorderLineStyle.hpp>
      24             : 
      25             : #include <tools/color.hxx>
      26             : #include <svl/poolitem.hxx>
      27             : #include <editeng/editengdllapi.h>
      28             : #include <svtools/ctrlbox.hxx>
      29             : 
      30             : // Line defaults in twips (former Writer defaults):
      31             : 
      32             : #define DEF_LINE_WIDTH_0        1
      33             : #define DEF_LINE_WIDTH_1        20
      34             : #define DEF_LINE_WIDTH_2        50
      35             : #define DEF_LINE_WIDTH_3        80
      36             : #define DEF_LINE_WIDTH_4        100
      37             : #define DEF_LINE_WIDTH_5        10
      38             : 
      39             : 
      40             : 
      41             : namespace editeng {
      42             : 
      43             :     // values from ::com::sun::star::table::BorderLineStyle
      44             :     typedef sal_Int16 SvxBorderStyle;
      45             : 
      46             :     // convert border style between Word formats and LO
      47             :     SvxBorderStyle EDITENG_DLLPUBLIC ConvertBorderStyleFromWord(int);
      48             :     /// convert border width in twips between Word formats and LO
      49             :     double EDITENG_DLLPUBLIC ConvertBorderWidthToWord(SvxBorderStyle, double);
      50             :     double EDITENG_DLLPUBLIC ConvertBorderWidthFromWord(SvxBorderStyle,
      51             :             double, int);
      52             : 
      53             :     class EDITENG_DLLPUBLIC SvxBorderLine
      54             :     {
      55             :     protected:
      56             :         Color  aColor;
      57             : 
      58             :         long m_nWidth;
      59             :         bool m_bMirrorWidths;
      60             :         BorderWidthImpl m_aWidthImpl;
      61             :         long m_nMult;
      62             :         long m_nDiv;
      63             : 
      64             :         SvxBorderStyle   m_nStyle;
      65             : 
      66             :         bool             m_bUseLeftTop;
      67             :         Color            (*m_pColorOutFn)( Color );
      68             :         Color            (*m_pColorInFn)( Color );
      69             :         Color            (*m_pColorGapFn)( Color );
      70             : 
      71             :     public:
      72             :         SvxBorderLine( const Color *pCol = 0,
      73             :                 long nWidth = 0, SvxBorderStyle nStyle =
      74             :                     ::com::sun::star::table::BorderLineStyle::SOLID,
      75             :                 bool bUseLeftTop = false,
      76             :                 Color (*pColorOutFn)( Color ) = &darkColor,
      77             :                 Color (*pColorInFn)( Color ) = &darkColor,
      78             :                 Color (*pColorGapFn)( Color ) = NULL );
      79             :         SvxBorderLine( const SvxBorderLine& r );
      80             : 
      81             :         SvxBorderLine& operator=( const SvxBorderLine& r );
      82             : 
      83       14594 :         const Color&    GetColor() const { return aColor; }
      84             :         Color           GetColorOut( bool bLeftOrTop = true ) const;
      85             :         Color           GetColorIn( bool bLeftOrTop = true ) const;
      86     1019116 :         bool            HasGapColor() const { return m_pColorGapFn != NULL; }
      87             :         Color           GetColorGap() const;
      88             : 
      89             :         void SetWidth( long nWidth = 0 );
      90             :         /** Guess the style and width from the three lines widths values.
      91             : 
      92             :             When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed
      93             :             using the three values to match the best possible style among the following:
      94             :                 - SvxBorderLine::DOUBLE
      95             :                 - SvxBorderLine::THINTHICK_SMALLGAP
      96             :                 - SvxBorderLine::THINTHICK_MEDIUMGAP
      97             :                 - SvxBorderLine::THINTHICK_LARGEGAP
      98             :                 - SvxBorderLine::THICKTHIN_SMALLGAP
      99             :                 - SvxBorderLine::THICKTHIN_MEDIUMGAP
     100             :                 - SvxBorderLine::THICKTHIN_LARGEGAP
     101             : 
     102             :             If no styles matches the width, then the width is set to 0.
     103             : 
     104             :             There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt,
     105             :             \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and
     106             :             SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and
     107             :             SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens
     108             :             also for thick-thin styles.
     109             : 
     110             :             \param nStyle the border style used to guess the width.
     111             :             \param nIn the width of the inner line in 1th pt
     112             :             \param nOut the width of the outer line in 1th pt
     113             :             \param nDist the width of the gap between the lines in 1th pt
     114             :          */
     115             :         void            GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 );
     116             : 
     117             :         // TODO Hacky method to mirror lines in only a few cases
     118           1 :         void            SetMirrorWidths( bool bMirror = true ) { m_bMirrorWidths = bMirror; }
     119       15646 :         long            GetWidth( ) const { return m_nWidth; }
     120             :         sal_uInt16      GetOutWidth() const;
     121             :         sal_uInt16      GetInWidth() const;
     122             :         sal_uInt16      GetDistance() const;
     123             : 
     124     1255415 :         SvxBorderStyle  GetBorderLineStyle() const { return m_nStyle; }
     125             : 
     126       54866 :         void            SetColor( const Color &rColor ) { aColor = rColor; }
     127             :         void            SetColorOutFn( Color (*pColorOutFn)( Color ) ) { m_pColorOutFn = pColorOutFn; }
     128             :         void            SetColorInFn( Color (*pColorInFn)( Color ) ) { m_pColorInFn = pColorInFn; }
     129             :         void            SetColorGapFn( Color (*pColorGapFn)( Color ) ) { m_pColorGapFn = pColorGapFn; }
     130             :         void            SetUseLeftTop( bool bUseLeftTop ) { m_bUseLeftTop = bUseLeftTop; }
     131             :         void            SetBorderLineStyle( SvxBorderStyle nNew );
     132             :         void            ScaleMetrics( long nMult, long nDiv );
     133             : 
     134             :         bool            operator==( const SvxBorderLine &rCmp ) const;
     135             : 
     136             :         OUString        GetValueString( SfxMapUnit eSrcUnit, SfxMapUnit eDestUnit,
     137             :                                         const IntlWrapper* pIntl,
     138             :                                         bool bMetricStr = false ) const;
     139             : 
     140             :         bool            HasPriority( const SvxBorderLine& rOtherLine ) const;
     141             : 
     142       63437 :         bool isEmpty() const {
     143       63437 :             return m_aWidthImpl.IsEmpty()
     144       63437 :                 || m_nStyle == ::com::sun::star::table::BorderLineStyle::NONE
     145      126874 :                 || m_nWidth == 0;
     146             :         }
     147         408 :         bool isDouble() const { return m_aWidthImpl.IsDouble(); }
     148       71183 :         sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); }
     149             : 
     150             :         static Color darkColor( Color aMain );
     151             :         static Color lightColor( Color aMain );
     152             : 
     153             :         static Color threeDLightColor( Color aMain );
     154             :         static Color threeDMediumColor( Color aMain );
     155             :         static Color threeDDarkColor( Color aMain );
     156             : 
     157             :         static BorderWidthImpl getWidthImpl( SvxBorderStyle nStyle );
     158             :     };
     159             : 
     160             : EDITENG_DLLPUBLIC bool operator!=( const SvxBorderLine& rLeft, const SvxBorderLine& rRight );
     161             : 
     162             : } // namespace editeng
     163             : 
     164             : #endif
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11