diff --git a/src/importexport/musicxml/internal/musicxml/import/importmusicxmlpass2.cpp b/src/importexport/musicxml/internal/musicxml/import/importmusicxmlpass2.cpp index 3fb824df9d931..aaf3156db3beb 100644 --- a/src/importexport/musicxml/internal/musicxml/import/importmusicxmlpass2.cpp +++ b/src/importexport/musicxml/internal/musicxml/import/importmusicxmlpass2.cpp @@ -959,6 +959,9 @@ static void addElemOffset(EngravingItem* el, track_idx_t track, const String& pl } else { el->setPlacement(placement == u"above" ? PlacementV::ABOVE : PlacementV::BELOW); el->setPropertyFlags(Pid::PLACEMENT, PropertyFlags::UNSTYLED); + if (!el->isSticking()) { + el->resetProperty(Pid::OFFSET); + } } } const Fraction& endTick = measure->score()->endTick(); @@ -1203,6 +1206,7 @@ static void addFermataToChord(const Notation& notation, ChordRest* cr) } if (!direction.empty()) { na->setPlacement(direction == "inverted" ? PlacementV::BELOW : PlacementV::ABOVE); + na->resetProperty(Pid::OFFSET); } else { na->setPlacement(na->propertyDefault(Pid::PLACEMENT).value()); } @@ -1465,6 +1469,7 @@ static void addTextToNote(int l, int c, String txt, String placement, String fon if (!placement.empty()) { t->setPlacement(placement == u"below" ? PlacementV::BELOW : PlacementV::ABOVE); t->setPropertyFlags(Pid::PLACEMENT, PropertyFlags::UNSTYLED); + t->resetProperty(Pid::OFFSET); } if (color.isValid()) { t->setColor(color); @@ -1496,6 +1501,7 @@ static void setSLinePlacement(SLine* sli, const String& placement) } else { sli->setPlacement(placement == u"above" ? PlacementV::ABOVE : PlacementV::BELOW); sli->setPropertyFlags(Pid::PLACEMENT, PropertyFlags::UNSTYLED); + sli->resetProperty(Pid::OFFSET); } } } @@ -3442,6 +3448,7 @@ void MusicXmlParserDirection::direction(const String& partId, if (!m_hasDefaultY) { t->setPlacement(PlacementV::ABOVE); // crude way to force placement TODO improve ? t->setPropertyFlags(Pid::PLACEMENT, PropertyFlags::UNSTYLED); + t->resetProperty(Pid::OFFSET); } } } @@ -4540,6 +4547,7 @@ void MusicXmlParserDirection::handleChordSym(const Fraction& tick, HarmonyMap& h ha->setTrack(m_track); ha->setPlacement(placement() == u"above" ? PlacementV::ABOVE : PlacementV::BELOW); ha->setPropertyFlags(Pid::PLACEMENT, PropertyFlags::UNSTYLED); + ha->resetProperty(Pid::OFFSET); ha->setVisible(m_visible); HarmonyDesc newHarmonyDesc(m_track, ha, nullptr); @@ -5385,7 +5393,8 @@ void MusicXmlParserPass2::barline(const String& partId, Measure* measure, const } if (fermataType == u"inverted") { fermata->setPlacement(PlacementV::BELOW); - } else if (fermataType == u"") { + fermata->resetProperty(Pid::OFFSET); + } else if (fermataType.empty()) { fermata->setPlacement(fermata->propertyDefault(Pid::PLACEMENT).value()); } @@ -7237,6 +7246,7 @@ FiguredBass* MusicXmlParserPass2::figuredBass() fb->setPlacement(placement == "above" ? PlacementV::ABOVE : PlacementV::BELOW); fb->setPropertyFlags(Pid::PLACEMENT, PropertyFlags::UNSTYLED); + fb->resetProperty(Pid::OFFSET); if (normalizedText.empty()) { delete fb; @@ -7383,6 +7393,7 @@ void MusicXmlParserPass2::harmony(const String& partId, Measure* measure, const if (!placement.isEmpty()) { ha->setPlacement(placement == "below" ? PlacementV::BELOW : PlacementV::ABOVE); ha->setPropertyFlags(Pid::PLACEMENT, PropertyFlags::UNSTYLED); + ha->resetProperty(Pid::OFFSET); } while (m_e.readNextStartElement()) { if (m_e.name() == "root") { @@ -7516,6 +7527,7 @@ void MusicXmlParserPass2::harmony(const String& partId, Measure* measure, const ha->setVisible(printObject); if (placement == u"below") { ha->setPlacement(PlacementV::BELOW); + ha->resetProperty(Pid::OFFSET); } if (color.isValid()) { ha->setColor(color); @@ -7730,6 +7742,7 @@ void MusicXmlParserLyric::parse() item->setPlacement(placement() == "above" ? PlacementV::ABOVE : PlacementV::BELOW); item->setPropertyFlags(Pid::PLACEMENT, PropertyFlags::UNSTYLED); + item->resetProperty(Pid::OFFSET); if (!RealIsNull(relX)) { PointF offset = item->offset(); diff --git a/src/importexport/musicxml/tests/data/testPlacementOffsetDefaults.xml b/src/importexport/musicxml/tests/data/testPlacementOffsetDefaults.xml new file mode 100644 index 0000000000000..ce79cac4a3267 --- /dev/null +++ b/src/importexport/musicxml/tests/data/testPlacementOffsetDefaults.xml @@ -0,0 +1,194 @@ + + + + + Untitled score + + + Composer / arranger + + MuseScore 4.4.1 + 2024-09-08 + + + + + + + + + + 6.99911 + 40 + + + 1696.94 + 1200.48 + + 85.7252 + 85.7252 + 85.7252 + 85.7252 + + + 85.7252 + 85.7252 + 85.7252 + 85.7252 + + + + 1.8 + 5.5 + 5 + 4.5 + 1 + 1 + 1.1 + 1 + 1.6 + 1.1 + 1.1 + 2.1 + 0.5 + 1.1 + 1 + 2.1 + 0.5 + 1 + 1.2 + 70 + 70 + 49 + + + + + + + title + Untitled score + + + subtitle + Subtitle + + + composer + Composer / arranger + + + + Voice + Vo. + + Voice + voice.vocals + + + + 1 + 53 + 78.7402 + 0 + + + + + + + + + 50 + 0 + + 170 + + + + 1 + + 0 + + + + G + 2 + + + + + 4 + 1 + + single + Lyrics + + + + + + + 4 + 1 + + single + lyrics + + + + + + + + 0 + -0 + + 205 + + + + + 4 + 1 + + single + lyrics + + + + + + + 4 + 1 + + single + lyrics + + + + + + + + 0 + 903.44 + + 205 + + + + + 4 + 1 + + + light-heavy + + + + diff --git a/src/importexport/musicxml/tests/data/testPlacementOffsetDefaults_ref.mscx b/src/importexport/musicxml/tests/data/testPlacementOffsetDefaults_ref.mscx new file mode 100644 index 0000000000000..07e3cb3cc5bf1 --- /dev/null +++ b/src/importexport/musicxml/tests/data/testPlacementOffsetDefaults_ref.mscx @@ -0,0 +1,211 @@ + + + + 480 + + 1 + 1 + 1 + 0 + + Composer / arranger + + + + + + + + Untitled score + + + + stdNormal + + 3 + + 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 + + + + + + + + + + 10 + + + + Untitled score + + + + + Subtitle + + + + Composer / arranger + + + + + + G + G + 1 + + + 4 + 4 + + + measure + 1/1 + + Lyrics + + + + + + + line + + + + measure + 1/1 + + + lyrics + + + + + + + + measure + 1/1 + + above + lyrics + + + + + + + line + + + + measure + 1/1 + + above + + lyrics + + + + + + + + measure + 1/1 + + + end + + + + + + diff --git a/src/importexport/musicxml/tests/musicxml_tests.cpp b/src/importexport/musicxml/tests/musicxml_tests.cpp index b42f0268904e4..3bff6875addfd 100644 --- a/src/importexport/musicxml/tests/musicxml_tests.cpp +++ b/src/importexport/musicxml/tests/musicxml_tests.cpp @@ -974,6 +974,9 @@ TEST_F(MusicXml_Tests, placementDefaults) { TEST_F(MusicXml_Tests, printSpacingNo) { musicXmlIoTestRef("testPrintSpacingNo"); } +TEST_F(MusicXml_Tests, placementOffsetDefaults) { + musicXmlImportTestRef("testPlacementOffsetDefaults"); +} TEST_F(MusicXml_Tests, repeatCounts) { musicXmlIoTest("testRepeatCounts"); }