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

Generated by: LCOV version 1.10