void Text::setHtml(const QString& s) { setUnstyled(); _doc->clear(); _doc->setHtml(s); textChanged(); }
bool Text::readProperties(const QDomElement& e) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "style") { int st; bool ok; int i = val.toInt(&ok); if (ok) { // obsolete old text styles switch (i) { case 1: i = TEXT_STYLE_UNSTYLED; break; case 2: i = TEXT_STYLE_TITLE; break; case 3: i = TEXT_STYLE_SUBTITLE; break; case 4: i = TEXT_STYLE_COMPOSER; break; case 5: i = TEXT_STYLE_POET; break; case 6: i = TEXT_STYLE_LYRIC1; break; case 7: i = TEXT_STYLE_LYRIC2; break; case 8: i = TEXT_STYLE_FINGERING; break; case 9: i = TEXT_STYLE_INSTRUMENT_LONG; break; case 10: i = TEXT_STYLE_INSTRUMENT_SHORT; break; case 11: i = TEXT_STYLE_INSTRUMENT_EXCERPT; break; case 12: i = TEXT_STYLE_DYNAMICS; break; case 13: i = TEXT_STYLE_TECHNIK; break; case 14: i = TEXT_STYLE_TEMPO; break; case 15: i = TEXT_STYLE_METRONOME; break; case 16: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_COPYRIGHT case 17: i = TEXT_STYLE_MEASURE_NUMBER; break; case 18: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_ODD case 19: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_EVEN case 20: i = TEXT_STYLE_TRANSLATOR; break; case 21: i = TEXT_STYLE_TUPLET; break; case 22: i = TEXT_STYLE_SYSTEM; break; case 23: i = TEXT_STYLE_STAFF; break; case 24: i = TEXT_STYLE_HARMONY; break; case 25: i = TEXT_STYLE_REHEARSAL_MARK; break; case 26: i = TEXT_STYLE_REPEAT; break; case 27: i = TEXT_STYLE_VOLTA; break; case 28: i = TEXT_STYLE_FRAME; break; case 29: i = TEXT_STYLE_TEXTLINE; break; case 30: i = TEXT_STYLE_GLISSANDO; break; case 31: i = TEXT_STYLE_STRING_NUMBER; break; case 32: i = TEXT_STYLE_OTTAVA; break; case 33: i = TEXT_STYLE_BENCH; break; case 34: i = TEXT_STYLE_HEADER; break; case 35: i = TEXT_STYLE_FOOTER; break; case 0: default: qDebug("Text:readProperties: style %d<%s> invalid", i, qPrintable(val)); i = TEXT_STYLE_UNSTYLED; break; } st = i; } else st = score()->style()->textStyleType(val); if (st == TEXT_STYLE_UNSTYLED) setUnstyled(); else if (st == TEXT_STYLE_UNKNOWN) _styleIndex = st; else setTextStyleType(st); } else if (tag == "styleName") // obsolete, unstyled text ; // _styleName = val; else if (tag == "data") // obsolete _doc->setHtml(val); else if (tag == "html") { QString s = Xml::htmlToString(e); setHtml(s); } else if (tag == "text") setText(val); else if (tag == "html-data") { QString s = Xml::htmlToString(e.firstChildElement()); if (score()->mscVersion() <= 114) { s.replace("MScore1", "FreeSerifMscore"); s.replace(QChar(0xe10e), QChar(0x266e)); //natural s.replace(QChar(0xe10c), QChar(0x266f)); // sharp s.replace(QChar(0xe10d), QChar(0x266d)); // flat s.replace(QChar(0xe104), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd5e))), // note2_Sym s.replace(QChar(0xe105), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd5f))); // note4_Sym //test s.replace(QChar(0xe105), QString("XXX")); s.replace(QChar(0xe106), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd60))); // note8_Sym s.replace(QChar(0xe107), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd61))); // note16_Sym s.replace(QChar(0xe108), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd62))); // note32_Sym s.replace(QChar(0xe109), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd63))); // note64_Sym s.replace(QChar(0xe10a), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd6d))); // dot s.replace(QChar(0xe10b), QString("%1%2%3%4").arg(QChar(0xd834)).arg(QChar(0xdd6d)).arg(QChar(0xd834)).arg(QChar(0xdd6d))); // dotdot s.replace(QChar(0xe167), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0b))); // coda s.replace(QChar(0xe168), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0c))); // varcoda s.replace(QChar(0xe169), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0c))); // segno if (_doc == 0) createDoc(); _doc->setHtml(s); if (isSimpleText()) { QString s = _doc->toPlainText(); delete _doc; _doc = 0; setText(s); } else { setUnstyled(); setHtml(s); } } else { setHtml(s); } } else if (tag == "subtype") // obsolete ; else if (tag == "frameWidth") { // obsolete qreal spMM = spatium() / MScore::DPMM; setFrameWidth(Spatium(val.toDouble() / spMM)); } else if (tag == "paddingWidth") { // obsolete qreal spMM = spatium() / MScore::DPMM; setPaddingWidth(Spatium(val.toDouble() / spMM)); } else if (_textStyle.readProperties(e)) ; else if (!Element::readProperties(e)) return false; return true; }
bool Text::readProperties(const QDomElement& e) { const QString& tag(e.tagName()); const QString& val(e.text()); if (tag == "style") { int st; bool ok; int i = val.toInt(&ok); if (ok) { // obsolete old text styles switch (i) { case 1: i = TEXT_STYLE_UNSTYLED; break; case 2: i = TEXT_STYLE_TITLE; break; case 3: i = TEXT_STYLE_SUBTITLE; break; case 4: i = TEXT_STYLE_COMPOSER; break; case 5: i = TEXT_STYLE_POET; break; case 6: i = TEXT_STYLE_LYRIC1; break; case 7: i = TEXT_STYLE_LYRIC2; break; case 8: i = TEXT_STYLE_FINGERING; break; case 9: i = TEXT_STYLE_INSTRUMENT_LONG; break; case 10: i = TEXT_STYLE_INSTRUMENT_SHORT; break; case 11: i = TEXT_STYLE_INSTRUMENT_EXCERPT; break; case 12: i = TEXT_STYLE_DYNAMICS; break; case 13: i = TEXT_STYLE_TECHNIK; break; case 14: i = TEXT_STYLE_TEMPO; break; case 15: i = TEXT_STYLE_METRONOME; break; case 16: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_COPYRIGHT case 17: i = TEXT_STYLE_MEASURE_NUMBER; break; case 18: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_ODD case 19: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_EVEN case 20: i = TEXT_STYLE_TRANSLATOR; break; case 21: i = TEXT_STYLE_TUPLET; break; case 22: i = TEXT_STYLE_SYSTEM; break; case 23: i = TEXT_STYLE_STAFF; break; case 24: i = TEXT_STYLE_HARMONY; break; case 25: i = TEXT_STYLE_REHEARSAL_MARK; break; case 26: i = TEXT_STYLE_REPEAT; break; case 27: i = TEXT_STYLE_VOLTA; break; case 28: i = TEXT_STYLE_FRAME; break; case 29: i = TEXT_STYLE_TEXTLINE; break; case 30: i = TEXT_STYLE_GLISSANDO; break; case 31: i = TEXT_STYLE_STRING_NUMBER; break; case 32: i = TEXT_STYLE_OTTAVA; break; case 33: i = TEXT_STYLE_BENCH; break; case 34: i = TEXT_STYLE_HEADER; break; case 35: i = TEXT_STYLE_FOOTER; break; case 0: default: qDebug("Text:readProperties: style %d<%s> invalid", i, qPrintable(val)); i = TEXT_STYLE_UNSTYLED; break; } st = i; } else st = score()->style()->textStyleType(val); if (st == TEXT_STYLE_UNSTYLED) setUnstyled(); else if (st == TEXT_STYLE_UNKNOWN) _styleIndex = st; else setTextStyleType(st); } else if (tag == "styleName") // obsolete, unstyled text ; // _styleName = val; else if (tag == "data") // obsolete _doc->setHtml(val); else if (tag == "html") { QString s = Xml::htmlToString(e); setHtml(s); } else if (tag == "text") setText(val); else if (tag == "html-data") { QString s = Xml::htmlToString(e.firstChildElement()); setHtml(s); } else if (tag == "subtype") // obsolete ; else if (_textStyle.readProperties(e)) ; // setUnstyled(); else if (!Element::readProperties(e)) return false; return true; }