本文整理汇总了C++中QXmlAttributes类的典型用法代码示例。如果您正苦于以下问题:C++ QXmlAttributes类的具体用法?C++ QXmlAttributes怎么用?C++ QXmlAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QXmlAttributes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: styleStyle
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;
}
示例2: startElement
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 = "@[email protected]" + 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 = "@[email protected]" + 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;
}
示例3: startElement
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;
}
示例4: onTrackListStart
void onTrackListStart(const QXmlAttributes& attrs)
{
m_dlg.m_vAlbums.back().m_nTrackCount = attrs.value("count").toInt();
}
示例5: startElement
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;
}
示例6: Environment
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("[email protected]"));
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());
//.........这里部分代码省略.........
示例7: onRelationListStart
void onRelationListStart(const QXmlAttributes& attrs)
{
m_bTargetIsUrl = "Url" == attrs.value("target-type");
}
示例8: startCompound
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;
}
}
示例9: startDocAnchor
void startDocAnchor(const QXmlAttributes& attrib )
{
m_fileName = attrib.value("file");
m_curString = "";
}
示例10: kDebug
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;
}
//.........这里部分代码省略.........
示例11: startTag
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;
}
示例12: frameTypeStr
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;
}
示例13: startElement
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);
}
示例14: startElement
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") {
//.........这里部分代码省略.........
示例15: startElement
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;
}