1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "pdfihelper.hxx"
23 #include <rtl/ustrbuf.hxx>
24 #include <basegfx/numeric/ftools.hxx>
27 using namespace com::sun::star
;
29 OUString
pdfi::getColorString( const rendering::ARGBColor
& rCol
)
31 OUStringBuffer
aBuf( 7 );
32 const sal_uInt8
nRed ( sal::static_int_cast
<sal_Int8
>( basegfx::fround( rCol
.Red
* 255.0 ) ) );
33 const sal_uInt8
nGreen( sal::static_int_cast
<sal_Int8
>( basegfx::fround( rCol
.Green
* 255.0 ) ) );
34 const sal_uInt8
nBlue ( sal::static_int_cast
<sal_Int8
>( basegfx::fround( rCol
.Blue
* 255.0 ) ) );
35 aBuf
.append( sal_Unicode('#') );
37 aBuf
.append( sal_Unicode('0') );
38 aBuf
.append( sal_Int32(nRed
), 16 );
40 aBuf
.append( sal_Unicode('0') );
41 aBuf
.append( sal_Int32(nGreen
), 16 );
43 aBuf
.append( sal_Unicode('0') );
44 aBuf
.append( sal_Int32(nBlue
), 16 );
46 // TODO(F3): respect alpha transparency (polygons etc.)
47 OSL_ASSERT(rCol
.Alpha
== 1.0);
49 return aBuf
.makeStringAndClear();
52 OUString
pdfi::unitMMString( double fMM
)
54 OUStringBuffer
aBuf( 32 );
55 aBuf
.append( rtl_math_round( fMM
, 2, rtl_math_RoundingMode_Floor
) );
56 aBuf
.appendAscii( "mm" );
58 return aBuf
.makeStringAndClear();
61 OUString
pdfi::convertPixelToUnitString( double fPix
)
63 OUStringBuffer
aBuf( 32 );
64 aBuf
.append( rtl_math_round( convPx2mm( fPix
), 2, rtl_math_RoundingMode_Floor
) );
65 aBuf
.appendAscii( "mm" );
67 return aBuf
.makeStringAndClear();
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */