[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : luke
Repository : xara
Revision   : 1774
Date       : Mon Jun 18 14:50:54 BST 2007

Changed paths:
   M /Trunk/XaraLX/filters/SVGFilter/styles.h
   M /Trunk/XaraLX/filters/SVGFilter/svgimporter.cpp
   M /Trunk/XaraLX/filters/SVGFilter/xargenerator.cpp

[JLM] Adds line endcap styles to the SVG importer. Works the same as the line join type style patch.


Diff:
Index: Trunk/XaraLX/filters/SVGFilter/xargenerator.cpp
===================================================================
--- Trunk/XaraLX/filters/SVGFilter/xargenerator.cpp	(revision 1773)
+++ Trunk/XaraLX/filters/SVGFilter/xargenerator.cpp	(revision 1774)
@@ -977,7 +977,7 @@
 	if (witch & STYLE_STROKE_LINEJOIN && style.IsStrokeLineJoinDefined()) {
 		JointType jt=style.GetStrokeLineJoin();
 		Rec.Reinit(TAG_JOINSTYLE, TAG_JOINSTYLE_SIZE);
-		ok = Rec.WriteBYTE(jt);
+		ok = Rec.WriteBYTE(BYTE(jt));
 		ok = m_pExporter->WriteRecord(&Rec);
 
 #if SVGDEBUG
@@ -997,6 +997,33 @@
 
 	}
 
+	if (witch & STYLE_STROKE_LINECAP && style.IsStrokeLineCapDefined()) {
+		LineCapType lct=style.GetStrokeLineCap();
+		Rec.Reinit(TAG_STARTCAP, TAG_STARTCAP_SIZE);
+		ok = Rec.WriteBYTE(BYTE(lct));
+		ok = m_pExporter->WriteRecord(&Rec);
+
+		Rec.Reinit(TAG_ENDCAP, TAG_ENDCAP_SIZE);
+		ok = Rec.WriteBYTE(BYTE(lct));
+		ok = m_pExporter->WriteRecord(&Rec);
+
+#if SVGDEBUG
+		switch(lct)
+		{
+			case LineCapButt:
+				svgtrace(DBGTRACE_STYLES, "stroke cap butt\n");
+			break;
+			case LineCapRound:
+				svgtrace(DBGTRACE_STYLES, "stroke cap round\n");
+			break;
+			case LineCapSquare:
+				svgtrace(DBGTRACE_STYLES, "stroke cap square\n");
+			break;
+		}
+#endif
+
+	}
+
 	if (witch & STYLE_STROKE_OPACITY && style.IsStrokeOpacityDefined()) {
 		double opacity = style.GetStrokeOpacity();
 		if (opacity < 1.0) {
Index: Trunk/XaraLX/filters/SVGFilter/styles.h
===================================================================
--- Trunk/XaraLX/filters/SVGFilter/styles.h	(revision 1773)
+++ Trunk/XaraLX/filters/SVGFilter/styles.h	(revision 1774)
@@ -208,6 +208,7 @@
 		m_strokeOpacity = 1.0;
 		m_strokeWidth = 1;
 		m_strokeLineJoin = MitreJoin;
+		m_strokeLineCap = LineCapButt;
 		m_strokeGradient = NULL;
 		m_opacity = 1.0;
 		m_stopOffset = 0.0;
@@ -230,6 +231,7 @@
 		m_strokeOpacity = copy.m_strokeOpacity;
 		m_strokeWidth = copy.m_strokeWidth;
 		m_strokeLineJoin = copy.m_strokeLineJoin;
+		m_strokeLineCap = copy.m_strokeLineCap;
 		m_strokeGradient = copy.m_strokeGradient;
 		m_opacity = copy.m_opacity;
 		m_stopOffset = copy.m_stopOffset;
@@ -293,6 +295,13 @@
 		m_strokeLineJoin = jt;
 	}
 
+	bool IsStrokeLineCapDefined() const { return m_defined & STYLE_STROKE_LINECAP; }
+	LineCapType GetStrokeLineCap() const { return m_strokeLineCap; }
+	void SetStrokeLineCap(LineCapType lct ) {
+		m_defined |= STYLE_STROKE_LINECAP;
+		m_strokeLineCap = lct;
+	}
+
 	bool IsStrokeGradientDefined() const { return m_defined & STYLE_STROKE_GRADIENT; }
 	Gradient* GetStrokeGradient() const { return m_strokeGradient; }
 	void SetStrokeGradient(Gradient* value) {
@@ -340,6 +349,7 @@
 	double		m_strokeOpacity;
 	INT32		m_strokeWidth;
 	JointType	m_strokeLineJoin;
+	LineCapType	m_strokeLineCap;
 	Gradient*	m_strokeGradient;
 	double		m_opacity;
 	double		m_stopOffset;
Index: Trunk/XaraLX/filters/SVGFilter/svgimporter.cpp
===================================================================
--- Trunk/XaraLX/filters/SVGFilter/svgimporter.cpp	(revision 1773)
+++ Trunk/XaraLX/filters/SVGFilter/svgimporter.cpp	(revision 1774)
@@ -1528,6 +1528,19 @@
 		}
 	}
 
+	sValue = GetStringProperty(cur, "stroke-linecap");
+	if (!sValue.IsEmpty()) {
+		if(sValue.CmpNoCase(_T("butt"))==0) {
+			style.SetStrokeLineCap(LineCapButt);
+		}
+		else if(sValue.CmpNoCase(_T("round"))==0) {
+			style.SetStrokeLineCap(LineCapRound);
+		}
+		else if(sValue.CmpNoCase(_T("square"))==0) {
+			style.SetStrokeLineCap(LineCapSquare);
+		}
+	}
+
 	if (IsPropertyDefined(cur, "opacity")) {
 		double fOpacity = GetClampedDoubleProperty(cur, "opacity");
 		style.SetOpacity(fOpacity);


Xara