Discussion:
[Libreoffice-commits] core.git: vcl/qa vcl/source
Caolán McNamara
2018-02-05 12:40:30 UTC
Permalink
vcl/qa/cppunit/graphicfilter/data/wmf/fail/ofz5942-1.wmf |binary
vcl/source/gdi/sallayout.cxx | 6 ++++++
2 files changed, 6 insertions(+)

New commits:
commit b189726c4f61a5d28a3b87112e7a85174b5573aa
Author: Caolán McNamara <***@redhat.com>
Date: Mon Feb 5 09:02:39 2018 +0000

ofz#5942 Out of memory

when missing a glyph in a grapheme we set the whole grapheme as missing. There
can be a huge long grapheme and iterating through each missing codepoint
results in the whole range pushed back repeatedly as missing.

Change-Id: Ib7c283389ee2357eb3b4264c78e558955ebad1eb
Reviewed-on: https://gerrit.libreoffice.org/49223
Tested-by: Jenkins <***@libreoffice.org>
Reviewed-by: Caolán McNamara <***@redhat.com>
Tested-by: Caolán McNamara <***@redhat.com>

diff --git a/vcl/qa/cppunit/graphicfilter/data/wmf/fail/ofz5942-1.wmf b/vcl/qa/cppunit/graphicfilter/data/wmf/fail/ofz5942-1.wmf
new file mode 100644
index 000000000000..f9a72867c593
Binary files /dev/null and b/vcl/qa/cppunit/graphicfilter/data/wmf/fail/ofz5942-1.wmf differ
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 07b65564d6c2..a282a0248621 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -270,6 +270,12 @@ void ImplLayoutRuns::AddRun( int nCharPos0, int nCharPos1, bool bRTL )
nCharPos1 = nTemp;
}

+ if (maRuns.size() >= 2 && nCharPos0 == maRuns[maRuns.size() - 2] && nCharPos1 == maRuns[maRuns.size() - 1])
+ {
+ //this run is the same as the last
+ return;
+ }
+
// append new run
maRuns.push_back( nCharPos0 );
maRuns.push_back( nCharPos1 );
Caolán McNamara
2018-02-06 09:27:19 UTC
Permalink
vcl/qa/cppunit/pdfexport/pdfexport.cxx | 20 ++++++++++----------
vcl/source/gdi/pdfwriter_impl.cxx | 23 +++++++++++++++--------
2 files changed, 25 insertions(+), 18 deletions(-)

New commits:
commit 2113de51158a6e6c14931109bb9a4e27303c0eab
Author: Caolán McNamara <***@redhat.com>
Date: Mon Feb 5 10:23:27 2018 +0000

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 <***@libreoffice.org>
Reviewed-by: Caolán McNamara <***@redhat.com>
Tested-by: Caolán McNamara <***@redhat.com>

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index a904a5dc638d..cb03680a4703 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -724,36 +724,36 @@ void PdfExportTest::testTdf108963()
float fX = 0;
float fY = 0;
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(245.4), fX);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(244.2), fY);
+ CPPUNIT_ASSERT_EQUAL(245395, static_cast<int>(round(fX * 1000)));
+ CPPUNIT_ASSERT_EQUAL(244233, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment));

pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 1);
CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment));
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(275.1), fX);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(267.6), fY);
+ CPPUNIT_ASSERT_EQUAL(275102, static_cast<int>(round(fX * 1000)));
+ CPPUNIT_ASSERT_EQUAL(267590, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment));

pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 2);
CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment));
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(287.5), fX);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(251.8), fY);
+ CPPUNIT_ASSERT_EQUAL(287518, static_cast<int>(round(fX * 1000)));
+ CPPUNIT_ASSERT_EQUAL(251801, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment));

pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 3);
CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment));
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(257.8), fX);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(228.4), fY);
+ CPPUNIT_ASSERT_EQUAL(257839, static_cast<int>(round(fX * 1000)));
+ CPPUNIT_ASSERT_EQUAL(228444, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment));

pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 4);
CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment));
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(245.4), fX);
- CPPUNIT_ASSERT_EQUAL(static_cast<float>(244.2), fY);
+ CPPUNIT_ASSERT_EQUAL(245395, static_cast<int>(round(fX * 1000)));
+ CPPUNIT_ASSERT_EQUAL(244233, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(FPDFPathSegment_GetClose(pSegment));
}
}
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 6435a6a18dd5..fcb30130d3c4 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -505,8 +505,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); }
@@ -837,14 +837,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
}
}

Loading...