diff options
author | Justin Luth <justin_luth@sil.org> | 2016-11-04 21:32:38 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2016-11-07 04:09:41 +0000 |
commit | 8eff1decd91cbfb10094c25d4cf1d2b434a4da72 (patch) | |
tree | bcc51a30d8eaa4acbaff628dabff996c2273779f /sw/qa/extras/ww8export | |
parent | bc6017d66fcf37db1f632a3ce667f4c3bf9d1d02 (diff) |
tdf#41542 MSWordExport: accommodate image's borderless padding
Honor the padding value even if the border is not visible.
Previously the padding information was just thrown out, and
the image scaled to fill the entire image size.
The unit test for tdf#77454 needed to be tweaked because surprisingly
it has border padding of 1 - which this patch turns into a negative crop.
Change-Id: I866d26e00f27221239d3291404f70fb57ac0896d
Reviewed-on: https://gerrit.libreoffice.org/30578
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'sw/qa/extras/ww8export')
-rwxr-xr-x | sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt | bin | 0 -> 17926 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export.cxx | 33 |
2 files changed, 23 insertions, 10 deletions
diff --git a/sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt b/sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt Binary files differnew file mode 100755 index 000000000000..019e19f247e1 --- /dev/null +++ b/sw/qa/extras/ww8export/data/tdf41542_imagePadding.odt diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 88a703d99782..d3d87332f48e 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -831,26 +831,39 @@ DECLARE_WW8EXPORT_TEST(testCharacterBorder, "charborder.odt") } } +DECLARE_WW8EXPORT_TEST(testTdf41542_imagePadding, "tdf41542_imagePadding.odt") +{ + // borderlessImage - image WITHOUT BORDERS : simulate padding with -crop + text::GraphicCrop crop = getProperty<text::GraphicCrop>(getShape(2), "GraphicCrop"); + CPPUNIT_ASSERT( crop.Left != 0 && crop.Right != 0 ); + CPPUNIT_ASSERT( crop.Left == crop.Top && crop.Right == crop.Bottom && crop.Left == crop.Right ); + + // borderedImage - image WITH BORDERS : simulate padding with -crop + crop = getProperty<text::GraphicCrop>(getShape(3), "GraphicCrop"); + CPPUNIT_ASSERT( crop.Left != 0 && crop.Right != 0 ); + CPPUNIT_ASSERT( crop.Left == crop.Top && crop.Right == crop.Bottom && crop.Left == crop.Right ); +} + DECLARE_WW8EXPORT_TEST(testFdo77454, "fdo77454.doc") { { - // check negative crops round-trip + // check negative crops round-trip (with border/padding of 1) text::GraphicCrop const crop = getProperty<text::GraphicCrop>(getShape(1), "GraphicCrop"); - CPPUNIT_ASSERT_EQUAL(sal_Int32( -439), crop.Left); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-7040), crop.Right); - CPPUNIT_ASSERT_EQUAL(sal_Int32( -220), crop.Top); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-7040), crop.Bottom); + CPPUNIT_ASSERT(abs(sal_Int32( -439) - crop.Left) <= 2); + CPPUNIT_ASSERT(abs(sal_Int32(-7040) - crop.Right) <= 2); + CPPUNIT_ASSERT(abs(sal_Int32( -220) - crop.Top) <= 2); + CPPUNIT_ASSERT(abs(sal_Int32(-7040) - crop.Bottom) <= 2); } { - // check positive crops round-trip + // check positive crops round-trip (with padding of 1) text::GraphicCrop const crop = getProperty<text::GraphicCrop>(getShape(2), "GraphicCrop"); - CPPUNIT_ASSERT_EQUAL(sal_Int32( 326), crop.Left); - CPPUNIT_ASSERT_EQUAL(sal_Int32( 1208), crop.Right); - CPPUNIT_ASSERT(abs(sal_Int32(1635) - crop.Top) <= 2); - CPPUNIT_ASSERT(abs(sal_Int32( 95) - crop.Bottom) <= 2); + CPPUNIT_ASSERT(abs(sal_Int32( 326) - crop.Left) <= 3); + CPPUNIT_ASSERT(abs(sal_Int32(1208) - crop.Right) <= 3); + CPPUNIT_ASSERT(abs(sal_Int32(1635) - crop.Top) <= 3); + CPPUNIT_ASSERT(abs(sal_Int32( 95) - crop.Bottom) <= 3); } } |