mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added handy new function parseXMLIfTagMatches(), and refactored a lot of old code that was parsing XML in a more clunky way
This commit is contained in:
parent
3b36c3e198
commit
0fb8c8e82a
20 changed files with 130 additions and 148 deletions
|
|
@ -1702,24 +1702,13 @@ std::unique_ptr<Drawable> Drawable::createFromSVG (const XmlElement& svgDocument
|
|||
return {};
|
||||
|
||||
SVGState state (&svgDocument);
|
||||
return std::unique_ptr<Drawable> (state.parseSVGElement (SVGState::XmlPath (&svgDocument, nullptr)));
|
||||
return std::unique_ptr<Drawable> (state.parseSVGElement (SVGState::XmlPath (&svgDocument, {})));
|
||||
}
|
||||
|
||||
std::unique_ptr<Drawable> Drawable::createFromSVGFile (const File& svgFile)
|
||||
{
|
||||
XmlDocument doc (svgFile);
|
||||
|
||||
if (auto outer = doc.getDocumentElement (true))
|
||||
{
|
||||
if (outer->hasTagName ("svg"))
|
||||
{
|
||||
if (auto svgDocument = doc.getDocumentElement())
|
||||
{
|
||||
SVGState state (svgDocument.get(), svgFile);
|
||||
return std::unique_ptr<Drawable> (state.parseSVGElement (SVGState::XmlPath (svgDocument.get(), nullptr)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (auto xml = parseXMLIfTagMatches (svgFile, "svg"))
|
||||
return createFromSVG (*xml);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue