summaryrefslogtreecommitdiffstats
path: root/drawinglayer/source/tools/emfphelperdata.cxx
diff options
context:
space:
mode:
authorBartosz Kosiorek <gang65@poczta.onet.pl>2018-04-11 01:05:01 +0200
committerBartosz Kosiorek <gang65@poczta.onet.pl>2018-04-16 23:10:15 +0200
commitdbe3c29a3bf74b0d037eb035eca11aa4836db8da (patch)
tree7d7c716ece62c1a3627fe39daa0084cd6b2aff9a /drawinglayer/source/tools/emfphelperdata.cxx
parenttdf#55058 Properly close shapes with close shape method. (diff)
downloadcore-dbe3c29a3bf74b0d037eb035eca11aa4836db8da.tar.gz
core-dbe3c29a3bf74b0d037eb035eca11aa4836db8da.zip
tdf#113624 EMF+ Add support for different units conversion
With previous implementation only Pixel unit was supported. Other units (eg. inch, milimeters, points, world) was treated as Pixel. With this patch the correct unit conversion was implemented to following records: - FontObject - PenObject - SetWorldTransform As a result records are properly scaled. Tested with DrawString record from: https://bugs.documentfoundation.org/attachment.cgi?id=140287 Change-Id: I77435ad8f1bbac08f298a03d91d0c7f1f1734e5c Reviewed-on: https://gerrit.libreoffice.org/52699 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'drawinglayer/source/tools/emfphelperdata.cxx')
-rw-r--r--drawinglayer/source/tools/emfphelperdata.cxx49
1 files changed, 44 insertions, 5 deletions
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index c4574a62fb45..cdf79d378b49 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -107,6 +107,44 @@ namespace emfplushelper
StringAlignmentFar = 0x00000002
} StringAlignment;
+ float EmfPlusHelperData::getUnitToPixelMultiplier(const UnitType aUnitType)
+ {
+ switch (aUnitType)
+ {
+ case UnitTypePixel:
+ {
+ return 1.0f;
+ }
+ case UnitTypePoint:
+ {
+ SAL_INFO("drawinglayer", "EMF+\t Converting Points to Pixels.");
+ return 1.333333f;
+ }
+ case UnitTypeInch:
+ {
+ SAL_INFO("drawinglayer", "EMF+\t TODO Test Converting Inches to Pixels, if it is working correctly.");
+ return 96.0f;
+ }
+ case UnitTypeMillimeter:
+ {
+ SAL_INFO("drawinglayer", "EMF+\t TODO Test Converting Milimeters to Pixels, if it is working correctly.");
+ return 3.779528f;
+ }
+ case UnitTypeDocument:
+ {
+ SAL_INFO("drawinglayer", "EMF+\t TODO Test Converting Documents to Pixels, if it is working correctly.");
+ return 0.32f;
+ }
+ case UnitTypeWorld:
+ case UnitTypeDisplay:
+ default:
+ {
+ SAL_WARN("drawinglayer", "EMF+\tTODO Unimplemented support of Unit Type: 0x" << std::hex << aUnitType);
+ }
+ }
+ return 1.0f;
+ }
+
void EmfPlusHelperData::processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, bool bUseWholeStream)
{
sal_uInt32 index;
@@ -1230,7 +1268,7 @@ namespace emfplushelper
}
else
{
- SAL_WARN("drawinglayer", "EMF+ DrawImage(Points) Wrong EMF+ file. Only Unit Type Pixel is support by EMF+ standard in DrawImage(Points)");
+ SAL_WARN("drawinglayer", "EMF+ DrawImage(Points) Wrong EMF+ file. Only Unit Type Pixel is support by EMF+ specification for DrawImage(Points)");
}
break;
}
@@ -1365,14 +1403,15 @@ namespace emfplushelper
SAL_INFO("drawinglayer", "EMF+ SetPageTransform");
SAL_INFO("drawinglayer", "EMF+\tscale: " << mfPageScale << " unit: " << flags);
- if (flags != UnitTypePixel)
+ if ((flags == UnitTypeDisplay) || (flags == UnitTypeWorld))
{
- SAL_WARN("drawinglayer", "EMF+\t TODO Only UnitTypePixel is supported. ");
+ SAL_WARN("drawinglayer", "EMF+ file error. UnitTypeDisplay and UnitTypeWorld are not supported by SetPageTransform in EMF+ specification.");
}
else
{
- mnMmX *= mfPageScale;
- mnMmY *= mfPageScale;
+ const float aPageScaleMul = mfPageScale * getUnitToPixelMultiplier(static_cast<UnitType>(flags));
+ mnMmX *= aPageScaleMul;
+ mnMmY *= aPageScaleMul;
mappingChanged();
}
break;