From 20adb41fc14713aef408e446a3bce1f69cb5d225 Mon Sep 17 00:00:00 2001 From: Klaus Rettinghaus Date: Fri, 8 Nov 2024 19:39:15 +0100 Subject: [PATCH] Fix GH#25048: Export Tempo as system text in MusicXML Backport of #25312 --- importexport/musicxml/exportxml.cpp | 5 +- libmscore/scoreElement.cpp | 13 +- libmscore/scoreElement.h | 2 +- mtest/musicxml/io/testClefs2.xml | 2 +- mtest/musicxml/io/testColorExport_ref.xml | 2 +- mtest/musicxml/io/testDirections2.xml | 4 +- mtest/musicxml/io/testInvalidLayout_ref.xml | 2 +- mtest/musicxml/io/testInvisibleDirection.xml | 2 +- mtest/musicxml/io/testSound1.xml | 2 +- mtest/musicxml/io/testSound1_ref.xml | 150 +++++++++++++++++++ mtest/musicxml/io/testSound2_ref.xml | 2 +- mtest/musicxml/io/testSwing_ref.xml | 2 +- mtest/musicxml/io/testSystemDirection.xml | 2 +- mtest/musicxml/io/testTempo1.xml | 8 +- mtest/musicxml/io/testTempo2_ref.xml | 6 +- mtest/musicxml/io/testTempo3_ref.xml | 2 +- mtest/musicxml/io/testTempo4_ref.xml | 2 +- mtest/musicxml/io/testTempo5.xml | 24 +-- mtest/musicxml/io/testTempo6.xml | 6 +- mtest/musicxml/io/testTempoOverlap_ref.xml | 32 ++-- mtest/musicxml/io/testTempoPrecision_ref.xml | 4 +- mtest/musicxml/io/testTuplets4.xml | 2 +- mtest/musicxml/io/tst_mxml_io.cpp | 2 +- 23 files changed, 219 insertions(+), 59 deletions(-) create mode 100644 mtest/musicxml/io/testSound1_ref.xml diff --git a/importexport/musicxml/exportxml.cpp b/importexport/musicxml/exportxml.cpp index 7c5cb7a4c8a38..4f2c44c9432de 100644 --- a/importexport/musicxml/exportxml.cpp +++ b/importexport/musicxml/exportxml.cpp @@ -4616,7 +4616,10 @@ void ExportMusicXml::tempoText(TempoText const* const text, int staff) qPrintable(text->xmlText())); */ _attr.doAttr(_xml, false); - _xml.stag(QString("direction placement=\"%1\"").arg((text->placement() == Placement::BELOW ) ? "below" : "above")); + QString tempoAttrs = QString("direction placement=\"%1\"").arg(text->placement() == Placement::BELOW ? "below" : "above"); + if (text->systemFlag()) + tempoAttrs += QString(" system=\"%1\"").arg(text->isLinked() ? "also-top" : "only-top"); + _xml.stag(tempoAttrs); wordsMetronome(_xml, _score, text, offset); if (staff) diff --git a/libmscore/scoreElement.cpp b/libmscore/scoreElement.cpp index e0605d17a1860..038a00f3bf468 100644 --- a/libmscore/scoreElement.cpp +++ b/libmscore/scoreElement.cpp @@ -270,7 +270,7 @@ static void changeProperty(ScoreElement* e, Pid t, const QVariant& st, PropertyF static void changeProperties(ScoreElement* e, Pid t, const QVariant& st, PropertyFlags ps) { if (propertyLink(t)) { - for (ScoreElement* ee : e->linkList()) + for (ScoreElement*& ee : e->linkList()) changeProperty(ee, t, st, ps); } else @@ -580,11 +580,18 @@ void ScoreElement::unlink() /// linked to this element //--------------------------------------------------------- -bool ScoreElement::isLinked(ScoreElement* se) +bool ScoreElement::isLinked(ScoreElement* se) const { - return se != this && _links && _links->contains(se); + if (se == this || !_links) { + return false; } + if (se == nullptr) { + return !_links->empty() && _links->mainElement() != this; + } + + return _links->contains(se); } + //--------------------------------------------------------- // undoUnlink //--------------------------------------------------------- diff --git a/libmscore/scoreElement.h b/libmscore/scoreElement.h index a9eb7cab0761c..60e93ec364f50 100644 --- a/libmscore/scoreElement.h +++ b/libmscore/scoreElement.h @@ -241,7 +241,7 @@ class ScoreElement { void linkTo(ScoreElement*); void unlink(); - bool isLinked(ScoreElement*); + bool isLinked(ScoreElement* se = nullptr) const; virtual void undoUnlink(); int lid() const { return _links ? _links->lid() : 0; } diff --git a/mtest/musicxml/io/testClefs2.xml b/mtest/musicxml/io/testClefs2.xml index 3ca5496dcd292..5e58a3a262dd1 100644 --- a/mtest/musicxml/io/testClefs2.xml +++ b/mtest/musicxml/io/testClefs2.xml @@ -49,7 +49,7 @@ 4 - + quarter diff --git a/mtest/musicxml/io/testColorExport_ref.xml b/mtest/musicxml/io/testColorExport_ref.xml index 2009eafa5dd6e..f6c333ab5de00 100644 --- a/mtest/musicxml/io/testColorExport_ref.xml +++ b/mtest/musicxml/io/testColorExport_ref.xml @@ -50,7 +50,7 @@ dominant - + quarter diff --git a/mtest/musicxml/io/testDirections2.xml b/mtest/musicxml/io/testDirections2.xml index cc91207c47810..dd768a79ae9b9 100644 --- a/mtest/musicxml/io/testDirections2.xml +++ b/mtest/musicxml/io/testDirections2.xml @@ -77,7 +77,7 @@ 2 - + Lento @@ -95,7 +95,7 @@ 4 1 - + Andante diff --git a/mtest/musicxml/io/testInvalidLayout_ref.xml b/mtest/musicxml/io/testInvalidLayout_ref.xml index b96fdb5ab55d3..7053906e664c0 100644 --- a/mtest/musicxml/io/testInvalidLayout_ref.xml +++ b/mtest/musicxml/io/testInvalidLayout_ref.xml @@ -50,7 +50,7 @@ 3 - + quarter diff --git a/mtest/musicxml/io/testInvisibleDirection.xml b/mtest/musicxml/io/testInvisibleDirection.xml index 399b7778bae6a..35509358e8f0b 100644 --- a/mtest/musicxml/io/testInvisibleDirection.xml +++ b/mtest/musicxml/io/testInvisibleDirection.xml @@ -48,7 +48,7 @@ 2 - + quarter diff --git a/mtest/musicxml/io/testSound1.xml b/mtest/musicxml/io/testSound1.xml index 5ddc90777e8b9..6193cb8c733e2 100644 --- a/mtest/musicxml/io/testSound1.xml +++ b/mtest/musicxml/io/testSound1.xml @@ -43,7 +43,7 @@ 2 - + quarter diff --git a/mtest/musicxml/io/testSound1_ref.xml b/mtest/musicxml/io/testSound1_ref.xml new file mode 100644 index 0000000000000..6193cb8c733e2 --- /dev/null +++ b/mtest/musicxml/io/testSound1_ref.xml @@ -0,0 +1,150 @@ + + + + + + MuseScore 0.7.0 + 2007-09-10 + + + + + + + + + + Music + + + + + + 1 + 1 + 78.7402 + 0 + + + + + + + 1 + + 0 + + + + G + 2 + + + + + + quarter + 60 + + + + + + + C + 4 + + 1 + 1 + quarter + up + + + + D + 4 + + 1 + 1 + quarter + up + + + + E + 4 + + 1 + 1 + quarter + up + + + + F + 4 + + 1 + 1 + quarter + up + + + + + + G + 4 + + 1 + 1 + quarter + up + + + + F + 4 + + 1 + 1 + quarter + up + + + + E + 4 + + 1 + 1 + quarter + up + + + + D + 4 + + 1 + 1 + quarter + up + + + + + + C + 4 + + 4 + 1 + whole + + + + diff --git a/mtest/musicxml/io/testSound2_ref.xml b/mtest/musicxml/io/testSound2_ref.xml index 5ddc90777e8b9..6193cb8c733e2 100644 --- a/mtest/musicxml/io/testSound2_ref.xml +++ b/mtest/musicxml/io/testSound2_ref.xml @@ -43,7 +43,7 @@ 2 - + quarter diff --git a/mtest/musicxml/io/testSwing_ref.xml b/mtest/musicxml/io/testSwing_ref.xml index 2bb2c922455ab..1999ad4cb427b 100644 --- a/mtest/musicxml/io/testSwing_ref.xml +++ b/mtest/musicxml/io/testSwing_ref.xml @@ -52,7 +52,7 @@ 1 - + quarter diff --git a/mtest/musicxml/io/testSystemDirection.xml b/mtest/musicxml/io/testSystemDirection.xml index c377e9ab21b70..68cf1432866da 100644 --- a/mtest/musicxml/io/testSystemDirection.xml +++ b/mtest/musicxml/io/testSystemDirection.xml @@ -113,7 +113,7 @@ - + Largo diff --git a/mtest/musicxml/io/testTempo1.xml b/mtest/musicxml/io/testTempo1.xml index 655f85e7a72a0..e53eac8a92637 100644 --- a/mtest/musicxml/io/testTempo1.xml +++ b/mtest/musicxml/io/testTempo1.xml @@ -48,7 +48,7 @@ 2 - + Largo @@ -145,7 +145,7 @@ - + Andante @@ -235,13 +235,13 @@ - + Vivace - + quarter diff --git a/mtest/musicxml/io/testTempo2_ref.xml b/mtest/musicxml/io/testTempo2_ref.xml index 8f485888357fa..f88393ccc3c2b 100644 --- a/mtest/musicxml/io/testTempo2_ref.xml +++ b/mtest/musicxml/io/testTempo2_ref.xml @@ -49,7 +49,7 @@ 2 - + quarter @@ -100,7 +100,7 @@ - + quarter @@ -152,7 +152,7 @@ - + half diff --git a/mtest/musicxml/io/testTempo3_ref.xml b/mtest/musicxml/io/testTempo3_ref.xml index b0cba3a4bfb3e..237cc05cb8a47 100644 --- a/mtest/musicxml/io/testTempo3_ref.xml +++ b/mtest/musicxml/io/testTempo3_ref.xml @@ -49,7 +49,7 @@ 2 - + half diff --git a/mtest/musicxml/io/testTempo4_ref.xml b/mtest/musicxml/io/testTempo4_ref.xml index 28ce9860f0bc7..f61e2f2b92800 100644 --- a/mtest/musicxml/io/testTempo4_ref.xml +++ b/mtest/musicxml/io/testTempo4_ref.xml @@ -63,7 +63,7 @@ 2 - + quarter diff --git a/mtest/musicxml/io/testTempo5.xml b/mtest/musicxml/io/testTempo5.xml index c9a7357660f34..1e44fe10ad250 100644 --- a/mtest/musicxml/io/testTempo5.xml +++ b/mtest/musicxml/io/testTempo5.xml @@ -49,7 +49,7 @@ 2 - + breve @@ -69,7 +69,7 @@ - + whole @@ -89,7 +89,7 @@ - + half @@ -109,7 +109,7 @@ - + quarter @@ -129,7 +129,7 @@ - + eighth @@ -149,7 +149,7 @@ - + 16th @@ -169,7 +169,7 @@ - + 32nd @@ -189,7 +189,7 @@ - + 64th @@ -209,7 +209,7 @@ - + 128th @@ -229,7 +229,7 @@ - + 256th @@ -249,7 +249,7 @@ - + 512th @@ -269,7 +269,7 @@ - + 1024th diff --git a/mtest/musicxml/io/testTempo6.xml b/mtest/musicxml/io/testTempo6.xml index a9418c419f619..0b360f19f6494 100644 --- a/mtest/musicxml/io/testTempo6.xml +++ b/mtest/musicxml/io/testTempo6.xml @@ -49,7 +49,7 @@ 2 - + quarter @@ -73,7 +73,7 @@ - + quarter @@ -97,7 +97,7 @@ - + quarter diff --git a/mtest/musicxml/io/testTempoOverlap_ref.xml b/mtest/musicxml/io/testTempoOverlap_ref.xml index 9cfa98893cccd..2b896db62a3b8 100644 --- a/mtest/musicxml/io/testTempoOverlap_ref.xml +++ b/mtest/musicxml/io/testTempoOverlap_ref.xml @@ -72,7 +72,7 @@ 2 - + quarter @@ -98,7 +98,7 @@ - + quarter @@ -114,7 +114,7 @@ - + quarter @@ -130,7 +130,7 @@ - + quarter @@ -147,7 +147,7 @@ - + quarter @@ -168,7 +168,7 @@ - + quarter @@ -184,7 +184,7 @@ - + quarter @@ -211,7 +211,7 @@ Direction words (empty) with sound tempo - + quarter @@ -227,7 +227,7 @@ - + quarter @@ -244,7 +244,7 @@ - + quarter @@ -270,7 +270,7 @@ - + quarter @@ -286,7 +286,7 @@ - + quarter @@ -302,7 +302,7 @@ - + quarter @@ -319,7 +319,7 @@ - + quarter @@ -340,7 +340,7 @@ - + quarter @@ -356,7 +356,7 @@ - + quarter diff --git a/mtest/musicxml/io/testTempoPrecision_ref.xml b/mtest/musicxml/io/testTempoPrecision_ref.xml index dd1d21ff30717..0e42821bee51b 100644 --- a/mtest/musicxml/io/testTempoPrecision_ref.xml +++ b/mtest/musicxml/io/testTempoPrecision_ref.xml @@ -48,7 +48,7 @@ 2 - + quarter @@ -64,7 +64,7 @@ - + Andante diff --git a/mtest/musicxml/io/testTuplets4.xml b/mtest/musicxml/io/testTuplets4.xml index de66c04aee8a4..3319a744c0807 100644 --- a/mtest/musicxml/io/testTuplets4.xml +++ b/mtest/musicxml/io/testTuplets4.xml @@ -49,7 +49,7 @@ 2 - + quarter diff --git a/mtest/musicxml/io/tst_mxml_io.cpp b/mtest/musicxml/io/tst_mxml_io.cpp index dced312d14c2a..b08b51d6715df 100644 --- a/mtest/musicxml/io/tst_mxml_io.cpp +++ b/mtest/musicxml/io/tst_mxml_io.cpp @@ -275,7 +275,7 @@ private slots: void slurs2() { mxmlIoTest("testSlurs2"); } void slurTieDirecton() { mxmlIoTest("testSlurTieDirection"); } void slurTieLineStyle() { mxmlIoTest("testSlurTieLineStyle"); } - void sound1() { mxmlIoTest("testSound1"); } + void sound1() { mxmlIoTestRef("testSound1"); } void sound2() { mxmlIoTestRef("testSound2"); } // void specialCharacters() { mxmlIoTest("testSpecialCharacters"); } // TODO void staffEmptiness() { mxmlImportTestRef("testStaffEmptiness"); }