LCOV - code coverage report
Current view: top level - editeng/source/items - borderline.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 162 231 70.1 %
Date: 2012-08-25 Functions: 21 24 87.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 100 244 41.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <basegfx/color/bcolor.hxx>
      30                 :            : #include <basegfx/color/bcolortools.hxx>
      31                 :            : 
      32                 :            : #include <editeng/borderline.hxx>
      33                 :            : #include <editeng/itemtype.hxx>
      34                 :            : 
      35                 :            : 
      36                 :            : using namespace ::com::sun::star::table::BorderLineStyle;
      37                 :            : 
      38                 :            : // class SvxBorderLine  --------------------------------------------------
      39                 :            : 
      40                 :            : namespace {
      41                 :            : 
      42                 :         27 :     Color lcl_compute3DColor( Color aMain, int nLight, int nMedium, int nDark )
      43                 :            :     {
      44                 :         27 :         basegfx::BColor color = aMain.getBColor( );
      45         [ +  - ]:         27 :         basegfx::BColor hsl = basegfx::tools::rgb2hsl( color );
      46                 :            : 
      47                 :         27 :         int nCoef = 0;
      48         [ -  + ]:         27 :         if ( hsl.getZ( ) >= 0.5 )
      49                 :          0 :             nCoef = nLight;
      50 [ +  - ][ -  + ]:         27 :         else if ( 0.5 > hsl.getZ() && hsl.getZ() >= 0.25 )
                 [ -  + ]
      51                 :          0 :             nCoef = nMedium;
      52                 :            :         else
      53                 :         27 :             nCoef = nDark;
      54                 :            : 
      55                 :         27 :         double L = hsl.getZ() * 255.0 + nCoef;
      56                 :         27 :         hsl.setZ( L / 255.0 );
      57 [ +  - ][ +  - ]:         27 :         color = basegfx::tools::hsl2rgb( hsl );
      58                 :            : 
      59                 :         27 :         return Color( color );
      60                 :            :     }
      61                 :            : } // Anonymous namespace
      62                 :            : 
      63                 :            : namespace editeng {
      64                 :            : 
      65                 :        120 : Color SvxBorderLine::darkColor( Color aMain )
      66                 :            : {
      67                 :        120 :     return aMain;
      68                 :            : }
      69                 :            : 
      70                 :          0 : Color SvxBorderLine::lightColor( Color aMain )
      71                 :            : {
      72                 :            : 
      73                 :            :     // Divide Luminance by 2
      74                 :          0 :     basegfx::BColor color = aMain.getBColor( );
      75         [ #  # ]:          0 :     basegfx::BColor hsl = basegfx::tools::rgb2hsl( color );
      76                 :          0 :     hsl.setZ( hsl.getZ() * 0.5 );
      77 [ #  # ][ #  # ]:          0 :     color = basegfx::tools::hsl2rgb( hsl );
      78                 :            : 
      79                 :          0 :     return Color( color );
      80                 :            : }
      81                 :            : 
      82                 :            : 
      83                 :          9 : Color SvxBorderLine::threeDLightColor( Color aMain )
      84                 :            : {
      85                 :            :     // These values have been defined in an empirical way
      86                 :          9 :     return lcl_compute3DColor( aMain, 3, 40, 83 );
      87                 :            : }
      88                 :            : 
      89                 :          9 : Color SvxBorderLine::threeDDarkColor( Color aMain )
      90                 :            : {
      91                 :            :     // These values have been defined in an empirical way
      92                 :          9 :     return lcl_compute3DColor( aMain, -85, -43, -1 );
      93                 :            : }
      94                 :            : 
      95                 :          9 : Color SvxBorderLine::threeDMediumColor( Color aMain )
      96                 :            : {
      97                 :            :     // These values have been defined in an empirical way
      98                 :          9 :     return lcl_compute3DColor( aMain, -42, -0, 42 );
      99                 :            : }
     100                 :            : 
     101                 :      11772 : SvxBorderLine::SvxBorderLine( const Color *pCol, long nWidth,
     102                 :            :        SvxBorderStyle nStyle, bool bUseLeftTop,
     103                 :            :        Color (*pColorOutFn)( Color ), Color (*pColorInFn)( Color ),
     104                 :            :        Color (*pColorGapFn)( Color ) )
     105                 :            : : m_nWidth( nWidth )
     106                 :            : , m_bMirrorWidths( false )
     107                 :      11772 : , m_aWidthImpl( SvxBorderLine::getWidthImpl( nStyle ) )
     108                 :            : , m_nMult( 1 )
     109                 :            : , m_nDiv( 1 )
     110                 :            : , m_nStyle( nStyle )
     111                 :            : , m_bUseLeftTop( bUseLeftTop )
     112                 :            : , m_pColorOutFn( pColorOutFn )
     113                 :            : , m_pColorInFn( pColorInFn )
     114                 :      11772 : , m_pColorGapFn( pColorGapFn )
     115                 :            : {
     116         [ +  + ]:      11772 :     if ( pCol )
     117                 :       4386 :         aColor = *pCol;
     118                 :      11772 : }
     119                 :            : 
     120                 :            : static const double THINTHICK_SMALLGAP_line2 = 15.0;
     121                 :            : static const double THINTHICK_SMALLGAP_gap   = 15.0;
     122                 :            : static const double THINTHICK_LARGEGAP_line1 = 30.0;
     123                 :            : static const double THINTHICK_LARGEGAP_line2 = 15.0;
     124                 :            : static const double THICKTHIN_SMALLGAP_line1 = 15.0;
     125                 :            : static const double THICKTHIN_SMALLGAP_gap   = 15.0;
     126                 :            : static const double THICKTHIN_LARGEGAP_line1 = 15.0;
     127                 :            : static const double THICKTHIN_LARGEGAP_line2 = 30.0;
     128                 :            : static const double OUTSET_line1 = 15.0;
     129                 :            : static const double INSET_line2  = 15.0;
     130                 :            : 
     131                 :            : double
     132                 :       2380 : ConvertBorderWidthFromWord(SvxBorderStyle const eStyle, double const fWidth)
     133                 :            : {
     134   [ +  +  +  -  :       2380 :     switch (eStyle)
          +  +  +  -  -  
                      - ]
     135                 :            :     {
     136                 :            :         // Single lines
     137                 :            :         case SOLID:
     138                 :            :         case DOTTED:
     139                 :            :         case DASHED:
     140                 :       1785 :             return fWidth;
     141                 :            :             break;
     142                 :            : 
     143                 :            :         // Double lines
     144                 :            :         case DOUBLE:
     145                 :         85 :             return fWidth * 3.0;
     146                 :            :             break;
     147                 :            : 
     148                 :            :         case THINTHICK_MEDIUMGAP:
     149                 :            :         case THICKTHIN_MEDIUMGAP:
     150                 :            :         case EMBOSSED:
     151                 :            :         case ENGRAVED:
     152                 :        216 :             return fWidth * 2.0;
     153                 :            :             break;
     154                 :            : 
     155                 :            :         case THINTHICK_SMALLGAP:
     156                 :          0 :             return fWidth + THINTHICK_SMALLGAP_line2 + THINTHICK_SMALLGAP_gap;
     157                 :            :             break;
     158                 :            : 
     159                 :            :         case THINTHICK_LARGEGAP:
     160                 :         84 :             return fWidth + THINTHICK_LARGEGAP_line1 + THINTHICK_LARGEGAP_line2;
     161                 :            :             break;
     162                 :            : 
     163                 :            :         case THICKTHIN_SMALLGAP:
     164                 :         45 :             return fWidth + THICKTHIN_SMALLGAP_line1 + THICKTHIN_SMALLGAP_gap;
     165                 :            :             break;
     166                 :            : 
     167                 :            :         case THICKTHIN_LARGEGAP:
     168                 :        165 :             return fWidth + THICKTHIN_LARGEGAP_line1 + THICKTHIN_LARGEGAP_line2;
     169                 :            :             break;
     170                 :            : 
     171                 :            :         case OUTSET:
     172                 :          0 :             return (fWidth * 2.0) + OUTSET_line1;
     173                 :            :             break;
     174                 :            : 
     175                 :            :         case INSET:
     176                 :          0 :             return (fWidth * 2.0) + INSET_line2;
     177                 :            :             break;
     178                 :            : 
     179                 :            :         default:
     180                 :            :             assert(false); // should only be called for known border style
     181                 :       2380 :             return 0;
     182                 :            :             break;
     183                 :            :     }
     184                 :            : }
     185                 :            : 
     186                 :            : double
     187                 :          6 : ConvertBorderWidthToWord(SvxBorderStyle const eStyle, double const fWidth)
     188                 :            : {
     189   [ +  -  -  -  :          6 :     switch (eStyle)
          -  -  -  -  -  
                      - ]
     190                 :            :     {
     191                 :            :         // Single lines
     192                 :            :         case SOLID:
     193                 :            :         case DOTTED:
     194                 :            :         case DASHED:
     195                 :          6 :             return fWidth;
     196                 :            :             break;
     197                 :            : 
     198                 :            :         // Double lines
     199                 :            :         case DOUBLE:
     200                 :          0 :             return fWidth / 3.0;
     201                 :            :             break;
     202                 :            : 
     203                 :            :         case THINTHICK_MEDIUMGAP:
     204                 :            :         case THICKTHIN_MEDIUMGAP:
     205                 :            :         case EMBOSSED:
     206                 :            :         case ENGRAVED:
     207                 :          0 :             return fWidth / 2.0;
     208                 :            :             break;
     209                 :            : 
     210                 :            :         case THINTHICK_SMALLGAP:
     211                 :          0 :             return fWidth - THINTHICK_SMALLGAP_line2 - THINTHICK_SMALLGAP_gap;
     212                 :            :             break;
     213                 :            : 
     214                 :            :         case THINTHICK_LARGEGAP:
     215                 :          0 :             return fWidth - THINTHICK_LARGEGAP_line1 - THINTHICK_LARGEGAP_line2;
     216                 :            :             break;
     217                 :            : 
     218                 :            :         case THICKTHIN_SMALLGAP:
     219                 :          0 :             return fWidth - THICKTHIN_SMALLGAP_line1 - THICKTHIN_SMALLGAP_gap;
     220                 :            :             break;
     221                 :            : 
     222                 :            :         case THICKTHIN_LARGEGAP:
     223                 :          0 :             return fWidth - THICKTHIN_LARGEGAP_line1 - THICKTHIN_LARGEGAP_line2;
     224                 :            :             break;
     225                 :            : 
     226                 :            :         case OUTSET:
     227                 :          0 :             return (fWidth - OUTSET_line1) / 2.0;
     228                 :            :             break;
     229                 :            : 
     230                 :            :         case INSET:
     231                 :          0 :             return (fWidth - INSET_line2) / 2.0;
     232                 :            :             break;
     233                 :            : 
     234                 :            :         default:
     235                 :            :             assert(false); // should only be called for known border style
     236                 :          6 :             return 0;
     237                 :            :             break;
     238                 :            :     }
     239                 :            : }
     240                 :            : 
     241                 :            : /** Get the BorderWithImpl object corresponding to the given #nStyle, all the
     242                 :            :     units handled by the resulting object are Twips and the
     243                 :            :     BorderWidthImpl::GetLine1() corresponds to the Outer Line.
     244                 :            :   */
     245                 :      23351 : BorderWidthImpl SvxBorderLine::getWidthImpl( SvxBorderStyle nStyle )
     246                 :            : {
     247                 :      23351 :     BorderWidthImpl aImpl;
     248                 :            : 
     249   [ +  +  +  +  :      23351 :     switch ( nStyle )
          +  +  +  +  +  
             +  -  -  - ]
     250                 :            :     {
     251                 :            :         // No line: no width
     252                 :            :         case NONE:
     253         [ +  - ]:         24 :             aImpl = BorderWidthImpl( 0, 0.0 );
     254                 :         24 :             break;
     255                 :            : 
     256                 :            :         // Single lines
     257                 :            :         case SOLID:
     258                 :            :         case DOTTED:
     259                 :            :         case DASHED:
     260         [ +  - ]:      20443 :             aImpl = BorderWidthImpl( CHANGE_LINE1, 1.0 );
     261                 :      20443 :             break;
     262                 :            : 
     263                 :            :         // Double lines
     264                 :            : 
     265                 :            :         case DOUBLE:
     266                 :            :             aImpl = BorderWidthImpl(
     267                 :            :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     268                 :            :                     // fdo#46112 fdo#38542 fdo#43249:
     269                 :            :                     // non-constant witdths must sum to 1
     270         [ +  - ]:        867 :                     1.0/3.0, 1.0/3.0, 1.0/3.0 );
     271                 :        867 :             break;
     272                 :            : 
     273                 :            :         case THINTHICK_SMALLGAP:
     274                 :            :             aImpl = BorderWidthImpl( CHANGE_LINE1, 1.0,
     275         [ +  - ]:        255 :                     THINTHICK_SMALLGAP_line2, THINTHICK_SMALLGAP_gap );
     276                 :        255 :             break;
     277                 :            : 
     278                 :            :         case THINTHICK_MEDIUMGAP:
     279                 :            :             aImpl = BorderWidthImpl(
     280                 :            :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     281         [ +  - ]:        249 :                     0.5, 0.25, 0.25 );
     282                 :        249 :             break;
     283                 :            : 
     284                 :            :         case THINTHICK_LARGEGAP:
     285                 :            :             aImpl = BorderWidthImpl( CHANGE_DIST,
     286         [ +  - ]:        336 :                     THINTHICK_LARGEGAP_line1, THINTHICK_LARGEGAP_line2, 1.0 );
     287                 :        336 :             break;
     288                 :            : 
     289                 :            :         case THICKTHIN_SMALLGAP:
     290                 :            :             aImpl = BorderWidthImpl( CHANGE_LINE2, THICKTHIN_SMALLGAP_line1,
     291         [ +  - ]:        288 :                     1.0, THICKTHIN_SMALLGAP_gap );
     292                 :        288 :             break;
     293                 :            : 
     294                 :            :         case THICKTHIN_MEDIUMGAP:
     295                 :            :             aImpl = BorderWidthImpl(
     296                 :            :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     297         [ +  - ]:        324 :                     0.25, 0.5, 0.25 );
     298                 :        324 :             break;
     299                 :            : 
     300                 :            :         case THICKTHIN_LARGEGAP:
     301                 :            :             aImpl = BorderWidthImpl( CHANGE_DIST, THICKTHIN_LARGEGAP_line1,
     302         [ +  - ]:        407 :                     THICKTHIN_LARGEGAP_line2, 1.0 );
     303                 :        407 :             break;
     304                 :            : 
     305                 :            :         // Engraved / Embossed
     306                 :            :         /*
     307                 :            :          *  Word compat: the lines widths are exactly following this rule, shouldbe:
     308                 :            :          *      0.75pt up to 3pt and then 3pt
     309                 :            :          */
     310                 :            : 
     311                 :            :         case EMBOSSED:
     312                 :            :         case ENGRAVED:
     313                 :            :             aImpl = BorderWidthImpl(
     314                 :            :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     315         [ +  - ]:        158 :                     0.25, 0.25, 0.5 );
     316                 :        158 :             break;
     317                 :            : 
     318                 :            :         // Inset / Outset
     319                 :            :         /*
     320                 :            :          * Word compat: the gap width should be measured relatively to the biggest width for the
     321                 :            :          *      row or column.
     322                 :            :          */
     323                 :            :         case OUTSET:
     324                 :            :             aImpl = BorderWidthImpl(
     325                 :            :                     CHANGE_LINE2 | CHANGE_DIST,
     326         [ #  # ]:          0 :                     OUTSET_line1, 0.5, 0.5 );
     327                 :          0 :             break;
     328                 :            : 
     329                 :            :         case INSET:
     330                 :            :             aImpl = BorderWidthImpl(
     331                 :            :                     CHANGE_LINE1 | CHANGE_DIST,
     332         [ #  # ]:          0 :                     0.5, INSET_line2, 0.5 );
     333                 :          0 :             break;
     334                 :            :     }
     335                 :            : 
     336                 :      23351 :     return aImpl;
     337                 :            : }
     338                 :            : 
     339                 :            : // -----------------------------------------------------------------------
     340                 :            : 
     341                 :      61691 : SvxBorderLine::SvxBorderLine( const SvxBorderLine& r )
     342                 :            : {
     343                 :      61691 :     *this = r;
     344                 :      61691 : }
     345                 :            : 
     346                 :            : // -----------------------------------------------------------------------
     347                 :            : 
     348                 :      61691 : SvxBorderLine& SvxBorderLine::operator=( const SvxBorderLine& r )
     349                 :            : {
     350                 :      61691 :     aColor = r.aColor;
     351                 :      61691 :     m_nWidth = r.m_nWidth;
     352                 :      61691 :     m_aWidthImpl = r.m_aWidthImpl;
     353                 :      61691 :     m_bMirrorWidths = r.m_bMirrorWidths;
     354                 :      61691 :     m_nMult = r.m_nMult;
     355                 :      61691 :     m_nDiv = r.m_nDiv;
     356                 :      61691 :     m_nStyle = r.m_nStyle;
     357                 :      61691 :     m_bUseLeftTop = r.m_bUseLeftTop;
     358                 :      61691 :     m_pColorOutFn = r.m_pColorOutFn;
     359                 :      61691 :     m_pColorInFn = r.m_pColorInFn;
     360                 :      61691 :     m_pColorGapFn = r.m_pColorGapFn;
     361                 :      61691 :     return *this;
     362                 :            : }
     363                 :            : 
     364                 :            : // -----------------------------------------------------------------------
     365                 :            : 
     366                 :          0 : void SvxBorderLine::ScaleMetrics( long nMult, long nDiv )
     367                 :            : {
     368                 :          0 :     m_nMult = nMult;
     369                 :          0 :     m_nDiv = nDiv;
     370                 :          0 : }
     371                 :            : 
     372                 :       3187 : void SvxBorderLine::GuessLinesWidths( SvxBorderStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn, sal_uInt16 nDist )
     373                 :            : {
     374         [ +  + ]:       3187 :     if (NONE == nStyle)
     375                 :            :     {
     376                 :        770 :         nStyle = SOLID;
     377 [ +  + ][ +  + ]:        770 :         if ( nOut > 0 && nIn > 0 )
     378                 :         13 :             nStyle = DOUBLE;
     379                 :            :     }
     380                 :            : 
     381         [ +  + ]:       3187 :     if ( nStyle == DOUBLE )
     382                 :            :     {
     383                 :            :         static SvxBorderStyle aDoubleStyles[] =
     384                 :            :         {
     385                 :            :             DOUBLE,
     386                 :            :             THINTHICK_SMALLGAP,
     387                 :            :             THINTHICK_MEDIUMGAP,
     388                 :            :             THINTHICK_LARGEGAP,
     389                 :            :             THICKTHIN_SMALLGAP,
     390                 :            :             THICKTHIN_MEDIUMGAP,
     391                 :            :             THICKTHIN_LARGEGAP
     392                 :            :         };
     393                 :            : 
     394                 :        308 :         size_t const len = SAL_N_ELEMENTS(aDoubleStyles);
     395                 :        308 :         long nWidth = 0;
     396                 :        308 :         SvxBorderStyle nTestStyle(NONE);
     397 [ +  + ][ +  + ]:       2095 :         for (size_t i = 0; i < len && nWidth == 0; ++i)
                 [ +  + ]
     398                 :            :         {
     399                 :       1787 :             nTestStyle = aDoubleStyles[i];
     400         [ +  - ]:       1787 :             BorderWidthImpl aWidthImpl = getWidthImpl( nTestStyle );
     401         [ +  - ]:       1787 :             nWidth = aWidthImpl.GuessWidth( nOut, nIn, nDist );
     402                 :            :         }
     403                 :            : 
     404                 :            :         // If anything matched, then set it
     405         [ +  + ]:        308 :         if ( nWidth > 0 )
     406                 :            :         {
     407                 :         65 :             nStyle = nTestStyle;
     408                 :         65 :             SetBorderLineStyle(nStyle);
     409                 :         65 :             m_nWidth = nWidth;
     410                 :            :         }
     411                 :            :         else
     412                 :            :         {
     413                 :            :             // fdo#38542: not a known double, default to something custom...
     414                 :        243 :             SetBorderLineStyle(nStyle);
     415                 :        243 :             m_nWidth = nOut + nIn + nDist;
     416         [ +  - ]:        243 :             if (nOut + nIn + nDist)
     417                 :            :             {
     418                 :            :                 m_aWidthImpl = BorderWidthImpl(
     419                 :            :                     CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST,
     420                 :            :                     static_cast<double>(nOut ) / static_cast<double>(m_nWidth),
     421                 :            :                     static_cast<double>(nIn  ) / static_cast<double>(m_nWidth),
     422         [ +  - ]:        243 :                     static_cast<double>(nDist) / static_cast<double>(m_nWidth));
     423                 :            :             }
     424                 :            :         }
     425                 :            :     }
     426                 :            :     else
     427                 :            :     {
     428                 :       2879 :         SetBorderLineStyle(nStyle);
     429 [ -  + ][ +  + ]:       2879 :         if (nOut == 0 && nIn > 0)
     430                 :            :         {
     431                 :            :             // If only inner width is given swap inner and outer widths for
     432                 :            :             // single line styles, otherwise GuessWidth() marks this as invalid
     433                 :            :             // and returns a 0 width.
     434         [ #  # ]:          0 :             switch (nStyle)
     435                 :            :             {
     436                 :            :                 case SOLID:
     437                 :            :                 case DOTTED:
     438                 :            :                 case DASHED:
     439                 :          0 :                     ::std::swap( nOut, nIn);
     440                 :          0 :                     break;
     441                 :            :                 default:
     442                 :            :                     ;   // nothing
     443                 :            :             }
     444                 :            :         }
     445                 :       2879 :         m_nWidth = m_aWidthImpl.GuessWidth( nOut, nIn, nDist );
     446                 :            :     }
     447                 :       3187 : }
     448                 :            : 
     449                 :     113373 : sal_uInt16 SvxBorderLine::GetOutWidth() const
     450                 :            : {
     451                 :     113373 :     sal_uInt16 nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
     452         [ -  + ]:     113373 :     if ( m_bMirrorWidths )
     453                 :          0 :         nOut = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
     454                 :     113373 :     return nOut;
     455                 :            : }
     456                 :            : 
     457                 :     111469 : sal_uInt16 SvxBorderLine::GetInWidth() const
     458                 :            : {
     459                 :     111469 :     sal_uInt16 nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine2( m_nWidth ), m_nMult, m_nDiv );
     460         [ -  + ]:     111469 :     if ( m_bMirrorWidths )
     461                 :          0 :         nIn = (sal_uInt16)Scale( m_aWidthImpl.GetLine1( m_nWidth ), m_nMult, m_nDiv );
     462                 :     111469 :     return nIn;
     463                 :            : }
     464                 :            : 
     465                 :      94877 : sal_uInt16 SvxBorderLine::GetDistance() const
     466                 :            : {
     467                 :      94877 :     return (sal_uInt16)Scale( m_aWidthImpl.GetGap( m_nWidth ), m_nMult, m_nDiv );
     468                 :            : }
     469                 :            : 
     470                 :            : // -----------------------------------------------------------------------
     471                 :            : 
     472                 :      76271 : sal_Bool SvxBorderLine::operator==( const SvxBorderLine& rCmp ) const
     473                 :            : {
     474                 :      76271 :     return ( ( aColor    == rCmp.aColor )            &&
     475                 :            :              ( m_nWidth == rCmp.m_nWidth )           &&
     476                 :            :              ( m_bMirrorWidths  == rCmp.m_bMirrorWidths )  &&
     477                 :      46150 :              ( m_aWidthImpl  == rCmp.m_aWidthImpl )  &&
     478                 :      45581 :              ( m_nStyle == rCmp.GetBorderLineStyle()) &&
     479                 :            :              ( m_bUseLeftTop == rCmp.m_bUseLeftTop ) &&
     480                 :            :              ( m_pColorOutFn == rCmp.m_pColorOutFn ) &&
     481                 :            :              ( m_pColorInFn == rCmp.m_pColorInFn )   &&
     482 [ +  + ][ +  -  :     168002 :              ( m_pColorGapFn == rCmp.m_pColorGapFn ) );
             +  +  +  + ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  + ]
     483                 :            : }
     484                 :            : 
     485                 :       9792 : void SvxBorderLine::SetBorderLineStyle( SvxBorderStyle nNew )
     486                 :            : {
     487                 :       9792 :     m_nStyle = nNew;
     488         [ +  - ]:       9792 :     m_aWidthImpl = getWidthImpl( m_nStyle );
     489                 :            : 
     490   [ +  +  -  -  :       9792 :     switch ( nNew )
                      + ]
     491                 :            :     {
     492                 :            :         case EMBOSSED:
     493                 :         80 :             m_pColorOutFn = threeDLightColor;
     494                 :         80 :             m_pColorInFn  = threeDDarkColor;
     495                 :         80 :             m_pColorGapFn = threeDMediumColor;
     496                 :         80 :             m_bUseLeftTop = true;
     497                 :         80 :             break;
     498                 :            :         case ENGRAVED:
     499                 :         78 :             m_pColorOutFn = threeDDarkColor;
     500                 :         78 :             m_pColorInFn  = threeDLightColor;
     501                 :         78 :             m_pColorGapFn = threeDMediumColor;
     502                 :         78 :             m_bUseLeftTop = true;
     503                 :         78 :             break;
     504                 :            :         case OUTSET:
     505                 :          0 :             m_pColorOutFn = lightColor;
     506                 :          0 :             m_pColorInFn  = darkColor;
     507                 :          0 :             m_bUseLeftTop = true;
     508                 :          0 :             m_pColorGapFn = NULL;
     509                 :          0 :             break;
     510                 :            :         case INSET:
     511                 :          0 :             m_pColorOutFn = darkColor;
     512                 :          0 :             m_pColorInFn  = lightColor;
     513                 :          0 :             m_bUseLeftTop = true;
     514                 :          0 :             m_pColorGapFn = NULL;
     515                 :          0 :             break;
     516                 :            :         default:
     517                 :       9634 :             m_pColorOutFn = darkColor;
     518                 :       9634 :             m_pColorInFn = darkColor;
     519                 :       9634 :             m_bUseLeftTop = false;
     520                 :       9634 :             m_pColorGapFn = NULL;
     521                 :       9634 :             break;
     522                 :            :     }
     523                 :       9792 : }
     524                 :            : 
     525                 :      43367 : Color SvxBorderLine::GetColorOut( bool bLeftOrTop ) const
     526                 :            : {
     527                 :      43367 :     Color aResult = aColor;
     528                 :            : 
     529 [ +  + ][ +  - ]:      43367 :     if ( m_aWidthImpl.IsDouble() && m_pColorOutFn != NULL )
                 [ +  + ]
     530                 :            :     {
     531 [ -  + ][ #  # ]:         69 :         if ( !bLeftOrTop && m_bUseLeftTop )
     532                 :          0 :             aResult = (*m_pColorInFn)( aColor );
     533                 :            :         else
     534                 :         69 :             aResult = (*m_pColorOutFn)( aColor );
     535                 :            :     }
     536                 :            : 
     537                 :      43367 :     return aResult;
     538                 :            : }
     539                 :            : 
     540                 :      43367 : Color SvxBorderLine::GetColorIn( bool bLeftOrTop ) const
     541                 :            : {
     542                 :      43367 :     Color aResult = aColor;
     543                 :            : 
     544 [ +  + ][ +  - ]:      43367 :     if ( m_aWidthImpl.IsDouble() && m_pColorInFn != NULL )
                 [ +  + ]
     545                 :            :     {
     546 [ -  + ][ #  # ]:         69 :         if ( !bLeftOrTop && m_bUseLeftTop )
     547                 :          0 :             aResult = (*m_pColorOutFn)( aColor );
     548                 :            :         else
     549                 :         69 :             aResult = (*m_pColorInFn)( aColor );
     550                 :            :     }
     551                 :            : 
     552                 :      43367 :     return aResult;
     553                 :            : }
     554                 :            : 
     555                 :      43367 : Color SvxBorderLine::GetColorGap( ) const
     556                 :            : {
     557                 :      43367 :     Color aResult = aColor;
     558                 :            : 
     559 [ +  + ][ +  + ]:      43367 :     if ( m_aWidthImpl.IsDouble() && m_pColorGapFn != NULL )
                 [ +  + ]
     560                 :            :     {
     561                 :          9 :         aResult = (*m_pColorGapFn)( aColor );
     562                 :            :     }
     563                 :            : 
     564                 :      43367 :     return aResult;
     565                 :            : }
     566                 :            : 
     567                 :            : // -----------------------------------------------------------------------
     568                 :            : 
     569                 :          0 : XubString SvxBorderLine::GetValueString( SfxMapUnit eSrcUnit,
     570                 :            :                                       SfxMapUnit eDestUnit,
     571                 :            :                                       const IntlWrapper* pIntl,
     572                 :            :                                       sal_Bool bMetricStr) const
     573                 :            : {
     574                 :            :     static const sal_uInt16 aStyleIds[] =
     575                 :            :     {
     576                 :            :         RID_SOLID,
     577                 :            :         RID_DOTTED,
     578                 :            :         RID_DASHED,
     579                 :            :         RID_DOUBLE,
     580                 :            :         RID_THINTHICK_SMALLGAP,
     581                 :            :         RID_THINTHICK_MEDIUMGAP,
     582                 :            :         RID_THINTHICK_LARGEGAP,
     583                 :            :         RID_THICKTHIN_SMALLGAP,
     584                 :            :         RID_THICKTHIN_MEDIUMGAP,
     585                 :            :         RID_THICKTHIN_LARGEGAP,
     586                 :            :         RID_EMBOSSED,
     587                 :            :         RID_ENGRAVED,
     588                 :            :         RID_OUTSET,
     589                 :            :         RID_INSET
     590                 :            :     };
     591                 :          0 :     sal_uInt16 nResId = aStyleIds[m_nStyle];
     592                 :          0 :     String aStr;
     593         [ #  # ]:          0 :     aStr += sal_Unicode('(');
     594 [ #  # ][ #  # ]:          0 :     aStr += ::GetColorString( aColor );
                 [ #  # ]
     595         [ #  # ]:          0 :     aStr += cpDelim;
     596                 :            : 
     597         [ #  # ]:          0 :     if ( nResId )
     598 [ #  # ][ #  # ]:          0 :         aStr += EE_RESSTR(nResId);
                 [ #  # ]
     599                 :            :     else
     600                 :            :     {
     601 [ #  # ][ #  # ]:          0 :         String sMetric = EE_RESSTR(GetMetricId( eDestUnit ));
         [ #  # ][ #  # ]
     602 [ #  # ][ #  # ]:          0 :         aStr += GetMetricText( (long)GetInWidth(), eSrcUnit, eDestUnit, pIntl );
         [ #  # ][ #  # ]
     603         [ #  # ]:          0 :         if ( bMetricStr )
     604         [ #  # ]:          0 :             aStr += sMetric;
     605         [ #  # ]:          0 :         aStr += cpDelim;
     606 [ #  # ][ #  # ]:          0 :         aStr += GetMetricText( (long)GetOutWidth(), eSrcUnit, eDestUnit, pIntl );
         [ #  # ][ #  # ]
     607         [ #  # ]:          0 :         if ( bMetricStr )
     608         [ #  # ]:          0 :             aStr += sMetric;
     609         [ #  # ]:          0 :         aStr += cpDelim;
     610 [ #  # ][ #  # ]:          0 :         aStr += GetMetricText( (long)GetDistance(), eSrcUnit, eDestUnit, pIntl );
         [ #  # ][ #  # ]
     611         [ #  # ]:          0 :         if ( bMetricStr )
     612 [ #  # ][ #  # ]:          0 :             aStr += sMetric;
     613                 :            :     }
     614         [ #  # ]:          0 :     aStr += sal_Unicode(')');
     615                 :          0 :     return aStr;
     616                 :            : }
     617                 :            : 
     618                 :      14960 : bool SvxBorderLine::HasPriority( const SvxBorderLine& rOtherLine ) const
     619                 :            : {
     620                 :      14960 :     const sal_uInt16 nThisSize = GetOutWidth() + GetDistance() + GetInWidth();
     621                 :      14960 :     const sal_uInt16 nOtherSize = rOtherLine.GetOutWidth() + rOtherLine.GetDistance() + rOtherLine.GetInWidth();
     622                 :            : 
     623         [ -  + ]:      14960 :     if ( nThisSize > nOtherSize )
     624                 :            :     {
     625                 :          0 :         return true;
     626                 :            :     }
     627         [ -  + ]:      14960 :     else if ( nThisSize < nOtherSize )
     628                 :            :     {
     629                 :          0 :         return false;
     630                 :            :     }
     631 [ -  + ][ #  # ]:      14960 :     else if ( rOtherLine.GetInWidth() && !GetInWidth() )
                 [ -  + ]
     632                 :            :     {
     633                 :          0 :         return true;
     634                 :            :     }
     635                 :            : 
     636                 :      14960 :     return false;
     637                 :            : }
     638                 :            : 
     639                 :            : } // namespace editeng
     640                 :            : 
     641                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10