summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-05-15 22:46:18 +0200
committerCaolán McNamara <caolanm@redhat.com>2015-05-20 14:07:47 +0000
commitd276993a1b60f66ce4322c29709c0c3907977663 (patch)
tree9bd8f92bab6c571a86406286aab66bd3fac1cb68
parent421adf500c0723126a293b7fbd51f22e1471f3cf (diff)
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 <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/source/gdi/mapmod.cxx8
-rw-r--r--vcl/source/outdev/map.cxx1
2 files changed, 9 insertions, 0 deletions
diff --git a/vcl/source/gdi/mapmod.cxx b/vcl/source/gdi/mapmod.cxx
index a64f43b6aed6..56ea787a6e97 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 b8bc6c5b05a1..599c814429ce 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;
}