Skip to content

Commit

Permalink
Merge pull request #20225 from rettinghaus/fix/lines
Browse files Browse the repository at this point in the history
Fix #18158: Do not export invisible text lines
  • Loading branch information
RomanPudashkin committed Dec 5, 2023
2 parents 627846a + e30f011 commit 6bdf8dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 18 additions & 6 deletions src/importexport/musicxml/internal/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5013,6 +5013,10 @@ void ExportMusicXml::hairpin(Hairpin const* const hp, staff_idx_t staff, const F
const auto isLineType = hp->isLineType();
int n;
if (isLineType) {
if (!hp->lineVisible() && ((hp->beginText().isEmpty() && hp->tick() == tick)
|| (hp->endText().isEmpty() && hp->tick() != tick))) {
return;
}
n = findDashes(hp);
if (n >= 0) {
dashes[n] = nullptr;
Expand Down Expand Up @@ -5249,6 +5253,12 @@ int ExportMusicXml::findBracket(const TextLineBase* tl) const
void ExportMusicXml::textLine(TextLineBase const* const tl, staff_idx_t staff, const Fraction& tick)
{
using namespace mu::draw;

if (!tl->lineVisible() && ((tl->beginText().isEmpty() && tl->tick() == tick)
|| (tl->endText().isEmpty() && tl->tick() != tick))) {
return;
}

int n;
// special case: a dashed line w/o hooks is written as dashes
const auto isDashes = tl->lineStyle() == LineType::DASHED && (tl->beginHookType() == HookType::NONE)
Expand Down Expand Up @@ -5350,13 +5360,15 @@ void ExportMusicXml::textLine(TextLineBase const* const tl, staff_idx_t staff, c
_xml.endElement();
}

_xml.startElement("direction-type");
if (isDashes) {
_xml.tag("dashes", { { "type", type }, { "number", n + 1 } });
} else {
_xml.tagRaw(QString("bracket type=\"%1\" number=\"%2\" line-end=\"%3\"%4").arg(type, QString::number(n + 1), lineEnd, rest));
if (tl->lineVisible()) {
_xml.startElement("direction-type");
if (isDashes) {
_xml.tag("dashes", { { "type", type }, { "number", n + 1 } });
} else {
_xml.tagRaw(QString("bracket type=\"%1\" number=\"%2\" line-end=\"%3\"%4").arg(type, QString::number(n + 1), lineEnd, rest));
}
_xml.endElement();
}
_xml.endElement();

if (!tl->endText().isEmpty() && tl->tick() != tick) {
_xml.startElement("direction-type");
Expand Down
2 changes: 0 additions & 2 deletions src/importexport/musicxml/tests/data/testColorExport_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@
</ornaments>
</notations>
</note>
<direction placement="below">
</direction>
</measure>
<measure number="6">
<direction placement="below">
Expand Down

0 comments on commit 6bdf8dc

Please sign in to comment.