void TempoText::read(XmlReader& e) { while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "tempo") setTempo(e.readDouble()); else if (tag == "followText") _followText = e.readInt(); else if (!Text::readProperties(e)) e.unknown(); } if (score()->mscVersion() <= 114) { // // Reset text in old version to // style. // //TODO if (textStyle() != TextStyleType::INVALID) { // setStyled(true); // styleChanged(); // } } // check sanity if (xmlText().isEmpty()) { setXmlText(QString("<sym>metNoteQuarterUp</sym> = %1").arg(lrint(60 * _tempo))); setVisible(false); } }
void TextBase::endEdit(EditData& ed) { TextEditData* ted = static_cast<TextEditData*>(ed.getData(this)); score()->undoStack()->remove(ted->startUndoIdx); // remove all undo/redo records // replace all undo/redo records collected during text editing with // one property change QString actualText = xmlText(); if (ted->oldXmlText.isEmpty()) { UndoStack* us = score()->undoStack(); UndoCommand* ucmd = us->last(); if (ucmd) { const QList<UndoCommand*>& cl = ucmd->commands(); const UndoCommand* cmd = cl.back(); if (strncmp(cmd->name(), "Add:", 4) == 0) { const AddElement* ae = static_cast<const AddElement*>(cmd); if (ae->getElement() == this) { if (actualText.isEmpty()) { // we just created this empty text, rollback that operation us->rollback(); score()->update(); ed.element = 0; } else { setXmlText(ted->oldXmlText); // reset text to value before editing us->reopen(); // combine undo records of text creation with text editing undoChangeProperty(Pid::TEXT, actualText); layout1(); score()->endCmd(); } return; } } } } if (actualText.isEmpty()) { qDebug("actual text is empty"); score()->startCmd(); score()->undoRemoveElement(this); ed.element = 0; score()->endCmd(); return; } setXmlText(ted->oldXmlText); // reset text to value before editing score()->startCmd(); undoChangeProperty(Pid::TEXT, actualText); // change property to set text to actual value again // this also changes text of linked elements layout1(); triggerLayout(); // force relayout even if text did not change score()->endCmd(); static const qreal w = 2.0; score()->addRefresh(canvasBoundingRect().adjusted(-w, -w, w, w)); }
TiXmlElement* CGlobalLightSettings::xml() { TiXmlElement* xmlLightSettings = new TiXmlElement( GetType().c_str() ); TiXmlElement* xmlAmbientColor = new TiXmlElement("AmbientColor"); xmlAmbientColor->LinkEndChild( xmlText( m_colAmbient ) ); xmlLightSettings->LinkEndChild( xmlAmbientColor ); return xmlLightSettings; }
TiXmlElement* CGlobalCameraSettings::xml() { TiXmlElement* xmlCameraSettings = new TiXmlElement( GetType().c_str() ); TiXmlElement* xmlDefaultCamera = new TiXmlElement("DefaultCamera"); xmlDefaultCamera->LinkEndChild( xmlText( m_sDefaultCamera ) ); xmlCameraSettings->LinkEndChild( xmlDefaultCamera ); return xmlCameraSettings; }
void TempoText::read(XmlReader& e) { while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "tempo") setTempo(e.readDouble()); else if (tag == "followText") _followText = e.readInt(); else if (!TextBase::readProperties(e)) e.unknown(); } // check sanity if (xmlText().isEmpty()) { setXmlText(QString("<sym>metNoteQuarterUp</sym> = %1").arg(lrint(60 * _tempo))); setVisible(false); } }
bool SaxParser::parseFromFile(const std::string& xmlFilePath, bool bUTF8) { std::wifstream inputFile(xmlFilePath.c_str()); if (inputFile.is_open()) { // Skip the BOM bytes. if (bUTF8) { inputFile.seekg(3); } std::wstring xmlText( (std::istreambuf_iterator<wchar_t>(inputFile)), std::istreambuf_iterator<wchar_t>()); return m_pImpl->parseXml(xmlText.c_str(), static_cast<int>(xmlText.length())); } return false; }
void TextBase::startEdit(EditData& ed) { ed.grips = 0; TextEditData* ted = new TextEditData(this); ted->e = this; ted->cursor.setRow(0); ted->cursor.setColumn(0); ted->cursor.clearSelection(); Q_ASSERT(!score()->undoStack()->active()); // make sure we are not in a Cmd ted->oldXmlText = xmlText(); ted->startUndoIdx = score()->undoStack()->getCurIdx(); if (layoutInvalid) layout(); if (!ted->cursor.set(ed.startMove)) ted->cursor.init(); qreal _spatium = spatium(); // refresh edit bounding box score()->addRefresh(canvasBoundingRect().adjusted(-_spatium, -_spatium, _spatium, _spatium)); ed.addData(ted); }
void Dynamic::endEdit() { Text::endEdit(); if (xmlText() != QString::fromUtf8(dynList[int(_dynamicType)].text)) _dynamicType = Type::OTHER; }
Token Lexer::xmlAtomImpl() { mark=idx; switch (idx[0]) { case 0: compiler->syntaxError(lineno, SYNTAXERR_XML_EOI_IN_MARKUP); case '<': switch (idx[1]) { case '!': if (idx[2] == '[' && idx[3] == 'C' && idx[4] == 'D' && idx[5] == 'A' && idx[6] == 'T' && idx[7] == 'A' && idx[8] == '[') { idx += 9; return xmlMarkup(T_XmlCDATA); } if (idx[2] == '-' && idx[3] == '-') { idx += 4; return xmlMarkup(T_XmlComment); } compiler->syntaxError(lineno, SYNTAXERR_XML_INVALID_LEFTBANG); case '?': idx += 2; return xmlMarkup(T_XmlProcessingInstruction); case '/': idx += 2; return T_XmlLeftAngleSlash; default: idx += 1; return T_XmlLeftAngle; } case '/': if (idx[1] == '>') { idx += 2; return T_XmlSlashRightAngle; } compiler->syntaxError(lineno, SYNTAXERR_XML_INVALID_SLASH); case '>': idx += 1; return T_XmlRightAngle; case '{': idx += 1; return T_XmlLeftBrace; case '}': idx += 1; return T_XmlRightBrace; case '=': idx += 1; return T_XmlEquals; case ' ': case '\t': case '\r': case '\n': return xmlWhitespace(); case '"': case '\'': return xmlString(); default: if (isXmlNameStart(idx[0])) return xmlName(); else return xmlText(); } }