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

Generated by: LCOV version 1.11