LCOV - code coverage report
Current view: top level - libreoffice/editeng/source/items - itemtype.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 83 0.0 %
Date: 2012-12-27 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <vcl/outdev.hxx>
      21             : #include <editeng/editrids.hrc>
      22             : #include <unotools/intlwrapper.hxx>
      23             : #include <unotools/localedatawrapper.hxx>
      24             : #include <editeng/itemtype.hxx>
      25             : #include <editeng/eerdll.hxx>
      26             : 
      27             : // -----------------------------------------------------------------------
      28             : 
      29           0 : XubString GetMetricText( long nVal, SfxMapUnit eSrcUnit, SfxMapUnit eDestUnit, const IntlWrapper* pIntl    )
      30             : {
      31           0 :     sal_Bool bNeg = sal_False;
      32           0 :     long nRet = 0;
      33           0 :     XubString sRet;
      34             : 
      35           0 :     if ( nVal < 0 )
      36             :     {
      37           0 :         bNeg = sal_True;
      38           0 :         nVal *= -1;
      39             :     }
      40             : 
      41           0 :     switch ( eDestUnit )
      42             :     {
      43             :         case SFX_MAPUNIT_100TH_MM:
      44             :         case SFX_MAPUNIT_10TH_MM:
      45             :         case SFX_MAPUNIT_MM:
      46             :         case SFX_MAPUNIT_CM:
      47             :         {
      48             :             nRet = (long)OutputDevice::LogicToLogic(
      49           0 :                 nVal, (MapUnit)eSrcUnit, (MapUnit)SFX_MAPUNIT_100TH_MM );
      50             : 
      51           0 :             switch ( eDestUnit )
      52             :             {
      53           0 :                 case SFX_MAPUNIT_100TH_MM:  nRet *= 1000; break;
      54           0 :                 case SFX_MAPUNIT_10TH_MM:   nRet *= 100; break;
      55           0 :                 case SFX_MAPUNIT_MM:        nRet *= 10; break;
      56             :                 default: ;//prevent warning
      57             :             }
      58           0 :             break;
      59             :         }
      60             : 
      61             :         case SFX_MAPUNIT_1000TH_INCH:
      62             :         case SFX_MAPUNIT_100TH_INCH:
      63             :         case SFX_MAPUNIT_10TH_INCH:
      64             :         case SFX_MAPUNIT_INCH:
      65             :         {
      66             :             nRet = (long)OutputDevice::LogicToLogic(
      67           0 :                 nVal, (MapUnit)eSrcUnit, (MapUnit)SFX_MAPUNIT_1000TH_INCH );
      68             : 
      69           0 :             switch ( eDestUnit )
      70             :             {
      71           0 :                 case SFX_MAPUNIT_1000TH_INCH:   nRet *= 1000; break;
      72           0 :                 case SFX_MAPUNIT_100TH_INCH:    nRet *= 100; break;
      73           0 :                 case SFX_MAPUNIT_10TH_INCH:     nRet *= 10; break;
      74             :                 default: ;//prevent warning
      75             :             }
      76           0 :             break;
      77             :         }
      78             : 
      79             :         case SFX_MAPUNIT_POINT:
      80             :         case SFX_MAPUNIT_TWIP:
      81             :         case SFX_MAPUNIT_PIXEL:
      82             :             return String::CreateFromInt32( (long)OutputDevice::LogicToLogic(
      83           0 :                         nVal, (MapUnit)eSrcUnit, (MapUnit)eDestUnit ));
      84             : 
      85             :         default:
      86             :             OSL_FAIL( "not supported mapunit" );
      87           0 :             return sRet;
      88             :     }
      89             : 
      90           0 :     if ( SFX_MAPUNIT_CM == eDestUnit || SFX_MAPUNIT_INCH == eDestUnit )
      91             :     {
      92           0 :         long nMod = nRet % 10;
      93             : 
      94           0 :         if ( nMod > 4 )
      95           0 :             nRet += 10 - nMod;
      96           0 :         else if ( nMod > 0 )
      97           0 :             nRet -= nMod;
      98             :     }
      99             : 
     100           0 :     if ( bNeg )
     101           0 :         sRet += sal_Unicode('-');
     102             : 
     103           0 :     long nDiff = 1000;
     104           0 :     for( int nDigits = 4; nDigits; --nDigits, nDiff /= 10 )
     105             :     {
     106           0 :         if ( nRet < nDiff )
     107           0 :             sRet += sal_Unicode('0');
     108             :         else
     109           0 :             sRet += String::CreateFromInt32( nRet / nDiff );
     110           0 :         nRet %= nDiff;
     111           0 :         if( 4 == nDigits )
     112             :         {
     113           0 :             if(pIntl)
     114           0 :                 sRet += pIntl->getLocaleData()->getNumDecimalSep();
     115             :             else
     116           0 :                 sRet += ',';
     117           0 :             if( !nRet )
     118             :             {
     119           0 :                 sRet += sal_Unicode('0');
     120           0 :                 break;
     121             :             }
     122             :         }
     123           0 :         else if( !nRet )
     124           0 :             break;
     125             :     }
     126           0 :     return sRet;
     127             : }
     128             : 
     129             : // -----------------------------------------------------------------------
     130             : 
     131           0 : XubString GetSvxString( sal_uInt16 nId )
     132             : {
     133           0 :     return EE_RESSTR( nId );
     134             : }
     135             : 
     136             : // -----------------------------------------------------------------------
     137             : 
     138           0 : XubString GetColorString( const Color& rCol )
     139             : {
     140           0 :     XubString sStr;
     141             : 
     142             :     ColorData nColData =
     143           0 :         RGB_COLORDATA( rCol.GetRed(), rCol.GetGreen(), rCol.GetBlue() );
     144           0 :     sal_uInt16 nColor = 0;
     145             : 
     146             :     static ColorData aColAry[] = {
     147             :         COL_BLACK, COL_BLUE, COL_GREEN, COL_CYAN,
     148             :         COL_RED, COL_MAGENTA, COL_BROWN, COL_GRAY,
     149             :         COL_LIGHTGRAY, COL_LIGHTBLUE, COL_LIGHTGREEN, COL_LIGHTCYAN,
     150             :         COL_LIGHTRED, COL_LIGHTMAGENTA, COL_YELLOW, COL_WHITE };
     151             : 
     152           0 :     while ( nColor < sizeof(aColAry)/sizeof(ColorData) &&
     153           0 :             aColAry[nColor] != nColData )
     154             :     {
     155           0 :         nColor += 1;
     156             :     }
     157             : 
     158           0 :     if ( nColor < sizeof(aColAry)/sizeof(ColorData) )
     159           0 :         sStr = EE_RESSTR( RID_SVXITEMS_COLOR_BEGIN + nColor + 1 );
     160             : 
     161           0 :     if ( !sStr.Len() )
     162             :     {
     163           0 :         sStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "RGB" ));
     164           0 :         sStr += sal_Unicode('(');
     165           0 :         sStr += String::CreateFromInt32( rCol.GetRed() );
     166           0 :         sStr += cpDelim;
     167           0 :         sStr += String::CreateFromInt32( rCol.GetGreen() );
     168           0 :         sStr += cpDelim;
     169           0 :         sStr += String::CreateFromInt32( rCol.GetBlue() );
     170           0 :         sStr += sal_Unicode(')');
     171             :     }
     172           0 :     return sStr;
     173             : }
     174             : 
     175             : // -----------------------------------------------------------------------
     176             : 
     177           0 : sal_uInt16 GetMetricId( SfxMapUnit eUnit )
     178             : {
     179           0 :     sal_uInt16 nId = RID_SVXITEMS_METRIC_MM;
     180             : 
     181           0 :     switch ( eUnit )
     182             :     {
     183             :         case SFX_MAPUNIT_100TH_MM:
     184             :         case SFX_MAPUNIT_10TH_MM:
     185             :         case SFX_MAPUNIT_MM:
     186           0 :             nId = RID_SVXITEMS_METRIC_MM;
     187           0 :             break;
     188             : 
     189             :         case SFX_MAPUNIT_CM:
     190           0 :             nId = RID_SVXITEMS_METRIC_CM;
     191           0 :             break;
     192             : 
     193             :         case SFX_MAPUNIT_1000TH_INCH:
     194             :         case SFX_MAPUNIT_100TH_INCH:
     195             :         case SFX_MAPUNIT_10TH_INCH:
     196             :         case SFX_MAPUNIT_INCH:
     197           0 :             nId = RID_SVXITEMS_METRIC_INCH;
     198           0 :             break;
     199             : 
     200             :         case SFX_MAPUNIT_POINT:
     201           0 :             nId = RID_SVXITEMS_METRIC_POINT;
     202           0 :             break;
     203             : 
     204             :         case SFX_MAPUNIT_TWIP:
     205           0 :             nId = RID_SVXITEMS_METRIC_TWIP;
     206           0 :             break;
     207             : 
     208             :         case SFX_MAPUNIT_PIXEL:
     209           0 :             nId = RID_SVXITEMS_METRIC_PIXEL;
     210           0 :             break;
     211             : 
     212             :         default:
     213             :             OSL_FAIL( "not supported mapunit" );
     214             :     }
     215           0 :     return nId;
     216             : }
     217             : 
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10