void SvgStyleParser::parseColorStops(QGradient *gradient, const KoXmlElement &e) { QGradientStops stops; QColor c; for (KoXmlNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) { KoXmlElement stop = n.toElement(); if (stop.tagName() == "stop") { float offset; QString temp = stop.attribute("offset"); if (temp.contains('%')) { temp = temp.left(temp.length() - 1); offset = temp.toFloat() / 100.0; } else offset = temp.toFloat(); QString stopColorStr = stop.attribute("stop-color"); if (!stopColorStr.isEmpty()) { if (stopColorStr == "inherit") { stopColorStr = inheritedAttribute("stop-color", stop); } parseColor(c, stopColorStr); } else { // try style attr QString style = stop.attribute("style").simplified(); QStringList substyles = style.split(';', QString::SkipEmptyParts); for (QStringList::Iterator it = substyles.begin(); it != substyles.end(); ++it) { QStringList substyle = it->split(':'); QString command = substyle[0].trimmed(); QString params = substyle[1].trimmed(); if (command == "stop-color") parseColor(c, params); if (command == "stop-opacity") c.setAlphaF(params.toDouble()); } } QString opacityStr = stop.attribute("stop-opacity"); if (!opacityStr.isEmpty()) { if (opacityStr == "inherit") { opacityStr = inheritedAttribute("stop-opacity", stop); } c.setAlphaF(opacityStr.toDouble()); } stops.append(QPair<qreal, QColor>(offset, c)); } } if (stops.count()) gradient->setStops(stops); }
int main ( int argc, char* argv[] ) { Rose_STL_Container<std::string> l = CommandlineProcessing::generateArgListFromArgcArgv(argc,argv); if ( CommandlineProcessing::isOptionWithParameter(l, "-taurose:","(v|verbose)",verbose ,false)) { std::cerr << "Verbose logging enabled" << std::endl; verbose = 1; std::cerr << "Verbose: " << verbose << std::endl; } SgProject* project = frontend(l); ROSE_ASSERT (project != NULL); SgFile & localFile = project->get_file(0); localFile.get_file_info()->display("localFile information"); InheritedAttribute inheritedAttribute(0); visitorTraversal exampleTraversal; exampleTraversal.traverse(project,inheritedAttribute); return 0; }