diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-02 15:24:06 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-02 17:45:23 +0000 |
commit | 1ade66e7e70ce13c419f1ffff5222dcedec281bd (patch) | |
tree | fa5357563413d48313182ee966f0ae5f99a26013 /oox | |
parent | d15f4fc67dfcae492c7acfbe815f5d9ba10ae4d4 (diff) |
oox: 89 DPI is not such a great default
Using the DPI from Application::GetDefaultDevice() is a much better
idea, especially that now oox::GraphicHelper::GraphicHelper() and
oox::drawingml::DrawingML::WriteSrcRect() are in sync.
Should fix the testCropPixel() failure in CppunitTest_sw_ooxmlexport
that appears on HiDPI systems.
Also, fix all the rounding problems that now became visible when the DPI
is the same for both import and export.
Change-Id: Iceb34a8a5a1eaa8ce0824491521ad6b4d2f6949c
Reviewed-on: https://gerrit.libreoffice.org/14280
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 8 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 8 | ||||
-rw-r--r-- | oox/source/helper/graphichelper.cxx | 7 |
3 files changed, 14 insertions, 9 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index d25f8bfb10a0..2c0d40f0ccd9 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -726,13 +726,13 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe { text::GraphicCrop aGraphCrop( 0, 0, 0, 0 ); if ( oClipRect.X1 ) - aGraphCrop.Left = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 ); + aGraphCrop.Left = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 ); if ( oClipRect.Y1 ) - aGraphCrop.Top = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 ); + aGraphCrop.Top = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 ); if ( oClipRect.X2 ) - aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 ); + aGraphCrop.Right = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 ); if ( oClipRect.Y2 ) - aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 ); + aGraphCrop.Bottom = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 ); rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop); } } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index fcacb7a88c02..214652ddf462 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1063,10 +1063,10 @@ void DrawingML::WriteSrcRect( Reference< XPropertySet > rXPropSet, const OUStrin if ( (0 != aGraphicCropStruct.Left) || (0 != aGraphicCropStruct.Top) || (0 != aGraphicCropStruct.Right) || (0 != aGraphicCropStruct.Bottom) ) { mpFS->singleElementNS( XML_a, XML_srcRect, - XML_l, I32S(((aGraphicCropStruct.Left) * 100000) / aOriginalSize.Width()), - XML_t, I32S(((aGraphicCropStruct.Top) * 100000) / aOriginalSize.Height()), - XML_r, I32S(((aGraphicCropStruct.Right) * 100000) / aOriginalSize.Width()), - XML_b, I32S(((aGraphicCropStruct.Bottom) * 100000) / aOriginalSize.Height()), + XML_l, I32S(rtl::math::round(static_cast<double>(aGraphicCropStruct.Left) * 100000 / aOriginalSize.Width())), + XML_t, I32S(rtl::math::round(static_cast<double>(aGraphicCropStruct.Top) * 100000 / aOriginalSize.Height())), + XML_r, I32S(rtl::math::round(static_cast<double>(aGraphicCropStruct.Right) * 100000 / aOriginalSize.Width())), + XML_b, I32S(rtl::math::round(static_cast<double>(aGraphicCropStruct.Bottom) * 100000 / aOriginalSize.Height())), FSEND ); } } diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 0638ffe6350b..2714cf5d25f2 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -34,6 +34,8 @@ #include <osl/diagnose.h> #include <comphelper/seqstream.hxx> #include <vcl/wmf.hxx> +#include <vcl/svapp.hxx> +#include <tools/gen.hxx> #include "oox/helper/containerhelper.hxx" #include "oox/helper/propertyset.hxx" #include "oox/token/properties.hxx" @@ -113,7 +115,10 @@ GraphicHelper::GraphicHelper( const Reference< XComponentContext >& rxContext, c // get the metric of the output device OSL_ENSURE( xFrame.is(), "GraphicHelper::GraphicHelper - cannot get target frame" ); - maDeviceInfo.PixelPerMeterX = maDeviceInfo.PixelPerMeterY = 3500.0; // some default just in case + // some default just in case, 100 000 is 1 meter in MM100 + Size aDefault = Application::GetDefaultDevice()->LogicToPixel(Size(100000, 100000), MapMode(MAP_100TH_MM)); + maDeviceInfo.PixelPerMeterX = aDefault.Width(); + maDeviceInfo.PixelPerMeterY = aDefault.Height(); if( xFrame.is() ) try { Reference< awt::XDevice > xDevice( xFrame->getContainerWindow(), UNO_QUERY_THROW ); |