vcl/source/gdi/mapmod.cxx | 8 ++++++++ vcl/source/outdev/map.cxx | 1 + 2 files changed, 9 insertions(+)
New commits: commit d276993a1b60f66ce4322c29709c0c3907977663 Author: Michael Stahl <mst...@redhat.com> Date: Fri May 15 22:46:18 2015 +0200 tdf#90604: vcl: reduce MapMode precision further to 32 bits... tdf#91195: vcl: reduce MapMode Fraction precision to avoid... ... overlow in ImplMapLogicToPixel. 50 bits is still too much, 44 appears to work for exporting PNG. DocumentToGraphicRenderer::renderToGraphic() converts a double to Fraction which is the source of the excess precision. (cherry picked from commit c8dad7ebb7c1738ae1348f92d67124c165d83f00) ... which mysteriously causes the Export PNG to produce a non-blank image again. The cause is probably that DocumentToGraphicRenderer::renderToGraphic() records a VCL MetaFile, and the ReadFraction/WriteFraction do only 32 bits, while the Fraction interface promises to handle "long". (regression from 2ce0aededea43231d91a0955fc0676120dcc4f13) (cherry picked from commit 21be3257d9d10f0f65c2ae49d7ef3beb81018bfc) vcl: fix the MapMode ctor too to limit precision to 32 bits (cherry picked from commit 0a9b99787c65e49f08b27566d277eab8306cca54) Change-Id: Ic4289a3157ea802c17f0bc24db94ea45eabd9728 Reviewed-on: https://gerrit.libreoffice.org/15800 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/source/gdi/mapmod.cxx b/vcl/source/gdi/mapmod.cxx index a64f43b..56ea787 100644 --- a/vcl/source/gdi/mapmod.cxx +++ b/vcl/source/gdi/mapmod.cxx @@ -33,6 +33,10 @@ struct MapMode::ImplMapMode sal_uLong mnRefCount; MapUnit meUnit; Point maOrigin; + // NOTE: these Fraction must NOT have more than 32 bits precision + // because ReadFraction / WriteFraction do only 32 bits, so more than + // that cannot be stored in MetaFiles! + // => call ReduceInaccurate whenever setting these Fraction maScaleX; Fraction maScaleY; bool mbSimple; @@ -158,6 +162,8 @@ MapMode::MapMode( MapUnit eUnit, const Point& rLogicOrg, mpImplMapMode->maOrigin = rLogicOrg; mpImplMapMode->maScaleX = rScaleX; mpImplMapMode->maScaleY = rScaleY; + mpImplMapMode->maScaleX.ReduceInaccurate(32); + mpImplMapMode->maScaleY.ReduceInaccurate(32); } MapMode::~MapMode() @@ -193,6 +199,7 @@ void MapMode::SetScaleX( const Fraction& rScaleX ) ImplMakeUnique(); mpImplMapMode->maScaleX = rScaleX; + mpImplMapMode->maScaleX.ReduceInaccurate(32); } void MapMode::SetScaleY( const Fraction& rScaleY ) @@ -200,6 +207,7 @@ void MapMode::SetScaleY( const Fraction& rScaleY ) ImplMakeUnique(); mpImplMapMode->maScaleY = rScaleY; + mpImplMapMode->maScaleY.ReduceInaccurate(32); } MapMode& MapMode::operator=( const MapMode& rMapMode ) diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index b8bc6c5..599c814 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -74,6 +74,7 @@ static Fraction ImplMakeFraction( long nN1, long nN2, long nD1, long nD2 ) aF = Fraction( i*nN1, nD1 ) * Fraction( nN2, nD2 ); } + aF.ReduceInaccurate(32); return aF; }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits