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

Generated by: LCOV version 1.10