From 6f54eee8453ae0371588e2109bb152922939a11b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 14 May 2020 18:02:23 +0200 Subject: DOCX export: fix interaction between the crop and the wrap polygon of image If the wrap polygon is influenced by crop at import time, we need to do the opposite at export time. Do this for RTF and DOCX, where there is matching import code in writerfilter/, leave DOC alone for now. Test this by changing testFdo76803 into an export test, then seeing how the first point's Y position fails and fixing up the exporter, so we get back the old good value. (cherry picked from commit c68b458514b35cae70c9a6630e06f46a867aa3b9) Change-Id: Ieef18aad3c76f7945c7348201b07bcb27a4cd48d --- writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx | 5 +++-- writerfilter/source/dmapper/WrapPolygonHandler.cxx | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx index 14fb181f2e07..37e462012c66 100644 --- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx +++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx @@ -162,13 +162,14 @@ CPPUNIT_TEST_FIXTURE(Test, testWrapPolyCrop) // 10582, the lower 33% of the graphic is cropped, and the wrap polygon covers the middle third // of the area vertically. Which means 10582*2/3 = 7054.67 is the cropped height, and the top of // the middle third is 2351.55. + // Then there is a 15 twips shift from the origo, so it's 2351.55 + 26.46 = 2378.01 in mm100. // // Without the accompanying fix in place, this test would have failed with: - // - Expected: 2361 + // - Expected: 2368 // - Actual : 3542 // i.e. the wrap polygon covered a larger-than-correct area, which end the end means 3 lines // were wrapping around the image, not only 2 as Word does it. - CPPUNIT_ASSERT_EQUAL(2361., aPolygon.getB2DPoint(0).getY()); + CPPUNIT_ASSERT_EQUAL(2368., aPolygon.getB2DPoint(0).getY()); } } diff --git a/writerfilter/source/dmapper/WrapPolygonHandler.cxx b/writerfilter/source/dmapper/WrapPolygonHandler.cxx index 14c1d6a0c5bf..aa23342443a4 100644 --- a/writerfilter/source/dmapper/WrapPolygonHandler.cxx +++ b/writerfilter/source/dmapper/WrapPolygonHandler.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -99,7 +100,7 @@ WrapPolygon::Pointer_t WrapPolygon::correctWordWrapPolygon(const awt::Size & rSr const long nWrap100Percent = 21600; Fraction aMove(nWrap100Percent, rSrcSize.Width); - aMove = aMove * Fraction(15, 1); + aMove = aMove * Fraction(convertTwipToMm100(15), 1); awt::Point aMovePoint(aMove.operator long(), 0); pResult = move(aMovePoint); -- cgit