filter/source/msfilter/msdffimp.cxx | 9 +++++++- sw/source/filter/html/htmlgrin.cxx | 28 ++++++++++++++++++++++++- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 9 +++++++- 3 files changed, 43 insertions(+), 3 deletions(-)
New commits: commit e997dce19086b7e23c44e86a6c908b726845bc4d Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Apr 19 17:35:19 2018 +0200 sw HTML import: lazy-read inline images Explicitly use the graphic descriptor to provide the image size, otherwise later Graphic::GetSizePixel() will swap in the graphic during HTML import. Change-Id: Ib785ce4f0fd31e09b148d2d53ed29dc4deee7b86 diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 869d92c3c435..3b3c4f93acb1 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -480,8 +480,34 @@ IMAGE_SETEVENT: std::unique_ptr<SvMemoryStream> 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) + { + pStream->Seek(0); + GraphicDescriptor aDescriptor(*pStream, /*pPath=*/nullptr); + if (aDescriptor.Detect(/*bExtendedInfo=*/true)) + { + nWidth = aDescriptor.GetSizePixel().getWidth(); + if (nWidth) + bWidthProvided = true; + + nHeight = aDescriptor.GetSizePixel().getHeight(); + if (nHeight) + bHeightProvided = true; + } + } + } + + if (!sGrfNm.isEmpty()) + { + if (ERRCODE_NONE == rFilter.ImportGraphic(aGraphic, "", *pStream)) + sGrfNm.clear(); + } } } else if (m_sBaseURL.isEmpty() || !aGraphicData.isEmpty()) commit 5f11766adf9e99ee323ca6d8ecb14d8fb3cd4770 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Apr 19 14:42:38 2018 +0200 sw RTF import: use GraphicDescriptor to determine size The size info in the markup is optional, and 0x0 is not a great default. Change-Id: I12506a98db2044ca76a4290eebb46bde7f6c1137 diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 371c16181d18..8ecb88d8d319 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -35,6 +35,7 @@ #include <rtl/uri.hxx> #include <rtl/tencinfo.h> #include <oox/helper/graphichelper.hxx> +#include <vcl/graphicfilter.hxx> #include "rtfsdrimport.hxx" #include "rtfreferenceproperties.hxx" #include "rtfskipdestination.hxx" @@ -891,7 +892,13 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS // provided by picw and pich. Graphic aGraphic(xGraphic); - Size aSize(aGraphic.GetPrefSize()); + Size aSize; + pStream->Seek(0); + GraphicDescriptor aDescriptor(*pStream, /*pPath=*/nullptr); + if (aDescriptor.Detect(/*bExtendedInfo=*/true)) + aSize = aDescriptor.GetSizePixel(); + else + aSize = aGraphic.GetPrefSize(); MapMode aMap(MapUnit::Map100thMM); if (aGraphic.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel) aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMap); commit 2ca1ebbfad366dc871c394772c7ca05b95c84358 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Apr 19 13:56:55 2018 +0200 DOC import: lazy-read images At least JPEG files are now only loaded when the user scrolls to the relevant page. Change-Id: I9699927282b99bcb71a0d271a20bbfd56a361ee8 diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 2e842b106f78..21a22a153999 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -6513,7 +6513,14 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool else { // and unleash our filter GraphicFilter& rGF = GraphicFilter::GetGraphicFilter(); - nRes = rGF.ImportGraphic( rData, "", *pGrStream ); + Graphic aGraphic = rGF.ImportUnloadedGraphic(*pGrStream); + if (aGraphic) + { + rData = aGraphic; + nRes = ERRCODE_NONE; + } + else + nRes = rGF.ImportGraphic( rData, "", *pGrStream ); // SJ: I40472, sometimes the aspect ratio (aMtfSize100) does not match and we get scaling problems, // then it is better to use the prefsize that is stored within the metafile. Bug #72846# for what the _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits