[Libreoffice-commits] core.git: filter/source include/vcl vcl/CppunitTest_vcl_mapmode.mk vcl/Module_vcl.mk vcl/qa vcl/source

2017-08-09 Thread Caolán McNamara
 filter/source/graphicfilter/eps/eps.cxx |   49 +++-
 include/vcl/mapmod.hxx  |3 -
 vcl/CppunitTest_vcl_mapmode.mk  |   49 
 vcl/Module_vcl.mk   |1 
 vcl/qa/cppunit/mapmode.cxx  |   65 
 vcl/source/gdi/mapmod.cxx   |   46 --
 6 files changed, 48 insertions(+), 165 deletions(-)

New commits:
commit 622347b913dd0aedaec1d0a4658e5dc7801f6bde
Author: Caolán McNamara 
Date:   Wed Aug 9 15:01:48 2017 +0100

send this MapMode scale thing back to where it came from

Change-Id: Ic33f4b4bf7a0df35f04778e474f5a136f06be4a6
Reviewed-on: https://gerrit.libreoffice.org/40926
Tested-by: Jenkins 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/filter/source/graphicfilter/eps/eps.cxx 
b/filter/source/graphicfilter/eps/eps.cxx
index 51577eb31393..7f4dd74e9982 100644
--- a/filter/source/graphicfilter/eps/eps.cxx
+++ b/filter/source/graphicfilter/eps/eps.cxx
@@ -213,6 +213,7 @@ private:
 inline void ImplWriteTextColor( sal_uLong nMode );
 voidImplWriteColor( sal_uLong nMode );
 
+static double   ImplGetScaling( const MapMode& );
 voidImplGetMapMode( const MapMode& );
 static bool ImplGetBoundingBox( double* nNumb, sal_uInt8* pSource, 
sal_uLong nSize );
 static sal_uInt8*   ImplSearchEntry( sal_uInt8* pSource, sal_uInt8 const * 
pDest, sal_uLong nComp, sal_uLong nSize );
@@ -2173,7 +2174,7 @@ void PSWriter::ImplWriteColor( sal_uLong nMode )
 void PSWriter::ImplGetMapMode( const MapMode& rMapMode )
 {
 ImplWriteLine( "tm setmatrix" );
-double fMul = rMapMode.GetUnitMultiplier();
+double fMul = ImplGetScaling(rMapMode);
 double fScaleX = (double)rMapMode.GetScaleX() * fMul;
 double fScaleY = (double)rMapMode.GetScaleY() * fMul;
 ImplTranslate( rMapMode.GetOrigin().X() * fScaleX, 
rMapMode.GetOrigin().Y() * fScaleY );
@@ -2214,6 +2215,52 @@ inline void PSWriter::ImplWriteLine( const char* 
pString, sal_uLong nMode )
 ImplExecMode( nMode );
 }
 
+double PSWriter::ImplGetScaling( const MapMode& rMapMode )
+{
+double nMul;
+switch (rMapMode.GetMapUnit())
+{
+case MapUnit::MapPixel :
+case MapUnit::MapSysFont :
+case MapUnit::MapAppFont :
+
+case MapUnit::Map100thMM :
+nMul = 1;
+break;
+case MapUnit::Map10thMM :
+nMul = 10;
+break;
+case MapUnit::MapMM :
+nMul = 100;
+break;
+case MapUnit::MapCM :
+nMul = 1000;
+break;
+case MapUnit::Map1000thInch :
+nMul = 2.54;
+break;
+case MapUnit::Map100thInch :
+nMul = 25.4;
+break;
+case MapUnit::Map10thInch :
+nMul = 254;
+break;
+case MapUnit::MapInch :
+nMul = 2540;
+break;
+case MapUnit::MapTwip :
+nMul = 1.7639;
+break;
+case MapUnit::MapPoint :
+nMul = 35.2778;
+break;
+default:
+nMul = 1.0;
+break;
+}
+return nMul;
+}
+
 
 void PSWriter::ImplWriteLineInfo( double fLWidth, double fMLimit,
   SvtGraphicStroke::CapType eLCap,
diff --git a/include/vcl/mapmod.hxx b/include/vcl/mapmod.hxx
index 6908833ec49c..b426326ac485 100644
--- a/include/vcl/mapmod.hxx
+++ b/include/vcl/mapmod.hxx
@@ -55,9 +55,6 @@ public:
 voidSetScaleY( const Fraction& rScaleY );
 const Fraction& GetScaleY() const;
 
-/// Gets the multiplier, which is relative to 1/100 mm units
-double  GetUnitMultiplier() const;
-
 MapMode&operator=( const MapMode& rMapMode );
 MapMode&operator=( MapMode&& rMapMode );
 booloperator==( const MapMode& rMapMode ) const;
diff --git a/vcl/CppunitTest_vcl_mapmode.mk b/vcl/CppunitTest_vcl_mapmode.mk
deleted file mode 100644
index e29a16af4e0f..
--- a/vcl/CppunitTest_vcl_mapmode.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_CppunitTest_CppunitTest,vcl_mapmode))
-
-$(eval $(call gb_CppunitTest_set_include,vcl_mapmode,\
-$$(INCLUDE) \
--I$(SRCDIR)/vcl/inc \
-))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,vcl_mapmode, \
-   vcl/qa/cppunit/mapmode \
-))
-
-$(eval $(call gb_CppunitTest_use_externals,vcl_mapmode,boost_headers))
-

[Libreoffice-commits] core.git: filter/source include/vcl vcl/CppunitTest_vcl_mapmode.mk vcl/Module_vcl.mk vcl/qa vcl/source

2016-02-14 Thread Chris Sherlock
 filter/source/graphicfilter/eps/eps.cxx |   49 
 include/vcl/graph.hxx   |3 +
 include/vcl/mapmod.hxx  |3 +
 vcl/CppunitTest_vcl_mapmode.mk  |   53 ++
 vcl/Module_vcl.mk   |1 
 vcl/qa/cppunit/mapmode.cxx  |   65 
 vcl/source/filter/jpeg/JpegWriter.cxx   |6 ++
 vcl/source/filter/jpeg/jpeg.h   |4 +
 vcl/source/filter/jpeg/jpegc.cxx|6 +-
 vcl/source/gdi/graph.cxx|   26 +++-
 vcl/source/gdi/mapmod.cxx   |   47 ++-
 11 files changed, 207 insertions(+), 56 deletions(-)

New commits:
commit f8355221ae62b89a706f2d04b63eda658f3ccfa5
Author: Chris Sherlock 
Date:   Sat Feb 13 16:08:01 2016 +1100

tdf#85761 vcl: JPEG export does not save PPI values correctly

JPEG values are currently hardcoded to 96PPI when we export JPEGs. The
Graphic class doesn't have an easy way to get the PPI, but this can
actually be calculated from the pref size and pref map mode (no idea
why it is called "Pref").

Interestingly, you need to get a multiplier to work this out, relative
to units of 100th mm. The EPS filter code had a function that does
exactly this, but it's entirely based on MapMode units so it was really
implemented in the wrong class IMO. I have thus moved it out of PSWriter
and into MapMode.

This also fixes tdf#65695, which was partially fixed, but had the JPEG
PPI hardcoded to 96dpi.

Also fixes tdf#97481.

Change-Id: Iedb674141dd4e22fcbfb7be357dc777f732aa3aa
Reviewed-on: https://gerrit.libreoffice.org/22339
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/filter/source/graphicfilter/eps/eps.cxx 
b/filter/source/graphicfilter/eps/eps.cxx
index 0800b4c..aaa5fd0 100644
--- a/filter/source/graphicfilter/eps/eps.cxx
+++ b/filter/source/graphicfilter/eps/eps.cxx
@@ -215,7 +215,6 @@ private:
 inline void ImplWriteTextColor( sal_uLong nMode = PS_RET );
 voidImplWriteColor( sal_uLong nMode );
 
-static double   ImplGetScaling( const MapMode& );
 voidImplGetMapMode( const MapMode& );
 static bool ImplGetBoundingBox( double* nNumb, sal_uInt8* pSource, 
sal_uLong nSize );
 static sal_uInt8*   ImplSearchEntry( sal_uInt8* pSource, sal_uInt8 const * 
pDest, sal_uLong nComp, sal_uLong nSize );
@@ -2197,56 +2196,10 @@ void PSWriter::ImplWriteColor( sal_uLong nMode )
 ImplExecMode( nMode );
 }
 
-double PSWriter::ImplGetScaling( const MapMode& rMapMode )
-{
-double  nMul;
-switch ( rMapMode.GetMapUnit() )
-{
-case MAP_PIXEL :
-case MAP_SYSFONT :
-case MAP_APPFONT :
-
-case MAP_100TH_MM :
-nMul = 1;
-break;
-case MAP_10TH_MM :
-nMul = 10;
-break;
-case MAP_MM :
-nMul = 100;
-break;
-case MAP_CM :
-nMul = 1000;
-break;
-case MAP_1000TH_INCH :
-nMul = 2.54;
-break;
-case MAP_100TH_INCH :
-nMul = 25.4;
-break;
-case MAP_10TH_INCH :
-nMul = 254;
-break;
-case MAP_INCH :
-nMul = 2540;
-break;
-case MAP_TWIP :
-nMul = 1.7639;
-break;
-case MAP_POINT :
-nMul = 35.2778;
-break;
-default:
-nMul = 1.0;
-break;
-}
-return nMul;
-}
-
 void PSWriter::ImplGetMapMode( const MapMode& rMapMode )
 {
 ImplWriteLine( "tm setmatrix" );
-double fMul = ImplGetScaling( rMapMode );
+double fMul = rMapMode.GetUnitMultiplier();
 double fScaleX = (double)rMapMode.GetScaleX() * fMul;
 double fScaleY = (double)rMapMode.GetScaleY() * fMul;
 ImplTranslate( rMapMode.GetOrigin().X() * fScaleX, 
rMapMode.GetOrigin().Y() * fScaleY );
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 4ca9491..7514f87 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 
 enum GraphicType
@@ -163,6 +164,8 @@ public:
 MapMode GetPrefMapMode() const;
 voidSetPrefMapMode( const MapMode& rPrefMapMode );
 
+basegfx::B2DSize GetPPI() const;
+
 SizeGetSizePixel( const OutputDevice* pRefDevice = nullptr ) 
const;
 
 sal_uLong   GetSizeBytes() const;
diff --git a/include/vcl/mapmod.hxx b/include/vcl/mapmod.hxx
index 508bdd8..77aa83d 100644
--- a/include/vcl/mapmod.hxx
+++ b/include/vcl/mapmod.hxx
@@ -61,6 +61,9 @@ public:
 voidSetScaleY( const Fraction& rScaleY );
 const Fraction& GetScaleY() const;
 
+/// Gets the