Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / basegfx / source / tools / numbertools.cxx
blob031bef3ba6e1de99acf4e1a6edb5ec97c95cca56
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <basegfx/utils/tools.hxx>
11 #include <basegfx/matrix/b2dhommatrix.hxx>
12 #include <basegfx/polygon/b2dpolypolygon.hxx>
13 #include <basegfx/polygon/b2dpolypolygontools.hxx>
15 #include <rtl/strbuf.hxx>
16 #include <rtl/math.hxx>
18 namespace basegfx { namespace utils
20 B2DPolyPolygon number2PolyPolygon(double fValue, sal_Int32 nTotalDigits, sal_Int32 nDecPlaces, bool bLitSegments)
22 // config here
23 // {
24 const double fSpace=0.2;
25 // }
26 // config here
28 OStringBuffer aNum;
29 rtl::math::doubleToStringBuffer(aNum,
30 fValue,
31 rtl_math_StringFormat_F,
32 nDecPlaces, '.',
33 nullptr, ',');
35 B2DPolyPolygon aRes;
36 B2DHomMatrix aMat;
37 double fCurrX=std::max(nTotalDigits-aNum.getLength(),
38 sal_Int32(0)) * (1.0+fSpace);
39 for( sal_Int32 i=0; i<aNum.getLength(); ++i )
41 B2DPolyPolygon aCurr=createSevenSegmentPolyPolygon(aNum[i],
42 bLitSegments);
44 aMat.identity();
45 aMat.translate(fCurrX,0.0);
46 aCurr.transform(aMat);
48 fCurrX += 1.0+fSpace;
50 aRes.append(aCurr);
53 return aRes;
56 } }
58 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */