sw/qa/extras/htmlimport/data/tdf122789.html | 7 +++++++ sw/qa/extras/htmlimport/htmlimport.cxx | 11 +++++++++++ sw/source/filter/html/htmlgrin.cxx | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-)
New commits: commit 8fa88c4b90c8b9e8abadded1a724a6ebdfa44d63 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Jun 3 21:15:18 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Jun 4 12:03:31 2019 +0200 tdf#122789 sw HTML import: fix handling of images with relative sizes Relative size should have priority over image size from image headers. (cherry picked from commit a628c01e783b8970ec6d1a4499f01981c077e607) Change-Id: I80cce79ff87c7eb359cb292526859435cb85f929 Reviewed-on: https://gerrit.libreoffice.org/73434 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/htmlimport/data/tdf122789.html b/sw/qa/extras/htmlimport/data/tdf122789.html new file mode 100644 index 000000000000..7ee6552013c7 --- /dev/null +++ b/sw/qa/extras/htmlimport/data/tdf122789.html @@ -0,0 +1,7 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html><head> + <meta http-equiv="content-type" content="text/html; charset=UTF-8"> + <title></title> +</head> +<body dir="ltr" lang="en-US"><p><img src="libreoffice.jpg" name="Image1" alt="Pic" align="bottom" width="70%" border="0"/></p> +</body></html> diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 7669cf86431a..6ab84cf1c7df 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -342,6 +342,17 @@ DECLARE_HTMLIMPORT_TEST(testImageSize, "image-size.html") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(aExpected.getHeight()), aSize.Height); } +DECLARE_HTMLIMPORT_TEST(testTdf122789, "tdf122789.html") +{ + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rFormats.size()); + // This failed, the image had an absolute size, not a relative one. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(70), rFormats[0]->GetAttrSet().GetFrameSize().GetWidthPercent()); +} + DECLARE_HTMLIMPORT_TEST(testReqIfPageStyle, "reqif-page-style.xhtml") { // Without the accompanying fix in place, this test would have failed with diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 92f0e37c1228..c4ffa075c620 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -644,7 +644,9 @@ IMAGE_SETEVENT: bool bSetScaleImageMap = false; sal_uInt8 nPrcWidth = 0, nPrcHeight = 0; - if ((!nWidth || !nHeight) && allowAccessLink(*m_xDoc)) + // bPrcWidth / bPrcHeight means we have a percent size. If that's not the case and we have no + // size from nWidth / nHeight either, then inspect the image header. + if ((!bPrcWidth && !nWidth) && (!bPrcHeight && !nHeight) && allowAccessLink(*m_xDoc)) { GraphicDescriptor aDescriptor(aGraphicURL); if (aDescriptor.Detect(/*bExtendedInfo=*/true)) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits