summaryrefslogtreecommitdiff
path: root/drawinglayer/source/tools/emfphelperdata.cxx
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 /drawinglayer/source/tools/emfphelperdata.cxx
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>
Diffstat (limited to 'drawinglayer/source/tools/emfphelperdata.cxx')
-rw-r--r--drawinglayer/source/tools/emfphelperdata.cxx66
1 files changed, 62 insertions, 4 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);