LCOV - code coverage report
Current view: top level - sdext/source/pdfimport/misc - pdfihelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 26 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 20 34 58.8 %

           Branch data     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                 :            : 
      21                 :            : #include "pdfihelper.hxx"
      22                 :            : 
      23                 :            : #include <rtl/ustrbuf.hxx>
      24                 :            : #include <basegfx/numeric/ftools.hxx>
      25                 :            : 
      26                 :            : using namespace pdfi;
      27                 :            : using namespace com::sun::star;
      28                 :            : 
      29                 :        140 : rtl::OUString pdfi::getColorString( const rendering::ARGBColor& rCol )
      30                 :            : {
      31                 :        140 :     rtl::OUStringBuffer aBuf( 7 );
      32                 :        140 :     const sal_uInt8 nRed  ( sal::static_int_cast<sal_Int8>( basegfx::fround( rCol.Red * 255.0 ) ) );
      33                 :        140 :     const sal_uInt8 nGreen( sal::static_int_cast<sal_Int8>( basegfx::fround( rCol.Green * 255.0 ) ) );
      34                 :        140 :     const sal_uInt8 nBlue ( sal::static_int_cast<sal_Int8>( basegfx::fround( rCol.Blue * 255.0 ) ) );
      35         [ +  - ]:        140 :     aBuf.append( sal_Unicode('#') );
      36         [ +  + ]:        140 :     if( nRed < 10 )
      37         [ +  - ]:        130 :         aBuf.append( sal_Unicode('0') );
      38         [ +  - ]:        140 :     aBuf.append( sal_Int32(nRed), 16 );
      39         [ +  + ]:        140 :     if( nGreen < 10 )
      40         [ +  - ]:        130 :         aBuf.append( sal_Unicode('0') );
      41         [ +  - ]:        140 :     aBuf.append( sal_Int32(nGreen), 16 );
      42         [ +  + ]:        140 :     if( nBlue < 10 )
      43         [ +  - ]:        130 :         aBuf.append( sal_Unicode('0') );
      44         [ +  - ]:        140 :     aBuf.append( sal_Int32(nBlue), 16 );
      45                 :            : 
      46                 :            :     // TODO(F3): respect alpha transparency (polygons etc.)
      47                 :            :     OSL_ASSERT(rCol.Alpha == 1.0);
      48                 :            : 
      49         [ +  - ]:        140 :     return aBuf.makeStringAndClear();
      50                 :            : }
      51                 :            : 
      52                 :         60 : rtl::OUString pdfi::unitMMString( double fMM )
      53                 :            : {
      54                 :         60 :     rtl::OUStringBuffer aBuf( 32 );
      55         [ +  - ]:         60 :     aBuf.append( rtl_math_round( fMM, 2, rtl_math_RoundingMode_Floor ) );
      56         [ +  - ]:         60 :     aBuf.appendAscii( "mm" );
      57                 :            : 
      58         [ +  - ]:         60 :     return aBuf.makeStringAndClear();
      59                 :            : }
      60                 :            : 
      61                 :        840 : rtl::OUString pdfi::convertPixelToUnitString( double fPix )
      62                 :            : {
      63                 :        840 :     rtl::OUStringBuffer aBuf( 32 );
      64         [ +  - ]:        840 :     aBuf.append( rtl_math_round( convPx2mm( fPix ), 2, rtl_math_RoundingMode_Floor ) );
      65         [ +  - ]:        840 :     aBuf.appendAscii( "mm" );
      66                 :            : 
      67         [ +  - ]:        840 :     return aBuf.makeStringAndClear();
      68                 :            : }
      69                 :            : 
      70                 :            : 
      71                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10