LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/editeng - borderline.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 12 91.7 %
Date: 2012-12-27 Functions: 9 10 90.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 SVX_BORDERLINE_HXX
      21             : #define SVX_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             :         sal_uInt16 nOutWidth;
      66             :         sal_uInt16 nInWidth;
      67             :         sal_uInt16 nDistance;
      68             : 
      69             :         bool             m_bUseLeftTop;
      70             :         Color            (*m_pColorOutFn)( Color );
      71             :         Color            (*m_pColorInFn)( Color );
      72             :         Color            (*m_pColorGapFn)( Color );
      73             : 
      74             :     public:
      75             :         SvxBorderLine( const Color *pCol = 0,
      76             :                 long nWidth = 0, SvxBorderStyle nStyle =
      77             :                     ::com::sun::star::table::BorderLineStyle::SOLID,
      78             :                 bool bUseLeftTop = false,
      79             :                 Color (*pColorOutFn)( Color ) = &darkColor,
      80             :                 Color (*pColorInFn)( Color ) = &darkColor,
      81             :                 Color (*pColorGapFn)( Color ) = NULL );
      82             :         SvxBorderLine( const SvxBorderLine& r );
      83             : 
      84             :         SvxBorderLine& operator=( const SvxBorderLine& r );
      85             : 
      86         458 :         const Color&    GetColor() const { return aColor; }
      87             :         Color           GetColorOut( bool bLeftOrTop = true ) const;
      88             :         Color           GetColorIn( bool bLeftOrTop = true ) const;
      89         350 :         bool            HasGapColor() const { return m_pColorGapFn != NULL; }
      90             :         Color           GetColorGap() const;
      91             : 
      92        7400 :         void            SetWidth( long nWidth = 0 ) { m_nWidth = nWidth; }
      93             :         /** Guess the style and width from the three lines widths values.
      94             : 
      95             :             When the value of nStyle is SvxBorderLine::DOUBLE, the style set will be guessed
      96             :             using the three values to match the best possible style among the following:
      97             :                 - SvxBorderLine::DOUBLE
      98             :                 - SvxBorderLine::THINTHICK_SMALLGAP
      99             :                 - SvxBorderLine::THINTHICK_MEDIUMGAP
     100             :                 - SvxBorderLine::THINTHICK_LARGEGAP
     101             :                 - SvxBorderLine::THICKTHIN_SMALLGAP
     102             :                 - SvxBorderLine::THICKTHIN_MEDIUMGAP
     103             :                 - SvxBorderLine::THICKTHIN_LARGEGAP
     104             : 
     105             :             If no styles matches the width, then the width is set to 0.
     106             : 
     107             :             There is one known case that could fit several styles: \a nIn = \a nDist = 0.75 pt,
     108             :             \a nOut = 1.5 pt. This case fits SvxBorderLine::THINTHICK_SMALLGAP and
     109             :             SvxBorderLine::THINTHICK_MEDIUMGAP with a 1.5 pt width and
     110             :             SvxBorderLine::THINTHICK_LARGEGAP with a 0.75 pt width. The same case happens
     111             :             also for thick-thin styles.
     112             : 
     113             :             \param nStyle the border style used to guess the width.
     114             :             \param nIn the width of the inner line in 1th pt
     115             :             \param nOut the width of the outer line in 1th pt
     116             :             \param nDist the width of the gap between the lines in 1th pt
     117             :          */
     118             :         void            GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn = 0, sal_uInt16 nDist = 0 );
     119             : 
     120             :         // TODO Hacky method to mirror lines in only a few cases
     121           0 :         void            SetMirrorWidths( bool bMirror = true ) { m_bMirrorWidths = bMirror; }
     122         912 :         long            GetWidth( ) const { return m_nWidth; }
     123             :         sal_uInt16      GetOutWidth() const;
     124             :         sal_uInt16      GetInWidth() const;
     125             :         sal_uInt16      GetDistance() const;
     126             : 
     127       40967 :         SvxBorderStyle  GetBorderLineStyle() const { return m_nStyle; }
     128             : 
     129        8706 :         void            SetColor( const Color &rColor ) { aColor = rColor; }
     130             :         void            SetColorOutFn( Color (*pColorOutFn)( Color ) ) { m_pColorOutFn = pColorOutFn; }
     131             :         void            SetColorInFn( Color (*pColorInFn)( Color ) ) { m_pColorInFn = pColorInFn; }
     132             :         void            SetColorGapFn( Color (*pColorGapFn)( Color ) ) { m_pColorGapFn = pColorGapFn; }
     133             :         void            SetUseLeftTop( bool bUseLeftTop ) { m_bUseLeftTop = bUseLeftTop; }
     134             :         void            SetBorderLineStyle( SvxBorderStyle nNew );
     135             :         void            ScaleMetrics( long nMult, long nDiv );
     136             : 
     137             :         sal_Bool            operator==( const SvxBorderLine &rCmp ) const;
     138             : 
     139             :         String          GetValueString( SfxMapUnit eSrcUnit, SfxMapUnit eDestUnit,
     140             :                                         const IntlWrapper* pIntl,
     141             :                                         sal_Bool bMetricStr = sal_False ) const;
     142             : 
     143             :         bool            HasPriority( const SvxBorderLine& rOtherLine ) const;
     144             : 
     145        3225 :         bool isEmpty() const {
     146        3225 :             return m_aWidthImpl.IsEmpty()
     147             :                 || m_nStyle == ::com::sun::star::table::BorderLineStyle::NONE
     148        3225 :                 || m_nWidth == 0;
     149             :         }
     150           2 :         bool isDouble() const { return m_aWidthImpl.IsDouble(); }
     151         816 :         sal_uInt16 GetScaledWidth() const { return GetOutWidth() + GetInWidth() + GetDistance(); }
     152             : 
     153             :         static Color darkColor( Color aMain );
     154             :         static Color lightColor( Color aMain );
     155             : 
     156             :         static Color threeDLightColor( Color aMain );
     157             :         static Color threeDMediumColor( Color aMain );
     158             :         static Color threeDDarkColor( Color aMain );
     159             : 
     160             :         static BorderWidthImpl getWidthImpl( SvxBorderStyle nStyle );
     161             :     };
     162             : 
     163             : // ============================================================================
     164             : 
     165             : } // namespace editeng
     166             : 
     167             : #endif
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10