void PageFormat::write(XmlWriter& xml) const { xml.stag("page-layout"); // convert inch to 1/10 spatium units // 20 - font design size in point // SPATIUM = 20/4 // qreal t = 10 * PPI / (20 / 4); qreal t = 2 * PPI; xml.tag("page-height", _size.height() * t); xml.tag("page-width", _size.width() * t); const char* type = "both"; if (_twosided) { type = "even"; xml.stag(QString("page-margins type=\"%1\"").arg(type)); xml.tag("left-margin", evenLeftMargin() * t); xml.tag("right-margin", evenRightMargin() * t); xml.tag("top-margin", evenTopMargin() * t); xml.tag("bottom-margin", evenBottomMargin() * t); xml.etag(); type = "odd"; } xml.stag(QString("page-margins type=\"%1\"").arg(type)); xml.tag("left-margin", oddLeftMargin() * t); xml.tag("right-margin", oddRightMargin() * t); xml.tag("top-margin", oddTopMargin() * t); xml.tag("bottom-margin", oddBottomMargin() * t); xml.etag(); xml.etag(); }
void Spacer::write(XmlWriter& xml) const { xml.stag(name()); xml.tag("subtype", int(_spacerType)); Element::writeProperties(xml); xml.tag("space", _gap / spatium()); xml.etag(); }
void Image::write(XmlWriter& xml) const { // attempt to convert the _linkPath to a path relative to the score // // TODO : on Save As, score()->fileInfo() still contains the old path and fname // if the Save As path is different, image relative path will be wrong! // QString relativeFilePath= QString(); if (!_linkPath.isEmpty() && _linkIsValid) { QFileInfo fi(_linkPath); // score()->fileInfo()->canonicalPath() would be better // but we are saving under a temp file name and the 'final' file // might not exist yet, so canonicalFilePath() may return only "/" // OTOH, the score 'final' file name is practically always canonical, at this point QString scorePath = score()->masterScore()->fileInfo()->absolutePath(); QString imgFPath = fi.canonicalFilePath(); // if imgFPath is in (or below) the directory of scorePath if (imgFPath.startsWith(scorePath, Qt::CaseSensitive)) { // relative img path is the part exceeding scorePath imgFPath.remove(0, scorePath.size()); if(imgFPath.startsWith('/')) imgFPath.remove(0, 1); relativeFilePath = imgFPath; } // try 1 level up else { // reduce scorePath by one path level fi.setFile(scorePath); scorePath = fi.path(); // if imgFPath is in (or below) the directory up the score directory if (imgFPath.startsWith(scorePath, Qt::CaseSensitive)) { // relative img path is the part exceeding new scorePath plus "../" imgFPath.remove(0, scorePath.size()); if (!imgFPath.startsWith('/')) imgFPath.prepend('/'); imgFPath.prepend(".."); relativeFilePath = imgFPath; } } } // if no match, use full _linkPath if (relativeFilePath.isEmpty()) relativeFilePath = _linkPath; xml.stag(this); BSymbol::writeProperties(xml); // keep old "path" tag, for backward compatibility and because it is used elsewhere // (for instance by Box:read(), Measure:read(), Note:read(), ...) xml.tag("path", _storeItem ? _storeItem->hashName() : relativeFilePath); xml.tag("linkPath", relativeFilePath); writeProperty(xml, Pid::AUTOSCALE); writeProperty(xml, Pid::SIZE); writeProperty(xml, Pid::LOCK_ASPECT_RATIO); writeProperty(xml, Pid::SIZE_IS_SPATIUM); xml.etag(); }
void Symbol::write(XmlWriter& xml) const { xml.stag(this); xml.tag("name", Sym::id2name(_sym)); if (_scoreFont) xml.tag("font", _scoreFont->name()); BSymbol::writeProperties(xml); xml.etag(); }
void FSymbol::write(XmlWriter& xml) const { xml.stag(this); xml.tag("font", _font.family()); xml.tag("fontsize", _font.pointSizeF()); xml.tag("code", _code); BSymbol::writeProperties(xml); xml.etag(); }
void TempoText::write(XmlWriter& xml) const { xml.stag(name()); xml.tag("tempo", _tempo); if (_followText) xml.tag("followText", _followText); TextBase::writeProperties(xml); xml.etag(); }
void Jump::write(XmlWriter& xml) const { xml.stag(name()); Text::writeProperties(xml); xml.tag("jumpTo", _jumpTo); xml.tag("playUntil", _playUntil); xml.tag("continueAt", _continueAt); writeProperty(xml, P_ID::PLAY_REPEATS); xml.etag(); }
void ScoreElement::writeProperty(XmlWriter& xml, P_ID id) const { if (propertyType(id) == P_TYPE::SP_REAL) { qreal _spatium = score()->spatium(); xml.tag(id, QVariant(getProperty(id).toReal()/_spatium), QVariant(propertyDefault(id).toReal()/_spatium)); } else xml.tag(id, getProperty(id), propertyDefault(id)); }
void Ambitus::write(XmlWriter& xml) const { xml.stag(this); xml.tag(Pid::HEAD_GROUP, int(_noteHeadGroup), int(NOTEHEADGROUP_DEFAULT)); xml.tag(Pid::HEAD_TYPE, int(_noteHeadType), int(NOTEHEADTYPE_DEFAULT)); xml.tag(Pid::MIRROR_HEAD,int(_dir), int(DIR_DEFAULT)); xml.tag("hasLine", _hasLine, true); xml.tag(Pid::LINE_WIDTH, _lineWidth, LINEWIDTH_DEFAULT); xml.tag("topPitch", _topPitch); xml.tag("topTpc", _topTpc); xml.tag("bottomPitch",_bottomPitch); xml.tag("bottomTpc", _bottomTpc); if (_topAccid.accidentalType() != AccidentalType::NONE) { xml.stag("topAccidental"); _topAccid.write(xml); xml.etag(); } if (_bottomAccid.accidentalType() != AccidentalType::NONE) { xml.stag("bottomAccidental"); _bottomAccid.write(xml); xml.etag(); } Element::writeProperties(xml); xml.etag(); }
void Part::write(XmlWriter& xml) const { xml.stag("Part"); foreach(const Staff* staff, _staves) staff->write(xml); if (!_show) xml.tag("show", _show); xml.tag("trackName", _partName); instrument()->write(xml, const_cast<Part*>(this)); // Safe, we do not write anything to it xml.etag(); }
void Omr::write(XmlWriter& xml) const { xml.stag("Omr"); xml.tag("path", _path); xml.tag("spatium", _spatium); xml.tag("dpmm", _dpmm); for(OmrPage* page : _pages) { page->write(xml); } xml.etag(); }
void StringData::write(XmlWriter& xml) const { xml.stag("StringData"); xml.tag("frets", _frets); foreach(instrString strg, stringTable) { if (strg.open) xml.tag("string open=\"1\"", strg.pitch); else xml.tag("string", strg.pitch); } xml.etag(); }
void Clef::write(XmlWriter& xml) const { xml.stag(name()); if (_clefTypes._concertClef != ClefType::INVALID) xml.tag("concertClefType", ClefInfo::tag(_clefTypes._concertClef)); if (_clefTypes._transposingClef != ClefType::INVALID) xml.tag("transposingClefType", ClefInfo::tag(_clefTypes._transposingClef)); if (!_showCourtesy) xml.tag("showCourtesyClef", _showCourtesy); Element::writeProperties(xml); xml.etag(); }
void Glissando::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(QString("%1 id=\"%2\"").arg(name()).arg(xml.spannerId(this))); if (_showText && !_text.isEmpty()) xml.tag("text", _text); xml.tag("subtype", int(_glissandoType)); writeProperty(xml, P_ID::PLAY); writeProperty(xml, P_ID::GLISSANDO_STYLE); SLine::writeProperties(xml); xml.etag(); }
void KeySig::write(XmlWriter& xml) const { xml.stag(name()); Element::writeProperties(xml); if (_sig.isAtonal()) { xml.tag("custom", 1); } else if (_sig.custom()) { xml.tag("custom", 1); for (const KeySym& ks : _sig.keySymbols()) { xml.stag("KeySym"); xml.tag("sym", Sym::id2name(ks.sym)); xml.tag("pos", ks.spos); xml.etag(); } } else { xml.tag("accidental", int(_sig.key())); } switch (_sig.mode()) { case KeyMode::NONE: xml.tag("mode", "none"); break; case KeyMode::MAJOR: xml.tag("mode", "major"); break; case KeyMode::MINOR: xml.tag("mode", "minor"); break; case KeyMode::UNKNOWN: default: ; } if (!_showCourtesy) xml.tag("showCourtesySig", _showCourtesy); xml.etag(); }
void LayoutBreak::write(XmlWriter& xml) const { xml.stag(this); Element::writeProperties(xml); writeProperty(xml, Pid::LAYOUT_BREAK); writeProperty(xml, Pid::PAUSE); if (!_startWithLongNames) xml.tag("startWithLongNames", _startWithLongNames); if (!_startWithMeasureOne) xml.tag("startWithMeasureOne", _startWithMeasureOne); xml.etag(); }
void StaffTextBase::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(name()); for (ChannelActions s : _channelActions) { int channel = s.channel; for (QString name : s.midiActionNames) xml.tagE(QString("MidiAction channel=\"%1\" name=\"%2\"").arg(channel).arg(name)); } for (int voice = 0; voice < VOICES; ++voice) { if (!_channelNames[voice].isEmpty()) xml.tagE(QString("channelSwitch voice=\"%1\" name=\"%2\"").arg(voice).arg(_channelNames[voice])); } if (_setAeolusStops) { for (int i = 0; i < 4; ++i) xml.tag(QString("aeolus group=\"%1\"").arg(i), aeolusStops[i]); } if (swing()) { QString swingUnit; if (swingParameters()->swingUnit == MScore::division / 2) swingUnit = TDuration(TDuration::DurationType::V_EIGHTH).name(); else if (swingParameters()->swingUnit == MScore::division / 4) swingUnit = TDuration(TDuration::DurationType::V_16TH).name(); else swingUnit = TDuration(TDuration::DurationType::V_ZERO).name(); int swingRatio = swingParameters()->swingRatio; xml.tagE(QString("swing unit=\"%1\" ratio= \"%2\"").arg(swingUnit).arg(swingRatio)); } TextBase::writeProperties(xml); xml.etag(); }
void Workspace::writeMenu(XmlWriter& xml, QMenu* menu) { // Recursively save QMenu for (QAction* action : menu->actions()) { if (action->isSeparator()) xml.tag("action", ""); else if (action->menu()) { xml.stag("Menu name=\"" + findStringFromMenu(action->menu()) + "\""); writeMenu(xml, action->menu()); xml.etag(); } else { xml.tag("action", findStringFromAction(action)); } } }
void Marker::write(XmlWriter& xml) const { xml.stag(name()); Text::writeProperties(xml); xml.tag("label", _label); xml.etag(); }
void BSymbol::writeProperties(XmlWriter& xml) const { if (systemFlag()) xml.tag("systemFlag", systemFlag()); for (const Element* e : leafs()) e->write(xml); Element::writeProperties(xml); }
void Stem::write(XmlWriter& xml) const { xml.stag("Stem"); Element::writeProperties(xml); if (_userLen != 0.0) xml.tag("userLen", _userLen / spatium()); xml.etag(); }
void Tremolo::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(name()); xml.tag("subtype", tremoloTypeName()); Element::writeProperties(xml); xml.etag(); }
void Vibrato::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(this); xml.tag("subtype", vibratoTypeName()); writeProperty(xml, Pid::PLAY); SLine::writeProperties(xml); xml.etag(); }
void Workspace::writeMenuBar(XmlWriter& xml, QMenuBar* mb) { // Loop through each menu in menubar. For each menu, call writeMenu. xml.stag("MenuBar"); if (!mb) mb = mscore->menuBar(); for (QAction* action : mb->actions()) { if (action->isSeparator()) xml.tag("action", ""); else if (action->menu()) { xml.stag("Menu name=\"" + findStringFromMenu(action->menu()) + "\""); writeMenu(xml, action->menu()); xml.etag(); } else xml.tag("action", findStringFromAction(action)); } xml.etag(); }
void TimeSig::write(XmlWriter& xml) const { xml.stag("TimeSig"); writeProperty(xml, P_ID::TIMESIG_TYPE); Element::writeProperties(xml); xml.tag("sigN", _sig.numerator()); xml.tag("sigD", _sig.denominator()); if (stretch() != Fraction(1,1)) { xml.tag("stretchN", stretch().numerator()); xml.tag("stretchD", stretch().denominator()); } writeProperty(xml, P_ID::NUMERATOR_STRING); writeProperty(xml, P_ID::DENOMINATOR_STRING); if (!_groups.empty()) _groups.write(xml); writeProperty(xml, P_ID::SHOW_COURTESY); writeProperty(xml, P_ID::SCALE); xml.etag(); }
void Ottava::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(this); xml.tag("subtype", ottavaDefault[int(ottavaType())].name); writeProperty(xml, Pid::PLACEMENT); // for (const StyledProperty& spp : *styledProperties()) // writeProperty(xml, spp.pid); TextLineBase::writeProperties(xml); xml.etag(); }
void Volta::write(XmlWriter& xml) const { xml.stag(QString("%1 id=\"%2\"").arg(name()).arg(xml.spannerId(this))); TextLineBase::writeProperties(xml); QString s; for (int i : _endings) { if (!s.isEmpty()) s += ", "; s += QString("%1").arg(i); } xml.tag("endings", s); xml.etag(); }
void Ottava::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(QString("%1 id=\"%2\"").arg(name()).arg(xml.spannerId(this))); xml.tag("subtype", ottavaDefault[int(ottavaType())].name); for (const StyledProperty& spp : *styledProperties()) writeProperty(xml, spp.pid); Element::writeProperties(xml); xml.etag(); }
void Fermata::write(XmlWriter& xml) const { if (!xml.canWrite(this)) { qDebug("%s not written", name()); return; } xml.stag(this); xml.tag("subtype", Sym::id2name(_symId)); writeProperty(xml, Pid::TIME_STRETCH); writeProperty(xml, Pid::PLAY); Element::writeProperties(xml); xml.etag(); }
void Trill::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(QString("%1 id=\"%2\"").arg(name()).arg(xml.spannerId(this))); xml.tag("subtype", trillTypeName()); writeProperty(xml, Pid::PLAY); writeProperty(xml, Pid::ORNAMENT_STYLE); SLine::writeProperties(xml); if (_accidental) _accidental->write(xml); xml.etag(); }