[Libreoffice-commits] core.git: include/basegfx svgio/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Mar 6 15:37:42 UTC 2019


 include/basegfx/DrawCommands.hxx      |   14 ++++++++++++
 svgio/source/svgreader/svgvisitor.cxx |   37 ++++++++++++++++++++++++++++------
 2 files changed, 45 insertions(+), 6 deletions(-)

New commits:
commit 8c0178870889a47c46fec8f59b7c94dcabf6d126
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Mar 3 00:00:23 2019 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Mar 6 16:37:01 2019 +0100

    parse more attributes in SvgDrawVisitor
    
    - add additional parameters for DrawRectangle, DrawPath
    - parse stroke width, stroke and fill color for path and rect
    - parse rx, ry for rect
    - use getCurrentViewPort for top-level SVG rectangle
    
    Change-Id: Ife498bdaa721852ef2542ac5df2be0e86dfb4e62
    Reviewed-on: https://gerrit.libreoffice.org/68785
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/basegfx/DrawCommands.hxx b/include/basegfx/DrawCommands.hxx
index 36321c312ba7..fda21e9231bb 100644
--- a/include/basegfx/DrawCommands.hxx
+++ b/include/basegfx/DrawCommands.hxx
@@ -58,10 +58,19 @@ class DrawRectangle : public DrawBase
 {
 public:
     basegfx::B2DRange maRectangle;
+    double mnRx;
+    double mnRy;
+
+    double mnStrokeWidth;
+    std::shared_ptr<basegfx::BColor> mpFillColor;
+    std::shared_ptr<basegfx::BColor> mpStrokeColor;
 
     DrawRectangle(basegfx::B2DRange const& rRectangle)
         : DrawBase(DrawCommandType::Rectangle)
         , maRectangle(rRectangle)
+        , mnRx(1.0)
+        , mnRy(1.0)
+        , mnStrokeWidth(1.0)
     {
     }
 };
@@ -71,9 +80,14 @@ class DrawPath : public DrawBase
 public:
     basegfx::B2DPolyPolygon maPolyPolygon;
 
+    double mnStrokeWidth;
+    std::shared_ptr<basegfx::BColor> mpFillColor;
+    std::shared_ptr<basegfx::BColor> mpStrokeColor;
+
     DrawPath(basegfx::B2DPolyPolygon const& rPolyPolygon)
         : DrawBase(DrawCommandType::Path)
         , maPolyPolygon(rPolyPolygon)
+        , mnStrokeWidth(1.0)
     {
     }
 };
diff --git a/svgio/source/svgreader/svgvisitor.cxx b/svgio/source/svgreader/svgvisitor.cxx
index 9ac651c66cc7..7b92e2fd0afb 100644
--- a/svgio/source/svgreader/svgvisitor.cxx
+++ b/svgio/source/svgreader/svgvisitor.cxx
@@ -18,6 +18,7 @@
 #include <svgpathnode.hxx>
 
 #include <svgvisitor.hxx>
+#include <tools/color.hxx>
 
 namespace svgio
 {
@@ -37,13 +38,9 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode)
         {
             auto const& rSvgNode = static_cast<svgio::svgreader::SvgSvgNode const&>(rNode);
 
-            double x = rSvgNode.getX().getNumber();
-            double y = rSvgNode.getY().getNumber();
-            double w = rSvgNode.getWidth().getNumber();
-            double h = rSvgNode.getHeight().getNumber();
+            basegfx::B2DRange aRange = rSvgNode.getCurrentViewPort();
 
-            static_cast<gfx::DrawRoot*>(mpCurrent.get())->maRectangle
-                = basegfx::B2DRange(x, y, x + w, y + h);
+            static_cast<gfx::DrawRoot*>(mpCurrent.get())->maRectangle = aRange;
         }
         break;
         case svgio::svgreader::SVGTokenG:
@@ -71,16 +68,44 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode)
 
             auto pRectangle
                 = std::make_shared<gfx::DrawRectangle>(basegfx::B2DRange(x, y, x + w, y + h));
+            pRectangle->mnRx = rRectNode.getRx().getNumber();
+            pRectangle->mnRy = rRectNode.getRy().getNumber();
+
+            pRectangle->mnStrokeWidth
+                = rRectNode.getSvgStyleAttributes()->getStrokeWidth().getNumber();
+
+            const basegfx::BColor* pFillColor = rRectNode.getSvgStyleAttributes()->getFill();
+            if (pFillColor)
+                pRectangle->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor);
+
+            const basegfx::BColor* pStrokeColor = rRectNode.getSvgStyleAttributes()->getStroke();
+            if (pStrokeColor)
+                pRectangle->mpStrokeColor = std::make_shared<basegfx::BColor>(*pStrokeColor);
+
             mpCurrent->maChildren.push_back(pRectangle);
         }
         break;
         case svgio::svgreader::SVGTokenPath:
         {
             auto const& rPathNode = static_cast<svgio::svgreader::SvgPathNode const&>(rNode);
+
             auto pPath = rPathNode.getPath();
             if (pPath)
             {
                 auto pDrawPath = std::make_shared<gfx::DrawPath>(*pPath);
+
+                pDrawPath->mnStrokeWidth
+                    = rPathNode.getSvgStyleAttributes()->getStrokeWidth().getNumber();
+
+                const basegfx::BColor* pFillColor = rPathNode.getSvgStyleAttributes()->getFill();
+                if (pFillColor)
+                    pDrawPath->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor);
+
+                const basegfx::BColor* pStrokeColor
+                    = rPathNode.getSvgStyleAttributes()->getStroke();
+                if (pStrokeColor)
+                    pDrawPath->mpStrokeColor = std::make_shared<basegfx::BColor>(*pStrokeColor);
+
                 mpCurrent->maChildren.push_back(pDrawPath);
             }
         }


More information about the Libreoffice-commits mailing list