vcl/source/gdi/pdfwriter_impl.cxx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
New commits: commit c9e980bbb5dd86b7e8b9c538e0b0ac6cbf317871 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Feb 5 10:23:27 2018 +0000 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Tue Jan 22 17:59:59 2019 +0100 tdf#96892 higher precision pdf fixed ints reverts commit 5f6065f980756fdb81c7018bedbb7f54e2b8214a Date: Thu Mar 3 20:44:47 2016 +0000 coverity#1355126 Logically dead code maybe we should be using more precision, but we haven't been in the past and... commit cd5cc12d4330d68d0a233a82eda30e983ce202a4 Date: Thu Mar 3 20:42:52 2016 +0000 nLog10Divisor is 1 and then fix the original appendFixedInt bug wrt higher precision settings and then bump those settings from 1 decimal place to 3 and adjust our pdf export test for the new precision Change-Id: Ib1b4c41ce2e651d5343919b253ffd46895c764ac Reviewed-on: https://gerrit.libreoffice.org/49227 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> (cherry picked from commit 2113de51158a6e6c14931109bb9a4e27303c0eab) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index d1ce1e0b28d5..201a59e77823 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -510,8 +510,8 @@ void doTestCode() } #endif -static const sal_Int32 nLog10Divisor = 1; -static const double fDivisor = 10.0; +static const sal_Int32 nLog10Divisor = 3; +static const double fDivisor = 1000.0; static inline double pixelToPoint( double px ) { return px/fDivisor; } static inline sal_Int32 pointToPixel( double pt ) { return sal_Int32(pt*fDivisor); } @@ -845,14 +845,21 @@ static void appendFixedInt( sal_Int32 nValue, OStringBuffer& rBuffer ) rBuffer.append( '-' ); nValue = -nValue; } - const sal_Int32 nFactor = 10; - const sal_Int32 nInt = nValue / nFactor; + sal_Int32 nFactor = 1, nDiv = nLog10Divisor; + while( nDiv-- ) + nFactor *= 10; + + sal_Int32 nInt = nValue / nFactor; rBuffer.append( nInt ); - sal_Int32 nDecimal = nValue % nFactor; - if (nDecimal) + if (nFactor > 1 && nValue % nFactor) { - rBuffer.append('.'); - rBuffer.append(nDecimal); + rBuffer.append( '.' ); + do + { + nFactor /= 10; + rBuffer.append((nValue / nFactor) % 10); + } + while (nFactor > 1 && nValue % nFactor); // omit trailing zeros } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits