diff options
author | Joren De Cuyper <jorendc@libreoffice.org> | 2014-07-15 13:52:10 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2014-07-15 14:28:29 +0000 |
commit | 2dbd2cb9a55c90f4f3db3a781526cc2246d0bdd7 (patch) | |
tree | 2aea05301e9c0d5c168febd5994aee2960a49949 | |
parent | f634ec520fa9e8c3e7b1f0660c7a6561bdff2aaa (diff) |
Avoid infinite loop when gathering "g" element styles
Same way of how fdo#74743 is fixed 3b7472b284131c09d91b69f26d5d26d54648f939
Change-Id: If6cc8eb6ff89b0081f27ff75a9b60a3e81cff1bd
Reviewed-on: https://gerrit.libreoffice.org/10326
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | svgio/qa/cppunit/SvgImportTest.cxx | 3 | ||||
-rw-r--r-- | svgio/qa/cppunit/data/RectWithStylesByGroup.svg | 18 | ||||
-rw-r--r-- | svgio/source/svgreader/svggnode.cxx | 8 |
3 files changed, 28 insertions, 1 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 23fcf904e01b..a5e5e17835d9 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -82,6 +82,9 @@ void Test::testStyles() Primitive2DSequence maSequenceRectWithParentStyle = parseSvg("/svgio/qa/cppunit/data/RectWithParentStyles.svg"); CPPUNIT_ASSERT_EQUAL(1, (int) maSequenceRectWithParentStyle.getLength()); + Primitive2DSequence maSequenceRectWithStylesByGroup = parseSvg("/svgio/qa/cppunit/data/RectWithStylesByGroup.svg"); + CPPUNIT_ASSERT_EQUAL(1, (int) maSequenceRectWithStylesByGroup.getLength()); + // TODO: Test if the 3 sequences are equal.. //const Primitive2DReference xReference(maSequenceRect[0]); } diff --git a/svgio/qa/cppunit/data/RectWithStylesByGroup.svg b/svgio/qa/cppunit/data/RectWithStylesByGroup.svg new file mode 100644 index 000000000000..6fefdf2f53f2 --- /dev/null +++ b/svgio/qa/cppunit/data/RectWithStylesByGroup.svg @@ -0,0 +1,18 @@ +<?xml version="1.0" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" + "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" + width="10cm" height="5cm" viewBox="0 0 1000 500"> + <defs> + <style type="text/css"><![CDATA[ + g { + fill: red; + stroke: blue; + stroke-width: 3 + } + ]]></style> + </defs> +<g> + <rect x="200" y="100" width="600" height="300"/> +</g> +</svg> diff --git a/svgio/source/svgreader/svggnode.cxx b/svgio/source/svgreader/svggnode.cxx index 82d3d5d124f2..45fa6a31ec53 100644 --- a/svgio/source/svgreader/svggnode.cxx +++ b/svgio/source/svgreader/svggnode.cxx @@ -43,7 +43,13 @@ namespace svgio const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const { - return checkForCssStyle(OUString("g"), maSvgStyleAttributes); + const SvgStyleAttributes* aCheckCssStyle = checkForCssStyle(OUString("g"), maSvgStyleAttributes); + const SvgStyleAttributes* aGetCssStyleParent = maSvgStyleAttributes.getCssStyleParent(); + + if (aGetCssStyleParent == NULL) + return aCheckCssStyle; + + return aGetCssStyleParent; } void SvgGNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) |