[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/source vcl/source
Caolán McNamara
caolanm at redhat.com
Wed Aug 9 20:02:12 UTC 2017
sw/source/core/docnode/ndnotxt.cxx | 18 +++---------------
vcl/source/filter/jpeg/jpegc.cxx | 6 +++---
vcl/source/gdi/graph.cxx | 24 +++++++++++++-----------
3 files changed, 19 insertions(+), 29 deletions(-)
New commits:
commit 939538e6a8d35c8ab4412908482feb053386bf3d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Aug 9 14:54:05 2017 +0100
Resolves: tdf#99286 for jpeg dpi use apis that know about MapUnit::MapPixel
move the code which can do this from sw to vcl
Change-Id: I9940fb80ecdbfe8f70afc500c691288ed0993701
Reviewed-on: https://gerrit.libreoffice.org/40932
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx
index 5ff587ef6b7f..91b923cb097f 100644
--- a/sw/source/core/docnode/ndnotxt.cxx
+++ b/sw/source/core/docnode/ndnotxt.cxx
@@ -121,21 +121,9 @@ const tools::PolyPolygon *SwNoTextNode::HasContour() const
{
if ( !bPixelGrf && bPixelContour )
{
- const Size aGrfPixelSize( GetGraphic().GetSizePixel() );
- const Size aGrfPrefMapModeSize( GetGraphic().GetPrefSize() );
- if ( aGrfMap.GetMapUnit() == MapUnit::MapInch )
- {
- nGrfDPIx = aGrfPixelSize.Width() / ( (double)aGrfMap.GetScaleX() * aGrfPrefMapModeSize.Width() );
- nGrfDPIy = aGrfPixelSize.Height() / ( (double)aGrfMap.GetScaleY() * aGrfPrefMapModeSize.Height() );
- }
- else
- {
- const Size aGrf1000thInchSize =
- OutputDevice::LogicToLogic( aGrfPrefMapModeSize,
- aGrfMap, MapUnit::Map1000thInch );
- nGrfDPIx = 1000.0 * aGrfPixelSize.Width() / aGrf1000thInchSize.Width();
- nGrfDPIy = 1000.0 * aGrfPixelSize.Height() / aGrf1000thInchSize.Height();
- }
+ basegfx::B2DSize aDPI = GetGraphic().GetPPI();
+ nGrfDPIx = aDPI.getX();
+ nGrfDPIy = aDPI.getY();
}
}
OSL_ENSURE( !bPixelGrf || aGrfMap == aContourMap,
diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx
index 8fc0ed83b8bf..3353fe9c247a 100644
--- a/vcl/source/filter/jpeg/jpegc.cxx
+++ b/vcl/source/filter/jpeg/jpegc.cxx
@@ -251,7 +251,7 @@ void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
}
bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream,
- long nWidth, long nHeight, basegfx::B2DSize const & aPPI, bool bGreys,
+ long nWidth, long nHeight, basegfx::B2DSize const & rPPI, bool bGreys,
long nQualityPercent, long aChromaSubsampling,
css::uno::Reference<css::task::XStatusIndicator> const & status )
{
@@ -290,8 +290,8 @@ bool WriteJPEG( JPEGWriter* pJPEGWriter, void* pOutputStream,
jpeg_set_quality( &cinfo, (int) nQualityPercent, FALSE );
cinfo.density_unit = 1;
- cinfo.X_density = aPPI.getX();
- cinfo.Y_density = aPPI.getY();
+ cinfo.X_density = rPPI.getX();
+ cinfo.Y_density = rPPI.getY();
if ( ( nWidth > 128 ) || ( nHeight > 128 ) )
jpeg_simple_progression( &cinfo );
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index db4f1a7d0363..f0ce35e0aaee 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <tools/fract.hxx>
#include <vcl/outdev.hxx>
#include <vcl/svapp.hxx>
#include <vcl/graph.hxx>
@@ -401,24 +402,25 @@ void Graphic::SetPrefMapMode( const MapMode& rPrefMapMode )
basegfx::B2DSize Graphic::GetPPI() const
{
- MapMode aMapMode = GetPrefMapMode();
+ double nGrfDPIx;
+ double nGrfDPIy;
- double fWidthInches = ( GetPrefSize().Width() * aMapMode.GetUnitMultiplier() ) / 2540;
- double fHeightInches = ( GetPrefSize().Height() * aMapMode.GetUnitMultiplier() ) / 2540;
- double fPpiX = 0;
- double fPpiY = 0;
-
- if ( fWidthInches > 0 || fHeightInches > 0 ) // we don't want a divide by 0 situation
+ const MapMode aGrfMap(GetPrefMapMode());
+ const Size aGrfPixelSize(GetSizePixel());
+ const Size aGrfPrefMapModeSize(GetPrefSize());
+ if (aGrfMap.GetMapUnit() == MapUnit::MapInch)
{
- fPpiX = GetSizePixel().Width() / fWidthInches;
- fPpiY = GetSizePixel().Height() / fHeightInches;
+ nGrfDPIx = aGrfPixelSize.Width() / ( (double)aGrfMap.GetScaleX() * aGrfPrefMapModeSize.Width() );
+ nGrfDPIy = aGrfPixelSize.Height() / ( (double)aGrfMap.GetScaleY() * aGrfPrefMapModeSize.Height() );
}
else
{
- SAL_WARN("vcl", "PPI X is " << fPpiX << " and PPI Y is " << fPpiY << ": thus we are making this 0 DPI. This is unlikely.");
+ const Size aGrf1000thInchSize = OutputDevice::LogicToLogic(aGrfPrefMapModeSize, aGrfMap, MapUnit::Map1000thInch);
+ nGrfDPIx = 1000.0 * aGrfPixelSize.Width() / aGrf1000thInchSize.Width();
+ nGrfDPIy = 1000.0 * aGrfPixelSize.Height() / aGrf1000thInchSize.Height();
}
- return basegfx::B2DSize( fPpiX, fPpiY );
+ return basegfx::B2DSize(nGrfDPIx, nGrfDPIy);
}
Size Graphic::GetSizePixel( const OutputDevice* pRefDevice ) const
More information about the Libreoffice-commits
mailing list