diff --git a/src/engraving/libmscore/textbase.cpp b/src/engraving/libmscore/textbase.cpp index 2f32f58b86994..8ab1294afc50d 100644 --- a/src/engraving/libmscore/textbase.cpp +++ b/src/engraving/libmscore/textbase.cpp @@ -2297,6 +2297,45 @@ void TextBase::resetFormatting() cursor()->format()->setValign(VerticalAlignment::AlignNormal); } +//--------------------------------------------------------- +// fragmentList +//--------------------------------------------------------- + +/* + Return the text as a single list of TextFragment + Used by the MusicXML formatted export to avoid parsing the xml text format + */ + +std::list TextBase::fragmentList() const +{ + std::list res; + + const TextBase* text = this; + std::unique_ptr tmpText; + if (layoutInvalid()) { + // Create temporary text object to avoid side effects + // of createLayout() call. + tmpText.reset(toTextBase(this->clone())); + tmpText->createLayout(); + text = tmpText.get(); + } + + for (const TextBlock& block : text->m_blocks) { + for (const TextFragment& f : block.fragments()) { + /* TODO TBD + if (f.text.empty()) // skip empty fragments, not to + continue; // insert extra HTML formatting + */ + res.push_back(f); + if (block.eol()) { + // simply append a newline + res.back().text += u"\n"; + } + } + } + return res; +} + //--------------------------------------------------------- // plainText // return plain text with symbols @@ -2448,34 +2487,6 @@ TranslatableString TextBase::subtypeUserName() const return score() ? score()->getTextStyleUserName(textStyleType()) : TConv::userName(textStyleType()); } -//--------------------------------------------------------- -// fragmentList -//--------------------------------------------------------- - -/* - Return the text as a single list of TextFragment - Used by the MusicXML formatted export to avoid parsing the xml text format - */ - -std::list TextBase::fragmentList() const -{ - std::list res; - for (const TextBlock& block : m_blocks) { - for (const TextFragment& f : block.fragments()) { - /* TODO TBD - if (f.text.empty()) // skip empty fragments, not to - continue; // insert extra HTML formatting - */ - res.push_back(f); - if (block.eol()) { - // simply append a newline - res.back().text += u"\n"; - } - } - } - return res; -} - //--------------------------------------------------------- // validateText // check if s is a valid musescore xml text string diff --git a/src/importexport/musicxml/internal/musicxml/exportxml.cpp b/src/importexport/musicxml/internal/musicxml/exportxml.cpp index ca67fad61616a..a9c60b9000a11 100644 --- a/src/importexport/musicxml/internal/musicxml/exportxml.cpp +++ b/src/importexport/musicxml/internal/musicxml/exportxml.cpp @@ -4337,7 +4337,6 @@ static void beatUnit(XmlWriter& xml, const TDuration dur) static void wordsMetronome(XmlWriter& xml, const MStyle& s, TextBase const* const text, const int offset) { - //LOGD("wordsMetronome('%s')", qPrintable(text->xmlText())); const std::list list = text->fragmentList(); std::list wordsLeft; // words left of metronome bool hasParen; // parenthesis diff --git a/src/importexport/musicxml/internal/musicxml/musicxmlfonthandler.cpp b/src/importexport/musicxml/internal/musicxml/musicxmlfonthandler.cpp index 5f137f379cce5..7c6775df6d644 100644 --- a/src/importexport/musicxml/internal/musicxml/musicxmlfonthandler.cpp +++ b/src/importexport/musicxml/internal/musicxml/musicxmlfonthandler.cpp @@ -194,7 +194,6 @@ bool MScoreTextToMXML::split(const std::list& in, const int pos, c void MScoreTextToMXML::writeTextFragments(const std::list& fr, XmlWriter& xml) { - //LOGD("MScoreTextToMXML::writeTextFragments defFmt %s", qPrintable(charFormat2QString(oldFormat))); //dumpText(fr); bool firstTime = true; // write additional attributes only the first time characters are written for (const TextFragment& f : fr) { diff --git a/src/importexport/musicxml/tests/data/testInvalidLayout.mscx b/src/importexport/musicxml/tests/data/testInvalidLayout.mscx new file mode 100644 index 0000000000000..f0015041219c4 --- /dev/null +++ b/src/importexport/musicxml/tests/data/testInvalidLayout.mscx @@ -0,0 +1,227 @@ + + + 3.6.2 + 3224f34 + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + 2023-06-03 + + + + Linux + + + + + Issue #293441 test file by MuseScore 3.6.2 + + Orchestral + + Voices + +
+ flutes + oboes + clarinets + saxophones + bassoons + +
+
+ horns + trumpets + cornets + flugelhorns + trombones + tubas +
+
+ timpani +
+
+ keyboard-percussion + drums + unpitched-metal-percussion + unpitched-wooden-percussion + other-percussion +
+ keyboards + harps + organs + synths +
+ plucked-strings +
+ +
+ voices +
+
+ orchestral-strings +
+ +
+ + + + stdNormal + + + Voice + + Voice + Vo. + Voice + 38 + 84 + 41 + 79 + voice.vocals + + 100 + 100 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 150 + 100 + + + 150 + 50 + + + 120 + 50 + + + 120 + 100 + + + + + + Fluid + + + + + + 14.1434 + 0 + + + Issue #293441 test file by MuseScore 3.6.2 + + + + Verify a TextBase in a multimeasure rest is exported correctly +During MusicXML export, the TempoText contains an invalid layout + + + + + + + 0 + + 4 + 4 + + + 1.3333299999999999 + 1 + 1 + + metNoteQuarterUp = 80 + + + measure + 4/4 + + + + + + 3 + + + 0 + + -2 + + 4 + 4 + + + 1.3333299999999999 + 1 + 1 + + -2 + + metNoteQuarterUp = 80 + + + measure + 12/4 + + + + + + + + measure + 4/4 + + + + + + + + measure + 4/4 + + + + +
+
diff --git a/src/importexport/musicxml/tests/data/testInvalidLayout_ref.xml b/src/importexport/musicxml/tests/data/testInvalidLayout_ref.xml new file mode 100644 index 0000000000000..b96fdb5ab55d3 --- /dev/null +++ b/src/importexport/musicxml/tests/data/testInvalidLayout_ref.xml @@ -0,0 +1,86 @@ + + + + + Issue #293441 test file by MuseScore 3.6.2 + + + + MuseScore 0.7.0 + 2007-09-10 + + + + + + + + + + Voice + Vo. + + Voice + + + + 1 + 53 + 78.7402 + 0 + + + + + + + 1 + + 0 + + + + G + 2 + + + 3 + + + + + + quarter + 80 + + + + + + + 4 + 1 + + + + + + 4 + 1 + + + + + + 4 + 1 + + + light-heavy + + + + diff --git a/src/importexport/musicxml/tests/musicxml_tests.cpp b/src/importexport/musicxml/tests/musicxml_tests.cpp index 7ebe5a00fc901..4b6be2ba51e8c 100644 --- a/src/importexport/musicxml/tests/musicxml_tests.cpp +++ b/src/importexport/musicxml/tests/musicxml_tests.cpp @@ -616,6 +616,9 @@ TEST_F(Musicxml_Tests, instrumentChangeMIDIportExport) { TEST_F(Musicxml_Tests, instrumentSound) { mxmlIoTestRef("testInstrumentSound"); } +TEST_F(Musicxml_Tests, invalidLayout) { + mxmlMscxExportTestRef("testInvalidLayout"); +} TEST_F(Musicxml_Tests, invalidTimesig) { mxmlIoTestRef("testInvalidTimesig"); }