LCOV - code coverage report
Current view: top level - sdext/source/pdfimport/misc - pdfihelper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 26 26 100.0 %
Date: 2014-04-11 Functions: 3 3 100.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             : 
      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         121 : OUString pdfi::getColorString( const rendering::ARGBColor& rCol )
      30             : {
      31         121 :     OUStringBuffer aBuf( 7 );
      32         121 :     const sal_uInt8 nRed  ( sal::static_int_cast<sal_Int8>( basegfx::fround( rCol.Red * 255.0 ) ) );
      33         121 :     const sal_uInt8 nGreen( sal::static_int_cast<sal_Int8>( basegfx::fround( rCol.Green * 255.0 ) ) );
      34         121 :     const sal_uInt8 nBlue ( sal::static_int_cast<sal_Int8>( basegfx::fround( rCol.Blue * 255.0 ) ) );
      35         121 :     aBuf.append( '#' );
      36         121 :     if( nRed < 16 )
      37         119 :         aBuf.append( '0' );
      38         121 :     aBuf.append( sal_Int32(nRed), 16 );
      39         121 :     if( nGreen < 16 )
      40         119 :         aBuf.append( '0' );
      41         121 :     aBuf.append( sal_Int32(nGreen), 16 );
      42         121 :     if( nBlue < 16 )
      43         102 :         aBuf.append( '0' );
      44         121 :     aBuf.append( sal_Int32(nBlue), 16 );
      45             : 
      46             :     // TODO(F3): respect alpha transparency (polygons etc.)
      47             :     OSL_ASSERT(rCol.Alpha == 1.0);
      48             : 
      49         121 :     return aBuf.makeStringAndClear();
      50             : }
      51             : 
      52          12 : OUString pdfi::unitMMString( double fMM )
      53             : {
      54          12 :     OUStringBuffer aBuf( 32 );
      55          12 :     aBuf.append( rtl_math_round( fMM, 2, rtl_math_RoundingMode_Floor ) );
      56          12 :     aBuf.appendAscii( "mm" );
      57             : 
      58          12 :     return aBuf.makeStringAndClear();
      59             : }
      60             : 
      61         180 : OUString pdfi::convertPixelToUnitString( double fPix )
      62             : {
      63         180 :     OUStringBuffer aBuf( 32 );
      64         180 :     aBuf.append( rtl_math_round( convPx2mm( fPix ), 2, rtl_math_RoundingMode_Floor ) );
      65         180 :     aBuf.appendAscii( "mm" );
      66             : 
      67         180 :     return aBuf.makeStringAndClear();
      68             : }
      69             : 
      70             : 
      71             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10