Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #18158: Do not export invisible text lines #20225

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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