bool KFormula13ContentHandler::startElement(const QString&, const QString& localName, const QString&, const QXmlAttributes& atts) { if (localName == "CONTENT" || localName == "FORMULASETTINGS" || localName == "FORMULA" || localName == "DENOMINATOR" || localName == "NUMERATOR") return true; parseMatrix(); QDomElement element; m_currentElement.appendChild(element); m_currentElement = element; if (localName == "SEQUENCE") m_currentElement.setTagName("mrow"); else if (localName == "BRACKET") { m_currentElement.setTagName("mfenced"); writeBracketAttributes(atts); } else if (localName == "SPACE") { m_currentElement.setTagName("mspace"); writeSpaceAttributes(atts); } else if (localName == "OVERLINE") { m_currentElement.setTagName("mover"); QDomElement tmp; tmp.setTagName("mo"); tmp.setNodeValue("‾"); m_currentElement.parentNode().appendChild(tmp); } else if (localName == "UNDERLINE") { m_currentElement.setTagName("munder"); QDomElement tmp; tmp.setTagName("mo"); tmp.setNodeValue("_"); m_currentElement.parentNode().appendChild(tmp); } else if (localName == "FRACTION") { m_currentElement.setTagName("mfrac"); if (atts.value("NOLINE").toInt() == 1) m_currentElement.setAttribute("linethickness", "0"); } else if (localName == "ROOT") m_currentElement.setTagName("msqrt"); else if (localName == "ROOTINDEX") { m_currentElement.setTagName("mrow"); m_currentElement.parentNode().toElement().setTagName("mroot"); } else if (localName == "MATRIX") { m_currentElement.setTagName("mtable"); int rows = atts.value("ROWS").toInt(); int cols = atts.value("COLUMNS").toInt(); m_matrixStack.push(QPair<int, int>(rows, cols)); } else if (localName == "MULTILINE") m_currentElement.setTagName("mtext"); else if (localName == "TEXT") { // m_currentElement. } return true; }
/* Modify an image tag. Basically we turn it back into a picture, write out the file, and modify the ENML */ void NoteFormatter::modifyImageTags(QDomDocument &doc, QDomElement &docElement, QDomElement &enMedia, QDomAttr &hash) { QLOG_DEBUG() << "Entering NoteFormatter::modifyImageTags"; QString mimetype = enMedia.attribute("type"); ResourceTable resourceTable; qint32 resLid = resourceTable.getLidByHashHex(QString::fromStdString(note.guid), hash.value()); Resource r; if (resLid>0) { //QFile tfile(global.fileManager.getResDirPath(QString::number(resLid)+type)); resourceTable.get(r, resLid); MimeReference ref; QString filename; if (r.__isset.attributes && r.attributes.__isset.fileName) filename = QString::fromStdString(r.attributes.fileName); QString type = ref.getExtensionFromMime(mimetype, filename); if (r.__isset.data && r.data.__isset.body && r.data.body.length() > 0) { enMedia.setAttribute("src", "file:///"+global.fileManager.getDbDirPath(QString("dba/") +QString::number(resLid) +type)); // Check if this is a LaTeX image if (r.__isset.attributes && r.attributes.__isset.sourceURL && QString::fromStdString(r.attributes.sourceURL).toLower().startsWith("http://latex.codecogs.com/gif.latex?")) { QDomElement newText(doc.createElement("a")); enMedia.setAttribute("en-tag", "en-latex"); newText.setAttribute("onMouseOver", "style.cursor='pointer'"); newText.setAttribute("title", QString::fromStdString(r.attributes.sourceURL)); newText.setAttribute("href", "latex://"+QString::number(resLid)); enMedia.parentNode().replaceChild(newText, enMedia); newText.appendChild(enMedia); } enMedia.setAttribute("onContextMenu", "window.browserWindow.imageContextMenu('" +QString::number(resLid) +"', '" +QString::number(resLid) +type +"');"); } } else { resourceError = true; readOnly = true; } // Reset the tags to something that WebKit will understand enMedia.setAttribute("en-tag", "en-media"); enMedia.setNodeValue(""); enMedia.setAttribute("lid", resLid); enMedia.setTagName("img"); }