From 116c4c4853a080ff7210de2d4e999959c0c0e0ce Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 8 Feb 2017 13:09:58 +0100 Subject: Add naive selector validation on entry in style dialog. (bzr r15497) --- src/attribute-rel-svg.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/attribute-rel-svg.cpp') diff --git a/src/attribute-rel-svg.cpp b/src/attribute-rel-svg.cpp index afa578061..1f4bee1b3 100644 --- a/src/attribute-rel-svg.cpp +++ b/src/attribute-rel-svg.cpp @@ -27,6 +27,27 @@ SPAttributeRelSVG * SPAttributeRelSVG::instance = NULL; bool SPAttributeRelSVG::foundFile = false; +/* + * This function returns true if element is an SVG element. + */ +bool SPAttributeRelSVG::isSVGElement(Glib::ustring element) +{ + if (SPAttributeRelSVG::instance == NULL) { + SPAttributeRelSVG::instance = new SPAttributeRelSVG(); + } + + // Always valid if data file not found! + if( !foundFile ) return true; + + // Strip off "svg:" from the element's name + Glib::ustring temp = element; + if ( temp.find("svg:") != std::string::npos ) { + temp.erase( temp.find("svg:"), 4 ); + } + + return (SPAttributeRelSVG::instance->attributesOfElements.count(temp) > 0); +} + /* * This functions checks whether an element -> attribute pair is allowed or not */ @@ -39,7 +60,7 @@ bool SPAttributeRelSVG::findIfValid(Glib::ustring attribute, Glib::ustring eleme // Always valid if data file not found! if( !foundFile ) return true; - // Strip of "svg:" from the element's name + // Strip off "svg:" from the element's name Glib::ustring temp = element; if ( temp.find("svg:") != std::string::npos ) { temp.erase( temp.find("svg:"), 4 ); -- cgit v1.2.3