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
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index 47f48c3..22940dd 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 );