diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-06-08 21:05:07 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-06-09 09:02:01 +0200 |
commit | 369355da5c1e25bad7124dd6e187d9e381759751 (patch) | |
tree | b997ba39c746f978954cbb69e60af36324c309e7 /sw/qa | |
parent | 37c9f427cb9dbebd0c145cd531c6d2afdc088488 (diff) |
tdf#133474 DOC import: fix lazy-loading of images with zero size
DOC typically contains images with a size hint outside the image, but
this is optional. Make sure that we load the image in case the size is
not available without loading.
The effect is that once SwWW8ImplReader::MapWrapIntoFlyFormat() calls
SwGrfNode::GetTwipSize(), we always get a valid size. Ideally without
loading the graphic.
Change-Id: I81536ceb44c6e455e9bf274a5852008443f9d64f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95857
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ww8import/data/image-lazy-read-0size.doc | bin | 0 -> 28160 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 16 |
2 files changed, 16 insertions, 0 deletions
diff --git a/sw/qa/extras/ww8import/data/image-lazy-read-0size.doc b/sw/qa/extras/ww8import/data/image-lazy-read-0size.doc Binary files differnew file mode 100644 index 000000000000..80306cb1deda --- /dev/null +++ b/sw/qa/extras/ww8import/data/image-lazy-read-0size.doc diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index dfbd496a31df..8a085472ea4a 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -186,6 +186,22 @@ DECLARE_OOXMLIMPORT_TEST(testImageLazyRead, "image-lazy-read.doc") CPPUNIT_ASSERT(!aGraphic.isAvailable()); } +DECLARE_OOXMLIMPORT_TEST(testImageLazyRead0size, "image-lazy-read-0size.doc") +{ + // Load a document with a single bitmap in it: it's declared as a WMF one, but actually a TGA + // bitmap. + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + SwNode* pNode = pDoc->GetNodes()[6]; + SwGrfNode* pGrfNode = pNode->GetGrfNode(); + CPPUNIT_ASSERT(pGrfNode); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 7590x10440 + // - Actual : 0x0 + // i.e. the size was 0, even if the actual bitmap had a non-0 size. + CPPUNIT_ASSERT_EQUAL(Size(7590, 10440), pGrfNode->GetTwipSize()); +} + DECLARE_WW8IMPORT_TEST(testTdf106799, "tdf106799.doc") { // Ensure that all text portions are calculated before testing. |