diff options
author | Jan Holesovsky <kendy@collabora.com> | 2022-11-24 11:22:49 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-11-25 10:50:58 +0100 |
commit | dc62b698f7a57b244dc80e0b607922505af233e9 (patch) | |
tree | ba6b0021f04c2b9b938cdee9d860c539bebac1b9 /sw | |
parent | bcc5f7f8d059a1add749a0e10ef1113e51dbab50 (diff) |
tdf#152199: Don't crop twice
We have a "GraphicCrop" property that is supposed to roundtrip the
cropping in OOXML, but there is no core feature backing it (ie. the
image is not shown cropped when this is imported and set).
Instead, to show the image "cropped", we crop the image physically on
import (throw away pixels that are 'outside' of the cropped area).
But - the "GraphicCrop" is then saved on export, together with the image
already physically cropped, which leads to garbled DOCX on re-import.
Given that the core feature to show image cropped when the "GraphicCrop"
is set, let's avoid setting it when we physically crop the image.
Change-Id: Ia1090ea9c6d22e60c77d52bf65281f6588d07d4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143214
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/crop-roundtrip.docx | bin | 0 -> 143445 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 15 |
2 files changed, 15 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/crop-roundtrip.docx b/sw/qa/extras/ooxmlexport/data/crop-roundtrip.docx Binary files differnew file mode 100644 index 000000000000..6db60d0e8c60 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/crop-roundtrip.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index bc48cc158975..2d5cca60eb27 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/text/XFootnotesSupplier.hpp> #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp> @@ -77,6 +78,20 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtDuplicatedId) assertXPath(pXmlDoc, "//w:sdt", 2); } +CPPUNIT_TEST_FIXTURE(Test, testImageCropping) +{ + loadAndReload("crop-roundtrip.docx"); + + // the image has no cropping after roundtrip, because it has been physically cropped + // NB: this test should be fixed when the core feature to show image cropped when it + // has the "GraphicCrop" is set is implemented + auto aGraphicCropStruct = getProperty<text::GraphicCrop>(getShape(1), "GraphicCrop"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGraphicCropStruct.Left); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGraphicCropStruct.Right); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGraphicCropStruct.Top); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aGraphicCropStruct.Bottom); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |