[Libreoffice-commits] core.git: drawinglayer/source
Bartosz Kosiorek (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 20 08:58:04 UTC 2019
drawinglayer/source/tools/emfpcustomlinecap.cxx | 8 --
drawinglayer/source/tools/emfphelperdata.cxx | 91 ++++++++++++++++++++++++
2 files changed, 92 insertions(+), 7 deletions(-)
New commits:
commit d15518584a3197e4b8318d0176352a0584f42167
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Wed Nov 13 07:39:46 2019 +0100
Commit: Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Wed Nov 20 09:56:55 2019 +0100
tdf#42112 Add support for Custom Line Cap
original patch updated by Chris Sherlock
Change-Id: Ie68c3cc40d2c7263a0f786a973da77b00e4cbeb8
Reviewed-on: https://gerrit.libreoffice.org/82564
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>
diff --git a/drawinglayer/source/tools/emfpcustomlinecap.cxx b/drawinglayer/source/tools/emfpcustomlinecap.cxx
index 82e8f94e0e37..98af0f5241c7 100644
--- a/drawinglayer/source/tools/emfpcustomlinecap.cxx
+++ b/drawinglayer/source/tools/emfpcustomlinecap.cxx
@@ -67,13 +67,7 @@ namespace emfplushelper
path.Read(s, pathFlags);
polygon = path.GetPolygon(rR, false);
mbIsFilled = bFill;
-
- // transformation to convert the path to what LibreOffice
- // expects
- B2DHomMatrix aMatrix;
- aMatrix.scale(1.0, -1.0);
- polygon.transform(aMatrix);
- };
+ }
void EMFPCustomLineCap::Read(SvStream& s, EmfPlusHelperData const & rR)
{
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index debbf5c0add1..5ed50e702386 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "emfpcustomlinecap.hxx"
#include "emfphelperdata.hxx"
#include "emfpbrush.hxx"
#include "emfppen.hxx"
@@ -480,6 +481,96 @@ namespace emfplushelper
pen->GetColor().GetTransparency() / 255.0));
}
+ if ((pen->penDataFlags & 0x00000800) && (pen->customStartCap->polygon.begin()->count() > 1))
+ {
+ SAL_WARN("drawinglayer", "EMF+\tCustom Start Line Cap");
+ ::basegfx::B2DPolyPolygon startCapPolygon(pen->customStartCap->polygon);
+
+ // get the gradient of the first line in the polypolygon
+ double x1 = polygon.begin()->getB2DPoint(0).getX();
+ double y1 = polygon.begin()->getB2DPoint(0).getY();
+ double x2 = polygon.begin()->getB2DPoint(1).getX();
+ double y2 = polygon.begin()->getB2DPoint(1).getY();
+
+ if ((x2 - x1) != 0)
+ {
+ double gradient = (y2 - y1) / (x2 - x1);
+
+ // now we get the angle that we need to rotate the arrow by
+ double angle = (M_PI / 2) - atan(gradient);
+
+ // rotate the arrow
+ startCapPolygon.transform(basegfx::utils::createRotateB2DHomMatrix(angle));
+ }
+
+ startCapPolygon.transform(maMapTransform);
+
+ basegfx::B2DHomMatrix tran(pen->penWidth, 0.0, polygon.begin()->getB2DPoint(0).getX(),
+ 0.0, pen->penWidth, polygon.begin()->getB2DPoint(0).getY());
+ startCapPolygon.transform(tran);
+
+ if (pen->customStartCap->mbIsFilled)
+ {
+ mrTargetHolders.Current().append(
+ std::make_unique<drawinglayer::primitive2d::PolyPolygonColorPrimitive2D>(
+ startCapPolygon,
+ pen->GetColor().getBColor()));
+ }
+ else
+ {
+ mrTargetHolders.Current().append(
+ std::make_unique<drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D>(
+ startCapPolygon,
+ lineAttribute,
+ aStrokeAttribute));
+ }
+ }
+
+ if ((pen->penDataFlags & 0x00001000) && (pen->customEndCap->polygon.begin()->count() > 1))
+ {
+ SAL_WARN("drawinglayer", "EMF+\tCustom End Line Cap");
+
+ ::basegfx::B2DPolyPolygon endCapPolygon(pen->customEndCap->polygon);
+
+ // get the gradient of the first line in the polypolygon
+ double x1 = polygon.begin()->getB2DPoint(polygon.begin()->count() - 1).getX();
+ double y1 = polygon.begin()->getB2DPoint(polygon.begin()->count() - 1).getY();
+ double x2 = polygon.begin()->getB2DPoint(polygon.begin()->count() - 2).getX();
+ double y2 = polygon.begin()->getB2DPoint(polygon.begin()->count() - 2).getY();
+
+ if ((x2 - x1) != 0)
+ {
+ double gradient = (y2 - y1) / (x2 - x1);
+
+ // now we get the angle that we need to rotate the arrow by
+ double angle = (M_PI / 2) - atan(gradient);
+
+ // rotate the arrow
+ endCapPolygon.transform(basegfx::utils::createRotateB2DHomMatrix(angle));
+ }
+
+ endCapPolygon.transform(maMapTransform);
+ basegfx::B2DHomMatrix tran(pen->penWidth, 0.0, polygon.begin()->getB2DPoint(polygon.begin()->count() - 1).getX(),
+ 0.0, pen->penWidth, polygon.begin()->getB2DPoint(polygon.begin()->count() - 1).getY());
+ endCapPolygon.transform(tran);
+
+ if (pen->customEndCap->mbIsFilled)
+ {
+ mrTargetHolders.Current().append(
+ std::make_unique<drawinglayer::primitive2d::PolyPolygonColorPrimitive2D>(
+ endCapPolygon,
+ pen->GetColor().getBColor()));
+ }
+ else
+ {
+ mrTargetHolders.Current().append(
+ std::make_unique<drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D>(
+ endCapPolygon,
+ lineAttribute,
+ aStrokeAttribute));
+ }
+ }
+
mrPropertyHolders.Current().setLineColor(pen->GetColor().getBColor());
mrPropertyHolders.Current().setLineColorActive(true);
mrPropertyHolders.Current().setFillColorActive(false);
More information about the Libreoffice-commits
mailing list