@@ -2368,7 +2368,7 @@ void MusicXMLParserPass2::attributes(const QString& partId, Measure* measure, co
2368
2368
} else if (_e.name () == " measure-style" ) {
2369
2369
measureStyle (measure);
2370
2370
} else if (_e.name () == " staff-details" ) {
2371
- staffDetails (partId);
2371
+ staffDetails (partId, measure );
2372
2372
} else if (_e.name () == " time" ) {
2373
2373
time (partId, measure, tick);
2374
2374
} else if (_e.name () == " transpose" ) {
@@ -2401,7 +2401,7 @@ static void setStaffLines(Score* score, staff_idx_t staffIdx, int stafflines)
2401
2401
Parse the /score-partwise/part/measure/attributes/staff-details node.
2402
2402
*/
2403
2403
2404
- void MusicXMLParserPass2::staffDetails (const QString& partId)
2404
+ void MusicXMLParserPass2::staffDetails (const QString& partId, Measure* measure )
2405
2405
{
2406
2406
// logDebugTrace("MusicXMLParserPass2::staffDetails");
2407
2407
@@ -2426,8 +2426,23 @@ void MusicXMLParserPass2::staffDetails(const QString& partId)
2426
2426
2427
2427
StringData* t = new StringData;
2428
2428
QString visible = _e.attributes ().value (" print-object" ).toString ();
2429
+ QString spacing = _e.attributes ().value (" print-spacing" ).toString ();
2429
2430
if (visible == " no" ) {
2430
- _score->staff (staffIdx)->setVisible (false );
2431
+ // EITHER:
2432
+ // 1) this indicates an empty staff that is hidden
2433
+ // 2) this indicates a cutaway measure. if it is a cutaway measure then print-spacing will be yes
2434
+ if (spacing == " yes" ) {
2435
+ measure->setStaffVisible (staffIdx, false );
2436
+ } else if (measure && !measure->hasVoices (staffIdx) && measure->isOnlyRests (staffIdx * VOICES)) {
2437
+ // measures with print-object="no" are generally exported by exporters such as dolet when empty staves are hidden.
2438
+ // for this reason, if we see an empty measure with print-object="no", we can assume that this indicates we should set
2439
+ // the hide empty staves style.
2440
+ _score->setStyleValue (Sid::hideEmptyStaves, true );
2441
+ _score->setStyleValue (Sid::dontHideStavesInFirstSystem, false );
2442
+ } else {
2443
+ // this doesn't apply to a measure, so we'll assume the entire staff has to be hidden.
2444
+ _score->staff (staffIdx)->setVisible (false );
2445
+ }
2431
2446
} else if (!visible.isEmpty () && visible != " yes" ) {
2432
2447
_logger->logError (QString (" print-object should be \" yes\" or \" no\" " ));
2433
2448
}
0 commit comments