fix #75816 : Implement space management for formatted text
This commit is contained in:
parent
7005b1037c
commit
ecfd7f2d09
3 changed files with 54 additions and 2 deletions
|
@ -704,8 +704,7 @@ QString XmlReader::readXml()
|
|||
case QXmlStreamReader::EndElement:
|
||||
return s;
|
||||
case QXmlStreamReader::Characters:
|
||||
if (!isWhitespace() || text().toString() == "\n")
|
||||
s += text().toString().toHtmlEscaped();
|
||||
s += text().toString().toHtmlEscaped();
|
||||
break;
|
||||
case QXmlStreamReader::Comment:
|
||||
break;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "libmscore/text.h"
|
||||
#include "libmscore/score.h"
|
||||
#include "libmscore/sym.h"
|
||||
#include "libmscore/xml.h"
|
||||
#include "mtest/testutils.h"
|
||||
|
||||
using namespace Ms;
|
||||
|
@ -36,6 +37,7 @@ class TestText : public QObject, public MTest
|
|||
void testTextProperties();
|
||||
void testCompatibility();
|
||||
void testDelete();
|
||||
void testReadWrite();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -368,6 +370,53 @@ void TestText::testCompatibility()
|
|||
QCOMPARE(text->convertFromHtml(sescape), QString("<font face=\"Times New Roman\"/>test&<>"'"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
/// testReadWrite
|
||||
//---------------------------------------------------------
|
||||
|
||||
void TestText::testReadWrite() {
|
||||
auto testrw = [](Score* score, Text* t) {
|
||||
QBuffer buffer;
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
Xml xml(&buffer);
|
||||
t->write(xml);
|
||||
buffer.close();
|
||||
|
||||
XmlReader e(buffer.buffer());
|
||||
Text* text2 = new Text(score);
|
||||
e.readNextStartElement();
|
||||
text2->read(e);
|
||||
QCOMPARE(t->xmlText(), text2->xmlText());
|
||||
};
|
||||
Text* text = new Text(score);
|
||||
text->setXmlText("test");
|
||||
testrw(score, text);
|
||||
|
||||
text = new Text(score);
|
||||
text->setXmlText("<b>Title</b><i>two</i>");
|
||||
testrw(score, text);
|
||||
|
||||
text = new Text(score);
|
||||
text->setXmlText("<i>Title</i> <b>Two</b>");
|
||||
testrw(score, text);
|
||||
|
||||
text = new Text(score);
|
||||
text->setXmlText("<i>Title</i> <b>Two</b>");
|
||||
testrw(score, text);
|
||||
|
||||
text = new Text(score);
|
||||
text->setXmlText("<i>Title</i>\t<b>Two</b>");
|
||||
testrw(score, text);
|
||||
|
||||
text = new Text(score);
|
||||
text->setXmlText("<i>Title</i>\n<b>Two</b>");
|
||||
testrw(score, text);
|
||||
|
||||
text = new Text(score);
|
||||
text->setXmlText("<i>Ti tle</i><b>Tw o</b>");
|
||||
testrw(score, text);
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestText)
|
||||
|
||||
#include "tst_text.moc"
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
</Staff>
|
||||
<trackName>Voice</trackName>
|
||||
<Instrument>
|
||||
<longName>
|
||||
</longName>
|
||||
<shortName>
|
||||
</shortName>
|
||||
<trackName>Voice</trackName>
|
||||
<minPitchP>36</minPitchP>
|
||||
<maxPitchP>94</maxPitchP>
|
||||
|
|
Loading…
Reference in a new issue