summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Jaap <patrick.jaap@tu-dresden.de>2017-08-25 14:08:29 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-09-15 02:33:48 +0200
commit588c5b0cff9bbdb2efbdfb259268154b0074e7e6 (patch)
treefee7cefd70b71576b2d369d13e7d4a72ac4a8e53
parente038dfdf05096edc0e9c38c9a686b5d23ba39352 (diff)
tdf#112012 EMF+ add dashed line support
add support for dashed lines as optional pen attribute. Change-Id: I8c49d178e1b25eb0b8cd15c32c2fc47497efb21b Reviewed-on: https://gerrit.libreoffice.org/41565 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--drawinglayer/source/tools/emfphelperdata.cxx66
-rw-r--r--drawinglayer/source/tools/emfppen.cxx7
-rw-r--r--drawinglayer/source/tools/emfppen.hxx7
3 files changed, 69 insertions, 11 deletions
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index fef6ca8a1b3c..2b8ecbb6b22e 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -418,10 +418,68 @@ namespace emfplushelper
transformedPenWidth,
lineJoin,
lineCap);
- mrTargetHolders.Current().append(
- new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
- polygon,
- lineAttribute));
+
+ if (pen->penDataFlags & 0x00000020 && pen->dashStyle != EmfPlusLineStyleCustom) // pen has a predifined line style
+ {
+ // taken from the old cppcanvas implementation
+ const std::vector<double> dash = { 3, 3 };
+ const std::vector<double> dot = { 1, 3 };
+ const std::vector<double> dashdot = { 3, 3, 1, 3 };
+ const std::vector<double> dashdotdot = { 3, 3, 1, 3, 1, 3 };
+
+ drawinglayer::attribute::StrokeAttribute aStrokeAttribute;
+
+ switch (pen->dashStyle)
+ {
+ case EmfPlusLineStyleSolid: // do nothing special, use default stroke attribute
+ break;
+ case EmfPlusLineStyleDash:
+ aStrokeAttribute = drawinglayer::attribute::StrokeAttribute(dash);
+ break;
+ case EmfPlusLineStyleDot:
+ aStrokeAttribute = drawinglayer::attribute::StrokeAttribute(dot);
+ break;
+ case EmfPlusLineStyleDashDot:
+ aStrokeAttribute = drawinglayer::attribute::StrokeAttribute(dashdot);
+ break;
+ case EmfPlusLineStyleDashDotDot:
+ aStrokeAttribute = drawinglayer::attribute::StrokeAttribute(dashdotdot);
+ break;
+
+ }
+ mrTargetHolders.Current().append(
+ new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
+ polygon,
+ lineAttribute,
+ aStrokeAttribute));
+ }
+ else if (pen->penDataFlags & 0x00000100) // pen has a custom dash line
+ {
+ // StrokeAttribute needs a double vector while the pen provides a float vector
+ std::vector<double> aPattern(pen->dashPattern.size());
+ for (size_t i=0; i<aPattern.size(); i++)
+ {
+ aPattern[i] = 0.5 * MapSize(double(pen->dashPattern[i]),0).getX();
+ // here, this is just a guess
+ // without transform it es way too small
+ // with 1 * MapSize(...) it es too large
+ // with 0.5 * MapSize is looks like in MSO
+ }
+ drawinglayer::attribute::StrokeAttribute strokeAttribute(aPattern);
+ mrTargetHolders.Current().append(
+ new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
+ polygon,
+ lineAttribute,
+ strokeAttribute));
+
+ }
+ else // no further line decoration, so use simple primitive
+ {
+ mrTargetHolders.Current().append(
+ new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D(
+ polygon,
+ lineAttribute));
+ }
mrPropertyHolders.Current().setLineColor(pen->GetColor().getBColor());
mrPropertyHolders.Current().setLineColorActive(true);
diff --git a/drawinglayer/source/tools/emfppen.cxx b/drawinglayer/source/tools/emfppen.cxx
index 1905b8cb6f48..686cac184254 100644
--- a/drawinglayer/source/tools/emfppen.cxx
+++ b/drawinglayer/source/tools/emfppen.cxx
@@ -60,13 +60,6 @@ namespace emfplushelper
PenDataCustomEndCap = 0x00001000
};
- const sal_Int32 EmfPlusLineStyleSolid = 0x00000000;
- const sal_Int32 EmfPlusLineStyleDash = 0x00000001;
- const sal_Int32 EmfPlusLineStyleDot = 0x00000002;
- const sal_Int32 EmfPlusLineStyleDashDot = 0x00000003;
- const sal_Int32 EmfPlusLineStyleDashDotDot = 0x00000004;
- const sal_Int32 EmfPlusLineStyleCustom = 0x00000005;
-
EMFPPen::EMFPPen()
: EMFPBrush()
, penDataFlags(0)
diff --git a/drawinglayer/source/tools/emfppen.hxx b/drawinglayer/source/tools/emfppen.hxx
index 754f89dec0c6..2a7f4d9320e1 100644
--- a/drawinglayer/source/tools/emfppen.hxx
+++ b/drawinglayer/source/tools/emfppen.hxx
@@ -34,6 +34,13 @@ namespace emfplushelper
const sal_uInt32 EmfPlusLineJoinTypeRound = 0x00000002;
const sal_uInt32 EmfPlusLineJoinTypeMiterClipped = 0x00000003;
+ const sal_Int32 EmfPlusLineStyleSolid = 0x00000000;
+ const sal_Int32 EmfPlusLineStyleDash = 0x00000001;
+ const sal_Int32 EmfPlusLineStyleDot = 0x00000002;
+ const sal_Int32 EmfPlusLineStyleDashDot = 0x00000003;
+ const sal_Int32 EmfPlusLineStyleDashDotDot = 0x00000004;
+ const sal_Int32 EmfPlusLineStyleCustom = 0x00000005;
+
struct EMFPCustomLineCap;
struct EMFPPen : public EMFPBrush