void StyleReader::styleStyle(const QXmlAttributes& attrs) { QString name = ""; QString listName = NULL; bool setDefaultStyle = false; bool isParaStyle = false; bool create = true; if (!defaultStyleCreated) { gtParagraphStyle* pstyle = new gtParagraphStyle(*(writer->getDefaultStyle())); pstyle->setDefaultStyle(true); currentStyle = dynamic_cast<gtStyle*>(pstyle); currentStyle->setName("default-style"); setDefaultStyle = true; defaultStyleCreated = true; parentStyle = currentStyle; } for (int i = 0; i < attrs.count(); ++i) { if (attrs.localName(i) == "style:family") { if (attrs.value(i) == "paragraph") { isParaStyle = true; readProperties = true; } else if (attrs.value(i) == "text") { isParaStyle = false; readProperties = true; } else { readProperties = false; return; } } else if (attrs.localName(i) == "style:name") name = attrs.value(i); else if (attrs.localName(i) == "style:parent-style-name") { if (styles.contains(attrs.value(i))) parentStyle = styles[attrs.value(i)]; else parentStyle = NULL; } else if (attrs.localName(i) == "style:list-style-name") listName = attrs.value(i); } if ((parentStyle == NULL) && (styles.contains("default-style"))) parentStyle = styles["default-style"]; if (create) { if (parentStyle == NULL) { parentStyle = new gtStyle("tmp-parent"); } if (isParaStyle) { gtParagraphStyle *tmpP; if (parentStyle->target() == "paragraph") { tmpP = dynamic_cast<gtParagraphStyle*>(parentStyle); assert(tmpP != NULL); gtParagraphStyle* tmp = new gtParagraphStyle(*tmpP); // tmp->setAutoLineSpacing(true); currentStyle = tmp; } else { gtParagraphStyle* tmp = new gtParagraphStyle(*parentStyle); // tmp->setAutoLineSpacing(true); currentStyle = tmp; } if (!listName.isNull()) { listParents[listName] = currentStyle; } } else currentStyle = new gtStyle(*parentStyle); currentStyle->setName(name); if (setDefaultStyle) { gtParagraphStyle* tmp = dynamic_cast<gtParagraphStyle*>(currentStyle); if (tmp) tmp->setDefaultStyle(true); } } else currentStyle = NULL; }
virtual bool startElement(const QString &namespaceURI, const QString &, const QString &qName, const QXmlAttributes &attrs) { kdDebug(26001) << "SVGFragmentSearcher::startElement, namespaceURI " << namespaceURI << ", qName " << qName << endl; bool parse = m_result; if(!parse) { int pos = attrs.index("id"); if(pos > -1 && attrs.value(pos) == m_id) parse = true; } if(parse) { DOM::Element impl = static_cast<DOM::Document *>(m_doc)->createElementNS(namespaceURI, qName); SVGElementImpl *newElement = SVGDocumentImpl::createElement(qName, impl, m_doc); newElement->setViewportElement(m_doc->rootElement()); if(m_currentNode) m_currentNode->appendChild(*newElement); else m_result = newElement; QXmlAttributes newAttrs; for(int i = 0; i < attrs.count(); i++) { QString name = attrs.localName(i); QString value = attrs.value(i); if(name == "id") { value = "@fragment@" + m_url.prettyURL() + "@" + value; m_idMap[value] = newElement; } else if(name == "href") { value.stripWhiteSpace(); if(value.startsWith("#")) { value.remove(0, 1); // Convert the id to its mangled version. QString id = "@fragment@" + m_url.prettyURL() + "@" + value; if(m_idMap.contains(id)) { // This is a local reference to an element within the fragment. // Just convert the href. value = id; } else { // This is a local reference to an id outside of the fragment. // Change it into an absolute href. value = m_url.prettyURL() + "#" + value; } } } newAttrs.append(attrs.qName(i), attrs.uri(i), attrs.localName(i), value); } newElement->setAttributes(newAttrs); m_currentNode = newElement; } return true; }
bool SketchXMLHandler::startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts) { if (qName == "sketch") { std::cerr << "[SketchXML] XML Version: " << atts.value("version").toStdString() << std::endl; } else if (qName == "project") { std::cerr << "[SketchXML] Project Version: " << atts.value("version").toStdString() << std::endl; } else if (qName == "theme") { if (InNode.top() == "colorTheme") { std::string hexval = atts.value("rgb").toStdString(); std::uint8_t* color = new std::uint8_t[4]; std::vector<std::string> hexgroups; std::string tmpstr = ""; char tmpstrcnt = 0; std::for_each(hexval.begin(), hexval.end(), [&](char chr){ if (chr == '#') return; else { tmpstr += chr; tmpstrcnt += 1; if (tmpstrcnt == 2) { hexgroups.insert(hexgroups.end(), tmpstr); tmpstr = ""; tmpstrcnt = 0; } } }); for (int i = 0; i < 3; i++) { unsigned long rawval = std::strtoul(hexgroups[i].c_str(), nullptr, 16); color[i] = char(rawval); } color[3] = 255; std::uint8_t cmindex = atoi(atts.value("id").toStdString().c_str()); ColorMap.insert(ColorMap.cend(), std::vector<std::uint8_t>()); ColorMap[cmindex].insert(ColorMap[cmindex].cend(), color[0]); ColorMap[cmindex].insert(ColorMap[cmindex].cend(), color[1]); ColorMap[cmindex].insert(ColorMap[cmindex].cend(), color[2]); ColorMap[cmindex].insert(ColorMap[cmindex].cend(), color[3]); //QT Creator doesn't handle std::hex that well std::cerr << "[SXML-ColorMap] Added color " << int(cmindex) << " with RGBA " << hexval << "FF" << std::endl; } } else if (qName == "shape") { if (InNode.top() == "shapes") { FlowNode fnode; std::vector<std::uint8_t> tmpkeep = ColorMap[atoi(atts.value("color").toStdString().c_str())]; fnode.ColorRGBA[0] = tmpkeep[0]; fnode.ColorRGBA[1] = tmpkeep[1]; fnode.ColorRGBA[2] = tmpkeep[2]; fnode.ColorRGBA[3] = tmpkeep[3]; fnode.Type = (NodeType)atoi(atts.value("kind").toStdString().c_str()); CurrentNodeID = atts.value("guid"); fnode.GUID = CurrentNodeID.toStdString(); fnode.FontSizeMult = 0.75 + (double(atoi(atts.value("fontSize").toStdString().c_str())) * 0.25); OrphanNodes[CurrentNodeID.toStdString()] = fnode; } } else if (qName == "center") { if (InNode.top() == "shape") { FlowNode fnode = OrphanNodes[CurrentNodeID.toStdString()]; fnode.CenterPosX = atts.value("x").toDouble(); fnode.CenterPosY = atts.value("y").toDouble(); OrphanNodes[CurrentNodeID.toStdString()] = fnode; } } else if (qName == "link") { if (InNode.top() == "links") { if (nodelinkmap.count(atts.value("parentShape").toStdString()) == 0) { nodelinkmap[atts.value("parentShape").toStdString()] = std::vector<std::string>(); } nodelinkmap[atts.value("parentShape").toStdString()].insert( nodelinkmap[atts.value("parentShape").toStdString()].cend(), atts.value("childShape").toStdString()); } } else if (qName == "sideLink") { if (InNode.top() == "sideLinks") { if (nodelinkmap.count(atts.value("backShape").toStdString()) == 0) { nodelinkmap[atts.value("backShape").toStdString()] = std::vector<std::string>(); } nodelinkmap[atts.value("backShape").toStdString()].insert( nodelinkmap[atts.value("backShape").toStdString()].cend(), atts.value("sideShape").toStdString()); } } InNode.push(qName); return true; }
void onTrackListStart(const QXmlAttributes& attrs) { m_dlg.m_vAlbums.back().m_nTrackCount = attrs.value("count").toInt(); }
bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, const QString &localName, const QString &/*qName*/, const QXmlAttributes &atts) { if(namespaceURI != QString::fromLatin1("http://www.w3.org/XML/2004/xml-schema-test-suite/")) return true; if (localName == QLatin1String("testSet")) { m_currentTestSet = new TestGroup(m_topLevelGroup); Q_ASSERT(m_currentTestSet); m_currentTestSet->setTitle(atts.value("name")); m_topLevelGroup->appendChild(m_currentTestSet); } else if (localName == QLatin1String("testGroup")) { m_currentTestGroup = new TestGroup(m_currentTestSet); Q_ASSERT(m_currentTestGroup); m_currentTestGroup->setTitle(atts.value("name")); m_currentTestSet->appendChild(m_currentTestGroup); m_inTestGroup = true; } else if (localName == QLatin1String("schemaTest")) { if (m_blackList.contains(atts.value("name"))) { m_currentTestCase = 0; m_schemaBlacklisted = true; return true; } m_schemaBlacklisted = false; m_currentTestCase = new XSDTSTestCase(TestCase::Standard, m_currentTestGroup, XSDTSTestCase::SchemaTest); Q_ASSERT(m_currentTestCase); m_counter++; m_currentTestCase->setName(QString::number(m_counter) + atts.value("name")); m_currentTestGroup->appendChild(m_currentTestCase); m_currentTestCase->setParent(m_currentTestGroup); m_inSchemaTest = true; } else if (localName == QLatin1String("instanceTest")) { if (m_schemaBlacklisted) { m_currentTestCase = 0; return true; } m_currentTestCase = new XSDTSTestCase(TestCase::Standard, m_currentTestGroup, XSDTSTestCase::InstanceTest); Q_ASSERT(m_currentTestCase); m_counter++; m_currentTestCase->setName(QString::number(m_counter) + atts.value("name")); m_currentTestGroup->appendChild(m_currentTestCase); m_inInstanceTest = true; } else if (localName == QLatin1String("schemaDocument") || localName == QLatin1String("instanceDocument")) { if (m_inSchemaTest) { m_currentTestCase->setSchemaUri(QUrl(atts.value("xlink:href"))); if (m_currentSchemaLink.isEmpty()) // we only use the first schema document for validation m_currentSchemaLink = atts.value("xlink:href"); } if (m_inInstanceTest) { m_currentTestCase->setInstanceUri(QUrl(atts.value("xlink:href"))); m_currentTestCase->setSchemaUri(QUrl(m_currentSchemaLink)); } } else if (localName == QLatin1String("expected") && (m_inSchemaTest || m_inInstanceTest)) { TestBaseLine *baseLine = new TestBaseLine(TestBaseLine::SchemaIsValid); if (atts.value("validity") == QLatin1String("valid")) { baseLine->setDetails(QLatin1String("true")); m_currentTestCase->setName(m_currentTestCase->name() + QLatin1String(" tokoe:valid")); } else { baseLine->setDetails(QLatin1String("false")); m_currentTestCase->setName(m_currentTestCase->name() + QLatin1String(" tokoe:invalid")); } m_currentTestCase->addBaseLine(baseLine); } else if (localName == QLatin1String("documentation") && m_inTestGroup) { m_inDescription = true; } return true; }
void TestSuiteResult::toXML(XMLWriter &receiver) const { /* If this data needs to be configurable in someway(say, another * XML format is supported), then break out the info into getters(alternatively, combined * with setters, or that the class is subclassed), and access the getters instead. */ const QString organizationName (QLatin1String("K Desktop Environment(KDE)")); const QString organizationWebsite (QLatin1String("http://www.kde.org/")); const QString submittorName (QLatin1String("Frans Englich")); const QString submittorEmail (QLatin1String("*****@*****.**")); const QString implementationVersion (QLatin1String("0.1")); const QString implementationName (QLatin1String("Patternist")); const QString implementationDescription (QLatin1String( "Patternist is an implementation written in C++ " "and with the Qt/KDE libraries. " "It is licensed under GNU LGPL and part of KDE, " "the K Desktop Environment.")); /* Not currently serialized: * - <implementation-defined-items> * - <features> * - <context-properties> */ receiver.startDocument(); /* <test-suite-result> */ receiver.startPrefixMapping(QString(), Global::xqtsResultNS); receiver.startElement(QLatin1String("test-suite-result")); receiver.endPrefixMapping(QString()); /* <implementation> */ QXmlAttributes implementationAtts; implementationAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), implementationName); implementationAtts.append(QLatin1String("version"), QString(), QLatin1String("version"), implementationVersion); receiver.startElement(QLatin1String("implementation"), implementationAtts); /* <organization> */ QXmlAttributes organizationAtts; organizationAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), organizationName); organizationAtts.append(QLatin1String("website"), QString(), QLatin1String("website"), organizationWebsite); receiver.startElement(QLatin1String("organization"), organizationAtts); /* </organization> */ receiver.endElement(QLatin1String("organization")); /* <submittor> */ QXmlAttributes submittorAtts; submittorAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), submittorName); submittorAtts.append(QLatin1String("email"), QString(), QLatin1String("email"), submittorEmail); receiver.startElement(QLatin1String("submittor"), submittorAtts); /* </submittor> */ receiver.endElement(QLatin1String("submittor")); /* <description> */ receiver.startElement(QLatin1String("description")); /* <p> */ receiver.startElement(QLatin1String("p")); receiver.characters(implementationDescription); /* </p> */ receiver.endElement(QLatin1String("p")); /* </description> */ receiver.endElement(QLatin1String("description")); /* </implementation> */ receiver.endElement(QLatin1String("implementation")); /* <syntax> */ receiver.startElement(QLatin1String("syntax")); receiver.characters(QLatin1String(QLatin1String("XQuery"))); /* </syntax> */ receiver.endElement(QLatin1String("syntax")); /* <test-run> */ QXmlAttributes test_runAtts; test_runAtts.append(QLatin1String("dateRun"), QString(), QLatin1String("dateRun"), m_runDate.toString(QLatin1String("yyyy-MM-dd"))); receiver.startElement(QLatin1String("test-run"), test_runAtts); /* <test-suite> */ QXmlAttributes test_suiteAtts; test_suiteAtts.append(QLatin1String("version"), QString(), QLatin1String("version"), m_testSuiteVersion); receiver.startElement(QLatin1String("test-suite"), test_suiteAtts); /* </test-suite> */ receiver.endElement(QLatin1String("test-suite")); /* </test-run> */ receiver.endElement(QLatin1String("test-run")); /* Serialize the TestResults: tons of test-case elements. */ const TestResult::List::const_iterator end(m_results.constEnd()); TestResult::List::const_iterator it(m_results.constBegin()); for(; it != end; ++it) (*it)->toXML(receiver); /* </test-suite-result> */ receiver.endElement(QLatin1String("test-suite-result")); receiver.endDocument(); }
void onRelationListStart(const QXmlAttributes& attrs) { m_bTargetIsUrl = "Url" == attrs.value("target-type"); }
void startCompound( const QXmlAttributes& attrib ) { m_curString = ""; QString kind = attrib.value("kind"); QString isObjC = attrib.value("objc"); if (kind=="class") { m_curClass = new TagClassInfo; m_curClass->kind = TagClassInfo::Class; m_state = InClass; } else if (kind=="struct") { m_curClass = new TagClassInfo; m_curClass->kind = TagClassInfo::Struct; m_state = InClass; } else if (kind=="union") { m_curClass = new TagClassInfo; m_curClass->kind = TagClassInfo::Union; m_state = InClass; } else if (kind=="interface") { m_curClass = new TagClassInfo; m_curClass->kind = TagClassInfo::Interface; m_state = InClass; } else if (kind=="exception") { m_curClass = new TagClassInfo; m_curClass->kind = TagClassInfo::Exception; m_state = InClass; } else if (kind=="protocol") { m_curClass = new TagClassInfo; m_curClass->kind = TagClassInfo::Protocol; m_state = InClass; } else if (kind=="category") { m_curClass = new TagClassInfo; m_curClass->kind = TagClassInfo::Category; m_state = InClass; } else if (kind=="file") { m_curFile = new TagFileInfo; m_state = InFile; } else if (kind=="namespace") { m_curNamespace = new TagNamespaceInfo; m_state = InNamespace; } else if (kind=="group") { m_curGroup = new TagGroupInfo; m_state = InGroup; } else if (kind=="page") { m_curPage = new TagPageInfo; m_state = InPage; } else if (kind=="package") { m_curPackage = new TagPackageInfo; m_state = InPackage; } else if (kind=="dir") { m_curDir = new TagDirInfo; m_state = InDir; } else { warn("Warning: Unknown compound attribute `%s' found!\n",kind.data()); } if (isObjC=="yes" && m_curClass) { m_curClass->isObjC = TRUE; } }
void startDocAnchor(const QXmlAttributes& attrib ) { m_fileName = attrib.value("file"); m_curString = ""; }
bool KWord13Parser::startElement(const QString&, const QString&, const QString& name, const QXmlAttributes& attributes) { kDebug(30520) << indent << "<" << name << ">"; // DEBUG indent += '*'; //DEBUG if (parserStack.isEmpty()) { kError(30520) << "Stack is empty!! Aborting! (in KWordParser::startElement)"; return false; } // Create a new stack element copying the top of the stack. KWord13StackItem *stackItem = new KWord13StackItem(*parserStack.current()); if (!stackItem) { kError(30520) << "Could not create Stack Item! Aborting! (in StructureParser::startElement)"; return false; } stackItem->itemName = name; bool success = false; // Order of element names: probability in a document if (name == "COLOR" || name == "FONT" || name == "SIZE" || name == "WEIGHT" || name == "ITALIC" || name == "UNDERLINE" || name == "STRIKEOUT" || name == "VERTALIGN" || name == "SHADOW" || name == "FONTATTRIBUTE" || name == "LANGUAGE" || name == "TEXTBACKGROUNDCOLOR" || name == "OFFSETFROMBASELINE") { success = startElementFormatOneProperty(name, attributes, stackItem); } else if (name == "FLOW" || name == "INDENTS" || name == "OFFSETS" || name == "LINESPACING" || name == "PAGEBREAKING" || name == "LEFTBORDER" || name == "RIGHTBORDER" || name == "FOLLOWING" || name == "TOPBORDER" || name == "BOTTOMBORDER" || name == "COUNTER") { success = startElementLayoutProperty(name, attributes, stackItem); } else if (name == "TEXT") { if (stackItem->elementType == KWord13TypeParagraph && m_currentParagraph) { stackItem->elementType = KWord13TypeText; m_currentParagraph->setText(QString()); } else { stackItem->elementType = KWord13TypeIgnore; } success = true; } else if (name == "NAME") { success = startElementName(name, attributes, stackItem); } else if (name == "FORMATS") { if (stackItem->elementType == KWord13TypeParagraph && m_currentParagraph) { stackItem->elementType = KWord13TypeFormatsPlural; } else { stackItem->elementType = KWord13TypeIgnore; } success = true; } else if (name == "PARAGRAPH") { success = startElementParagraph(name, attributes, stackItem); } else if (name == "FORMAT") { success = startElementFormat(name, attributes, stackItem); } else if (name == "LAYOUT") { success = startElementLayout(name, attributes, stackItem); } else if (name == "TYPE") { // ### TEMPORARY if (m_currentFormat && (stackItem->elementType == KWord13TypeVariable)) { ((KWord13FormatFour*) m_currentFormat) -> m_text = attributes.value("text"); } success = true; } else if (name == "KEY") { success = startElementKey(name, attributes, stackItem); } else if (name == "ANCHOR") { success = startElementAnchor(name, attributes, stackItem); } else if (name == "PICTURE" || name == "IMAGE" || name == "CLIPART") { // ### TODO: keepAspectRatio (but how to transform it to OASIS) if (stackItem->elementType == KWord13TypePictureFrameset) { stackItem->elementType = KWord13TypePicture; } success = true; } else if (name == "FRAME") { success = startElementFrame(name, attributes, stackItem); } else if (name == "FRAMESET") { success = startElementFrameset(name, attributes, stackItem); } else if (name == "STYLE") { success = startElementLayout(name, attributes, stackItem); } else if (name == "DOC") { success = startElementDocumentAttributes(name, attributes, stackItem, KWord13TypeBottom, KWord13TypeDocument); } else if (name == "PAPER") { success = startElementDocumentAttributes(name, attributes, stackItem, KWord13TypeDocument, KWord13TypePaper); } else if (name == "PAPERBORDERS") { success = startElementDocumentAttributes(name, attributes, stackItem, KWord13TypePaper, KWord13TypeEmpty); } else if ((name == "ATTRIBUTES") || (name == "VARIABLESETTINGS") || (name == "FOOTNOTESETTINGS") || (name == "ENDNOTESETTINGS")) { success = startElementDocumentAttributes(name, attributes, stackItem, KWord13TypeDocument, KWord13TypeEmpty); } else if (name == "FRAMESTYLE") { // ### TODO, but some of the <STYLE> children are also children of <FRAMESTYLE>, so we have to set it to "ignore" stackItem->elementType = KWord13TypeIgnore; success = true; } else if (name == "PICTURES" || name == "PIXMAPS" || name == "CLIPARTS") { // We just need a separate "type" for the <KEY> children stackItem->elementType = KWord13TypePicturesPlural; success = true; } else { stackItem->elementType = KWord13TypeUnknown; success = true; } if (success) { parserStack.push(stackItem); } else { // We have a problem so destroy our resources. delete stackItem; } return success; }
bool TupPaletteParser::startTag(const QString &tag, const QXmlAttributes &atts) { if (root() == "Palette") { if (tag == root()) { k->paletteName = atts.value("name"); if (atts.value("editable") == "true") k->isEditable = true; else k->isEditable = false; } else if (tag == "Color") { QColor c = QColor(atts.value("colorName")); c.setAlpha( atts.value("alpha").toInt() ); if (c.isValid()) { k->brushes << c; } else { #ifdef K_DEBUG QString msg = "TupPaletteParser::startTag() - Error: Invalid color!"; #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif } } else if (tag == "Gradient") { if (k->gradient) delete k->gradient; k->gradient = 0; k->gradientStops.clear(); QGradient::Type type = QGradient::Type(atts.value("type").toInt()); QGradient::Spread spread = QGradient::Spread(atts.value("spread").toInt()); switch (type) { case QGradient::LinearGradient: { k->gradient = new QLinearGradient(atts.value("startX").toDouble(), atts.value("startY").toDouble(),atts.value("finalX").toDouble(), atts.value("finalY").toDouble()); } break; case QGradient::RadialGradient: { k->gradient = new QRadialGradient(atts.value("centerX").toDouble(), atts.value("centerY").toDouble(), atts.value("radius").toDouble(), atts.value("focalX").toDouble(),atts.value("focalY").toDouble() ); } break; case QGradient::ConicalGradient: { k->gradient = new QConicalGradient(atts.value("centerX").toDouble(), atts.value("centerY").toDouble(),atts.value("angle").toDouble()); } break; default: { #ifdef K_DEBUG QString msg = "TupPaletteParser::startTag() - No gradient type: " + QString::number(type); #ifdef Q_OS_WIN32 qDebug() << msg; #else tFatal() << msg; #endif #endif } break; } k->gradient->setSpread(spread); } else if (tag == "Stop") { QColor c(atts.value("colorName") ); c.setAlpha(atts.value("alpha").toInt()); // k->gradientStops << qMakePair(atts.value("value").toDouble(), c); k->gradientStops << qMakePair((qreal)(atts.value("value").toDouble()), c); } } return true; }
bool KWord13Parser::startElementFrameset(const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem) { Q_UNUSED(name); const QString frameTypeStr(attributes.value("frameType")); const QString frameInfoStr(attributes.value("frameInfo")); if (frameTypeStr.isEmpty() || frameInfoStr.isEmpty()) { kError(30520) << "<FRAMESET> without frameType or frameInfo attribute!"; return false; } const int frameType = frameTypeStr.toInt(); const int frameInfo = frameInfoStr.toInt(); if (frameType == 1) { stackItem->elementType = KWord13TypeFrameset; KWordTextFrameset* frameset = new KWordTextFrameset(frameType, frameInfo, attributes.value("name")); // Normal text frame (in or outside a table) if ((!frameInfo) && attributes.value("grpMgr").isEmpty()) { m_kwordDocument->m_normalTextFramesetList.append(frameset); stackItem->m_currentFrameset = m_kwordDocument->m_normalTextFramesetList.current(); } else if (!frameInfo) { // We just store the frameset in the frameset table list // Grouping the framesets by table will be done after the parsing, not now. m_kwordDocument->m_tableFramesetList.append(frameset); stackItem->m_currentFrameset = m_kwordDocument->m_tableFramesetList.current(); } else if (frameInfo >= 1 && frameInfo <= 6) { m_kwordDocument->m_headerFooterFramesetList.append(frameset); stackItem->m_currentFrameset = m_kwordDocument->m_headerFooterFramesetList.current(); } else if (frameInfo == 7) { m_kwordDocument->m_footEndNoteFramesetList.append(frameset); stackItem->m_currentFrameset = m_kwordDocument->m_footEndNoteFramesetList.current(); } else { kError(30520) << "Unknown text frameset!"; m_kwordDocument->m_otherFramesetList.append(frameset); stackItem->m_currentFrameset = m_kwordDocument->m_otherFramesetList.current(); } } else if ((frameType == 2) // picture or image || (frameType == 5)) { // ciipart if (!frameInfo) { kWarning(30520) << "Unknown FrameInfo for pictures: " << frameInfo; } stackItem->elementType = KWord13TypePictureFrameset; KWord13PictureFrameset* frameset = new KWord13PictureFrameset(frameType, frameInfo, attributes.value("name")); m_kwordDocument->m_otherFramesetList.append(frameset); stackItem->m_currentFrameset = m_kwordDocument->m_otherFramesetList.current(); } // ### frameType == 6 : horizontal line (however KWord did not save it correctly) // ### frameType == 4 : formula // ### frametype == 3 : embedded (but only in <SETTINGS>) else { // Frame of unknown/unsupported type kWarning(30520) << "Unknown/unsupported <FRAMESET> type! Type: " << frameTypeStr << " Info: " << frameInfoStr; stackItem->elementType = KWord13TypeUnknownFrameset; KWord13Frameset* frameset = new KWord13Frameset(frameType, frameInfo, attributes.value("name")); m_kwordDocument->m_otherFramesetList.append(frameset); stackItem->m_currentFrameset = m_kwordDocument->m_otherFramesetList.current(); } return true; }
bool MappingsHandler::startElement(const QString& /* namespaceURI */, const QString& localName, const QString& /* qName */, const QXmlAttributes& attr) { if(localName == "define"){ /* 変数初期化 */ m_code = 0; m_mask = 0; m_mapcode = 0; m_unicode = 0; m_mapmodifiers.clear(); m_mapunicodes.clear(); for(int i=0; i<attr.length(); i++){ if(attr.localName(i).lower() == "key"){ /* keyname */ m_code = KeyNames::getCode(attr.value(i)); } else if(attr.localName(i).lower() == "code"){ /* keycode */ m_code = KHUtil::hex2int(attr.value(i).lower()); } } } else if(localName == "modifier"){ /* modifier keys */ for(int i=0; i<attr.length(); i++){ if(attr.value(i).lower() == "on"){ m_mask |= m_pModifiers->getMask(attr.localName(i)); } } } else if(localName == "map"){ /* mapping key */ for(int i=0; i<attr.length(); i++){ if(attr.localName(i).lower() == "key"){ /* keyname */ m_mapcode = KeyNames::getCode(attr.value(i)); } else if(attr.localName(i).lower() == "code"){ /* keycode */ m_mapcode = KHUtil::hex2int(attr.value(i).lower()); } } } else if(localName == "map_modifier"){ /* mapping modifiers */ for(int i=0; i<attr.length(); i++){ m_mapmodifiers[attr.localName(i)] = attr.value(i); } } else if(localName == "map_unicode"){ /* mapping unicodes */ for(int i=0; i<attr.length(); i++){ if(attr.localName(i).lower() == "char"){ /* unicode char */ m_unicode = attr.value(i)[0].unicode(); } else if(attr.localName(i).lower() == "code"){ /* unicode code */ m_unicode = KHUtil::hex2int(attr.value(i).lower()); } else { m_mapunicodes[attr.localName(i)] = attr.value(i); } } } return(true); }
bool StyleReader::startElement(const QString&, const QString&, const QString &name, const QXmlAttributes &attrs) { if (name == "style:default-style") defaultStyle(attrs); else if (name == "style:paragraph-properties" || name == "style:text-properties" || name == "style:list-level-properties") styleProperties(attrs); else if (name == "style:style") styleStyle(attrs); else if (name == "style:tab-stop") tabStop(attrs); else if (name == "text:list-style") { for (int i = 0; i < attrs.count(); ++i) if (attrs.localName(i) == "style:name") currentList = attrs.value(i); currentListStyle = new ListStyle(currentList); inList = true; } else if (((name == "text:list-level-style-bullet") || (name == "text:list-level-style-number") || (name == "text:list-level-style-image")) && (inList)) { BulletType bstyle = Bullet; QString prefix = ""; QString suffix = ""; QString bullet = "-"; uint ulevel = 0; uint displayLevels = 1; uint startAt = 0; QString level = ""; for (int i = 0; i < attrs.count(); ++i) { if (attrs.localName(i) == "text:level") { ulevel = QString(attrs.value(i)).toUInt(); gtStyle *plist; if (attrs.value(i) == "1") { plist = listParents[currentList]; } else { int level = (attrs.value(i)).toInt(); --level; plist = styles[QString(currentList + "_%1").arg(level)]; } gtParagraphStyle *pstyle; if (plist == NULL) { if (styles.contains("default-style")) plist = new gtStyle(*(styles["default-style"])); else { gtParagraphStyle* pstyle = new gtParagraphStyle(*(writer->getDefaultStyle())); pstyle->setDefaultStyle(true); plist = dynamic_cast<gtStyle*>(pstyle); } } if (plist->target() == "paragraph") { pstyle = dynamic_cast<gtParagraphStyle*>(plist); assert(pstyle != NULL); gtParagraphStyle* tmp = new gtParagraphStyle(*pstyle); currentStyle = tmp; } else { gtParagraphStyle* tmp = new gtParagraphStyle(*plist); currentStyle = tmp; } currentStyle->setName(currentList + "_" + attrs.value(i)); } else if (attrs.localName(i) == "style:num-prefix") prefix = attrs.value(i); else if (attrs.localName(i) == "style:num-suffix") suffix = attrs.value(i); else if (attrs.localName(i) == "text:bullet-char") bullet = attrs.value(i); else if (attrs.localName(i) == "style:num-format") { QString tmp = attrs.value(i); if (tmp == "i") bstyle = LowerRoman; else if (tmp == "I") bstyle = UpperRoman; else if (tmp == "a") bstyle = LowerAlpha; else if (tmp == "A") bstyle = UpperAlpha; else if (tmp == "1") bstyle = Number; } else if (attrs.localName(i) == "text:start-value") { startAt = QString(attrs.value(i)).toUInt(); if (startAt > 0) --startAt; } else if (attrs.localName(i) == "text:display-levels") { displayLevels = QString(attrs.value(i)).toUInt(); if (displayLevels == 0) displayLevels = 1; } } if (bstyle == Bullet) { prefix = ""; suffix = ""; } ListLevel *llevel = new ListLevel(ulevel, bstyle, prefix, suffix, bullet, displayLevels, startAt); currentListStyle->addLevel(ulevel, llevel); readProperties = true; gtParagraphStyle* s = dynamic_cast<gtParagraphStyle*>(currentStyle); assert(s != NULL); if (bstyle == Bullet || bstyle == Graphic) { s->setBullet(true, bullet); } else { Q_ASSERT(((int) bstyle > 0) && ((int) bstyle < 6)); s->setNum(true, (int) bstyle -1, ulevel, startAt+1, prefix, suffix); } } else if ((name == "style:drop-cap") && (readProperties)) { if (currentStyle->target() == "paragraph") { for (int i = 0; i < attrs.count(); ++i) { if (attrs.localName(i) == "style:lines") { bool ok = false; QString sd = attrs.value(i); int dh = sd.toInt(&ok); if (ok) { gtParagraphStyle* s = dynamic_cast<gtParagraphStyle*>(currentStyle); assert(s != NULL); s->setDropCapHeight(dh); s->setDropCap(true); } } } } } else if (name == "style:font-face") { QString key = ""; QString family = ""; QString style = ""; for (int i = 0; i < attrs.count(); ++i) { if (attrs.localName(i) == "style:name") key = attrs.value(i); else if (attrs.localName(i) == "svg:font-family") { family = attrs.value(i); family = family.remove("'"); } else if (attrs.localName(i) == "style:font-style-name") style += attrs.value(i) + " "; } QString name = family + " " + style; name = name.simplified(); fonts[key] = name; } return true; }
bool XMLReader::startElement(const QString &, const QString &localName, const QString &, const QXmlAttributes &attributes) { if (localName == "arthur" ) { QString engineName = attributes.value("engine"); QString defaultStr = attributes.value("default"); QString foreignStr = attributes.value("foreign"); QString referenceStr = attributes.value("reference"); QString genDate = attributes.value("generationDate"); engine = new XMLEngine(engineName, defaultStr == "true"); engine->foreignEngine = (foreignStr == "true"); engine->referenceEngine = (referenceStr == "true"); if (!genDate.isEmpty()) engine->generationDate = QDateTime::fromString(genDate); else engine->generationDate = QDateTime::currentDateTime(); } else if (localName == "suite") { QString suiteName = attributes.value("dir"); suite = new XMLSuite(suiteName); } else if (localName == "file") { QString testName = attributes.value("name"); QString outputName = attributes.value("output"); file = new XMLFile(testName, outputName); } else if (localName == "data") { QString dateStr = attributes.value("date"); QString timeStr = attributes.value("time_to_render"); QString itrStr = attributes.value("iterations"); QString detailsStr = attributes.value("details"); QString maxElapsedStr = attributes.value("maxElapsed"); QString minElapsedStr = attributes.value("minElapsed"); XMLData data(dateStr, timeStr.toInt(), (!itrStr.isEmpty())?itrStr.toInt():1); data.details = detailsStr; if (maxElapsedStr.isEmpty()) data.maxElapsed = data.timeToRender; else data.maxElapsed = maxElapsedStr.toInt(); if (minElapsedStr.isEmpty()) data.minElapsed = data.timeToRender; else data.minElapsed = minElapsedStr.toInt(); file->data.append(data); } else { qDebug()<<"Error while parsing element :"<<localName; return false; } return true; }
bool TypeRuleParser::startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts) { Q_UNUSED(namespaceURI); Q_UNUSED(qName); // Save current element so that we know where the characters() belong to QString name(localName.toLower()); // Is this a known element? if (!schema().knownElement(name)) { QStringList chdn = schema().children(_elems.top()); typeRuleErrorLoc(QString("Element \"%1\" is unknown. Allowed " "elements in this context are: %2") .arg(name) .arg(chdn.isEmpty() ? QString("(none)") : chdn.join(", "))); } // Is this an allowed children of this element? if (!schema().allowedChild(_elems.top(), name)) { QStringList chdn = schema().children(_elems.top()); typeRuleErrorLoc(QString("Element \"%1\" not allowed here. Allowed " "elements in this context are: %2") .arg(name) .arg(chdn.isEmpty() ? QString("(none)") : chdn.join(", "))); } const XmlElement& elem = schema().element(name); static const KeyValueStore osFilterAttr = OsFilter::supportedFilters(); OsFilter* osf = 0; QString attr; KeyValueStore attributes; // Check the element's attributes for (int i = 0; i < atts.count(); ++i) { // Compare attributes case-insensitive attr = atts.localName(i).toLower(); // Is the attribute known to OsFilter? if (osFilterAttr.contains(attr)) { // Create a new OS filter, if not yet done if (!osf) { // Are OS filters allowed here? if (!elem.optionalAttributes.contains(attr)) typeRuleErrorLoc(QString("Operating system filters are not " "allowed for element \"%1\".") .arg(name)); // Create new filter based on the stack top (if exists) osf = _osfStack.isEmpty() ? new OsFilter() : new OsFilter(*_osfStack.top().osf); _osfStack.push(OsFilterScope(name, osf)); } osf->parseOption(attr, atts.value(i)); } else if (!elem.optionalAttributes.contains(attr) && !elem.requiredAttributes.contains(attr)) { QStringList list(elem.requiredAttributes); list.append(elem.optionalAttributes); typeRuleErrorLoc(QString("Unknown attribute \"%1\" for element \"%2\". " "Allowed attributes are: %3") .arg(attr) .arg(name) .arg(list.isEmpty() ? QString("(none)") : list.join(", "))); } else { attributes[attr] = atts.value(i); if (attr == xml::priority) { bool ok; int prio = atts.value(i).toInt(&ok); if (!ok) typeRuleErrorLoc(QString("Not a valid integer number: %1") .arg(atts.value(i))); _priorities.push(PriorityScope(name, prio)); } } } // Did we find all required attributes? for (int i = 0; i < elem.requiredAttributes.size(); ++i) { if (atts.index(elem.requiredAttributes[i]) < 0) typeRuleErrorLoc(QString("Element \"%1\" requires attribute \"%2\" " "to be specified.") .arg(name) .arg(elem.requiredAttributes[i])); } // Check if the OS filter is same if (osf) { if (!osf->minVersion().isEmpty() && !osf->maxVersion().isEmpty() && OsFilter::compareVersions(osf->minVersion(), osf->maxVersion()) > 0) { typeRuleErrorLoc(QString("Within element \"%0\": min. OS version " "is larger than max. version: %1 > %2") .arg(name) .arg(osf->minVersion().join(".")) .arg(osf->maxVersion().join("."))); } } // Check if we have multiple elements of that name in current scope if (!elem.allowMultiple && _children.top().contains(name)) { typeRuleErrorLoc(QString("Only one element \"%1\" is allowed here.") .arg(name)); } // <typeknowledge> if (name == xml::typeknowledge) { // Parse the version bool ok; float ver = atts.value(xml::version).toFloat(&ok); if (!ok) typeRuleErrorLoc(QString("Non-numeric version specified: %1") .arg(atts.value(xml::version))); // Print a warning if version is newer than the current one if (ver > xml::currentVer) Console::warnMsg(QString("The rule file \"%1\" has version %2, our " "version is %3.") .arg(ShellUtil::shortFileName(_reader->currFile())) .arg(ver) .arg(xml::currentVer)); } // <rule> else if (name == xml::rule) { _rule = new TypeRule(); _rule->setSrcLine(_locator ? _locator->lineNumber() : -1); } // <filter> else if (name == xml::filter) _filter = new InstanceFilter(); // <action> else if (name == xml::action) { errorIfNull(_rule); TypeRuleAction::ActionType type = TypeRuleAction::strToActionType(attributes[xml::type]); TypeRuleAction* action = 0; switch (type) { case TypeRuleAction::atExpression: action = new ExpressionAction(); break; case TypeRuleAction::atFunction: if (!attributes.contains(xml::file)) { typeRuleErrorLoc(QString("Action type \"%1\" in attribute \"%2\" " "requires the file name to be specified " "in the additional attribute \"%3\" in " "element \"%4\".") .arg(attributes[xml::type]) .arg(xml::type) .arg(xml::file) .arg(name)); } action = new FuncCallScriptAction(); break; case TypeRuleAction::atInlineCode: action = new ProgramScriptAction(); break; default: { typeRuleErrorLoc(QString("Unknown action type '%1', must be one " "of: %2") .arg(attributes[xml::type]) .arg(TypeRuleAction::supportedActionTypes().join(", "))); } } action->setSrcLine(_locator ? _locator->lineNumber() : 0); _rule->setAction(action); } // Clear old data _cdata.clear(); // Push element and attributes onto stack _elems.push(name); _attributes.push(attributes); _children.top().insert(name); _children.push(QSet<QString>()); return true; }
void QWbXmlReader::parseElementBody() { QString name; QXmlAttributes attrs; bool hasAttrs; bool hasContent; while ( d->tokenType != QWbXmlToken_EOF) { switch ( d->tokenType ) { case QWbXmlToken_Tag: { name = d->tokenValue; hasAttrs = !d->tagMode; hasContent = d->hasContent; nextToken(); attrs.clear(); if ( hasAttrs ) parseAttributes( attrs ); d->contentHandler->startElement ( QString(), name, name, attrs ); if ( hasContent ) parseElementBody(); d->contentHandler->endElement( QString(), name, name ); } break; case QWbXmlToken_EndTag: { nextToken(); return; } // Not reached. case QWbXmlToken_PI: { nextToken(); attrs.clear(); parseAttributes( attrs ); if ( attrs.length() > 0 ) { d->contentHandler->processingInstruction ( attrs.localName(0), attrs.value(0) ); } } break; case QWbXmlToken_String: { d->contentHandler->characters( d->tokenValue ); nextToken(); } break; default: { nextToken(); } break; } } }
bool MyMoneyXmlContentHandler::startElement(const QString& /* namespaceURI */, const QString& /* localName */, const QString& qName, const QXmlAttributes & atts) { if (m_level == 0) { QString s = qName.toLower(); if (s == "transaction" || s == "account" || s == "price" || s == "payee" || s == "tag" || s == "currency" || s == "security" || s == "keyvaluepairs" || s == "institution" || s == "report" || s == "budget" || s == "fileinfo" || s == "user" || s == "scheduled_tx" || s == "onlinejob") { m_baseNode = m_doc.createElement(qName); for (int i = 0; i < atts.count(); ++i) { m_baseNode.setAttribute(atts.qName(i), atts.value(i)); } m_currNode = m_baseNode; m_level = 1; } else if (s == "transactions") { qDebug("reading transactions"); if (atts.count()) { int count = atts.value(QLatin1String("count")).toInt(); m_reader->signalProgress(0, count, i18n("Loading transactions...")); m_elementCount = 0; } } else if (s == "accounts") { qDebug("reading accounts"); if (atts.count()) { int count = atts.value(QLatin1String("count")).toInt(); m_reader->signalProgress(0, count, i18n("Loading accounts...")); m_elementCount = 0; } } else if (s == "securities") { qDebug("reading securities"); if (atts.count()) { int count = atts.value(QLatin1String("count")).toInt(); m_reader->signalProgress(0, count, i18n("Loading securities...")); m_elementCount = 0; } } else if (s == "currencies") { qDebug("reading currencies"); if (atts.count()) { int count = atts.value(QLatin1String("count")).toInt(); m_reader->signalProgress(0, count, i18n("Loading currencies...")); m_elementCount = 0; } } else if (s == "reports") { qDebug("reading reports"); if (atts.count()) { int count = atts.value(QLatin1String("count")).toInt(); m_reader->signalProgress(0, count, i18n("Loading reports...")); m_elementCount = 0; } } else if (s == "prices") { qDebug("reading prices"); if (atts.count()) { int count = atts.value(QLatin1String("count")).toInt(); m_reader->signalProgress(0, count, i18n("Loading prices...")); m_elementCount = 0; } } else if (s == "pricepair") { if (atts.count()) { m_reader->d->m_fromSecurity = atts.value(QLatin1String("from")); m_reader->d->m_toSecurity = atts.value(QLatin1String("to")); } } } else { m_level++; QDomElement node = m_doc.createElement(qName); for (int i = 0; i < atts.count(); ++i) { node.setAttribute(atts.qName(i), atts.value(i)); } m_currNode.appendChild(node); m_currNode = node; } return true; }
void onRelStart(const QXmlAttributes& attrs) { CB_ASSERT (m_albumInfo.m_strId == convStr(attrs.value("id"))); }
// // startElement() is called at the beginning of an XML element. // Dispatch control using the element name. Handle an element-specific // attributes. Set-up state variables to handle the contents of the // element as the XML parse proceeds. // bool CDCConfig::startElement( const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts) { Q_UNUSED(namespaceURI); Q_UNUSED(localName); QString elementName = qName.lower() ; if ( elementName == "ebp" ) { ///////////////////////////////////////////////////////// // <ebp> Read and store event-based profiling parameters ///////////////////////////////////////////////////////// #ifdef _DEBUG assert( !atts.value("name").isNull() ) ; assert( !atts.value("mux_period").isNull() ) ; #endif m_configType = DCConfigEBP ; // Use the default name when configuration name is missing if (! atts.value("name").isNull()) { m_configName = atts.value("name") ; } m_multiplexPeriod = atts.value("mux_period").toInt(0, 10) ; } else if ( elementName == "event" ) { ///////////////////////////////////////////////////////// // <event> Read and store // event parameters in the last event group on list ///////////////////////////////////////////////////////// #ifdef _DEBUG assert( !atts.value("select").isNull() ) ; assert( !atts.value("mask").isNull() ) ; assert( !atts.value("os").isNull() ) ; assert( !atts.value("user").isNull() ) ; assert( !atts.value("count").isNull() ) ; // "edge_detect" is an optional attribute // "host" is an optional attribute // "guest" is an optional attribute #endif // Retrieve and store EBP-related attribute values PerfEvent e; e.setSelect(atts.value("select").toUInt(0, 16)); e.setUmask(atts.value("mask").toUInt(0, 16)); e.setOs("T" == atts.value("os").upper()); e.setUsr("T" == atts.value("user").upper()); if (! atts.value("edge_detect").isNull()) e.setEdge("T" == atts.value("edge_detect").upper()); if (! atts.value("host").isNull()) e.setHost("T" == atts.value("host").upper()); if (! atts.value("guest").isNull()) e.setGuest("T" == atts.value("guest").upper()); e.count = atts.value("count").toULong(0, 10) ; /* // TODO: Suravee: Need to change this to support non-AMD events if (m_pEventsFile) { CpuEvent ce; m_pEventsFile->findEventByValue(e.select, ce); e.opName = ce.op_name; } */ m_eventContainer.add(e); } else if ( elementName == "tool_tip" ) { ///////////////////////////////////////////////////////// // <tool_tip> Set the current tooltip string to empty ///////////////////////////////////////////////////////// m_toolTip = "" ; m_toolTipIsOpen = true ; } else if ( elementName == "description" ) { ///////////////////////////////////////////////////////// // <description> Set the current description string to empty ///////////////////////////////////////////////////////// m_description = "" ; m_descriptionIsOpen = true ; } else if ( elementName == "tbp" ) { ///////////////////////////////////////////////////////// // <tbp> time-based profiling configuration parameters ///////////////////////////////////////////////////////// #ifdef _DEBUG assert( !atts.value("name").isNull() ) ; assert( !atts.value("interval").isNull() ) ; #endif m_configType = DCConfigTBP ; // if (atts.value("name").isNull()) m_xmlSemanticError = true ; // Use the default name when configuration name is missing if (! atts.value("name").isNull()) { m_configName = atts.value("name") ; } m_interval = atts.value("interval").toFloat(0) ; } else if ( elementName == "tbp_perf" ) { ///////////////////////////////////////////////////////// // <tbp> PERF time-based profiling configuration parameters ///////////////////////////////////////////////////////// #ifdef _DEBUG assert( !atts.value("name").isNull() ) ; assert( !atts.value("interval").isNull() ) ; #endif m_configType = DCConfigTBPPerf ; // if (atts.value("name").isNull()) m_xmlSemanticError = true ; // Use the default name when configuration name is missing if (! atts.value("name").isNull()) { m_configName = atts.value("name") ; } m_interval = atts.value("interval").toFloat(0) ; } else if ( elementName == "dc_configuration" ) { ///////////////////////////////////////////////////////// // <dc_configuration> ///////////////////////////////////////////////////////// #ifdef _DEBUG assert( !atts.value("cpu_type").isNull() ) ; #endif m_cpuType = atts.value("cpu_type") ; if (m_cpuType.isEmpty()) { // Use current cpu_type if not specified. m_cpuType = getCurrentCpuType(); if (m_cpuType.isEmpty()) { // TODO: Should be handled better fprintf(stderr,"Cannot determine cpu_type for DC Configuration.\n"); return false; } } // TODO: Suravee: Work on this. // SetupEventsFile(m_cpuType); } else if ( elementName == "group" ) { // Ignore this (older DC Config file). } else { // Unrecognized element name return( false ) ; } return( true ) ; }
void onRelStart(const QXmlAttributes& attrs) { m_dlg.m_vAlbums.push_back(MusicBrainzAlbumInfo()); m_dlg.m_vAlbums.back().m_strId = convStr(attrs.value("id")); }
bool ObjectXMLReader::ObjectXMLFileHandler::startElement(const QString & namespaceURI,const QString & localName,const QString & qName,const QXmlAttributes & atts) { //for each item encountered, collect the name and create the object. Then set its scene printf("Start:%s\n",qName.toLatin1().constData()); if (qName.compare("plane")==0) { string name; int i=0; bool found = false; while ((i<atts.count()) && (!found)) { if (atts.qName(i).compare("name")==0) { name = atts.value(i).toLatin1().constData(); found = true; } i++; } obj = new Plane(name); obj->setScene(scene); } else if (qName.compare("sphere")==0) { string name; int i=0; bool found = false; while ((i<atts.count()) && (!found)) { if (atts.qName(i).compare("name")==0) { name = atts.value(i).toLatin1().constData(); found = true; } i++; } obj = new Sphere(name); obj->setScene(scene); } else if (qName.compare("cylinder")==0) { //In the case of the cylinder, handle the inner radius QString inner; float inner_radius; int i=0; bool found = false; while ((i<atts.count()) && (!found)) { if (atts.qName(i).compare("inner")==0) { inner = atts.value(i); found = true; } i++; } if (found) { inner_radius = inner.toFloat(); } else inner_radius = 0.0f; string name; i=0; found = false; while ((i<atts.count()) && (!found)) { if (atts.qName(i).compare("name")==0) { name = atts.value(i).toLatin1().constData(); found = true; } i++; } obj = new Cylinder(name,inner_radius); obj->setScene(scene); } else if (qName.compare("cone")==0) { string name; int i=0; bool found = false; while ((i<atts.count()) && (!found)) { if (atts.qName(i).compare("name")==0) { name = atts.value(i).toLatin1().constData(); found = true; } i++; } obj = new Cone(name); obj->setScene(scene); } else if (qName.compare("box")==0) { string name; int i=0; bool found = false; while ((i<atts.count()) && (!found)) { if (atts.qName(i).compare("name")==0) { name = atts.value(i).toLatin1().constData(); found = true; } i++; } obj = new Box(name); obj->setScene(scene); } else if (qName.compare("group")==0) { string name; int i=0; bool found = false; while((i<atts.count()) && (!found)) { if(atts.qName(i).compare("name")==0) { name = atts.value(i).toLatin1().constData(); found = true; } i++; } obj = new Group(name, scene, scene->getAnimation()); //in the case of groups, push the group the the currentGroup stack scene->getCurrentGroup().top()->addChild(obj); scene->getCurrentGroup().push((Group*)obj); } else if (qName.compare("light")==0) { } else if (qName.compare("mesh")==0) { } else if (qName.compare("image")==0) { } else if (qName.compare("texture")==0) { } return true; }
void TestCase::toXML(XMLWriter &receiver) const { /* <test-case> */ QXmlAttributes test_caseAtts; test_caseAtts.append(QLatin1String("is-XPath2"), QString(), QLatin1String("is-XPath2"), isXPath() ? QLatin1String("true") : QLatin1String("false")); test_caseAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), name()); test_caseAtts.append(QLatin1String("creator"), QString(), QLatin1String("creator"), creator()); QString scen; switch(scenario()) { case Standard: { scen = QLatin1String("standard"); break; } case ParseError: { scen = QLatin1String("parse-error"); break; } case RuntimeError: { scen = QLatin1String("runtime-error"); break; } case Trivial: { scen = QLatin1String("trivial"); break; } default: /* includes 'AnyError' */ Q_ASSERT(false); } test_caseAtts.append(QLatin1String("scenario"), QString(), QLatin1String("scenario"), scen); test_caseAtts.append(QLatin1String(QLatin1String("FilePath")), QString(), QLatin1String("FilePath"), QString()); receiver.startElement(QLatin1String("test-case"), test_caseAtts); /* <description> */ receiver.startElement(QLatin1String("description"), test_caseAtts); receiver.characters(description()); /* </description> */ receiver.endElement(QLatin1String("description")); /* <query> */ QXmlAttributes queryAtts; queryAtts.append(QLatin1String("date"), QString(), QLatin1String("date"), /* This date is a dummy. */ QDate::currentDate().toString(Qt::ISODate)); queryAtts.append(QLatin1String("name"), QString(), QLatin1String("name"), testCasePath().toString()); receiver.startElement(QLatin1String("query"), queryAtts); /* </query> */ receiver.endElement(QLatin1String("query")); /* Note: this is invalid, we don't add spec-citation. */ TestBaseLine::List bls(baseLines()); const TestBaseLine::List::const_iterator end(bls.constEnd()); TestBaseLine::List::const_iterator it(bls.constBegin()); for(; it != end; ++it) (*it)->toXML(receiver); /* </test-case> */ receiver.endElement(QLatin1String("test-case")); }
bool TestSuiteHandler::startElement(const QString &namespaceURI, const QString &localName, const QString &/*qName*/, const QXmlAttributes &atts) { if(namespaceURI != Global::xqtsCatalogNS) return true; else if(m_isExcluding) { if(localName == QLatin1String("test-group")) { m_testGroupName.push(atts.value(QLatin1String("name"))); return true; } else return true; } /* The elements are handled roughly in the order of highest occurrence in the catalog file. */ if(localName == QLatin1String("test-case")) { XQTSTestCase *const c = new XQTSTestCase( TestCase::scenarioFromString(atts.value(QLatin1String("scenario"))), m_container); c->setName(atts.value(QLatin1String("name"))); c->setCreator(atts.value(QLatin1String("Creator"))); c->setIsXPath(Global::readBoolean(atts.value(QLatin1String("is-XPath2")))); c->setLastModified(QDate::fromString(atts.value(QLatin1String("version-drop")), Qt::ISODate)); Q_ASSERT(c->lastModified().isNull() || c->lastModified().isValid()); m_currentQueryPath = m_queryOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")))); m_currentBaselinePath = m_baselineOffset.resolved(QUrl(atts.value(QLatin1String("FilePath")))); m_container->appendChild(c); m_tc = c; } else if(localName == QLatin1String("query")) { m_tc->setQueryPath(m_currentQueryPath.resolved(atts.value(QLatin1String("name")) + m_xqueryFileExtension)); } else if(localName == QLatin1String("input-file") || localName == QLatin1String("input-URI")) { m_currentInputVariable = atts.value(QLatin1String("variable")); } else if(localName == QLatin1String("output-file")) { m_baseLine = new TestBaseLine(TestBaseLine::identifierFromString(atts.value(QLatin1String("compare")))); } else if(localName == QLatin1String("expected-error")) { m_baseLine = new TestBaseLine(TestBaseLine::ExpectedError); } else if(localName == QLatin1String("test-group")) { m_testGroupName.push(atts.value(QLatin1String("name"))); if(m_exclusionList.contains(m_testGroupName.top())) { /* Ok, this group is supposed to be excluded, we don't * insert it into the tree. */ m_isExcluding = true; return true; } else { Q_ASSERT(m_container); TestGroup *const newGroup = new TestGroup(m_container); m_container->appendChild(newGroup); m_container = newGroup; } } else if(localName == QLatin1String("source")) { m_sourceMap.insert(atts.value(QLatin1String("ID")), m_sourceOffset.resolved(QUrl(atts.value(QLatin1String("FileName"))))); } else if(localName == QLatin1String("test-suite")) { m_ts = new TestSuite(); m_ts->setVersion(atts.value(QLatin1String("version"))); m_ts->setDesignDate(QDate::fromString(atts.value(QLatin1String("CatalogDesignDate")), Qt::ISODate)); Q_ASSERT(m_ts->designDate().isValid()); m_container = m_ts; m_xqueryFileExtension = atts.value(QLatin1String("XQueryFileExtension")); m_queryOffset = m_catalogFile.resolved(atts.value(QLatin1String("XQueryQueryOffsetPath"))); m_baselineOffset = m_catalogFile.resolved(atts.value(QLatin1String("ResultOffsetPath"))); m_sourceOffset = m_catalogFile.resolved(atts.value(QLatin1String("SourceOffsetPath"))); } else if(localName == QLatin1String("input-query")) { m_tcSourceInputs.insert(atts.value(QLatin1String("variable")), ExternalSourceLoader::VariableValue(m_currentQueryPath.resolved(atts.value(QLatin1String("name")) + m_xqueryFileExtension), ExternalSourceLoader::Query)); } return true; }
bool VOCatalogHeaderParser::startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes) { if (qName == "TABLEDATA") { m_tableData++; m_desc = true; } if (qName == "RESOURCE") { m_resource++; for (int i = 0; i < attributes.count(); i++) { if (attributes.qName(i) == "name") { m_current.m_name = attributes.value(i); } else if (attributes.qName(i) == "ID") { m_current.m_id = attributes.value(i); } /* else if (attributes.qName(i) == "type") { m_current.m_type = attributes.value(i); } */ } } if (m_resource) { if (qName == "DESCRIPTION" && m_queue.last() == "RESOURCE") { m_desc = true; } if (qName == "TABLE") { m_table++; for (int i = 0; i < attributes.count(); i++) { if (attributes.qName(i) == "nrows") { m_current.m_count = attributes.value(i).toLongLong(); } } } if (m_table) { if (qName == "COOSYS") { VOCooSys coo; for (int i = 0; i < attributes.count(); i++) { if (attributes.qName(i) == "ID") { coo.m_id = attributes.value(i); } else if (attributes.qName(i) == "system") { coo.m_system = attributes.value(i); } else if (attributes.qName(i) == "equinox") { coo.m_equinox = attributes.value(i); } else if (attributes.qName(i) == "epoch") { coo.m_epoch = attributes.value(i).toDouble(); } } m_cooSys.append(coo); } if (qName == "FIELD") { m_field.clear(); for (int i = 0; i < attributes.count(); i++) { if (attributes.qName(i) == "name") { m_field.m_name = attributes.value(i); } else if (attributes.qName(i) == "ucd") { m_field.m_ucd = attributes.value(i); } else if (attributes.qName(i) == "ref") { m_field.m_ref = attributes.value(i); } else if (attributes.qName(i) == "display") { m_field.m_display = attributes.value(i).toInt(); } else if (attributes.qName(i) == "datatype") { m_field.m_dataType = toDataType(attributes.value(i)); } else if (attributes.qName(i) == "unit") { m_field.m_unit = attributes.value(i); } else if (attributes.qName(i) == "width") { m_field.m_width = attributes.value(i).toInt(); } else if (attributes.qName(i) == "precision") { m_field.m_precision = attributes.value(i).toInt(); } else if (attributes.qName(i) == "arraysize") { m_field.m_arraysize = attributes.value(i).toInt(); } } m_desc = true; } } } m_queue.append(qName); return true; }
bool Parser::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& attributes) { bool rc = false; QString str; while (true) { if (qName == "config") { } else if (qName == "config_global") { str = attributes.value("name"); if (str.isEmpty()) { error_ = "No item name specified."; break; } if (str == "namespace") { str = attributes.value("value"); if (!str.isEmpty()) generator_.addNamespace(str); else { error_ = "Anonymuous namespace specified."; break; } } if (str == "include") { str = attributes.value("value"); if (!str.isEmpty()) generator_.addinclude(str); else { error_ ="Include statement without file name."; break; } } if (str == "Include") { str = attributes.value("value"); if (!str.isEmpty()) generator_.addInclude(str); else { error_ = "Include statement without file name."; break; } } if (str == "src_Include") { str = attributes.value("value"); if (!str.isEmpty()) generator_.addSrcInclude(str); else { error_ = "Source Include statement without file name."; break; } } if (str == "forward") { str = attributes.value("value"); if (!str.isEmpty()) generator_.addForwardDeclaration(str); else { error_ = "Forward declaration statement without name."; break; } } if (str == "local_forward") { str = attributes.value("value"); if (!str.isEmpty()) generator_.addLocalForwardDeclaration(str); else { error_ = "Local forward declaration statement without name."; break; } } } else if (qName == "config_group") { str = attributes.value("name"); if (str.isEmpty()) { error_ = "No group name specified."; break; } group_ = str; } else if (qName == "config_item") { class_ = Class(); // get class name str = attributes.value("name"); if (str.isNull()) str = ""; parsing_ = true; class_.setName(str); // get parent str = attributes.value("parent"); if (!str.isEmpty()) { class_.setParent(str + "Parameters"); } // final attribute str = attributes.value("final"); if (!str.isEmpty()) class_.setFinal(str != "false"); // dummy attribute str = attributes.value("dummy"); if (!str.isEmpty()) class_.setDummy(str == "true"); // dummy attribute str = attributes.value("extern"); if (!str.isEmpty()) class_.setExtern(str == "true"); // get instance tag instance_ = (attributes.value(QString("instance")) == QString("true")); } else if (parsing_) { if (qName == "config_parameter") { parameterParsing_ = true; QString name = attributes.value("name"); if (name.isEmpty()) { error_ = "No parameter name specified."; break; } name[0] = name[0].lower(); QString type = attributes.value("type"); if (type.isEmpty()) { error_ = "No parameter type specified."; break; } if (type == "string") { type = "std::" + type; string_ = true; } else if (type == "std::string") { string_ = true; } else if (type.startsWith("vector<")) { type = "std::" + type; vector_ = true; } else if (type.startsWith("std::vector<")) { vector_ = true; } else if (type.startsWith("set<")) { type = "std::" + type; set_ = true; } else if (type.startsWith("std::set<")) { set_ = true; } else if (type == "Angle") { type = "Miro::" + type; } else if (type == "angle" || type == "Miro::Angle") { angle_ = true; } else if (type == "ACE_Time_Value") { timeValue_ = true; } else if (type == "ACE_INET_Addr") { inetAddr_ = true; } else if (type == "ACE_TTY_IO::Serial_Params") { serialParams_ = true; } else if (type == "ScanDescriptionIDL") { type = "Miro::" + type; scanDescription_ = true; } else if (type == "Miro::ScanDescriptionIDL") { scanDescription_ = true; } QString def = attributes.value("default"); if (def.isNull()) def = ""; QString fullDef; if (type == "ACE_Time_Value" && def.find('.') != -1) { error_ = "ACE_Time_Value format is (x, y), no dot."; break; } else if (type == "std::string") fullDef = "\"" + def + "\""; else if (type == "Miro::Angle") fullDef = "Miro::deg2Rad(" + def + ")"; else if (type == "angle") fullDef = "Miro::deg2Rad(" + def + ")"; else if (type == "char") fullDef = "'" + def + "'"; else if (type == "ACE_INET_Addr") fullDef = "\"" + def + "\""; else fullDef = def; str = attributes.value("inherited"); if (!str.isEmpty() && str == QString("true")) { if (def.isEmpty()) { error_ = "Parameter taged inherited without default value."; break; } class_.addToConstructor(name + QString(" = ") + fullDef + QString(";")); } else { QString measure = attributes.value("measure"); class_.addParameter(Parameter(type, name, def, fullDef, measure, QString())); } } else if (qName == "constructor") { ctorParsing_ = true; ctor_ = ""; } else if (qName == "documentation") { docuParsing_ = true; docu_ = ""; } else { error_ = "Unknown tag name: " + qName; break; } } else { error_ = "Unknown tag name: " + qName; break; } rc = true; break; } return rc; }
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts) { if(depth == 0) { Parser::Event *e = new Parser::Event; QXmlAttributes a; for(int n = 0; n < atts.length(); ++n) { QString uri = atts.uri(n); QString ln = atts.localName(n); if(a.index(uri, ln) == -1) a.append(atts.qName(n), uri, ln, atts.value(n)); } e->setDocumentOpen(namespaceURI, localName, qName, a, nsnames, nsvalues); nsnames.clear(); nsvalues.clear(); e->setActualString(in->lastString()); in->resetLastData(); eventList.append(e); in->pause(true); } else { QDomElement e = doc->createElementNS(namespaceURI, qName); for(int n = 0; n < atts.length(); ++n) { QString uri = atts.uri(n); QString ln = atts.localName(n); bool have; if(!uri.isEmpty()) { have = e.hasAttributeNS(uri, ln); if(qt_bug_have) have = !have; } else have = e.hasAttribute(ln); if(!have) e.setAttributeNS(uri, atts.qName(n), atts.value(n)); } if(depth == 1) { elem = e; current = e; } else { current.appendChild(e); current = e; } } ++depth; return true; }
bool OsmHandler::startElement( const QString & pUri, const QString & pLocalName, const QString & pName, const QXmlAttributes & pAttrs ) { Q_UNUSED( pUri ); Q_UNUSED( pName ); QString name = pLocalName; if ( name == "osm" ) { if ( pAttrs.value( "version" ) != "0.6" ) { mError = "Invalid OSM version. Only files of v0.6 are supported."; return false; } } else if ( name == "node" ) { //todo: test if pAttrs.value("visible").toUtf8() is "true" -> if not, node has to be ignored! mObjectId = pAttrs.value( "id" ); mObjectType = "node"; double id = pAttrs.value( "id" ).toInt(); double lat = pAttrs.value( "lat" ).toDouble(); double lon = pAttrs.value( "lon" ).toDouble(); QString timestamp = pAttrs.value( "timestamp" ); QString user = pAttrs.value( "user" ); if ( lat < yMin ) yMin = lat; if ( lat > yMax ) yMax = lat; if ( lon < xMin ) xMin = lon; if ( lon > xMax ) xMax = lon; sqlite3_bind_int( mStmtInsertNode, 1, id ); sqlite3_bind_double( mStmtInsertNode, 2, lat ); sqlite3_bind_double( mStmtInsertNode, 3, lon ); sqlite3_bind_text( mStmtInsertNode, 4, timestamp.toUtf8(), -1, SQLITE_TRANSIENT ); // TODO: maybe static? sqlite3_bind_text( mStmtInsertNode, 5, user.toUtf8(), -1, SQLITE_TRANSIENT ); // TODO: maybe static? if ( sqlite3_step( mStmtInsertNode ) != SQLITE_DONE ) { QgsDebugMsg( "Storing node information into database failed." ); return false; } sqlite3_reset( mStmtInsertNode ); // make ready for next insert // store version number of this object sqlite3_bind_text( mStmtInsertVersion, 1, pAttrs.value( "id" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertVersion, 2, mObjectType.toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertVersion, 3, pAttrs.value( "version" ).toUtf8(), -1, SQLITE_TRANSIENT ); if ( sqlite3_step( mStmtInsertVersion ) != SQLITE_DONE ) { QgsDebugMsg( "Storing version information into database failed." ); return false; } sqlite3_reset( mStmtInsertVersion ); // make ready for next insert // increase node counter mPointCnt++; } else if ( name == "way" ) { mObjectId = pAttrs.value( "id" ); mObjectType = "way"; mPosId = 1; mFirstMemberAppeared = 0; //todo: test if pAttrs.value("visible").toUtf8() is "true" -> if not, way has to be ignored! sqlite3_bind_text( mStmtInsertWay, 1, mObjectId.toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertWay, 2, pAttrs.value( "timestamp" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertWay, 3, pAttrs.value( "user" ).toUtf8(), -1, SQLITE_TRANSIENT ); // store version number of this object sqlite3_bind_text( mStmtInsertVersion, 1, pAttrs.value( "id" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertVersion, 2, mObjectType.toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertVersion, 3, pAttrs.value( "version" ).toUtf8(), -1, SQLITE_TRANSIENT ); if ( sqlite3_step( mStmtInsertVersion ) != SQLITE_DONE ) { QgsDebugMsg( "Storing version information into database failed." ); return false; } sqlite3_reset( mStmtInsertVersion ); // make ready for next insert } else if ( name == "nd" ) { // store id of the first and last way member to be able to decide if the way is closed (polygon) or not if ( firstWayMemberId == "" ) { firstWayMemberId = pAttrs.value( "ref" ); } lastWayMemberId = pAttrs.value( "ref" ); if ( firstWayMemberId == lastWayMemberId ) mFirstMemberAppeared++; if (( firstWayMemberId != lastWayMemberId ) || ( mFirstMemberAppeared < 2 ) ) { sqlite3_bind_text( mStmtInsertWayMember, 1, mObjectId.toUtf8(), -1, SQLITE_TRANSIENT ); // TODO: maybe static? sqlite3_bind_int( mStmtInsertWayMember, 2, mPosId ); sqlite3_bind_text( mStmtInsertWayMember, 3, pAttrs.value( "ref" ).toUtf8(), -1, SQLITE_TRANSIENT ); if ( sqlite3_step( mStmtInsertWayMember ) != SQLITE_DONE ) { QgsDebugMsg( "Storing way-node relationship into database failed." ); return false; }; sqlite3_reset( mStmtInsertWayMember ); } mPosId++; } else if ( name == "relation" ) { mObjectId = pAttrs.value( "id" ); mRelationType = ""; mObjectType = "relation"; mPosId = 1; //todo: test if pAttrs.value("visible").toUtf8() is "true" -> if not, relation has to be ignored! sqlite3_bind_text( mStmtInsertRelation, 1, mObjectId.toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertRelation, 2, pAttrs.value( "timestamp" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertRelation, 3, pAttrs.value( "user" ).toUtf8(), -1, SQLITE_TRANSIENT ); // store version number of this object sqlite3_bind_text( mStmtInsertVersion, 1, pAttrs.value( "id" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertVersion, 2, mObjectType.toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertVersion, 3, pAttrs.value( "version" ).toUtf8(), -1, SQLITE_TRANSIENT ); if ( sqlite3_step( mStmtInsertVersion ) != SQLITE_DONE ) { QgsDebugMsg( "Storing version information into database failed." ); return false; } sqlite3_reset( mStmtInsertVersion ); // make ready for next insert } else if ( name == "member" ) { sqlite3_bind_text( mStmtInsertRelationMember, 1, mObjectId.toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_int( mStmtInsertRelationMember, 2, mPosId ); sqlite3_bind_text( mStmtInsertRelationMember, 3, pAttrs.value( "ref" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertRelationMember, 4, pAttrs.value( "type" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertRelationMember, 5, pAttrs.value( "role" ).toUtf8(), -1, SQLITE_TRANSIENT ); if ( sqlite3_step( mStmtInsertRelationMember ) != SQLITE_DONE ) { QgsDebugMsg( "Storing relation-feature relationship into database failed." ); return false; }; sqlite3_reset( mStmtInsertRelationMember ); mPosId++; } else if ( name == "tag" ) { if ( mCnt == COMMIT_AFTER_TAGS ) { sqlite3_exec( mDatabase, "COMMIT;", 0, 0, 0 ); sqlite3_exec( mDatabase, "BEGIN;", 0, 0, 0 ); mCnt = 0; } mCnt++; sqlite3_bind_text( mStmtInsertTag, 1, pAttrs.value( "k" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertTag, 2, pAttrs.value( "v" ).toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertTag, 3, mObjectId.toUtf8(), -1, SQLITE_TRANSIENT ); sqlite3_bind_text( mStmtInsertTag, 4, mObjectType.toUtf8(), -1, SQLITE_TRANSIENT ); // we've got node parameters -> let's create new database record if ( sqlite3_step( mStmtInsertTag ) != SQLITE_DONE ) { QgsDebugMsg( QString( "Storing tag into database failed. K:%1, V:%2." ).arg( pAttrs.value( "k" ) ).arg( pAttrs.value( "v" ) ) ); return false; } sqlite3_reset( mStmtInsertTag ); // if we are under xml tag <relation> and we reach xml tag <tag k="type" v="...">, lets insert prepared relation into DB if (( mObjectType == "relation" ) && ( pAttrs.value( "k" ) == "type" ) ) { mRelationType = pAttrs.value( "v" ); } } else if ( name == "bounds" ) { // e.g. <bounds minlat="41.388625" minlon="2.15426" maxlat="41.391732" maxlon="2.158192"/> // xMin = pAttrs.value("minlon").toDouble(); // xMax = pAttrs.value("maxlon").toDouble(); // yMin = pAttrs.value("minlat").toDouble(); // yMax = pAttrs.value("maxlat").toDouble(); } return true; }
QColor ThemeManager::getColor(const QXmlAttributes& atts) { QColor color(atts.value("color")); return color; }
void StyleReader::styleProperties(const QXmlAttributes& attrs) { if ((currentStyle == NULL) || (!readProperties)) return; gtParagraphStyle* pstyle = NULL; if (currentStyle->target() == "paragraph") pstyle = dynamic_cast<gtParagraphStyle*>(currentStyle); else pstyle = NULL; QString align = NULL; QString force = NULL; bool hasColorTag = false; for (int i = 0; i < attrs.count(); ++i) { if ((attrs.localName(i) == "style:font-name") && (!inList)) currentStyle->getFont()->setName(getFont(attrs.value(i))); else if (attrs.localName(i) == "fo:font-size") { double size = 0; double psize = 0; if (parentStyle != NULL) psize = static_cast<double>(parentStyle->getFont()->getSize()); else if (styles.contains("default-style")) psize = static_cast<double>(styles["default-style"]->getFont()->getSize()); psize = psize / 10; size = getSize(attrs.value(i), psize); int nsize = static_cast<int>(size * 10); currentStyle->getFont()->setSize(nsize); if (pstyle) pstyle->setLineSpacing(writer->getPreferredLineSpacing(nsize)); } else if ((attrs.localName(i) == "fo:line-height") && (parentStyle != NULL)) { gtParagraphStyle* ppstyle; if (parentStyle->target() == "paragraph") { ppstyle = dynamic_cast<gtParagraphStyle*>(parentStyle); assert(ppstyle != NULL); ppstyle->setLineSpacing(getSize(attrs.value(i), writer->getPreferredLineSpacing(currentStyle->getFont()->getSize()))); } } else if (attrs.localName(i) == "fo:color") { currentStyle->getFont()->setColor(attrs.value(i)); hasColorTag = true; } else if ((attrs.localName(i) == "style:use-window-font-color") && (attrs.value(i) == "true")) { currentStyle->getFont()->setColor("Black"); hasColorTag = true; } else if ((attrs.localName(i) == "fo:font-weight") && (attrs.value(i) == "bold")) currentStyle->getFont()->setWeight(BOLD); else if ((attrs.localName(i) == "fo:font-style") && (attrs.value(i) == "italic")) currentStyle->getFont()->setSlant(ITALIC); else if ((attrs.localName(i) == "style:text-underline-style") && (attrs.value(i) != "none")) currentStyle->getFont()->toggleEffect(UNDERLINE); else if ((attrs.localName(i) == "style:text-crossing-out") && (attrs.value(i) != "none")) currentStyle->getFont()->toggleEffect(STRIKETHROUGH); else if ((attrs.localName(i) == "fo:font-variant") && (attrs.value(i) == "small-caps")) currentStyle->getFont()->toggleEffect(SMALL_CAPS); else if ((attrs.localName(i) == "style:text-outline") && (attrs.value(i) == "true")) { currentStyle->getFont()->toggleEffect(OUTLINE); currentStyle->getFont()->setStrokeColor("Black"); currentStyle->getFont()->setColor("White"); } else if (attrs.localName(i) == "fo:letter-spacing") currentStyle->getFont()->setKerning(static_cast<int>(getSize(attrs.value(i), -1.0))); else if (attrs.localName(i) == "style:text-scale") currentStyle->getFont()->setHscale(static_cast<int>(getSize(attrs.value(i), -1.0))); else if ((attrs.localName(i) == "style:text-position") && (((attrs.value(i)).indexOf("sub") != -1) || (((attrs.value(i)).left(1) == "-") && ((attrs.value(i)).left(1) != "0")))) currentStyle->getFont()->toggleEffect(SUBSCRIPT); else if ((attrs.localName(i) == "style:text-position") && (((attrs.value(i)).indexOf("super") != -1) || (((attrs.value(i)).left(1) != "-") && ((attrs.value(i)).left(1) != "0")))) currentStyle->getFont()->toggleEffect(SUPERSCRIPT); else if ((attrs.localName(i) == "fo:margin-top") && (pstyle != NULL)) pstyle->setSpaceAbove(getSize(attrs.value(i))); else if ((attrs.localName(i) == "fo:margin-bottom") && (pstyle != NULL)) pstyle->setSpaceBelow(getSize(attrs.value(i))); else if ((attrs.localName(i) == "fo:margin-left") && (pstyle != NULL)) { if (inList) pstyle->setIndent(pstyle->getIndent() + getSize(attrs.value(i))); else pstyle->setIndent(getSize(attrs.value(i))); } else if ((attrs.localName(i) == "text:space-before") && (pstyle != NULL)) { /*if (inList) pstyle->setIndent(pstyle->getIndent() + getSize(attrs.value(i))); else*/ pstyle->setIndent(getSize(attrs.value(i))); } else if ((attrs.localName(i) == "fo:text-indent") && (pstyle != NULL)) pstyle->setFirstLineIndent(getSize(attrs.value(i))); else if ((attrs.localName(i) == "fo:text-align") && (pstyle != NULL)) align = attrs.value(i); else if ((attrs.localName(i) == "style:justify-single-word") && (pstyle != NULL)) force = attrs.value(i); } // Qt4 NULL -> isNull() if (!align.isNull()) { if (align == "end") pstyle->setAlignment(RIGHT); else if (align == "center") pstyle->setAlignment(CENTER); else if (align == "justify") { if (force == "false") pstyle->setAlignment(BLOCK); else pstyle->setAlignment(FORCED); } } if (!hasColorTag) currentStyle->getFont()->setColor("Black"); }