Skip to content

Commit

Permalink
export page numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
rettinghaus committed Oct 25, 2024
1 parent 0697944 commit 46c90a7
Showing 1 changed file with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class ExportMusicXml : public muse::Injectable
void keysigTimesig(const Measure* m, const Part* p);
void chordAttributes(Chord* chord, Notations& notations, Technical& technical, TrillHash& trillStart, TrillHash& trillStop);
void wavyLineStartStop(const ChordRest* cr, Notations& notations, Ornaments& ornaments, TrillHash& trillStart, TrillHash& trillStop);
void print(const Measure* const m, const int partNr, const int firstStaffOfPart, const int nrStavesInPart,
void print(const Measure* const m, const int partNr, const int firstStaffOfPart, const size_t nrStavesInPart,
const MeasurePrintContext& mpc);
void measureLayout(const double distance);
void findAndExportClef(const Measure* const m, const int staves, const track_idx_t strack, const track_idx_t etrack);
Expand Down Expand Up @@ -7161,41 +7161,48 @@ static bool hasPageBreak(const System* const system)
*/

void ExportMusicXml::print(const Measure* const m, const int partNr, const int firstStaffOfPart,
const int nrStavesInPart, const MeasurePrintContext& mpc)
const size_t nrStavesInPart, const MeasurePrintContext& mpc)
{
const MeasureBase* const prevSysMB = lastMeasureBase(mpc.prevSystem);

const bool prevMeasLineBreak = prevSysMB ? prevSysMB->lineBreak() : false;
const bool prevMeasSectionBreak = prevSysMB ? prevSysMB->sectionBreak() : false;
const bool prevPageBreak = hasPageBreak(mpc.lastSystemPrevPage);

String newSystemOrPage; // new-[system|page]="yes" or empty
if (!mpc.scoreStart) {
IMusicXmlConfiguration::MusicXmlExportBreaksType exportBreaksType = configuration()->exportBreaksType();
XmlWriter::Attributes attributes;

IMusicXmlConfiguration::MusicXmlExportBreaksType exportBreaksType = configuration()->exportBreaksType();
if (!mpc.scoreStart) {
if (exportBreaksType == IMusicXmlConfiguration::MusicXmlExportBreaksType::All) {
if (mpc.pageStart) {
newSystemOrPage = u" new-page=\"yes\"";
attributes.push_back({ "new-page", "yes" });
} else if (mpc.systemStart) {
newSystemOrPage = u" new-system=\"yes\"";
attributes.push_back({ "new-system", "yes" });
}
} else if (exportBreaksType == IMusicXmlConfiguration::MusicXmlExportBreaksType::Manual) {
if (mpc.pageStart && prevPageBreak) {
newSystemOrPage = u" new-page=\"yes\"";
attributes.push_back({ "new-page", "yes" });
} else if (mpc.systemStart && (prevMeasLineBreak || prevMeasSectionBreak)) {
newSystemOrPage = u" new-system=\"yes\"";
attributes.push_back({ "new-system", "yes" });
}
}
}

bool doBreak = mpc.scoreStart || (!newSystemOrPage.empty());
if (mpc.pageStart && m->system()) {
const int pageNumber = m->system()->page()->no() + 1 + m->score()->pageNumberOffset();
if (exportBreaksType != IMusicXmlConfiguration::MusicXmlExportBreaksType::No) {
attributes.push_back({ "page-number", pageNumber });
}
}

bool doBreak = mpc.scoreStart || !attributes.empty();
bool doLayout = configuration()->exportLayout();

if (doBreak) {
if (doLayout) {
m_xml.startElementRaw(String(u"print%1").arg(newSystemOrPage));
m_xml.startElement("print", attributes);
const MStyle& style = score()->style();
const double pageWidth = getTenthsFromInches(style.styleD(Sid::pageWidth));
const double pageWidth = getTenthsFromInches(style.styleD(Sid::pageWidth));
const double lm = getTenthsFromInches(style.styleD(Sid::pageOddLeftMargin));
const double rm = getTenthsFromInches(style.styleD(Sid::pageWidth)
- style.styleD(Sid::pagePrintableWidth)
Expand Down Expand Up @@ -7243,7 +7250,7 @@ void ExportMusicXml::print(const Measure* const m, const int partNr, const int f
}

// Staff layout elements.
for (int staffIdx = (firstStaffOfPart == 0) ? 1 : 0; staffIdx < nrStavesInPart; staffIdx++) {
for (size_t staffIdx = (firstStaffOfPart == 0) ? 1 : 0; staffIdx < nrStavesInPart; ++staffIdx) {
// calculate distance between this and previous staff using the bounding boxes
const int staffNr = firstStaffOfPart + staffIdx;
const RectF& prevBbox = system->staff(staffNr - 1)->bbox();
Expand All @@ -7260,8 +7267,8 @@ void ExportMusicXml::print(const Measure* const m, const int partNr, const int f
}

m_xml.endElement();
} else if (!newSystemOrPage.empty()) {
m_xml.tagRaw(String(u"print%1").arg(newSystemOrPage));
} else if (!attributes.empty()) {
m_xml.tag("print", attributes);
}
} else if (m->prev() && m->prev()->isHBox()) {
m_xml.startElement("print");
Expand Down Expand Up @@ -8185,7 +8192,7 @@ void ExportMusicXml::writeMeasure(const Measure* const m,

m_xml.startElementRaw(measureTag);

print(m, partIndex, staffCount, static_cast<int>(staves), mpc);
print(m, partIndex, staffCount, staves, mpc);

m_attr.start();

Expand Down

0 comments on commit 46c90a7

Please sign in to comment.