[Libreoffice-commits] core.git: drawinglayer/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Jan 7 22:18:18 UTC 2019
drawinglayer/source/tools/emfphelperdata.cxx | 34 +++++++++++----------------
drawinglayer/source/tools/emfppen.cxx | 7 +++++
2 files changed, 22 insertions(+), 19 deletions(-)
New commits:
commit 7809ec859d5bdb5dedb259a362a15324088b334c
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Sun Jan 6 01:17:33 2019 +0100
Commit: Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Mon Jan 7 23:17:57 2019 +0100
tdf#122498 EMF+ Fix rotation of Ellipse, Arc and Pie
To draw any shape with EMF+ the shape needs to be created
and next the transformation matrix needs to be applied.
Unfortunately for Ellipse, Arc and Pie only position and ratio
was transformed. The rotation was not handled correctly.
With this patch the transformation matrix is applied after
creation of the shape.
Change-Id: I63a797e7cddfd304f94e7e5c8e2ce15063dc55e5
Reviewed-on: https://gerrit.libreoffice.org/65898
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index 5df791ec3ca4..3c9707df083a 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -971,8 +971,6 @@ namespace emfplushelper
SAL_INFO("drawinglayer", "EMF+\t RectData: " << dx << "," << dy << " " << dw << "x" << dh);
startAngle = basegfx::deg2rad(startAngle);
sweepAngle = basegfx::deg2rad(sweepAngle);
- ::basegfx::B2DPoint mappedCenter(Map(dx + dw / 2, dy + dh / 2));
- ::basegfx::B2DSize mappedSize(MapSize(dw / 2, dh / 2));
float endAngle = startAngle + sweepAngle;
startAngle = fmodf(startAngle, static_cast<float>(M_PI * 2));
@@ -980,14 +978,12 @@ namespace emfplushelper
{
startAngle += static_cast<float>(M_PI * 2.0);
}
-
endAngle = fmodf(endAngle, static_cast<float>(M_PI * 2.0));
if (endAngle < 0.0)
{
endAngle += static_cast<float>(M_PI * 2.0);
}
-
if (sweepAngle < 0)
{
std::swap(endAngle, startAngle);
@@ -996,17 +992,18 @@ namespace emfplushelper
SAL_INFO("drawinglayer", "EMF+\t adjusted angles: start " <<
basegfx::rad2deg(startAngle) << ", end: " << basegfx::rad2deg(endAngle) <<
" startAngle: " << startAngle << " sweepAngle: " << sweepAngle);
-
- ::basegfx::B2DPolygon polygon = basegfx::utils::createPolygonFromEllipseSegment(
- mappedCenter, mappedSize.getX(), mappedSize.getY(), startAngle, endAngle);
-
+ const ::basegfx::B2DPoint centerPoint(dx + 0.5 * dw, dy + 0.5 * dh);
+ ::basegfx::B2DPolygon polygon(
+ ::basegfx::utils::createPolygonFromEllipseSegment(centerPoint,
+ 0.5 * dw, 0.5 * dh,
+ startAngle, endAngle));
if (type != EmfPlusRecordTypeDrawArc)
{
- polygon.append(mappedCenter);
+ polygon.append(centerPoint);
polygon.setClosed(true);
}
-
::basegfx::B2DPolyPolygon polyPolygon(polygon);
+ polyPolygon.transform(maMapTransform);
if (type == EmfPlusRecordTypeFillPie)
EMFPPlusFillPolygon(polyPolygon, flags & 0x8000, brushIndexOrColor);
else
@@ -1054,11 +1051,10 @@ namespace emfplushelper
float dx, dy, dw, dh;
ReadRectangle(rMS, dx, dy, dw, dh, bool(flags & 0x4000));
SAL_INFO("drawinglayer", "EMF+ RectData: " << dx << "," << dy << " " << dw << "x" << dh);
- ::basegfx::B2DPoint mappedCenter(Map(dx + dw / 2, dy + dh / 2));
- ::basegfx::B2DSize mappedSize(MapSize(dw / 2, dh / 2));
::basegfx::B2DPolyPolygon polyPolygon(
- ::basegfx::utils::createPolygonFromEllipse(mappedCenter, mappedSize.getX(), mappedSize.getY()));
-
+ ::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(dx + 0.5 * dw, dy + 0.5 * dh),
+ 0.5 * dw, 0.5 * dh));
+ polyPolygon.transform(maMapTransform);
if (type == EmfPlusRecordTypeFillEllipse)
EMFPPlusFillPolygon(polyPolygon, flags & 0x8000, brushIndexOrColor);
else
@@ -1518,7 +1514,7 @@ namespace emfplushelper
}
case EmfPlusRecordTypeSetWorldTransform:
{
- SAL_INFO("drawinglayer", "EMF+ SetWorldTransform, Post multiply: " << (flags & 0x2000));
+ SAL_INFO("drawinglayer", "EMF+ SetWorldTransform, Post multiply: " << bool(flags & 0x2000));
readXForm(rMS, maWorldTransform);
mappingChanged();
SAL_INFO("drawinglayer", "EMF+\t: " << maWorldTransform);
@@ -1536,7 +1532,7 @@ namespace emfplushelper
}
case EmfPlusRecordTypeMultiplyWorldTransform:
{
- SAL_INFO("drawinglayer", "EMF+ MultiplyWorldTransform, post multiply: " << (flags & 0x2000));
+ SAL_INFO("drawinglayer", "EMF+ MultiplyWorldTransform, post multiply: " << bool(flags & 0x2000));
basegfx::B2DHomMatrix transform;
readXForm(rMS, transform);
@@ -1563,7 +1559,7 @@ namespace emfplushelper
}
case EmfPlusRecordTypeTranslateWorldTransform:
{
- SAL_INFO("drawinglayer", "EMF+ TranslateWorldTransform, Post multiply: " << (flags & 0x2000));
+ SAL_INFO("drawinglayer", "EMF+ TranslateWorldTransform, Post multiply: " << bool(flags & 0x2000));
basegfx::B2DHomMatrix transform;
float eDx, eDy;
@@ -1601,7 +1597,7 @@ namespace emfplushelper
transform.set(1, 1, eSy);
SAL_INFO("drawinglayer", "EMF+ ScaleWorldTransform Sx: " << eSx <<
- " Sy: " << eSy << ", Post multiply:" << (flags & 0x2000));
+ " Sy: " << eSy << ", Post multiply:" << bool(flags & 0x2000));
SAL_INFO("drawinglayer",
"EMF+\t World transform matrix: " << maWorldTransform);
@@ -1630,7 +1626,7 @@ namespace emfplushelper
rMS.ReadFloat(eAngle);
SAL_INFO("drawinglayer", "EMF+ RotateWorldTransform Angle: " << eAngle <<
- ", post multiply: " << (flags & 0x2000));
+ ", post multiply: " << bool(flags & 0x2000));
// Skipping flags & 0x2000
// For rotation transformation there is no difference between post and pre multiply
maWorldTransform.rotate(basegfx::deg2rad(eAngle));
diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx
index 637c0e2d2011..eb0f593f9867 100644
--- a/drawinglayer/source/tools/emfppen.cxx
+++ b/drawinglayer/source/tools/emfppen.cxx
@@ -173,6 +173,7 @@ namespace emfplushelper
if (penDataFlags & PenDataTransform)
{
EmfPlusHelperData::readXForm(s, pen_transformation);
+ SAL_WARN("drawinglayer", "EMF+\t\t TODO PenDataTransform: " << pen_transformation);
}
if (penDataFlags & PenDataStartCap)
@@ -198,6 +199,7 @@ namespace emfplushelper
if (penDataFlags & PenDataJoin)
{
s.ReadInt32(lineJoin);
+ SAL_WARN("drawinglayer", "EMF+\t\t TODO PenDataJoin: 0x" << std::hex << lineJoin);
}
else
{
@@ -207,6 +209,7 @@ namespace emfplushelper
if (penDataFlags & PenDataMiterLimit)
{
s.ReadFloat(mitterLimit);
+ SAL_WARN("drawinglayer", "EMF+\t\t TODO PenDataMiterLimit: 0x" << std::hex << mitterLimit);
}
else
{
@@ -226,6 +229,7 @@ namespace emfplushelper
if (penDataFlags & PenDataDashedLineCap)
{
s.ReadInt32(dashCap);
+ SAL_WARN("drawinglayer", "EMF+\t\t TODO PenDataDashedLineCap: 0x" << std::hex << dashCap);
}
else
{
@@ -235,6 +239,7 @@ namespace emfplushelper
if (penDataFlags & PenDataDashedLineOffset)
{
s.ReadFloat(dashOffset);
+ SAL_WARN("drawinglayer", "EMF+\t\t TODO PenDataDashedLineOffset: 0x" << std::hex << dashOffset);
}
else
{
@@ -266,6 +271,7 @@ namespace emfplushelper
if (penDataFlags & PenDataNonCenter)
{
s.ReadInt32(alignment);
+ SAL_WARN("drawinglayer", "EMF+\t\t TODO PenDataNonCenter: 0x" << std::hex << alignment);
}
else
{
@@ -288,6 +294,7 @@ namespace emfplushelper
{
s.ReadFloat(compoundArray[i]);
}
+ SAL_WARN("drawinglayer", "EMF+\t\t TODO PenDataCompoundLine: 0x");
}
if (penDataFlags & PenDataCustomStartCap)
More information about the Libreoffice-commits
mailing list