LCOV - code coverage report
Current view: top level - editeng/source/items - borderline.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 229 278 82.4 %
Date: 2014-11-03 Functions: 25 29 86.2 %
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             : #include <basegfx/color/bcolor.hxx>
      21             : #include <basegfx/color/bcolortools.hxx>
      22             : 
      23             : #include <editeng/borderline.hxx>
      24             : #include <editeng/itemtype.hxx>
      25             : 
      26             : 
      27             : using namespace ::com::sun::star::table::BorderLineStyle;
      28             : 
      29             : // class SvxBorderLine  --------------------------------------------------
      30             : 
      31             : namespace {
      32             : 
      33          48 :     Color lcl_compute3DColor( Color aMain, int nLight, int nMedium, int nDark )
      34             :     {
      35          48 :         basegfx::BColor color = aMain.getBColor( );
      36          96 :         basegfx::BColor hsl = basegfx::tools::rgb2hsl( color );
      37             : 
      38          48 :         int nCoef = 0;
      39          48 :         if ( hsl.getZ( ) >= 0.5 )
      40           6 :             nCoef = nLight;
      41          42 :         else if ( 0.5 > hsl.getZ() && hsl.getZ() >= 0.25 )
      42           0 :             nCoef = nMedium;
      43             :         else
      44          42 :             nCoef = nDark;
      45             : 
      46          48 :         double L = hsl.getZ() * 255.0 + nCoef;
      47          48 :         hsl.setZ( L / 255.0 );
      48          48 :         color = basegfx::tools::hsl2rgb( hsl );
      49             : 
      50          96 :         return Color( color );
      51             :     }
      52             : } // Anonymous namespace
      53             : 
      54             : namespace editeng {
      55             : 
      56        7250 : Color SvxBorderLine::darkColor( Color aMain )
      57             : {
      58        7250 :     return aMain;
      59             : }
      60             : 
      61           2 : Color SvxBorderLine::lightColor( Color aMain )
      62             : {
      63             : 
      64             :     // Divide Luminance by 2
      65           2 :     basegfx::BColor color = aMain.getBColor( );
      66           4 :     basegfx::BColor hsl = basegfx::tools::rgb2hsl( color );
      67           2 :     hsl.setZ( hsl.getZ() * 0.5 );
      68           2 :     color = basegfx::tools::hsl2rgb( hsl );
      69             : 
      70           4 :     return Color( color );
      71             : }
      72             : 
      73             : 
      74          16 : Color SvxBorderLine::threeDLightColor( Color aMain )
      75             : {
      76             :     // These values have been defined in an empirical way
      77          16 :     return lcl_compute3DColor( aMain, 3, 40, 83 );
      78             : }
      79             : 
      80          16 : Color SvxBorderLine::threeDDarkColor( Color aMain )
      81             : {
      82             :     // These values have been defined in an empirical way
      83          16 :     return lcl_compute3DColor( aMain, -85, -43, -1 );
      84             : }
      85             : 
      86          16 : Color SvxBorderLine::threeDMediumColor( Color aMain )
      87             : {
      88             :     // These values have been defined in an empirical way
      89          16 :     return lcl_compute3DColor( aMain, -42, -0, 42 );
      90             : }
      91             : 
      92      103205 : SvxBorderLine::SvxBorderLine( const Color *pCol, long nWidth,
      93             :        SvxBorderStyle nStyle, bool bUseLeftTop,
      94             :        Color (*pColorOutFn)( Color ), Color (*pColorInFn)( Color ),
      95             :        Color (*pColorGapFn)( Color ) )
      96             : : m_nWidth( nWidth )
      97             : , m_bMirrorWidths( false )
      98      103205 : , m_aWidthImpl( SvxBorderLine::getWidthImpl( nStyle ) )
      99             : , m_nMult( 1 )
     100             : , m_nDiv( 1 )
     101             : , m_nStyle( nStyle )
     102             : , m_bUseLeftTop( bUseLeftTop )
     103             : , m_pColorOutFn( pColorOutFn )
     104             : , m_pColorInFn( pColorInFn )
     105      206410 : , m_pColorGapFn( pColorGapFn )
     106             : {
     107      103205 :     if ( pCol )
     108        9452 :         aColor = *pCol;
     109      103205 : }
     110             : 
     111             : 
     112             : SvxBorderStyle
     113       64470 : ConvertBorderStyleFromWord(int const nWordLineStyle)
     114             : {
     115       64470 :     switch (nWordLineStyle)
     116             :     {
     117             :         // First the single lines
     118             :         case  1:
     119             :         case  2: // thick line
     120             :         case  5: // hairline
     121             :         // and the unsupported special cases which we map to a single line
     122             :         case 20:
     123       46004 :             return SOLID;
     124             :         case  6:
     125         236 :             return DOTTED;
     126             :         case  7:
     127          54 :             return DASHED;
     128             :         case 22:
     129         166 :             return FINE_DASHED;
     130             :         case 8:
     131           0 :             return DASH_DOT;
     132             :         case 9:
     133           0 :             return DASH_DOT_DOT;
     134             :         // then the shading beams which we represent by a double line
     135             :         case 23:
     136           0 :             return DOUBLE;
     137             :         // then the double lines, for which we have good matches
     138             :         case  3:
     139             :         case 10: // Don't have triple so use double
     140             :         case 21: // Don't have double wave: use double instead
     141         424 :             return DOUBLE;
     142             :         case 11:
     143          84 :             return THINTHICK_SMALLGAP;
     144             :         case 12:
     145             :         case 13: // Don't have thin thick thin, so use thick thin
     146          82 :             return THICKTHIN_SMALLGAP;
     147             :         case 14:
     148           8 :             return THINTHICK_MEDIUMGAP;
     149             :         case 15:
     150             :         case 16: // Don't have thin thick thin, so use thick thin
     151          56 :             return THICKTHIN_MEDIUMGAP;
     152             :         case 17:
     153          42 :             return THINTHICK_LARGEGAP;
     154             :         case 18:
     155             :         case 19: // Don't have thin thick thin, so use thick thin
     156         174 :             return THICKTHIN_LARGEGAP;
     157             :         case 24:
     158          44 :             return EMBOSSED;
     159             :         case 25:
     160          44 :             return ENGRAVED;
     161             :         case 26:
     162         364 :             return OUTSET;
     163             :         case 27:
     164         158 :             return INSET;
     165             :         default:
     166       16530 :             return css::table::BorderLineStyle::NONE;
     167             :     }
     168             : }
     169             : 
     170             : static const double THINTHICK_SMALLGAP_line2 = 15.0;
     171             : static const double THINTHICK_SMALLGAP_gap   = 15.0;
     172             : static const double THINTHICK_LARGEGAP_line1 = 30.0;
     173             : static const double THINTHICK_LARGEGAP_line2 = 15.0;
     174             : static const double THICKTHIN_SMALLGAP_line1 = 15.0;
     175             : static const double THICKTHIN_SMALLGAP_gap   = 15.0;
     176             : static const double THICKTHIN_LARGEGAP_line1 = 15.0;
     177             : static const double THICKTHIN_LARGEGAP_line2 = 30.0;
     178             : static const double OUTSET_line1 = 15.0;
     179             : static const double INSET_line2  = 15.0;
     180             : 
     181             : double
     182       47900 : ConvertBorderWidthFromWord(SvxBorderStyle const eStyle, double const i_fWidth,
     183             :         int const nWordLineStyle)
     184             : {
     185             :     // fdo#68779: at least for RTF, 0.75pt is the default if width is missing
     186       47900 :     double const fWidth((i_fWidth == 0.0) ? 15.0 : i_fWidth);
     187       47900 :     switch (eStyle)
     188             :     {
     189             :         // Single lines
     190             :         case SOLID:
     191       45996 :             switch (nWordLineStyle)
     192             :             {
     193             :                 case 2:
     194           0 :                     return (fWidth * 2.0); // thick
     195             :                 case 5: // fdo#55526: map 0 hairline width to > 0
     196           0 :                     return (fWidth > 1.0) ? fWidth : 1.0;
     197             :                 default:
     198       45996 :                     return fWidth;
     199             :             }
     200             :             break;
     201             : 
     202             :         case DOTTED:
     203             :         case DASHED:
     204             :         case DASH_DOT:
     205             :         case DASH_DOT_DOT:
     206         258 :             return fWidth;
     207             : 
     208             :         // Display a minimum effective border width of 1pt
     209             :         case FINE_DASHED:
     210         166 :             return (fWidth > 0 && fWidth < 20) ? 20 : fWidth;
     211             : 
     212             :         // Double lines
     213             :         case DOUBLE:
     214         424 :             return fWidth * 3.0;
     215             : 
     216             :         case THINTHICK_MEDIUMGAP:
     217             :         case THICKTHIN_MEDIUMGAP:
     218             :         case EMBOSSED:
     219             :         case ENGRAVED:
     220         152 :             return fWidth * 2.0;
     221             : 
     222             :         case THINTHICK_SMALLGAP:
     223          84 :             return fWidth + THINTHICK_SMALLGAP_line2 + THINTHICK_SMALLGAP_gap;
     224             : 
     225             :         case THINTHICK_LARGEGAP:
     226          42 :             return fWidth + THINTHICK_LARGEGAP_line1 + THINTHICK_LARGEGAP_line2;
     227             : 
     228             :         case THICKTHIN_SMALLGAP:
     229          82 :             return fWidth + THICKTHIN_SMALLGAP_line1 + THICKTHIN_SMALLGAP_gap;
     230             : 
     231             :         case THICKTHIN_LARGEGAP:
     232         174 :             return fWidth + THICKTHIN_LARGEGAP_line1 + THICKTHIN_LARGEGAP_line2;
     233             : 
     234             :         case OUTSET:
     235         364 :             return (fWidth * 2.0) + OUTSET_line1;
     236             : 
     237             :         case INSET:
     238         158 :             return (fWidth * 2.0) + INSET_line2;
     239             : 
     240             :         default:
     241             :             assert(false); // should only be called for known border style
     242           0 :             return 0;
     243             :     }
     244             : }
     245             : 
     246             : double
     247        9750 : ConvertBorderWidthToWord(SvxBorderStyle const eStyle, double const fWidth)
     248             : {
     249        9750 :     switch (eStyle)
     250             :     {
     251             :         // Single lines
     252             :         case SOLID:
     253             :         case DOTTED:
     254             :         case DASHED:
     255             :         case FINE_DASHED:
     256             :         case DASH_DOT:
     257             :         case DASH_DOT_DOT:
     258        9588 :             return fWidth;
     259             : 
     260             :         // Double lines
     261             :         case DOUBLE:
     262          46 :             return fWidth / 3.0;
     263             : 
     264             :         case THINTHICK_MEDIUMGAP:
     265             :         case THICKTHIN_MEDIUMGAP:
     266             :         case EMBOSSED:
     267             :         case ENGRAVED:
     268           0 :             return fWidth / 2.0;
     269             : 
     270             :         case THINTHICK_SMALLGAP:
     271          42 :             return fWidth - THINTHICK_SMALLGAP_line2 - THINTHICK_SMALLGAP_gap;
     272             : 
     273             :         case THINTHICK_LARGEGAP:
     274           0 :             return fWidth - THINTHICK_LARGEGAP_line1 - THINTHICK_LARGEGAP_line2;
     275             : 
     276             :         case THICKTHIN_SMALLGAP:
     277          14 :             return fWidth - THICKTHIN_SMALLGAP_line1 - THICKTHIN_SMALLGAP_gap;
     278             : 
     279             :         case THICKTHIN_LARGEGAP:
     280          36 :             return fWidth - THICKTHIN_LARGEGAP_line1 - THICKTHIN_LARGEGAP_line2;
     281             : 
     282             :         case OUTSET:
     283          24 :             return (fWidth - OUTSET_line1) / 2.0;
     284             : 
     285             :         case INSET:
     286           0 :             return (fWidth - INSET_line2) / 2.0;
     287             : 
     288             :         default:
     289             :             assert(false); // should only be called for known border style
     290           0 :             return 0;
     291             :     }
     292             : }
     293             : 
     294             : /** Get the BorderWithImpl object corresponding to the given #nStyle, all the
     295             :     units handled by the resulting object are Twips and the
     296             :     BorderWidthImpl::GetLine1() corresponds to the Outer Line.
     297             :   */
     298      226795 : BorderWidthImpl SvxBorderLine::getWidthImpl( SvxBorderStyle nStyle )
     299             : {
     300      226795 :     BorderWidthImpl aImpl;
     301             : 
     302      226795 :     switch ( nStyle )
     303             :     {
     304             :         // No line: no width
     305             :         case css::table::BorderLineStyle::NONE:
     306         552 :             aImpl = BorderWidthImpl( 0, 0.0 );
     307         552 :             break;
     308             : 
     309             :         // Single lines
     310             :         case SOLID:
     311             :         case DOTTED:
     312             :         case DASHED:
     313             :         case FINE_DASHED:
     314             :         case DASH_DOT:
     315             :         case DASH_DOT_DOT:
     316      222913 :             aImpl = BorderWidthImpl( CHANGE_LINE1, 1.0 );
     317      222913 :             break;
     318             : 
     319             :         // Double lines
     320             : 
     321             :         case DOUBLE:
     322        2000 :             aImpl = BorderWidthImpl(
     323             :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     324             :                     // fdo#46112 fdo#38542 fdo#43249:
     325             :                     // non-constant witdths must sum to 1
     326        1000 :                     1.0/3.0, 1.0/3.0, 1.0/3.0 );
     327        1000 :             break;
     328             : 
     329             :         case DOUBLE_THIN:
     330         392 :             aImpl = BorderWidthImpl(CHANGE_DIST, 10.0, 10.0, 1.0);
     331         392 :             break;
     332             : 
     333             :         case THINTHICK_SMALLGAP:
     334         668 :             aImpl = BorderWidthImpl( CHANGE_LINE1, 1.0,
     335         334 :                     THINTHICK_SMALLGAP_line2, THINTHICK_SMALLGAP_gap );
     336         334 :             break;
     337             : 
     338             :         case THINTHICK_MEDIUMGAP:
     339         464 :             aImpl = BorderWidthImpl(
     340             :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     341         232 :                     0.5, 0.25, 0.25 );
     342         232 :             break;
     343             : 
     344             :         case THINTHICK_LARGEGAP:
     345         508 :             aImpl = BorderWidthImpl( CHANGE_DIST,
     346         254 :                     THINTHICK_LARGEGAP_line1, THINTHICK_LARGEGAP_line2, 1.0 );
     347         254 :             break;
     348             : 
     349             :         case THICKTHIN_SMALLGAP:
     350         644 :             aImpl = BorderWidthImpl( CHANGE_LINE2, THICKTHIN_SMALLGAP_line1,
     351         322 :                     1.0, THICKTHIN_SMALLGAP_gap );
     352         322 :             break;
     353             : 
     354             :         case THICKTHIN_MEDIUMGAP:
     355         496 :             aImpl = BorderWidthImpl(
     356             :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     357         248 :                     0.25, 0.5, 0.25 );
     358         248 :             break;
     359             : 
     360             :         case THICKTHIN_LARGEGAP:
     361         648 :             aImpl = BorderWidthImpl( CHANGE_DIST, THICKTHIN_LARGEGAP_line1,
     362         324 :                     THICKTHIN_LARGEGAP_line2, 1.0 );
     363         324 :             break;
     364             : 
     365             :         // Engraved / Embossed
     366             :         /*
     367             :          *  Word compat: the lines widths are exactly following this rule, shouldbe:
     368             :          *      0.75pt up to 3pt and then 3pt
     369             :          */
     370             : 
     371             :         case EMBOSSED:
     372             :         case ENGRAVED:
     373         236 :             aImpl = BorderWidthImpl(
     374             :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     375         118 :                     0.25, 0.25, 0.5 );
     376         118 :             break;
     377             : 
     378             :         // Inset / Outset
     379             :         /*
     380             :          * Word compat: the gap width should be measured relatively to the biggest width for the
     381             :          *      row or column.
     382             :          */
     383             :         case OUTSET:
     384         140 :             aImpl = BorderWidthImpl(
     385             :                     CHANGE_LINE2 | CHANGE_DIST,
     386          70 :                     OUTSET_line1, 0.5, 0.5 );
     387          70 :             break;
     388             : 
     389             :         case INSET:
     390          72 :             aImpl = BorderWidthImpl(
     391             :                     CHANGE_LINE1 | CHANGE_DIST,
     392          36 :                     0.5, INSET_line2, 0.5 );
     393          36 :             break;
     394             :     }
     395             : 
     396      226795 :     return aImpl;
     397             : }
     398             : 
     399             : 
     400             : 
     401      485970 : SvxBorderLine::SvxBorderLine( const SvxBorderLine& r )
     402             : {
     403      485970 :     *this = r;
     404      485970 : }
     405             : 
     406             : 
     407             : 
     408      485976 : SvxBorderLine& SvxBorderLine::operator=( const SvxBorderLine& r )
     409             : {
     410      485976 :     aColor = r.aColor;
     411      485976 :     m_nWidth = r.m_nWidth;
     412      485976 :     m_aWidthImpl = r.m_aWidthImpl;
     413      485976 :     m_bMirrorWidths = r.m_bMirrorWidths;
     414      485976 :     m_nMult = r.m_nMult;
     415      485976 :     m_nDiv = r.m_nDiv;
     416      485976 :     m_nStyle = r.m_nStyle;
     417      485976 :     m_bUseLeftTop = r.m_bUseLeftTop;
     418      485976 :     m_pColorOutFn = r.m_pColorOutFn;
     419      485976 :     m_pColorInFn = r.m_pColorInFn;
     420      485976 :     m_pColorGapFn = r.m_pColorGapFn;
     421      485976 :     return *this;
     422             : }
     423             : 
     424             : 
     425             : 
     426           0 : void SvxBorderLine::ScaleMetrics( long nMult, long nDiv )
     427             : {
     428           0 :     m_nMult = nMult;
     429           0 :     m_nDiv = nDiv;
     430           0 : }
     431             : 
     432       28758 : void SvxBorderLine::GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn, sal_uInt16 nDist )
     433             : {
     434       28758 :     if (css::table::BorderLineStyle::NONE == nStyle)
     435             :     {
     436        7028 :         nStyle = SOLID;
     437        7028 :         if ( nOut > 0 && nIn > 0 )
     438          22 :             nStyle = DOUBLE;
     439             :     }
     440             : 
     441       28758 :     if ( nStyle == DOUBLE )
     442             :     {
     443             :         static const SvxBorderStyle aDoubleStyles[] =
     444             :         {
     445             :             DOUBLE,
     446             :             DOUBLE_THIN,
     447             :             THINTHICK_SMALLGAP,
     448             :             THINTHICK_MEDIUMGAP,
     449             :             THINTHICK_LARGEGAP,
     450             :             THICKTHIN_SMALLGAP,
     451             :             THICKTHIN_MEDIUMGAP,
     452             :             THICKTHIN_LARGEGAP
     453             :         };
     454             : 
     455             :         static size_t const len = SAL_N_ELEMENTS(aDoubleStyles);
     456         298 :         long nWidth = 0;
     457         298 :         SvxBorderStyle nTestStyle(css::table::BorderLineStyle::NONE);
     458        2116 :         for (size_t i = 0; i < len && nWidth == 0; ++i)
     459             :         {
     460        1818 :             nTestStyle = aDoubleStyles[i];
     461        1818 :             BorderWidthImpl aWidthImpl = getWidthImpl( nTestStyle );
     462        1818 :             nWidth = aWidthImpl.GuessWidth( nOut, nIn, nDist );
     463             :         }
     464             : 
     465             :         // If anything matched, then set it
     466         298 :         if ( nWidth > 0 )
     467             :         {
     468         108 :             nStyle = nTestStyle;
     469         108 :             SetBorderLineStyle(nStyle);
     470         108 :             m_nWidth = nWidth;
     471             :         }
     472             :         else
     473             :         {
     474             :             // fdo#38542: not a known double, default to something custom...
     475         190 :             SetBorderLineStyle(nStyle);
     476         190 :             m_nWidth = nOut + nIn + nDist;
     477         190 :             if (nOut + nIn + nDist)
     478             :             {
     479         380 :                 m_aWidthImpl = BorderWidthImpl(
     480             :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     481             :                     static_cast<double>(nOut ) / static_cast<double>(m_nWidth),
     482             :                     static_cast<double>(nIn  ) / static_cast<double>(m_nWidth),
     483         190 :                     static_cast<double>(nDist) / static_cast<double>(m_nWidth));
     484             :             }
     485             :         }
     486             :     }
     487             :     else
     488             :     {
     489       28460 :         SetBorderLineStyle(nStyle);
     490       28460 :         if (nOut == 0 && nIn > 0)
     491             :         {
     492             :             // If only inner width is given swap inner and outer widths for
     493             :             // single line styles, otherwise GuessWidth() marks this as invalid
     494             :             // and returns a 0 width.
     495           0 :             switch (nStyle)
     496             :             {
     497             :                 case SOLID:
     498             :                 case DOTTED:
     499             :                 case DASHED:
     500             :                 case FINE_DASHED:
     501             :                 case DASH_DOT:
     502             :                 case DASH_DOT_DOT:
     503           0 :                     ::std::swap( nOut, nIn);
     504           0 :                     break;
     505             :                 default:
     506             :                     ;   // nothing
     507             :             }
     508             :         }
     509       28460 :         m_nWidth = m_aWidthImpl.GuessWidth( nOut, nIn, nDist );
     510             :     }
     511       28758 : }
     512             : 
     513     2242109 : sal_uInt16 SvxBorderLine::GetOutWidth() const
     514             : {
     515     2242109 :     sal_uInt16 nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
     516     2242109 :     if ( m_bMirrorWidths )
     517          10 :         nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
     518     2242109 :     return nOut;
     519             : }
     520             : 
     521     2244273 : sal_uInt16 SvxBorderLine::GetInWidth() const
     522             : {
     523     2244273 :     sal_uInt16 nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
     524     2244273 :     if ( m_bMirrorWidths )
     525          10 :         nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
     526     2244273 :     return nIn;
     527             : }
     528             : 
     529     2224683 : sal_uInt16 SvxBorderLine::GetDistance() const
     530             : {
     531     2224683 :     return (sal_uInt16)Scale( m_aWidthImpl.GetGap( m_nWidth ), m_nMult, m_nDiv );
     532             : }
     533             : 
     534             : 
     535             : 
     536      482517 : bool SvxBorderLine::operator==( const SvxBorderLine& rCmp ) const
     537             : {
     538      941756 :     return ( ( aColor    == rCmp.aColor )            &&
     539      831834 :              ( m_nWidth == rCmp.m_nWidth )           &&
     540      745190 :              ( m_bMirrorWidths  == rCmp.m_bMirrorWidths )  &&
     541      744792 :              ( m_aWidthImpl  == rCmp.m_aWidthImpl )  &&
     542      743982 :              ( m_nStyle == rCmp.GetBorderLineStyle()) &&
     543      743570 :              ( m_bUseLeftTop == rCmp.m_bUseLeftTop ) &&
     544      743570 :              ( m_pColorOutFn == rCmp.m_pColorOutFn ) &&
     545     1226087 :              ( m_pColorInFn == rCmp.m_pColorInFn )   &&
     546      854302 :              ( m_pColorGapFn == rCmp.m_pColorGapFn ) );
     547             : }
     548             : 
     549      121772 : void SvxBorderLine::SetBorderLineStyle( SvxBorderStyle nNew )
     550             : {
     551      121772 :     m_nStyle = nNew;
     552      121772 :     m_aWidthImpl = getWidthImpl( m_nStyle );
     553             : 
     554      121772 :     switch ( nNew )
     555             :     {
     556             :         case EMBOSSED:
     557          56 :             m_pColorOutFn = threeDLightColor;
     558          56 :             m_pColorInFn  = threeDDarkColor;
     559          56 :             m_pColorGapFn = threeDMediumColor;
     560          56 :             m_bUseLeftTop = true;
     561          56 :             break;
     562             :         case ENGRAVED:
     563          62 :             m_pColorOutFn = threeDDarkColor;
     564          62 :             m_pColorInFn  = threeDLightColor;
     565          62 :             m_pColorGapFn = threeDMediumColor;
     566          62 :             m_bUseLeftTop = true;
     567          62 :             break;
     568             :         case OUTSET:
     569          70 :             m_pColorOutFn = lightColor;
     570          70 :             m_pColorInFn  = darkColor;
     571          70 :             m_bUseLeftTop = true;
     572          70 :             m_pColorGapFn = NULL;
     573          70 :             break;
     574             :         case INSET:
     575          36 :             m_pColorOutFn = darkColor;
     576          36 :             m_pColorInFn  = lightColor;
     577          36 :             m_bUseLeftTop = true;
     578          36 :             m_pColorGapFn = NULL;
     579          36 :             break;
     580             :         default:
     581      121548 :             m_pColorOutFn = darkColor;
     582      121548 :             m_pColorInFn = darkColor;
     583      121548 :             m_bUseLeftTop = false;
     584      121548 :             m_pColorGapFn = NULL;
     585      121548 :             break;
     586             :     }
     587      121772 : }
     588             : 
     589     2067029 : Color SvxBorderLine::GetColorOut( bool bLeftOrTop ) const
     590             : {
     591     2067029 :     Color aResult = aColor;
     592             : 
     593     2067029 :     if ( m_aWidthImpl.IsDouble() && m_pColorOutFn != NULL )
     594             :     {
     595        3642 :         if ( !bLeftOrTop && m_bUseLeftTop )
     596           6 :             aResult = (*m_pColorInFn)( aColor );
     597             :         else
     598        3636 :             aResult = (*m_pColorOutFn)( aColor );
     599             :     }
     600             : 
     601     2067029 :     return aResult;
     602             : }
     603             : 
     604     2067029 : Color SvxBorderLine::GetColorIn( bool bLeftOrTop ) const
     605             : {
     606     2067029 :     Color aResult = aColor;
     607             : 
     608     2067029 :     if ( m_aWidthImpl.IsDouble() && m_pColorInFn != NULL )
     609             :     {
     610        3642 :         if ( !bLeftOrTop && m_bUseLeftTop )
     611           6 :             aResult = (*m_pColorOutFn)( aColor );
     612             :         else
     613        3636 :             aResult = (*m_pColorInFn)( aColor );
     614             :     }
     615             : 
     616     2067029 :     return aResult;
     617             : }
     618             : 
     619     2067029 : Color SvxBorderLine::GetColorGap( ) const
     620             : {
     621     2067029 :     Color aResult = aColor;
     622             : 
     623     2067029 :     if ( m_aWidthImpl.IsDouble() && m_pColorGapFn != NULL )
     624             :     {
     625          16 :         aResult = (*m_pColorGapFn)( aColor );
     626             :     }
     627             : 
     628     2067029 :     return aResult;
     629             : }
     630             : 
     631       70864 : void SvxBorderLine::SetWidth( long nWidth )
     632             : {
     633       70864 :     m_nWidth = nWidth;
     634       70864 : }
     635             : 
     636           0 : OUString SvxBorderLine::GetValueString( SfxMapUnit eSrcUnit,
     637             :                                       SfxMapUnit eDestUnit,
     638             :                                       const IntlWrapper* pIntl,
     639             :                                       bool bMetricStr) const
     640             : {
     641             :     static const sal_uInt16 aStyleIds[] =
     642             :     {
     643             :         RID_SOLID,
     644             :         RID_DOTTED,
     645             :         RID_DASHED,
     646             :         RID_DOUBLE,
     647             :         RID_THINTHICK_SMALLGAP,
     648             :         RID_THINTHICK_MEDIUMGAP,
     649             :         RID_THINTHICK_LARGEGAP,
     650             :         RID_THICKTHIN_SMALLGAP,
     651             :         RID_THICKTHIN_MEDIUMGAP,
     652             :         RID_THICKTHIN_LARGEGAP,
     653             :         RID_EMBOSSED,
     654             :         RID_ENGRAVED,
     655             :         RID_OUTSET,
     656             :         RID_INSET,
     657             :         RID_FINE_DASHED,
     658             :         RID_DOUBLE_THIN,
     659             :         RID_DASH_DOT,
     660             :         RID_DASH_DOT_DOT
     661             :     };
     662           0 :     OUString aStr = "(" + ::GetColorString( aColor ) + OUString(cpDelim);
     663             : 
     664           0 :     if ( m_nStyle < int(SAL_N_ELEMENTS(aStyleIds)) )
     665             :     {
     666           0 :         sal_uInt16 nResId = aStyleIds[m_nStyle];
     667           0 :         aStr += EE_RESSTR(nResId);
     668             :     }
     669             :     else
     670             :     {
     671           0 :         OUString sMetric = EE_RESSTR(GetMetricId( eDestUnit ));
     672           0 :         aStr += GetMetricText( (long)GetInWidth(), eSrcUnit, eDestUnit, pIntl );
     673           0 :         if ( bMetricStr )
     674           0 :             aStr += sMetric;
     675           0 :         aStr += cpDelim;
     676           0 :         aStr += GetMetricText( (long)GetOutWidth(), eSrcUnit, eDestUnit, pIntl );
     677           0 :         if ( bMetricStr )
     678           0 :             aStr += sMetric;
     679           0 :         aStr += cpDelim;
     680           0 :         aStr += GetMetricText( (long)GetDistance(), eSrcUnit, eDestUnit, pIntl );
     681           0 :         if ( bMetricStr )
     682           0 :             aStr += sMetric;
     683             :     }
     684           0 :     aStr += ")";
     685           0 :     return aStr;
     686             : }
     687             : 
     688           0 : bool SvxBorderLine::HasPriority( const SvxBorderLine& rOtherLine ) const
     689             : {
     690           0 :     const sal_uInt16 nThisSize = GetScaledWidth();
     691           0 :     const sal_uInt16 nOtherSize = rOtherLine.GetScaledWidth();
     692             : 
     693           0 :     if ( nThisSize > nOtherSize )
     694             :     {
     695           0 :         return true;
     696             :     }
     697           0 :     else if ( nThisSize < nOtherSize )
     698             :     {
     699           0 :         return false;
     700             :     }
     701           0 :     else if ( rOtherLine.GetInWidth() && !GetInWidth() )
     702             :     {
     703           0 :         return true;
     704             :     }
     705             : 
     706           0 :     return false;
     707             : }
     708             : 
     709           0 : bool operator!=( const SvxBorderLine& rLeft, const SvxBorderLine& rRight )
     710             : {
     711           0 :     return !(rLeft == rRight);
     712             : }
     713             : 
     714         669 : } // namespace editeng
     715             : 
     716             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10