Kaydet (Commit) 588c5b0c authored tarafından Patrick Jaap's avatar Patrick Jaap Kaydeden (comit) Thorsten Behrens

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/41565Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst e038dfdf
......@@ -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);
......
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment