Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / basegfx / source / tools / numbertools.cxx
blob6b8543a8eff013cabdd13dd878d39e6c148e7a39
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/tools/tools.hxx>
11 #include <basegfx/matrix/b2dhommatrix.hxx>
12 #include <basegfx/polygon/b2dpolypolygon.hxx>
13 #include <basegfx/polygon/b2dpolypolygontools.hxx>
15 #include <rtl/ustrbuf.hxx>
16 #include <rtl/math.hxx>
18 #include <utility>
20 namespace basegfx { namespace tools
22 B2DPolyPolygon number2PolyPolygon(double fValue, sal_Int32 nTotalDigits, sal_Int32 nDecPlaces, bool bLitSegments)
24 // config here
25 // {
26 const double fSpace=0.2;
27 // }
28 // config here
30 rtl::OUStringBuffer aNum;
31 rtl::math::doubleToUStringBuffer(aNum,
32 fValue,
33 rtl_math_StringFormat_F,
34 nDecPlaces, '.',
35 0, ',');
37 B2DPolyPolygon aRes;
38 B2DHomMatrix aMat;
39 double fCurrX=std::max(nTotalDigits-aNum.getLength(),
40 sal_Int32(0)) * (1.0+fSpace);
41 for( sal_Int32 i=0; i<aNum.getLength(); ++i )
43 B2DPolyPolygon aCurr;
44 aCurr=createSevenSegmentPolyPolygon(aNum[i],
45 bLitSegments);
47 aMat.identity();
48 aMat.translate(fCurrX,0.0);
49 aCurr.transform(aMat);
51 fCurrX += 1.0+fSpace;
53 aRes.append(aCurr);
56 return aRes;
59 } }
61 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */