svgio/qa/cppunit/SvgImportTest.cxx            |   14 ++++++++++++++
 svgio/qa/cppunit/data/tdf150124.svg           |   12 ++++++++++++
 svgio/source/svgreader/svgdocumenthandler.cxx |    9 +++------
 svgio/source/svgreader/svgnode.cxx            |   14 ++------------
 4 files changed, 31 insertions(+), 18 deletions(-)

New commits:
commit a11ad45498ff2ff2b1698715114e5ea8eabdd609
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Jul 3 14:11:43 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jul 3 20:51:21 2023 +0200

    tdf#150124: do nothing when parent is of unkown type
    
    Change-Id: I745b2a81200b0d8138b5f1b844849f20571d9546
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153906
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 0af2cd35a96e..c2dad58de2de 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -135,6 +135,20 @@ CPPUNIT_TEST_FIXTURE(Test, testSymbol)
     assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#00d000");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf150124)
+{
+    Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf150124.svg");
+    CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+    drawinglayer::Primitive2dXmlDump dumper;
+    xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+    CPPUNIT_ASSERT (pDocument);
+
+    assertXPathChildren(pDocument, "/primitive2D", 1);
+    assertXPath(pDocument, "/primitive2D/hiddengeometry", 1);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf155819)
 {
     Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf155819.svg");
diff --git a/svgio/qa/cppunit/data/tdf150124.svg 
b/svgio/qa/cppunit/data/tdf150124.svg
new file mode 100644
index 000000000000..29b2a1e3fd46
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf150124.svg
@@ -0,0 +1,12 @@
+<svg id="svg-root" width="100%" height="100%"
+  viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg";
+  xmlns:xlink="http://www.w3.org/1999/xlink";>
+  <invented>
+  <rect id='r1' x='0' y='0' width='50' height='50' fill='red'/>
+  <g>
+    <rect id='r2' x='60' y='0' width='50' height='50' fill='green'/>
+  </g>
+  <circle id="myCircle" cx="50" cy="50" r="40" stroke="blue" />
+  </invented>
+  <use href="myCircle" x="20" fill="white" stroke="red" />
+</svg>
diff --git a/svgio/source/svgreader/svgdocumenthandler.cxx 
b/svgio/source/svgreader/svgdocumenthandler.cxx
index 7a313df98648..d95690e6f5d7 100644
--- a/svgio/source/svgreader/svgdocumenthandler.cxx
+++ b/svgio/source/svgreader/svgdocumenthandler.cxx
@@ -413,8 +413,7 @@ namespace
 
                 default:
                 {
-                    /// invalid token, ignore
-                    SAL_INFO( "svgio", "Unknown Base SvgToken <" + aName + "> 
(!)" );
+                    mpTarget = new SvgNode(SVGToken::Unknown, maDocument, 
mpTarget);
                     break;
                 }
             }
@@ -498,6 +497,8 @@ namespace
                 /// structural element pattern
                 case SVGToken::Pattern:
 
+                default:
+
                 /// content handling after parsing
                 {
                     if(mpTarget)
@@ -516,10 +517,6 @@ namespace
                     }
                     break;
                 }
-                default:
-                {
-                    /// invalid token, ignore
-                }
             }
 
             if(pSvgTitleDescNode && mpTarget)
diff --git a/svgio/source/svgreader/svgnode.cxx 
b/svgio/source/svgreader/svgnode.cxx
index 37b34deff0f6..d87c76d81e20 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -395,21 +395,11 @@ namespace {
             mbDecomposing(false),
             mbCssStyleVectorBuilt(false)
         {
-            OSL_ENSURE(SVGToken::Unknown != maType, "SvgNode with unknown type 
created (!)");
-
-            if(pParent)
+            // tdf#150124 ignore when parent is unknown
+            if(pParent && pParent->getType() != SVGToken::Unknown)
             {
                 pParent->maChildren.emplace_back(this);
             }
-            else
-            {
-#ifdef DBG_UTIL
-                if(SVGToken::Svg != getType())
-                {
-                    OSL_ENSURE(false, "No parent for this node (!)");
-                }
-#endif
-            }
         }
 
         SvgNode::~SvgNode()

Reply via email to