From a0f5c5e6d16ef9e3db140a922912ff2a49a224b7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 23 Apr 2018 14:10:10 +0200 Subject: sw HTML import: lazy-read inline images Also prefer Graphic::GetPrefSize() over Graphic::GetSizePixel(), since the previous does not swap in the image. Change-Id: I100da14716448e72b687ce8ad1800326f0b3735e Reviewed-on: https://gerrit.libreoffice.org/53322 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/source/filter/html/htmlgrin.cxx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'sw/source') diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 869d92c3c435..cb25a316277f 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -480,8 +480,25 @@ IMAGE_SETEVENT: std::unique_ptr const pStream(aGraphicURL.getData()); if (pStream) { - if (ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, "", *pStream)) + GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter(); + aGraphic = rFilter.ImportUnloadedGraphic(*pStream); + if (aGraphic) + { sGrfNm.clear(); + + if (!bHeightProvided || !bWidthProvided) + { + Size aPrefSize = aGraphic.GetPrefSize(); + nWidth = aPrefSize.getWidth(); + nHeight = aPrefSize.getHeight(); + } + } + + if (!sGrfNm.isEmpty()) + { + if (ERRCODE_NONE == rFilter.ImportGraphic(aGraphic, "", *pStream)) + sGrfNm.clear(); + } } } else if (m_sBaseURL.isEmpty() || !aGraphicData.isEmpty()) @@ -497,7 +514,7 @@ IMAGE_SETEVENT: aGraphic.SetDefaultType(); } - if (!bHeightProvided || !bWidthProvided) + if (!nHeight || !nWidth) { Size aPixelSize = aGraphic.GetSizePixel(Application::GetDefaultDevice()); if (!bWidthProvided) -- cgit