Skip to content

Commit

Permalink
fix #21205: don't show page number on first page
Browse files Browse the repository at this point in the history
unless $P gets used instead of the default of $p, just like the default
setting for 1.x scores.
Also add $c and $C for copyright, with $c being a shortcut for
$:copyright: and $C showing it on first page only.
  • Loading branch information
Jojo-Schmitz committed Mar 10, 2014
1 parent 5297c96 commit 87436c2
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions libmscore/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,13 +602,16 @@ void Page::doRebuildBspTree()

//---------------------------------------------------------
// replaceTextMacros
// $p - page number
// $$ - $
// $p - page number, except on first page
// $P - page number, on all pages
// $n - number of pages
// $f - file name
// $F - file path+name
// $d - current date
// $D - creation date
// $C - copyright, on first page only
// $c - copyright, on all pages
// $$ - the $ sign itself
// $:tag: - meta data tag
// already defined tags:
// movementNumber
Expand All @@ -621,19 +624,19 @@ void Page::doRebuildBspTree()

QString Page::replaceTextMacros(const QString& s) const
{
int pageno = no() + 1 + _score->pageNumberOffset();
QString d;
int n = s.size();
for (int i = 0; i < n; ++i) {
for (int i = 0, n = s.size(); i < n; ++i) {
QChar c = s[i];
if (c == '$' && (i < (n-1))) {
QChar c = s[i+1];
switch(c.toLatin1()) {
case 'p':
d += QString("%1").arg(pageno);
case 'p': // not on first page 1
if (_no) // FALLTHROUGH
case 'P': // on all pages
d += QString("%1").arg(_no + 1 + _score->pageNumberOffset());
break;
case 'n':
d += QString("%1").arg(_score->pages().size() + _score->pageNumberOffset());
d += QString("%1").arg(_score->npages() + _score->pageNumberOffset());
break;
case 'f':
d += _score->name();
Expand All @@ -646,12 +649,16 @@ QString Page::replaceTextMacros(const QString& s) const
break;
case 'D':
{
QString creationDate = score()->metaTag("creationDate");
if(!creationDate.isNull()) {
QString creationDate = _score->metaTag("creationDate");
if (!creationDate.isNull())
d += QDate::fromString(creationDate, Qt::ISODate).toString(Qt::DefaultLocaleShortDate);
}
}
break;
case 'C': // only on first page
if (!_no) // FALLTHROUGH
case 'c':
d += _score->metaTag("copyright");
break;
case '$':
d += '$';
break;
Expand All @@ -665,7 +672,7 @@ QString Page::replaceTextMacros(const QString& s) const
tag += s[k];
}
if (k != n) { // found ':' ?
d += score()->metaTag(tag);
d += _score->metaTag(tag);
i = k-1;
}
}
Expand All @@ -689,7 +696,7 @@ QString Page::replaceTextMacros(const QString& s) const

bool Page::isOdd() const
{
return (_no + 1 + score()->pageNumberOffset()) & 1;
return (_no + 1 + _score->pageNumberOffset()) & 1;
}

//---------------------------------------------------------
Expand Down

2 comments on commit 87436c2

@mgavioli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand the rationale behind the distinction between $p and $P:

  1. Are there cases when you need not to display the page number only, but the other header/footer elements remain displayed (i.e. a distinction not covered by the general "Hide on first page" header/footer property)?
  2. The "first page" is the first page of the score or page no. 1? They are different concepts, if page numbers are offset.

@Jojo-Schmitz
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. yes, there are, e.g when a score has only one page I don't want to see the number, but I do want to see the copyright. Also this was the default in 1.x.
  2. it is first page, not page Fix make -f Makefile.osx revision on osx #1

Please sign in to comment.