diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2021-07-29 22:02:25 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-08-04 14:39:34 +0200 |
commit | 4fb5817ecb614bd0c83afb3627d7caadbfe8c082 (patch) | |
tree | 7efd5c1f1124916cd80ab94696084ed7e0362430 /sw/qa/extras/ooxmlimport | |
parent | 71b3d7392bd3d0871c7383748d49ae5d46c80e51 (diff) |
tdf#143476 improve import of lockedCanvas
A lockedCanvas is used in Word 2007 to include dml-shapes. It is
treated similar to a group, only that its content is not editable.
This patch changes the implementation so, that the lockedCanvas is
imported as group. Prior only content was imported in the case the
content was a single custom-shape or a single group.
That has resulted in these errors:
Image or line in a lockedCanvas were not imported at all.
Only one of several shapes in a lockedCanvas was imported.
I have changed mpShape to mpShapePtr to reflect the data type and be
consistent with ShapeContext.
The patch changes GraphicImport so, that lockedCanvas as special
version of a group is detected and handled. That solves regression
from commit 3262fc5ef3bde5b158909d11ccb008161ea95519
Change-Id: I57005e64ff073bca6ebb46a404486203fb6802ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119684
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/extras/ooxmlimport')
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_image_line.docx | bin | 0 -> 11649 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_position.docx | bin | 0 -> 278044 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_twoShapes.docx | bin | 0 -> 22179 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 3 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 38 |
5 files changed, 40 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_image_line.docx b/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_image_line.docx Binary files differnew file mode 100644 index 000000000000..9a5c87e347c4 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_image_line.docx diff --git a/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_position.docx b/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_position.docx Binary files differnew file mode 100644 index 000000000000..a63615a311b1 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_position.docx diff --git a/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_twoShapes.docx b/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_twoShapes.docx Binary files differnew file mode 100644 index 000000000000..6e654f3d3330 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf143476_lockedCanvas_twoShapes.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index f6d986544993..3b59da527c3f 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -720,7 +720,8 @@ CPPUNIT_TEST_FIXTURE(Test, testN820504) CPPUNIT_TEST_FIXTURE(Test, testFdo43641) { load(mpTestDocumentPath, "fdo43641.docx"); - uno::Reference<container::XIndexAccess> xGroupShape(getShape(1), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xGroupLockedCanvas(getShape(1), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xGroupShape(xGroupLockedCanvas->getByIndex(0), uno::UNO_QUERY); uno::Reference<drawing::XShape> xLine(xGroupShape->getByIndex(1), uno::UNO_QUERY); // This was 2200, not 2579 in mm100, i.e. the size of the line shape was incorrect. // File cx=928694EMU = 2579.7Hmm, round up 2580Hmm. Currently off by 1. diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 86f91c91fcaf..e132befdd09f 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -48,6 +48,44 @@ public: } }; +CPPUNIT_TEST_FIXTURE(Test, testTdf143476LockedCanvas_twoShapes) +{ + // Given a lockedCanvas in a docx document with compatibility to Word version 12 (2007). + // It contains two shapes. Error was, that the lockedCanvas was not imported as group at all, + // and only one shape was imported and that one was scaled to lockedCanvas area. + load(mpTestDocumentPath, "tdf143476_lockedCanvas_twoShapes.docx"); + // The group shape corresponds to the lockedCanvas. + uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xGroup.is()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xGroup->getCount()); + uno::Reference<drawing::XShape> xShape(xGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(14200), xShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1120), xShape->getPosition().Y); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1928), xShape->getSize().Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1593), xShape->getSize().Height); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf143476LockedCanvas_position) +{ + // Given a lockedCanvas in a docx document with compatibility to Word version 12 (2007). + // Tests fix for regression introduced by 3262fc5ef3bde5b158909d11ccb008161ea95519 + // Error was, that the imported shape had wrong position. + load(mpTestDocumentPath, "tdf143476_lockedCanvas_position.docx"); + // The group shape corresponds to the lockedCanvas. + uno::Reference<drawing::XShape> xGroupShape(getShape(1), uno::UNO_QUERY); + // Without fix in place the test failed with position 185|947. + CPPUNIT_ASSERT_EQUAL(sal_Int32(2351), xGroupShape->getPosition().X); + CPPUNIT_ASSERT_EQUAL(sal_Int32(26), xGroupShape->getPosition().Y); +} + +CPPUNIT_TEST_FIXTURE(Test, testTdf143476LockedCanvas_image_line) +{ + // Given a lockedCanvas in a docx document with compatibility to Word version 12 (2007). + // It contains an image and a line. Error was, that both were not imported. + load(mpTestDocumentPath, "tdf143476_lockedCanvas_image_line.docx"); + CPPUNIT_ASSERT_MESSAGE("No shapes imported", getShapes() > 0); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf143475rotatedWord2007imageInline) { // Given a docx document with compatibility to Word version 12 (2007), which has a shape |