summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-02-19 08:46:10 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-02-19 07:27:34 +0100
commitce671c2275195f7545366ec9a11100c105ac366b (patch)
tree75f2eba6d1640ba3d43f6abd41333f59709bca2d /drawinglayer
parent409a9dbc04c4b98a3f9ca81618906b16937ff2f0 (diff)
Some more unit conversion unification
Change-Id: I8f0afb93ffb8bd1b88efca802fad5e9aeb447021 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111168 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/tools/wmfemfhelper.cxx34
1 files changed, 8 insertions, 26 deletions
diff --git a/drawinglayer/source/tools/wmfemfhelper.cxx b/drawinglayer/source/tools/wmfemfhelper.cxx
index f5a171b9e204..f287e2a4e23c 100644
--- a/drawinglayer/source/tools/wmfemfhelper.cxx
+++ b/drawinglayer/source/tools/wmfemfhelper.cxx
@@ -47,6 +47,7 @@
#include <sal/log.hxx>
#include <tools/fract.hxx>
#include <tools/stream.hxx>
+#include <tools/UnitConversion.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/gradient.hxx>
#include <vcl/hatch.hxx>
@@ -2523,34 +2524,15 @@ namespace wmfemfhelper
}
else
{
- switch(rMapMode.GetMapUnit())
+ const auto eFrom = MapToO3tlLength(rPropertyHolders.Current().getMapUnit()),
+ eTo = MapToO3tlLength(rMapMode.GetMapUnit());
+ if (eFrom != o3tl::Length::invalid && eTo != o3tl::Length::invalid)
{
- case MapUnit::Map100thMM :
- {
- if(MapUnit::MapTwip == rPropertyHolders.Current().getMapUnit())
- {
- // MapUnit::MapTwip -> MapUnit::Map100thMM
- const double fTwipTo100thMm(127.0 / 72.0);
- aMapping.scale(fTwipTo100thMm, fTwipTo100thMm);
- }
- break;
- }
- case MapUnit::MapTwip :
- {
- if(MapUnit::Map100thMM == rPropertyHolders.Current().getMapUnit())
- {
- // MapUnit::Map100thMM -> MapUnit::MapTwip
- const double f100thMmToTwip(72.0 / 127.0);
- aMapping.scale(f100thMmToTwip, f100thMmToTwip);
- }
- break;
- }
- default :
- {
- OSL_FAIL("implInterpretMetafile: MetaActionType::MAPMODE with unsupported MapUnit (!)");
- break;
- }
+ const double fConvert(o3tl::convert(1.0, eFrom, eTo));
+ aMapping.scale(fConvert, fConvert);
}
+ else
+ OSL_FAIL("implInterpretMetafile: MetaActionType::MAPMODE with unsupported MapUnit (!)");
aMapping = getTransformFromMapMode(rMapMode) * aMapping;
rPropertyHolders.Current().setMapUnit(rMapMode.GetMapUnit());