vcl/qa/cppunit/pdfexport/pdfexport2.cxx |    5 +---
 vcl/source/gdi/pdfwriter_impl.cxx       |   38 --------------------------------
 2 files changed, 3 insertions(+), 40 deletions(-)

New commits:
commit 0d986755e4153230670c820dc52cc40cd72dfa87
Author:     Mike Kaganski <[email protected]>
AuthorDate: Sun Sep 28 20:34:45 2025 +0200
Commit:     Mike Kaganski <[email protected]>
CommitDate: Sun Sep 28 22:23:25 2025 +0200

    Simplify appendDouble using rtl::math::doubleToStringBuffer
    
    Change-Id: I37a755e2488780188ff07d27d66f0aafda4cb453
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191583
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 12a4ddbb6058..5a907d457d9f 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -231,9 +231,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf124272)
     aZCodec.Decompress(rObjectStream, aUncompressed);
     CPPUNIT_ASSERT(aZCodec.EndCompression());
 
-    OString aBitmap("Q q 299.899 782.189 m
"
-                    "55.2 435.889 l 299.899 435.889 l 299.899 782.189 l
"
-                    "h"_ostr);
+    OString aBitmap("Q q 299.9 782.19 m
"
+                    "55.2 435.89 l 299.9 435.89 l 299.9 782.19 l h"_ostr);
 
     auto pStart = static_cast<const char*>(aUncompressed.GetData());
     const char* pEnd = pStart + aUncompressed.GetSize();
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index f1276245a4d6..be2ebc17199a 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -386,43 +386,7 @@ void appendFixedInt( sal_Int32 nValue, OStringBuffer& 
rBuffer )
 // appends a double. PDF does not accept exponential format, only fixed point
 void appendDouble( double fValue, OStringBuffer& rBuffer, sal_Int32 nPrecision 
= 10 )
 {
-    bool bNeg = false;
-    if( fValue < 0.0 )
-    {
-        bNeg = true;
-        fValue=-fValue;
-    }
-
-    sal_Int64 nInt = static_cast<sal_Int64>(fValue);
-    fValue -= static_cast<double>(nInt);
-    // optimizing hardware may lead to a value of 1.0 after the subtraction
-    if( rtl::math::approxEqual(fValue, 1.0) || log10( 1.0-fValue ) <= 
-nPrecision )
-    {
-        nInt++;
-        fValue = 0.0;
-    }
-    sal_Int64 nFrac = 0;
-    if( fValue )
-    {
-        fValue *= pow( 10.0, static_cast<double>(nPrecision) );
-        nFrac = static_cast<sal_Int64>(fValue);
-    }
-    if( bNeg && ( nInt || nFrac ) )
-        rBuffer.append( '-' );
-    rBuffer.append( nInt );
-    if( !nFrac )
-        return;
-
-    int i;
-    rBuffer.append( '.' );
-    sal_Int64 nBound = static_cast<sal_Int64>(pow( 10.0, nPrecision - 1.0 
)+0.5);
-    for ( i = 0; ( i < nPrecision ) && nFrac; i++ )
-    {
-        sal_Int64 nNumb = nFrac / nBound;
-        nFrac -= nNumb * nBound;
-        rBuffer.append( nNumb );
-        nBound /= 10;
-    }
+    rtl::math::doubleToStringBuffer(rBuffer, fValue, rtl_math_StringFormat_F, 
nPrecision, '.', true);
 }
 
 void appendColor( const Color& rColor, OStringBuffer& rBuffer, bool 
bConvertToGrey )

Reply via email to