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 63de59a18360b4415a23ff76b4373f0afadd9840
Author: Caolán McNamara <caol...@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/40931
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Michael Stahl <mst...@redhat.com>

diff --git a/sw/source/core/docnode/ndnotxt.cxx 
b/sw/source/core/docnode/ndnotxt.cxx
index 3c3938857945..57d85b4f32d6 100644
--- a/sw/source/core/docnode/ndnotxt.cxx
+++ b/sw/source/core/docnode/ndnotxt.cxx
@@ -119,21 +119,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 c674c667c788..4305f065ed54 100644
--- a/vcl/source/filter/jpeg/jpegc.cxx
+++ b/vcl/source/filter/jpeg/jpegc.cxx
@@ -279,7 +279,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 )
 {
@@ -315,8 +315,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 d863a2413506..ee33fffd4fd4 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>
@@ -402,24 +403,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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to