From 9f2b6c3830aa49e6e40b8df895085d93e623deae Mon Sep 17 00:00:00 2001 From: Marc Sabatella Date: Mon, 14 Mar 2016 20:51:05 -0600 Subject: [PATCH] fix #102071: sym not processed in line properties --- libmscore/text.cpp | 40 +++++++++++++++++++++++++++++++++++++++ libmscore/text.h | 2 ++ mscore/lineproperties.cpp | 12 ++++++------ mscore/propertymenu.cpp | 4 ++-- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/libmscore/text.cpp b/libmscore/text.cpp index cb2f52a1c19d..8f2407886f16 100644 --- a/libmscore/text.cpp +++ b/libmscore/text.cpp @@ -2898,6 +2898,46 @@ QString Text::convertToHtml(const QString& s, const TextStyle& st) return QString("%3").arg(family).arg(size).arg(s); } +//--------------------------------------------------------- +// tagEscape +//--------------------------------------------------------- + +QString Text::tagEscape(QString s) + { + QStringList tags = { "sym", "b", "i", "u", "sub", "sup" }; + for (QString tag : tags) { + QString openTag = "<" + tag + ">"; + QString openProxy = "!!" + tag + "!!"; + QString closeTag = ""; + QString closeProxy = "!!/" + tag + "!!"; + s.replace(openTag, openProxy); + s.replace(closeTag, closeProxy); + } + s = Xml::xmlString(s); + for (QString tag : tags) { + QString openTag = "<" + tag + ">"; + QString openProxy = "!!" + tag + "!!"; + QString closeTag = ""; + QString closeProxy = "!!/" + tag + "!!"; + s.replace(openProxy, openTag); + s.replace(closeProxy, closeTag); + } + return s; + } + +//--------------------------------------------------------- +// unEscape +//--------------------------------------------------------- + +QString Text::unEscape(QString s) + { + s.replace("<", "<"); + s.replace(">", ">"); + s.replace("&", "&"); + s.replace(""", "\""); + return s; + } + //--------------------------------------------------------- // accessibleInfo //--------------------------------------------------------- diff --git a/libmscore/text.h b/libmscore/text.h index cf6745489291..ef3f9de92608 100644 --- a/libmscore/text.h +++ b/libmscore/text.h @@ -322,6 +322,8 @@ class Text : public Element { virtual void textChanged() {} QString convertFromHtml(const QString& ss) const; static QString convertToHtml(const QString&, const TextStyle&); + static QString tagEscape(QString s); + static QString unEscape(QString s); void undoSetText(const QString& s) { undoChangeProperty(P_ID::TEXT, s); } virtual QString accessibleInfo() override; diff --git a/mscore/lineproperties.cpp b/mscore/lineproperties.cpp index 6f830b3b251d..eb0b866a0972 100644 --- a/mscore/lineproperties.cpp +++ b/mscore/lineproperties.cpp @@ -54,9 +54,9 @@ LineProperties::LineProperties(TextLine* l, QWidget* parent) otl = l; tl = l->clone(); - beginText->setText(otl->beginText()); - continueText->setText(otl->continueText()); - endText->setText(otl->endText()); + beginText->setText(Text::unEscape(otl->beginText())); + continueText->setText(Text::unEscape(otl->continueText())); + endText->setText(Text::unEscape(otl->endText())); setTextPlace(otl->beginTextPlace(), beginTextPlace); setTextPlace(otl->continueTextPlace(), continueTextPlace); @@ -138,15 +138,15 @@ void LineProperties::accept() otl->undoChangeProperty(P_ID::END_TEXT_PLACE, int(pt)); if (beginText->text() != otl->beginText()) - otl->undoChangeProperty(P_ID::BEGIN_TEXT, Xml::xmlString(beginText->text())); + otl->undoChangeProperty(P_ID::BEGIN_TEXT, Text::tagEscape(beginText->text())); else if (otl->beginText().isEmpty()) otl->setBeginText(""); if (continueText->text() != otl->continueText()) - otl->undoChangeProperty(P_ID::CONTINUE_TEXT, Xml::xmlString(continueText->text())); + otl->undoChangeProperty(P_ID::CONTINUE_TEXT, Text::tagEscape(continueText->text())); else if (otl->continueText().isEmpty()) otl->setContinueText(""); if (endText->text() != otl->endText()) - otl->undoChangeProperty(P_ID::END_TEXT, Xml::xmlString(endText->text())); + otl->undoChangeProperty(P_ID::END_TEXT, Text::tagEscape(endText->text())); else if (otl->endText().isEmpty()) otl->setEndText(""); diff --git a/mscore/propertymenu.cpp b/mscore/propertymenu.cpp index df3fc72923af..754ec6161f27 100644 --- a/mscore/propertymenu.cpp +++ b/mscore/propertymenu.cpp @@ -414,14 +414,14 @@ void ScoreView::elementPropertyAction(const QString& cmd, Element* e) else if (cmd == "v-props") { VoltaSegment* vs = static_cast(e); VoltaProperties vp; - vp.setText(vs->volta()->text()); + vp.setText(Text::unEscape(vs->volta()->text())); vp.setEndings(vs->volta()->endings()); int rv = vp.exec(); if (rv) { QString txt = vp.getText(); QList l = vp.getEndings(); if (txt != vs->volta()->text()) - vs->volta()->undoChangeProperty(P_ID::BEGIN_TEXT, Xml::xmlString(txt)); + vs->volta()->undoChangeProperty(P_ID::BEGIN_TEXT, Text::tagEscape(txt)); if (l != vs->volta()->endings()) vs->volta()->undoChangeProperty(P_ID::VOLTA_ENDING, QVariant::fromValue(l)); }