[Libreoffice-commits] core.git: 2 commits - svgio/qa vcl/source vcl/uiconfig
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Mar 7 07:34:49 UTC 2019
svgio/qa/cppunit/SvgRead.cxx | 65 ++++++++++---
svgio/qa/cppunit/data/path.svg | 3
vcl/source/gdi/WidgetDefinitionReader.cxx | 25 +++--
vcl/uiconfig/theme_definitions/definition.xml | 129 ++++++++++++++------------
4 files changed, 141 insertions(+), 81 deletions(-)
New commits:
commit 0b25b7a8b29468c0b83a1114da4640625f60a06d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Mar 3 21:32:43 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Mar 7 08:34:31 2019 +0100
Make definition state attribute default to "any"
...and remove all the "any" from definition.xml
Change-Id: I8a91129c89255c83c1c2f975bf9acb710b664efc
Reviewed-on: https://gerrit.libreoffice.org/68828
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/source/gdi/WidgetDefinitionReader.cxx b/vcl/source/gdi/WidgetDefinitionReader.cxx
index 8a7270e718f1..52f15823cf02 100644
--- a/vcl/source/gdi/WidgetDefinitionReader.cxx
+++ b/vcl/source/gdi/WidgetDefinitionReader.cxx
@@ -55,6 +55,13 @@ bool readColor(OString const& rString, Color& rColor)
return true;
}
+OString getValueOrAny(OString const& rInputString)
+{
+ if (rInputString.isEmpty())
+ return "any";
+ return rInputString;
+}
+
ControlPart xmlStringToControlPart(OString const& sPart)
{
if (sPart.equalsIgnoreAsciiCase("NONE"))
@@ -308,16 +315,14 @@ void WidgetDefinitionReader::readPart(tools::XmlWalker& rWalker,
{
if (rWalker.name() == "state")
{
- OString sEnabled = rWalker.attribute("enabled");
- OString sFocused = rWalker.attribute("focused");
- OString sPressed = rWalker.attribute("pressed");
- OString sRollover = rWalker.attribute("rollover");
- OString sDefault = rWalker.attribute("default");
- OString sSelected = rWalker.attribute("selected");
- OString sButtonValue = rWalker.attribute("button-value");
- OString sExtra = rWalker.attribute("extra");
- if (sExtra.isEmpty())
- sExtra = "any";
+ OString sEnabled = getValueOrAny(rWalker.attribute("enabled"));
+ OString sFocused = getValueOrAny(rWalker.attribute("focused"));
+ OString sPressed = getValueOrAny(rWalker.attribute("pressed"));
+ OString sRollover = getValueOrAny(rWalker.attribute("rollover"));
+ OString sDefault = getValueOrAny(rWalker.attribute("default"));
+ OString sSelected = getValueOrAny(rWalker.attribute("selected"));
+ OString sButtonValue = getValueOrAny(rWalker.attribute("button-value"));
+ OString sExtra = getValueOrAny(rWalker.attribute("extra"));
std::shared_ptr<WidgetDefinitionState> pState = std::make_shared<WidgetDefinitionState>(
sEnabled, sFocused, sPressed, sRollover, sDefault, sSelected, sButtonValue, sExtra);
diff --git a/vcl/uiconfig/theme_definitions/definition.xml b/vcl/uiconfig/theme_definitions/definition.xml
index d12161d6081c..6b5f85fd9bb8 100644
--- a/vcl/uiconfig/theme_definitions/definition.xml
+++ b/vcl/uiconfig/theme_definitions/definition.xml
@@ -54,12 +54,23 @@
<fontColor value="#000000"/>
</style>
+ <!-- <state> attributes:
+ enabled="any"
+ focused="any"
+ pressed="any"
+ rollover="any"
+ default="any"
+ selected="any"
+ button-value="any"
+ extra="any"
+ -->
+
<pushbutton>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<external source="pushbutton-default.svgx" />
</state>
- <state enabled="true" focused="any" pressed="any" rollover="true" default="any" selected="any" button-value="any">
+ <state enabled="true" rollover="true">
<external source="pushbutton-rollover.svgx" />
</state>
</part>
@@ -67,22 +78,22 @@
<radiobutton>
<part value="Entire">
- <state enabled="true" focused="any" pressed="false" rollover="any" default="any" selected="any" button-value="true">
+ <state enabled="true" pressed="false" button-value="true">
<image source="tick-on.svgx" />
</state>
- <state enabled="true" focused="any" pressed="true" rollover="any" default="any" selected="any" button-value="true">
+ <state enabled="true" pressed="true" button-value="true">
<image source="tick-on-pressed.svgx" />
</state>
- <state enabled="false" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="true">
+ <state enabled="false" button-value="true">
<image source="tick-on-disabled.svgx" />
</state>
- <state enabled="true" focused="any" pressed="false" rollover="any" default="any" selected="any" button-value="false">
+ <state enabled="true" pressed="false" button-value="false">
<image source="tick-off.svgx" />
</state>
- <state enabled="true" focused="any" pressed="true" rollover="any" default="any" selected="any" button-value="false">
+ <state enabled="true" pressed="true" button-value="false">
<image source="tick-off-pressed.svgx" />
</state>
- <state enabled="false" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="false">
+ <state enabled="false" button-value="false">
<image source="tick-on-disabled.svgx" />
</state>
</part>
@@ -90,22 +101,22 @@
<checkbox>
<part value="Entire">
- <state enabled="true" focused="any" pressed="false" rollover="any" default="any" selected="any" button-value="true">
+ <state enabled="true" pressed="false" button-value="true">
<image source="switch-on.svgx" />
</state>
- <state enabled="true" focused="any" pressed="true" rollover="any" default="any" selected="any" button-value="true">
+ <state enabled="true" pressed="true" button-value="true">
<image source="switch-on-pressed.svgx" />
</state>
- <state enabled="false" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="true">
+ <state enabled="false" button-value="true">
<image source="switch-on-disabled.svgx" />
</state>
- <state enabled="true" focused="any" pressed="false" rollover="any" default="any" selected="any" button-value="false">
+ <state enabled="true" pressed="false" button-value="false">
<image source="switch-off.svgx" />
</state>
- <state enabled="true" focused="any" pressed="true" rollover="any" default="any" selected="any" button-value="false">
+ <state enabled="true" pressed="true" button-value="false">
<image source="switch-off-pressed.svgx" />
</state>
- <state enabled="false" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="false">
+ <state enabled="false" button-value="false">
<image source="switch-on-disabled.svgx" />
</state>
</part>
@@ -113,22 +124,22 @@
<combobox>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<external source="spinbox-entire.svgx" />
</state>
</part>
<part value="SubEdit">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
</state>
</part>
<part value="ButtonUp">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<line stroke="#C7C7C7" stroke-width="4" x1="0.2" y1="0.6" x2="0.5" y2="0.4"/>
<line stroke="#C7C7C7" stroke-width="4" x1="0.5" y1="0.4" x2="0.8" y2="0.6"/>
</state>
</part>
<part value="ButtonDown">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<line stroke="#C7C7C7" stroke-width="4" x1="0.2" y1="0.4" x2="0.5" y2="0.6"/>
<line stroke="#C7C7C7" stroke-width="4" x1="0.5" y1="0.6" x2="0.8" y2="0.4"/>
</state>
@@ -137,7 +148,7 @@
<editbox>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#FFFFFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1" />
<line stroke="#C7C7C7" stroke-width="2" x1="0.0" y1="0.9" x2="1.0" y2="0.9"/>
</state>
@@ -146,28 +157,28 @@
<listbox>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1" />
</state>
</part>
<part value="ListboxWindow">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1" />
</state>
</part>
<part value="Focus">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#007AFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1" />
</state>
</part>
<part value="ButtonUp">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<line stroke="#007AFF" stroke-width="4" x1="0.2" y1="0.6" x2="0.5" y2="0.4"/>
<line stroke="#007AFF" stroke-width="4" x1="0.5" y1="0.4" x2="0.8" y2="0.6"/>
</state>
</part>
<part value="ButtonDown">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<line stroke="#007AFF" stroke-width="4" x1="0.2" y1="0.4" x2="0.5" y2="0.6"/>
<line stroke="#007AFF" stroke-width="4" x1="0.5" y1="0.6" x2="0.8" y2="0.4"/>
</state>
@@ -176,17 +187,17 @@
<spinbox>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<external source="spinbox-entire.svgx" />
</state>
</part>
<part value="ButtonDown">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<external source="spinbox-left.svgx" />
</state>
</part>
<part value="ButtonUp">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<external source="spinbox-right.svgx" />
</state>
</part>
@@ -194,13 +205,13 @@
<scrollbar>
<part value="ThumbHorz">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#C7C7C7" fill="#C7C7C7" stroke-width="1" />
<line stroke="#007AFF" stroke-width="5" x1="0.01" y1="0.5" x2="0.99" y2="0.5"/>
</state>
</part>
<part value="ThumbVert">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#C7C7C7" fill="#C7C7C7" stroke-width="1" />
<line stroke="#007AFF" stroke-width="5" x1="0.5" y1="0.01" x2="0.5" y2="0.99"/>
</state>
@@ -214,22 +225,22 @@
<part value="ButtonRight">
</part>
<part value="TrackHorzLeft">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#C7C7C7" fill="#C7C7C7" stroke-width="1" />
</state>
</part>
<part value="TrackHorzRight">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#C7C7C7" fill="#C7C7C7" stroke-width="1" />
</state>
</part>
<part value="TrackVertUpper">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#C7C7C7" fill="#C7C7C7" stroke-width="1" />
</state>
</part>
<part value="TrackVertLower">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#C7C7C7" fill="#C7C7C7" stroke-width="1" />
</state>
</part>
@@ -237,17 +248,17 @@
<slider>
<part value="Button">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<circ stroke="#AAAAAA" fill="#FFFFFF" stroke-width="1" rx="7" ry="7"/>
</state>
</part>
<part value="TrackHorzArea">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<line stroke="#007AFF" fill="#007AFF" stroke-width="10" x1="0.0" y1="0.5" x2="1.0" y2="0.5"/>
</state>
</part>
<part value="TrackVertArea">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<line stroke="#007AFF" fill="#007AFF" stroke-width="10" x1="0.5" y1="0.0" x2="0.5" y2="1.0"/>
</state>
</part>
@@ -255,12 +266,12 @@
<fixedline>
<part value="SeparatorHorz">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<line stroke="#007AFF" fill="#007AFF" stroke-width="2" x1="0.0" y1="0.5" x2="1.0" y2="0.5"/>
</state>
</part>
<part value="SeparatorVert">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<line stroke="#007AFF" fill="#007AFF" stroke-width="2" x1="0.5" y1="0.0" x2="0.5" y2="1.0"/>
</state>
</part>
@@ -268,7 +279,7 @@
<progress>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#007AFF" fill="#007AFF" stroke-width="1" rx="7" ry="7"/>
</state>
</part>
@@ -276,22 +287,22 @@
<tabitem>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="false" button-value="any" extra="first">
+ <state selected="false" extra="first">
<external source="tabitem-first.svgx" />
</state>
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="false" button-value="any" extra="middle">
+ <state selected="false" extra="middle">
<external source="tabitem-middle.svgx" />
</state>
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="false" button-value="any" extra="last">
+ <state selected="false" extra="last">
<external source="tabitem-last.svgx" />
</state>
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="true" button-value="any" extra="first">
+ <state selected="true" extra="first">
<external source="tabitem-first-selected.svgx" />
</state>
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="true" button-value="any" extra="middle">
+ <state selected="true" extra="middle">
<external source="tabitem-middle-selected.svgx" />
</state>
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="true" button-value="any" extra="last">
+ <state selected="true" extra="last">
<external source="tabitem-last-selected.svgx" />
</state>
</part>
@@ -299,7 +310,7 @@
<tabheader>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#FFFFFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
@@ -307,7 +318,7 @@
<tabpane>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#FFFFFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
@@ -315,7 +326,7 @@
<tabbody>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#FFFFFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
@@ -323,12 +334,12 @@
<windowbackground>
<part value="BackgroundWindow">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#FF0000" fill="#FF0000" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="BackgroundDialog">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#0000FF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
@@ -336,12 +347,12 @@
<frame>
<part value="Entire">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#00FF00" fill="#00FF00" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="Border">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#00FF00" fill="#00FF00" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
@@ -349,43 +360,43 @@
<toolbar>
<part value="DrawBackgroundHorz">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#FFFFFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="DrawBackgroundVert">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#FFFFFF" fill="#FFFFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="ThumbHorz">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#00FFFF" fill="#00FFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="ThumbVert">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#00FFFF" fill="#00FFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="SeparatorVert">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#00FFFF" fill="#00FFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="SeparatorHorz">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#00FFFF" fill="#00FFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
<part value="Button">
- <state enabled="any" focused="any" pressed="any" rollover="any" default="any" selected="any" button-value="any">
+ <state>
<rect stroke="#00FFFF" fill="#00FFFF" stroke-width="1" rx="1" ry="1"/>
</state>
</part>
commit 208a6896958b5281c11875b5c57806ca2daa9118
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun Mar 3 14:05:35 2019 +0100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Mar 7 08:34:22 2019 +0100
Update SvgRead test - add new parameters and path parsing
Change-Id: Ic19bd2167cc359eef02648fa0ebd1d858fdeaec5
Reviewed-on: https://gerrit.libreoffice.org/68827
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/svgio/qa/cppunit/SvgRead.cxx b/svgio/qa/cppunit/SvgRead.cxx
index 3c7974794e1b..996be9d21f08 100644
--- a/svgio/qa/cppunit/SvgRead.cxx
+++ b/svgio/qa/cppunit/SvgRead.cxx
@@ -40,23 +40,26 @@
#include <svggnode.hxx>
#include <basegfx/DrawCommands.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
namespace
{
using namespace css;
-class Test : public test::BootstrapFixture
+class TestParsing : public test::BootstrapFixture
{
- void test();
+ void testSimpleRectangle();
+ void testPath();
uno::Reference<io::XInputStream> parseSvg(const OUString& aSource);
public:
- CPPUNIT_TEST_SUITE(Test);
- CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE(TestParsing);
+ CPPUNIT_TEST(testSimpleRectangle);
+ CPPUNIT_TEST(testPath);
CPPUNIT_TEST_SUITE_END();
};
-uno::Reference<io::XInputStream> Test::parseSvg(const OUString& aSource)
+uno::Reference<io::XInputStream> TestParsing::parseSvg(const OUString& aSource)
{
SvFileStream aFileStream(aSource, StreamMode::READ);
std::size_t nSize = aFileStream.remainingSize();
@@ -70,7 +73,7 @@ uno::Reference<io::XInputStream> Test::parseSvg(const OUString& aSource)
return aInputStream;
}
-void Test::test()
+void TestParsing::testSimpleRectangle()
{
OUString aSvgFile = "/svgio/qa/cppunit/data/Rect.svg";
OUString aUrl = m_directories.getURLFromSrc(aSvgFile);
@@ -84,18 +87,56 @@ void Test::test()
uno::Any aAny = xSvgParser->getDrawCommands(xStream, aPath);
CPPUNIT_ASSERT(aAny.has<sal_uInt64>());
- gfx::DrawRoot* pDrawRoot = reinterpret_cast<gfx::DrawRoot*>(aAny.get<sal_uInt64>());
+ auto* pDrawRoot = reinterpret_cast<gfx::DrawRoot*>(aAny.get<sal_uInt64>());
+
+ basegfx::B2DRange aSurfaceRectangle(0, 0, 120, 120);
CPPUNIT_ASSERT_EQUAL(size_t(1), pDrawRoot->maChildren.size());
- CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(0, 0, 120, 120), pDrawRoot->maRectangle);
+ CPPUNIT_ASSERT_EQUAL(aSurfaceRectangle, pDrawRoot->maRectangle);
+ auto* pDrawBase = pDrawRoot->maChildren[0].get();
CPPUNIT_ASSERT_EQUAL(gfx::DrawCommandType::Rectangle, pDrawRoot->maChildren[0]->getType());
- CPPUNIT_ASSERT_EQUAL(
- basegfx::B2DRange(10, 10, 110, 110),
- static_cast<gfx::DrawRectangle*>(pDrawRoot->maChildren[0].get())->maRectangle);
+ auto* pDrawRect = static_cast<gfx::DrawRectangle*>(pDrawBase);
+ CPPUNIT_ASSERT_EQUAL(basegfx::B2DRange(10, 10, 110, 110), pDrawRect->maRectangle);
+ CPPUNIT_ASSERT_EQUAL(3.0, pDrawRect->mnStrokeWidth);
+ CPPUNIT_ASSERT(bool(pDrawRect->mpStrokeColor));
+ 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)));
+}
+
+void TestParsing::testPath()
+{
+ OUString aSvgFile = "/svgio/qa/cppunit/data/path.svg";
+ OUString aUrl = m_directories.getURLFromSrc(aSvgFile);
+ OUString aPath = m_directories.getPathFromSrc(aSvgFile);
+
+ uno::Reference<io::XInputStream> xStream = parseSvg(aUrl);
+ CPPUNIT_ASSERT(xStream.is());
+
+ uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
+ const uno::Reference<graphic::XSvgParser> xSvgParser = graphic::SvgTools::create(xContext);
+
+ uno::Any aAny = xSvgParser->getDrawCommands(xStream, aPath);
+ CPPUNIT_ASSERT(aAny.has<sal_uInt64>());
+ auto* pDrawRoot = reinterpret_cast<gfx::DrawRoot*>(aAny.get<sal_uInt64>());
+
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pDrawRoot->maChildren.size());
+
+ auto* pDrawBase = pDrawRoot->maChildren[0].get();
+ CPPUNIT_ASSERT_EQUAL(gfx::DrawCommandType::Path, pDrawBase->getType());
+ auto* pDrawPath = static_cast<gfx::DrawPath*>(pDrawBase);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("m1 1h42v24h-42v-24z"),
+ basegfx::utils::exportToSvgD(pDrawPath->maPolyPolygon, true, true, false));
+ CPPUNIT_ASSERT_EQUAL(0.0, pDrawPath->mnStrokeWidth);
+ CPPUNIT_ASSERT(bool(pDrawPath->mpStrokeColor));
+ 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_TEST_SUITE_REGISTRATION(Test);
+CPPUNIT_TEST_SUITE_REGISTRATION(TestParsing);
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/svgio/qa/cppunit/data/path.svg b/svgio/qa/cppunit/data/path.svg
new file mode 100644
index 000000000000..1722181c872e
--- /dev/null
+++ b/svgio/qa/cppunit/data/path.svg
@@ -0,0 +1,3 @@
+<svg width="44" height="26" xmlns="http://www.w3.org/2000/svg">
+ <path d="M1 1 H 43 V 25 H 1 L 1 1 Z" fill="#007aff" stroke="#fff" stroke-width="0"/>
+</svg>
More information about the Libreoffice-commits
mailing list