Skip to content
Closed
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
11 changes: 8 additions & 3 deletions importexport/musicxml/importmxmlpass1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ static VBox* addCreditWords(Score* const score, const CreditWordsList& crWords,
}

//---------------------------------------------------------
// createMeasuresAndVboxes
// createDefaultHeader
//---------------------------------------------------------

void MusicXMLParserPass1::createDefaultHeader(Score* const score)
Expand Down Expand Up @@ -1163,8 +1163,13 @@ void MusicXMLParserPass1::identification()
QString strType = _e.attributes().value("type").toString();
_score->setMetaTag(strType, _e.readElementText());
}
else if (_e.name() == "rights")
_score->setMetaTag("copyright", _e.readElementText());
else if (_e.name() == "rights") {
_score->setMetaTag("copyright", _e.readElementText().trimmed());
bool copyrightFirstPageOnly = true; // TODO: expose as import setting
if (copyrightFirstPageOnly)
// Somewhat temporary fix: hide footer and make copyright a text box
_score->setStyleValue(Sid::showFooter, false);
}
else if (_e.name() == "encoding") {
// TODO
while (_e.readNextStartElement()) {
Expand Down
56 changes: 55 additions & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@
#include "libmscore/system.h"
#include "libmscore/tempo.h"
#include "libmscore/tempotext.h"
#include "libmscore/text.h"
#include "libmscore/tie.h"
#include "libmscore/timesig.h"
#include "libmscore/tremolo.h"
#include "libmscore/trill.h"
#include "libmscore/utils.h"
#include "libmscore/box.h"
#include "libmscore/volta.h"
#include "libmscore/textline.h"
#include "libmscore/barline.h"
Expand Down Expand Up @@ -619,6 +621,52 @@ static void setPartInstruments(MxmlLogger* logger, const QXmlStreamReader* const
}
}
}

//---------------------------------------------------------
// addCopyrightVBox
//---------------------------------------------------------

static MeasureBase* findFirstPageBreak(Score* score)
{
for (MeasureBase* mb = score->first(); mb; mb = mb->next())
if (mb->pageBreak())
return mb;
// If no imported pageBreaks, find the last measure of the
// second-to-last or last system of the first page
score->doLayout();
if (score->pages().size() == 1) return score->last();
auto firstPageSystems = score->pages().first()->systems();
MeasureBase* lastMeasureOfFirstPageAdjusted = firstPageSystems[firstPageSystems.length() - 2]->measures().back();
return lastMeasureOfFirstPageAdjusted ? lastMeasureOfFirstPageAdjusted : score->last();
}

//---------------------------------------------------------
// addCopyrightVBox
//---------------------------------------------------------

/**
Adds VBox at the end of the first page with copyright info
*/

void MusicXMLParserPass2::addCopyrightVBox()
{
if (_score->metaTag("copyright").isEmpty())
return;
Text* copyrightText = new Text(_score);
VBox* copyrightVBox = new VBox(_score);
copyrightText->setPlainText(_score->metaTag("copyright"));
copyrightText->setAlign(Align::BASELINE | Align::HCENTER);
copyrightText->setPropertyFlags(Pid::ALIGN, PropertyFlags::UNSTYLED);
copyrightVBox->add(copyrightText);
copyrightVBox->setAutoSizeEnabled(true);
MeasureBase* mb = findFirstPageBreak(_score);
_score->addMeasure(copyrightVBox, mb->next());
copyrightVBox->setPageBreak(true);
if (mb->pageBreak()) {
mb->setPageBreak(false);
mb->setLineBreak(true);
}
}

//---------------------------------------------------------
// text2syms
Expand Down Expand Up @@ -1893,10 +1941,16 @@ void MusicXMLParserPass2::scorePartwise()
_score->lastMeasure()->setEndBarLineType(BarLineType::NORMAL, 0);

_score->connectArpeggios();
_score->fixupLaissezVibrer();
_score->fixupLaissezVibrer();
cleanFretDiagrams(_score->firstMeasure());
if (_pass1.hasInferredHeaderText())
reformatHeaderVBox(_score->measures()->first());

bool copyrightFirstPageOnly = true; // TODO: expose as import setting
if (copyrightFirstPageOnly)
// Somewhat temporary fix: hide footer and make copyright a text box
addCopyrightVBox();

cleanUpLayoutBreaks(_score, _logger);
}

Expand Down
1 change: 1 addition & 0 deletions importexport/musicxml/importmxmlpass2.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class MusicXMLParserPass2 {
void doEnding(const QString& partId, Measure* measure, const QString& number, const QString& type, const QString& text, const bool print);
void staffDetails(const QString& partId);
void staffTuning(StringData* t);
void addCopyrightVBox();
void skipLogCurrElem();

// multi-measure rest state handling
Expand Down
Loading