LCOV - code coverage report
Current view: top level - editeng/source/items - itemtype.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 83 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 127 0.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 <vcl/outdev.hxx>
      30                 :            : #include <editeng/editrids.hrc>
      31                 :            : #include <unotools/intlwrapper.hxx>
      32                 :            : #include <unotools/localedatawrapper.hxx>
      33                 :            : #include <editeng/itemtype.hxx>
      34                 :            : #include <editeng/eerdll.hxx>
      35                 :            : 
      36                 :            : // -----------------------------------------------------------------------
      37                 :            : 
      38                 :          0 : XubString GetMetricText( long nVal, SfxMapUnit eSrcUnit, SfxMapUnit eDestUnit, const IntlWrapper* pIntl    )
      39                 :            : {
      40                 :          0 :     sal_Bool bNeg = sal_False;
      41                 :          0 :     long nRet = 0;
      42         [ #  # ]:          0 :     XubString sRet;
      43                 :            : 
      44         [ #  # ]:          0 :     if ( nVal < 0 )
      45                 :            :     {
      46                 :          0 :         bNeg = sal_True;
      47                 :          0 :         nVal *= -1;
      48                 :            :     }
      49                 :            : 
      50   [ #  #  #  # ]:          0 :     switch ( eDestUnit )
      51                 :            :     {
      52                 :            :         case SFX_MAPUNIT_100TH_MM:
      53                 :            :         case SFX_MAPUNIT_10TH_MM:
      54                 :            :         case SFX_MAPUNIT_MM:
      55                 :            :         case SFX_MAPUNIT_CM:
      56                 :            :         {
      57                 :            :             nRet = (long)OutputDevice::LogicToLogic(
      58         [ #  # ]:          0 :                 nVal, (MapUnit)eSrcUnit, (MapUnit)SFX_MAPUNIT_100TH_MM );
      59                 :            : 
      60   [ #  #  #  # ]:          0 :             switch ( eDestUnit )
      61                 :            :             {
      62                 :          0 :                 case SFX_MAPUNIT_100TH_MM:  nRet *= 1000; break;
      63                 :          0 :                 case SFX_MAPUNIT_10TH_MM:   nRet *= 100; break;
      64                 :          0 :                 case SFX_MAPUNIT_MM:        nRet *= 10; break;
      65                 :            :                 default: ;//prevent warning
      66                 :            :             }
      67                 :          0 :             break;
      68                 :            :         }
      69                 :            : 
      70                 :            :         case SFX_MAPUNIT_1000TH_INCH:
      71                 :            :         case SFX_MAPUNIT_100TH_INCH:
      72                 :            :         case SFX_MAPUNIT_10TH_INCH:
      73                 :            :         case SFX_MAPUNIT_INCH:
      74                 :            :         {
      75                 :            :             nRet = (long)OutputDevice::LogicToLogic(
      76         [ #  # ]:          0 :                 nVal, (MapUnit)eSrcUnit, (MapUnit)SFX_MAPUNIT_1000TH_INCH );
      77                 :            : 
      78   [ #  #  #  # ]:          0 :             switch ( eDestUnit )
      79                 :            :             {
      80                 :          0 :                 case SFX_MAPUNIT_1000TH_INCH:   nRet *= 1000; break;
      81                 :          0 :                 case SFX_MAPUNIT_100TH_INCH:    nRet *= 100; break;
      82                 :          0 :                 case SFX_MAPUNIT_10TH_INCH:     nRet *= 10; break;
      83                 :            :                 default: ;//prevent warning
      84                 :            :             }
      85                 :          0 :             break;
      86                 :            :         }
      87                 :            : 
      88                 :            :         case SFX_MAPUNIT_POINT:
      89                 :            :         case SFX_MAPUNIT_TWIP:
      90                 :            :         case SFX_MAPUNIT_PIXEL:
      91                 :            :             return String::CreateFromInt32( (long)OutputDevice::LogicToLogic(
      92 [ #  # ][ #  # ]:          0 :                         nVal, (MapUnit)eSrcUnit, (MapUnit)eDestUnit ));
      93                 :            : 
      94                 :            :         default:
      95                 :            :             OSL_FAIL( "not supported mapunit" );
      96         [ #  # ]:          0 :             return sRet;
      97                 :            :     }
      98                 :            : 
      99 [ #  # ][ #  # ]:          0 :     if ( SFX_MAPUNIT_CM == eDestUnit || SFX_MAPUNIT_INCH == eDestUnit )
     100                 :            :     {
     101                 :          0 :         long nMod = nRet % 10;
     102                 :            : 
     103         [ #  # ]:          0 :         if ( nMod > 4 )
     104                 :          0 :             nRet += 10 - nMod;
     105         [ #  # ]:          0 :         else if ( nMod > 0 )
     106                 :          0 :             nRet -= nMod;
     107                 :            :     }
     108                 :            : 
     109         [ #  # ]:          0 :     if ( bNeg )
     110         [ #  # ]:          0 :         sRet += sal_Unicode('-');
     111                 :            : 
     112                 :          0 :     long nDiff = 1000;
     113         [ #  # ]:          0 :     for( int nDigits = 4; nDigits; --nDigits, nDiff /= 10 )
     114                 :            :     {
     115         [ #  # ]:          0 :         if ( nRet < nDiff )
     116         [ #  # ]:          0 :             sRet += sal_Unicode('0');
     117                 :            :         else
     118 [ #  # ][ #  # ]:          0 :             sRet += String::CreateFromInt32( nRet / nDiff );
                 [ #  # ]
     119                 :          0 :         nRet %= nDiff;
     120         [ #  # ]:          0 :         if( 4 == nDigits )
     121                 :            :         {
     122         [ #  # ]:          0 :             if(pIntl)
     123 [ #  # ][ #  # ]:          0 :                 sRet += pIntl->getLocaleData()->getNumDecimalSep();
                 [ #  # ]
     124                 :            :             else
     125         [ #  # ]:          0 :                 sRet += ',';
     126         [ #  # ]:          0 :             if( !nRet )
     127                 :            :             {
     128         [ #  # ]:          0 :                 sRet += sal_Unicode('0');
     129                 :          0 :                 break;
     130                 :            :             }
     131                 :            :         }
     132         [ #  # ]:          0 :         else if( !nRet )
     133                 :          0 :             break;
     134                 :            :     }
     135 [ #  # ][ #  # ]:          0 :     return sRet;
     136                 :            : }
     137                 :            : 
     138                 :            : // -----------------------------------------------------------------------
     139                 :            : 
     140                 :          0 : XubString GetSvxString( sal_uInt16 nId )
     141                 :            : {
     142 [ #  # ][ #  # ]:          0 :     return EE_RESSTR( nId );
     143                 :            : }
     144                 :            : 
     145                 :            : // -----------------------------------------------------------------------
     146                 :            : 
     147                 :          0 : XubString GetColorString( const Color& rCol )
     148                 :            : {
     149                 :          0 :     XubString sStr;
     150                 :            : 
     151                 :            :     ColorData nColData =
     152                 :          0 :         RGB_COLORDATA( rCol.GetRed(), rCol.GetGreen(), rCol.GetBlue() );
     153                 :          0 :     sal_uInt16 nColor = 0;
     154                 :            : 
     155                 :            :     static ColorData aColAry[] = {
     156                 :            :         COL_BLACK, COL_BLUE, COL_GREEN, COL_CYAN,
     157                 :            :         COL_RED, COL_MAGENTA, COL_BROWN, COL_GRAY,
     158                 :            :         COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTGREEN, COL_LIGHTCYAN,
     159                 :            :         COL_LIGHTRED, COL_LIGHTMAGENTA, COL_YELLOW, COL_WHITE };
     160                 :            : 
     161 [ #  # ][ #  # ]:          0 :     while ( nColor < sizeof(aColAry)/sizeof(ColorData) &&
                 [ #  # ]
     162                 :          0 :             aColAry[nColor] != nColData )
     163                 :            :     {
     164                 :          0 :         nColor += 1;
     165                 :            :     }
     166                 :            : 
     167         [ #  # ]:          0 :     if ( nColor < sizeof(aColAry)/sizeof(ColorData) )
     168 [ #  # ][ #  # ]:          0 :         sStr = EE_RESSTR( RID_SVXITEMS_COLOR_BEGIN + nColor + 1 );
                 [ #  # ]
     169                 :            : 
     170         [ #  # ]:          0 :     if ( !sStr.Len() )
     171                 :            :     {
     172         [ #  # ]:          0 :         sStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "RGB" ));
     173         [ #  # ]:          0 :         sStr += sal_Unicode('(');
     174 [ #  # ][ #  # ]:          0 :         sStr += String::CreateFromInt32( rCol.GetRed() );
                 [ #  # ]
     175         [ #  # ]:          0 :         sStr += cpDelim;
     176 [ #  # ][ #  # ]:          0 :         sStr += String::CreateFromInt32( rCol.GetGreen() );
                 [ #  # ]
     177         [ #  # ]:          0 :         sStr += cpDelim;
     178 [ #  # ][ #  # ]:          0 :         sStr += String::CreateFromInt32( rCol.GetBlue() );
                 [ #  # ]
     179         [ #  # ]:          0 :         sStr += sal_Unicode(')');
     180                 :            :     }
     181                 :          0 :     return sStr;
     182                 :            : }
     183                 :            : 
     184                 :            : // -----------------------------------------------------------------------
     185                 :            : 
     186                 :          0 : sal_uInt16 GetMetricId( SfxMapUnit eUnit )
     187                 :            : {
     188                 :          0 :     sal_uInt16 nId = RID_SVXITEMS_METRIC_MM;
     189                 :            : 
     190   [ #  #  #  #  :          0 :     switch ( eUnit )
                #  #  # ]
     191                 :            :     {
     192                 :            :         case SFX_MAPUNIT_100TH_MM:
     193                 :            :         case SFX_MAPUNIT_10TH_MM:
     194                 :            :         case SFX_MAPUNIT_MM:
     195                 :          0 :             nId = RID_SVXITEMS_METRIC_MM;
     196                 :          0 :             break;
     197                 :            : 
     198                 :            :         case SFX_MAPUNIT_CM:
     199                 :          0 :             nId = RID_SVXITEMS_METRIC_CM;
     200                 :          0 :             break;
     201                 :            : 
     202                 :            :         case SFX_MAPUNIT_1000TH_INCH:
     203                 :            :         case SFX_MAPUNIT_100TH_INCH:
     204                 :            :         case SFX_MAPUNIT_10TH_INCH:
     205                 :            :         case SFX_MAPUNIT_INCH:
     206                 :          0 :             nId = RID_SVXITEMS_METRIC_INCH;
     207                 :          0 :             break;
     208                 :            : 
     209                 :            :         case SFX_MAPUNIT_POINT:
     210                 :          0 :             nId = RID_SVXITEMS_METRIC_POINT;
     211                 :          0 :             break;
     212                 :            : 
     213                 :            :         case SFX_MAPUNIT_TWIP:
     214                 :          0 :             nId = RID_SVXITEMS_METRIC_TWIP;
     215                 :          0 :             break;
     216                 :            : 
     217                 :            :         case SFX_MAPUNIT_PIXEL:
     218                 :          0 :             nId = RID_SVXITEMS_METRIC_PIXEL;
     219                 :          0 :             break;
     220                 :            : 
     221                 :            :         default:
     222                 :            :             OSL_FAIL( "not supported mapunit" );
     223                 :            :     }
     224                 :          0 :     return nId;
     225                 :            : }
     226                 :            : 
     227                 :            : 
     228                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10