incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1228153 - in /incubator/ooo/branches/alg/linecap/main/filter/source/svg: svgwriter.cxx svgwriter.hxx
Date Fri, 06 Jan 2012 12:37:16 GMT
Author: alg
Date: Fri Jan  6 12:37:16 2012
New Revision: 1228153

URL: http://svn.apache.org/viewvc?rev=1228153&view=rev
Log:
linecap: Adapted Svg exporter (LineJoin was missing, too, also added). Roundtrip with new
importer  works well now

Modified:
    incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.cxx
    incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.hxx

Modified: incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.cxx?rev=1228153&r1=1228152&r2=1228153&view=diff
==============================================================================
--- incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.cxx (original)
+++ incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.cxx Fri Jan  6 12:37:16
2012
@@ -83,6 +83,10 @@ static const char   aXMLAttrGradientUnit
 static const char   aXMLAttrOffset[] = "offset";
 static const char   aXMLAttrStopColor[] = "stop-color";
 
+// added support for LineJoin and LineCap
+static const char   aXMLAttrStrokeLinejoin[] = "stroke-linejoin";
+static const char   aXMLAttrStrokeLinecap[] = "stroke-linecap";
+
 // -----------------------------------------------------------------------------
 
 static const sal_Unicode pBase64[] = 
@@ -673,7 +677,52 @@ void SVGActionWriter::ImplWriteShape( co
         sal_Int32 nStrokeWidth = ( bApplyMapping ? ImplMap( rShape.mnStrokeWidth ) : rShape.mnStrokeWidth
);
         mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStrokeWidth, ::rtl::OUString::valueOf(
nStrokeWidth ) );
     }
-        
+
+    // support for LineJoin
+    switch(rShape.maLineJoin)
+    {
+        default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE
+        case basegfx::B2DLINEJOIN_MITER:
+        {
+            // miter is Svg default, so no need to write until the exporter might write styles.
+            // If this happens, activate here
+            // mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, ::rtl::OUString::createFromAscii("miter"));
+            break;
+        }
+        case basegfx::B2DLINEJOIN_BEVEL:
+        {
+            mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, ::rtl::OUString::createFromAscii("bevel"));
+            break;
+        }
+        case basegfx::B2DLINEJOIN_ROUND:
+        {
+            mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinejoin, ::rtl::OUString::createFromAscii("round"));
+            break;
+        }
+    }
+
+    // support for LineCap
+    switch(rShape.maLineCap)
+    {
+        default: /* com::sun::star::drawing::LineCap_BUTT */
+        {
+            // butt is Svg default, so no need to write until the exporter might write styles.
+            // If this happens, activate here
+            // mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, ::rtl::OUString::createFromAscii("butt"));
+            break;
+        }
+        case com::sun::star::drawing::LineCap_ROUND:
+        {
+            mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, ::rtl::OUString::createFromAscii("round"));
+            break;
+        }
+        case com::sun::star::drawing::LineCap_SQUARE:
+        {
+            mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrStrokeLinecap, ::rtl::OUString::createFromAscii("square"));
+            break;
+        }
+    }
+
     if( rShape.maDashArray.size() )
     {
         const ::rtl::OUString   aComma( B2UCONST( "," ) );
@@ -1464,6 +1513,46 @@ void SVGActionWriter::ImplWriteActions( 
                         mapCurShape->maShapeLineColor.SetTransparency( (sal_uInt8) FRound(
aStroke.getTransparency() * 255.0 ) );
                         mapCurShape->mnStrokeWidth = FRound( aStroke.getStrokeWidth()
); 
                         aStroke.getDashArray( mapCurShape->maDashArray );
+
+                        // added support for LineJoin
+                        switch(aStroke.getJoinType())
+                        {
+                            default: /* SvtGraphicStroke::joinMiter,  SvtGraphicStroke::joinNone
*/
+                            {
+                                mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_MITER;
+                                break;
+                            }
+                            case SvtGraphicStroke::joinRound:
+                            {
+                                mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_ROUND;
+                                break;
+                            }
+                            case SvtGraphicStroke::joinBevel:
+                            {
+                                mapCurShape->maLineJoin = basegfx::B2DLINEJOIN_BEVEL;
+                                break;
+                            }
+                        }
+
+                        // added support for LineCap
+                        switch(aStroke.getCapType())
+                        {
+                            default: /* SvtGraphicStroke::capButt */
+                            {
+                                mapCurShape->maLineCap = com::sun::star::drawing::LineCap_BUTT;
+                                break;
+                            }
+                            case SvtGraphicStroke::capRound:
+                            {
+                                mapCurShape->maLineCap = com::sun::star::drawing::LineCap_ROUND;
+                                break;
+                            }
+                            case SvtGraphicStroke::capSquare:
+                            {
+                                mapCurShape->maLineCap = com::sun::star::drawing::LineCap_SQUARE;
+                                break;
+                            }
+                        }
                     }
                     
                     // write open shape in every case

Modified: incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.hxx?rev=1228153&r1=1228152&r2=1228153&view=diff
==============================================================================
--- incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.hxx (original)
+++ incubator/ooo/branches/alg/linecap/main/filter/source/svg/svgwriter.hxx Fri Jan  6 12:37:16
2012
@@ -137,20 +137,26 @@ public:
 
 struct SVGShapeDescriptor
 {
-    PolyPolygon                 maShapePolyPoly;
-    Color                       maShapeFillColor;
-    Color                       maShapeLineColor;
-    sal_Int32                   mnStrokeWidth;
-    SvtGraphicStroke::DashArray maDashArray;
-    ::std::auto_ptr< Gradient > mapShapeGradient;
-    ::rtl::OUString             maId;
+    PolyPolygon                         maShapePolyPoly;
+    Color                               maShapeFillColor;
+    Color                               maShapeLineColor;
+    sal_Int32                           mnStrokeWidth;
+    SvtGraphicStroke::DashArray         maDashArray;
+    ::std::auto_ptr< Gradient >         mapShapeGradient;
+    ::rtl::OUString                     maId;
+
+    // added support for LineJoin and LineCap
+    basegfx::B2DLineJoin                maLineJoin;
+    com::sun::star::drawing::LineCap    maLineCap;
 
     // -------------------------------------------------------------------------
 
     SVGShapeDescriptor() :
         maShapeFillColor( Color( COL_TRANSPARENT ) ),
         maShapeLineColor( Color( COL_TRANSPARENT ) ),
-        mnStrokeWidth( 0 )
+        mnStrokeWidth( 0 ),
+        maLineJoin(basegfx::B2DLINEJOIN_MITER), // miter is Svg 'stroke-linejoin' default
+        maLineCap(com::sun::star::drawing::LineCap_BUTT) // butt is Svg 'stroke-linecap'
default
     {
     }
 };



Mime
View raw message