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

Generated by: LCOV version 1.10