From a9020e461803964a206d5551884b70717eed165c Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 28 Apr 2014 15:16:53 +0200 Subject: fdo#74336 limit the size of the non-placeable WMF image For a non-placable WMF image the size is unknown and needs to be calculated by using a bounding box over all elements. Sometimes this results in a very big image which is not drawn correctly when using dashes and dots. This change normalizes the size to reasonable values. Change-Id: I0e5b71fb011c5a9dff1c5cb13e29d5578570ca65 --- vcl/source/filter/wmf/winwmf.cxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx index 47f48c348020..22940dd3ed57 100644 --- a/vcl/source/filter/wmf/winwmf.cxx +++ b/vcl/source/filter/wmf/winwmf.cxx @@ -1141,6 +1141,20 @@ bool WMFReader::ReadHeader() { pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the metaactions GetPlaceableBound( aPlaceableBound, pWMF ); + + // The image size is not known so normalize the calculated bounds so that the + // resulting image is not too big + const long aMaxWidth = 1024; + const double fMaxWidth = static_cast(aMaxWidth); + if (aPlaceableBound.GetWidth() > aMaxWidth) + { + double fRatio = aPlaceableBound.GetWidth() / fMaxWidth; + aPlaceableBound = Rectangle( + aPlaceableBound.Top() / fRatio, + aPlaceableBound.Left() / fRatio, + aPlaceableBound.Bottom() / fRatio, + aPlaceableBound.Right() / fRatio); + } } pWMF->Seek( nStrmPos ); -- cgit v1.2.3