[Libreoffice-commits] core.git: drawinglayer/source

Bartosz Kosiorek (via logerrit) logerrit at kemper.freedesktop.org
Sat Apr 4 20:53:46 UTC 2020


 drawinglayer/source/tools/emfpfont.cxx       |    3 ---
 drawinglayer/source/tools/emfphelperdata.cxx |   26 +++++++++++++++-----------
 drawinglayer/source/tools/emfphelperdata.hxx |    2 +-
 drawinglayer/source/tools/emfppen.cxx        |    2 --
 4 files changed, 16 insertions(+), 17 deletions(-)

New commits:
commit 6c59c9d2b8818674640a50656ffba90f9cd3900e
Author:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Tue Mar 31 18:09:16 2020 +0200
Commit:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Sat Apr 4 22:53:11 2020 +0200

    tdf#131644 Do not depend on actual DPI during EMF+ import
    
    Change-Id: If38062ddb9afc9af7a4e9cf2c701c7f801361a93
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91434
    Tested-by: Jenkins
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/drawinglayer/source/tools/emfpfont.cxx b/drawinglayer/source/tools/emfpfont.cxx
index 185b813540b2..b1dcaa12359f 100644
--- a/drawinglayer/source/tools/emfpfont.cxx
+++ b/drawinglayer/source/tools/emfpfont.cxx
@@ -56,9 +56,6 @@ namespace emfplushelper
         SAL_INFO("drawinglayer", "EMF+\tReserved: 0x" << reserved << std::dec);
         SAL_INFO("drawinglayer", "EMF+\tLength: " << length);
 
-        //tdf#113624 Convert unit to Pixels
-        emSize = emSize * EmfPlusHelperData::getUnitToPixelMultiplier(static_cast<UnitType>(sizeUnit));
-
         if (length > 0 && length < 0x4000)
         {
             rtl_uString *pStr = rtl_uString_alloc(length);
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index a52ad4b5e8cf..2758509f9856 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -233,7 +233,7 @@ namespace emfplushelper
     {
     }
 
-    float EmfPlusHelperData::getUnitToPixelMultiplier(const UnitType aUnitType)
+    float EmfPlusHelperData::getUnitToPixelMultiplier(const UnitType aUnitType, const sal_uInt32 aDPI)
     {
         switch (aUnitType)
         {
@@ -241,16 +241,16 @@ namespace emfplushelper
                 return 1.0f;
 
             case UnitTypePoint:
-                return Application::GetDefaultDevice()->GetDPIX() / 72.0;
+                return aDPI / 72.0;
 
             case UnitTypeInch:
-                return Application::GetDefaultDevice()->GetDPIX();
+                return aDPI;
 
             case UnitTypeMillimeter:
-                return Application::GetDefaultDevice()->GetDPIX() / 25.4;
+                return aDPI / 25.4;
 
             case UnitTypeDocument:
-                return Application::GetDefaultDevice()->GetDPIX() / 300.0;
+                return aDPI / 300.0;
 
             case UnitTypeWorld:
             case UnitTypeDisplay:
@@ -285,6 +285,7 @@ namespace emfplushelper
                 EMFPPen *pen = new EMFPPen();
                 maEMFPObjects[index].reset(pen);
                 pen->Read(rObjectStream, *this);
+                pen->penWidth = pen->penWidth * getUnitToPixelMultiplier(static_cast<UnitType>(pen->penUnit), mnHDPI);
                 break;
             }
             case EmfPlusObjectTypePath:
@@ -328,6 +329,9 @@ namespace emfplushelper
                 font->sizeUnit = 0;
                 font->fontFlags = 0;
                 font->Read(rObjectStream);
+                // tdf#113624 Convert unit to Pixels
+                font->emSize = font->emSize * getUnitToPixelMultiplier(static_cast<UnitType>(font->sizeUnit), mnHDPI);
+
                 break;
             }
             case EmfPlusObjectTypeStringFormat:
@@ -1700,9 +1704,8 @@ namespace emfplushelper
                         }
                         else
                         {
-                            const float aPageScaleMul = mfPageScale * getUnitToPixelMultiplier(static_cast<UnitType>(flags));
-                            mnMmX *= aPageScaleMul;
-                            mnMmY *= aPageScaleMul;
+                            mnMmX *= mfPageScale * getUnitToPixelMultiplier(static_cast<UnitType>(flags), mnHDPI);
+                            mnMmY *= mfPageScale * getUnitToPixelMultiplier(static_cast<UnitType>(flags), mnVDPI);
                             mappingChanged();
                         }
                         break;
@@ -1799,11 +1802,12 @@ namespace emfplushelper
                             SAL_WARN("drawinglayer", "EMF+\t file error. UnitTypeDisplay and UnitTypeWorld are not supported by BeginContainer in EMF+ specification.");
                             break;
                         }
-                        const float aPageScale = getUnitToPixelMultiplier(static_cast<UnitType>(flags));
+                        const float aPageScaleX = getUnitToPixelMultiplier(static_cast<UnitType>(flags), mnHDPI);
+                        const float aPageScaleY = getUnitToPixelMultiplier(static_cast<UnitType>(flags), mnVDPI);
                         GraphicStatePush(mGSContainerStack, stackIndex);
                         const basegfx::B2DHomMatrix transform = basegfx::utils::createScaleTranslateB2DHomMatrix(
-                            aPageScale * ( dw / sw ), aPageScale * ( dh / sh ),
-                            aPageScale * ( dx - sx ), aPageScale * ( dy - sy) );
+                            aPageScaleX * ( dw / sw ), aPageScaleY * ( dh / sh ),
+                            aPageScaleX * ( dx - sx ), aPageScaleY * ( dy - sy) );
                         maWorldTransform *= transform;
                         mappingChanged();
                         break;
diff --git a/drawinglayer/source/tools/emfphelperdata.hxx b/drawinglayer/source/tools/emfphelperdata.hxx
index de85f2f84e31..500ceb323b02 100644
--- a/drawinglayer/source/tools/emfphelperdata.hxx
+++ b/drawinglayer/source/tools/emfphelperdata.hxx
@@ -254,7 +254,7 @@ namespace emfplushelper
         static bool readXForm(SvStream& rIn, basegfx::B2DHomMatrix& rTarget);
         static ::basegfx::B2DPolyPolygon combineClip(::basegfx::B2DPolyPolygon const & leftPolygon, int combineMode, ::basegfx::B2DPolyPolygon const & rightPolygon);
 
-        static float getUnitToPixelMultiplier(const UnitType aUnitType);
+        static float getUnitToPixelMultiplier(const UnitType aUnitType, const sal_uInt32 aDPI);
     };
 }
 
diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx
index 5182c84b023f..c5e7d457be61 100644
--- a/drawinglayer/source/tools/emfppen.cxx
+++ b/drawinglayer/source/tools/emfppen.cxx
@@ -213,8 +213,6 @@ namespace emfplushelper
         SAL_INFO("drawinglayer", "EMF+\t\tUnit: " << UnitTypeToString(penUnit));
         SAL_INFO("drawinglayer", "EMF+\t\tWidth: " << std::dec << penWidth);
 
-        penWidth = penWidth * EmfPlusHelperData::getUnitToPixelMultiplier(static_cast<UnitType>(penUnit));
-
         // If a zero width is specified, a minimum value must be used, which is determined by the units
         if (penWidth == 0.0)
         { //TODO Check if these values is correct


More information about the Libreoffice-commits mailing list