summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-05-14 18:02:23 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-05-15 10:51:06 +0200
commit6f54eee8453ae0371588e2109bb152922939a11b (patch)
treee1d3c9e5bc9fcd9fade755723771f476699f1b81 /writerfilter
parent2400f319c45853ae0d70487e5b140c20439a9b61 (diff)
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
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx5
-rw-r--r--writerfilter/source/dmapper/WrapPolygonHandler.cxx3
2 files changed, 5 insertions, 3 deletions
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 <com/sun/star/drawing/PointSequence.hpp>
#include <com/sun/star/text/GraphicCrop.hpp>
#include <comphelper/sequence.hxx>
+#include <tools/mapunit.hxx>
#include <ooxml/resourceids.hxx>
@@ -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);