Kaydet (Commit) a628c01e authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#122789 sw HTML import: fix handling of images with relative sizes

Relative size should have priority over image size from image headers.

Change-Id: I80cce79ff87c7eb359cb292526859435cb85f929
Reviewed-on: https://gerrit.libreoffice.org/73413
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst 32eeb405
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<body dir="ltr" lang="en-US"><p><img src="libreoffice.jpg" name="Image1" alt="Pic" align="bottom" width="70%" border="0"/></p>
......@@ -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());
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
......@@ -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))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment