diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-04-28 15:16:53 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-04-28 17:39:12 +0200 |
commit | a9020e461803964a206d5551884b70717eed165c (patch) | |
tree | 348b6bf0b3d3c8d49ba493bc1df3f871bc573d58 | |
parent | 2ac96e52b05e9b9072788b80688a13436359b439 (diff) |
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
-rw-r--r-- | vcl/source/filter/wmf/winwmf.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
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<double>(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 ); |