From fcb00ac8ebe2acb429f09ef5b728b8c73a5bbc37 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Fri, 5 Apr 2019 12:52:58 +0900 Subject: support opacity for widget definition draw SVGs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This opacity influences the whole shape (stroke and fill). Change-Id: I82e10e07dbf2f321805b55a5f4831a513e52dab8 Reviewed-on: https://gerrit.libreoffice.org/70292 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- svgio/qa/cppunit/SvgRead.cxx | 4 +++- svgio/qa/cppunit/data/VisiotorTest-Rect.svg | 4 ++++ svgio/qa/cppunit/data/path.svg | 2 +- svgio/source/svgreader/svgvisitor.cxx | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 svgio/qa/cppunit/data/VisiotorTest-Rect.svg (limited to 'svgio') diff --git a/svgio/qa/cppunit/SvgRead.cxx b/svgio/qa/cppunit/SvgRead.cxx index cd81bfbddc39..45b0158a0240 100644 --- a/svgio/qa/cppunit/SvgRead.cxx +++ b/svgio/qa/cppunit/SvgRead.cxx @@ -74,7 +74,7 @@ uno::Reference TestParsing::parseSvg(const OUString& aSource) void TestParsing::testSimpleRectangle() { - OUString aSvgFile = "/svgio/qa/cppunit/data/Rect.svg"; + OUString aSvgFile = "/svgio/qa/cppunit/data/VisiotorTest-Rect.svg"; OUString aUrl = m_directories.getURLFromSrc(aSvgFile); OUString aPath = m_directories.getPathFromSrc(aSvgFile); @@ -102,6 +102,7 @@ void TestParsing::testSimpleRectangle() CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), sal_Int32(Color(*pDrawRect->mpStrokeColor))); CPPUNIT_ASSERT(bool(pDrawRect->mpFillColor)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00cc00), sal_Int32(Color(*pDrawRect->mpFillColor))); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, pDrawRect->mnOpacity, 1E-12); } void TestParsing::testPath() @@ -133,6 +134,7 @@ void TestParsing::testPath() CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), sal_Int32(Color(*pDrawPath->mpStrokeColor))); CPPUNIT_ASSERT(bool(pDrawPath->mpFillColor)); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x007aff), sal_Int32(Color(*pDrawPath->mpFillColor))); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, pDrawPath->mnOpacity, 1E-12); } CPPUNIT_TEST_SUITE_REGISTRATION(TestParsing); diff --git a/svgio/qa/cppunit/data/VisiotorTest-Rect.svg b/svgio/qa/cppunit/data/VisiotorTest-Rect.svg new file mode 100644 index 000000000000..4cd2d3602ea3 --- /dev/null +++ b/svgio/qa/cppunit/data/VisiotorTest-Rect.svg @@ -0,0 +1,4 @@ + + + + diff --git a/svgio/qa/cppunit/data/path.svg b/svgio/qa/cppunit/data/path.svg index 1722181c872e..559ceec6d557 100644 --- a/svgio/qa/cppunit/data/path.svg +++ b/svgio/qa/cppunit/data/path.svg @@ -1,3 +1,3 @@ - + diff --git a/svgio/source/svgreader/svgvisitor.cxx b/svgio/source/svgreader/svgvisitor.cxx index 7b92e2fd0afb..011ce5492fa3 100644 --- a/svgio/source/svgreader/svgvisitor.cxx +++ b/svgio/source/svgreader/svgvisitor.cxx @@ -74,6 +74,8 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode) pRectangle->mnStrokeWidth = rRectNode.getSvgStyleAttributes()->getStrokeWidth().getNumber(); + pRectangle->mnOpacity = rRectNode.getSvgStyleAttributes()->getOpacity().getNumber(); + const basegfx::BColor* pFillColor = rRectNode.getSvgStyleAttributes()->getFill(); if (pFillColor) pRectangle->mpFillColor = std::make_shared(*pFillColor); @@ -97,6 +99,8 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode) pDrawPath->mnStrokeWidth = rPathNode.getSvgStyleAttributes()->getStrokeWidth().getNumber(); + pDrawPath->mnOpacity = rPathNode.getSvgStyleAttributes()->getOpacity().getNumber(); + const basegfx::BColor* pFillColor = rPathNode.getSvgStyleAttributes()->getFill(); if (pFillColor) pDrawPath->mpFillColor = std::make_shared(*pFillColor); -- cgit