summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2016-04-09 23:15:09 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2016-04-26 16:42:27 +0000
commit32cec4ca8bf1e09dd33aa461984e8e8ae34f4a7c (patch)
tree5591a63de12179505a0e7a4870632754585152d3 /svgio
parent4905c8bf7834b1ca79139c62f4e8b0672e9ddc13 (diff)
tdf#48066 render stroke-miterlimit correctly in SVG import
The property stroke-miterlimit is transported to the renderers via a new member mfMiterMinimumAngle in class LineAttribute Several drawPolyLine methods are adapted. This patch does not include changes in MetaAction. Presentation mode, printing, and PDF-export is still wrong. Corrected LineJoinMiter to LineJoinBevel in canvas, that s closer to NONE. Removed DrawPolyLine method without MiterMinimumAngle and adapted calls accordingly. Change-Id: I6bcd24add5d85c4d9a39e3788e0682091c5fc9c4 Reviewed-on: https://gerrit.libreoffice.org/23946 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de> Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/inc/svgio/svgreader/svgstyleattributes.hxx2
-rw-r--r--svgio/inc/svgio/svgreader/svgtools.hxx3
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx24
-rw-r--r--svgio/source/svgreader/svgtools.cxx18
4 files changed, 35 insertions, 12 deletions
diff --git a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
index f711feb3af63..141218b3e042 100644
--- a/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
+++ b/svgio/inc/svgio/svgreader/svgstyleattributes.hxx
@@ -378,7 +378,7 @@ namespace svgio
/// StrokeMiterLimit content
SvgNumber getStrokeMiterLimit() const;
- void setStrokeMiterLimit(const SvgNumber& rStrokeMiterLimit = SvgNumber()) { maStrokeMiterLimit = rStrokeMiterLimit; }
+ void setStrokeMiterLimit(const SvgNumber& rStrokeMiterLimit = SvgNumber(4.0,Unit_none,false)) { maStrokeMiterLimit = rStrokeMiterLimit; }
/// StrokeOpacity content
SvgNumber getStrokeOpacity() const;
diff --git a/svgio/inc/svgio/svgreader/svgtools.hxx b/svgio/inc/svgio/svgreader/svgtools.hxx
index 4c940ee819db..f65cf059e481 100644
--- a/svgio/inc/svgio/svgreader/svgtools.hxx
+++ b/svgio/inc/svgio/svgreader/svgtools.hxx
@@ -83,7 +83,8 @@ namespace svgio
Unit_mm, // 3.543307 px
Unit_in, // 90 px
- Unit_percent // relative to range
+ Unit_percent, // relative to range
+ Unit_none // for stroke-miterlimit, which has no unit
};
class SvgNumber
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 2d5bc8548495..201ec68422a3 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -676,13 +676,27 @@ namespace svgio
// todo: Handle getStrokeDashOffset()
+ // convert svg:stroke-miterlimit to LineAttrute:mfMiterMinimumAngle
+ // The default needs to be set explicitely, because svg default <> Draw default
+ double fMiterMinimumAngle;
+ if (getStrokeMiterLimit().isSet())
+ {
+ fMiterMinimumAngle = 2.0 * asin(1.0/getStrokeMiterLimit().getNumber());
+ }
+ else
+ {
+ fMiterMinimumAngle = 2.0 * asin(0.25); // 1.0/default 4.0
+ }
+
// prepare line attribute
drawinglayer::primitive2d::Primitive2DReference aNewLinePrimitive;
+
const drawinglayer::attribute::LineAttribute aLineAttribute(
pStroke ? *pStroke : basegfx::BColor(0.0, 0.0, 0.0),
fStrokeWidth,
aB2DLineJoin,
- aLineCap);
+ aLineCap,
+ fMiterMinimumAngle);
if(aDashArray.empty())
{
@@ -1411,9 +1425,9 @@ namespace svgio
if(readSingleNumber(aContent, aNum))
{
- if(aNum.isPositive())
- {
- setStrokeMiterLimit(aNum);
+ if(basegfx::fTools::moreOrEqual(aNum.getNumber(), 1.0))
+ { //readSingleNumber sets Unit_px as default, if unit is missing. Correct it here.
+ setStrokeMiterLimit(SvgNumber(aNum.getNumber(), Unit_none));
}
}
break;
@@ -2297,7 +2311,7 @@ namespace svgio
}
// default is 4
- return SvgNumber(4.0);
+ return SvgNumber(4.0, Unit_none);
}
SvgNumber SvgStyleAttributes::getStrokeOpacity() const
diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx
index 14e5bdaa9553..3bc457344cb4 100644
--- a/svgio/source/svgreader/svgtools.cxx
+++ b/svgio/source/svgreader/svgtools.cxx
@@ -189,6 +189,13 @@ namespace svgio
return fRetval;
}
+ case Unit_none:
+ {
+#ifdef DBG_UTIL
+ myAssert("Design error, this case should have been handled in the caller");
+#endif
+ return mfNumber;
+ }
default:
{
OSL_ENSURE(false, "Do not use with percentage! ");
@@ -219,6 +226,7 @@ namespace svgio
case Unit_in:
case Unit_em:
case Unit_ex:
+ case Unit_none:
{
return solveNonPercentage( rInfoProvider);
}
@@ -473,13 +481,13 @@ namespace svgio
}
else if('t' == aCharB)
{
- // 'pt' == 1.25 px
+ // 'pt' == 4/3 px
aRetval = Unit_pt;
bTwoCharValid = true;
}
else if('c' == aCharB)
{
- // 'pc' == 15 px
+ // 'pc' == 16 px
aRetval = Unit_pc;
bTwoCharValid = true;
}
@@ -489,7 +497,7 @@ namespace svgio
{
if('n' == aCharB)
{
- // 'in' == 90 px
+ // 'in' == 96 px, since CSS 2.1
aRetval = Unit_in;
bTwoCharValid = true;
}
@@ -499,7 +507,7 @@ namespace svgio
{
if('m' == aCharB)
{
- // 'cm' == 35.43307 px
+ // 'cm' == 37.79527559 px
aRetval = Unit_cm;
bTwoCharValid = true;
}
@@ -509,7 +517,7 @@ namespace svgio
{
if('m' == aCharB)
{
- // 'mm' == 3.543307 px
+ // 'mm' == 3.779528 px
aRetval = Unit_mm;
bTwoCharValid = true;
}