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

Generated by: LCOV version 1.10