void Hairpin::read(XmlReader& e) { foreach(SpannerSegment* seg, spannerSegments()) delete seg; spannerSegments().clear(); int id = e.intAttribute("id", -1); e.addSpanner(id, this); while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") _hairpinType = Type(e.readInt()); else if (tag == "lineWidth") { setLineWidth(Spatium(e.readDouble())); lineWidthStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinHeight") { setHairpinHeight(Spatium(e.readDouble())); hairpinHeightStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinContHeight") { setHairpinContHeight(Spatium(e.readDouble())); hairpinContHeightStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinCircledTip") _hairpinCircledTip = e.readInt(); else if (tag == "veloChange") _veloChange = e.readInt(); else if (tag == "dynType") _dynRange = Dynamic::Range(e.readInt()); else if (tag == "useTextLine") _useTextLine = e.readInt(); else if (!TextLine::readProperties(e)) e.unknown(); } }
bool TablatureFretFont::read(XmlReader& e) { defPitch = 9.0; defYOffset = 0.0; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); int val = e.intAttribute("value"); if (tag == "family") family = e.readElementText(); else if (tag == "displayName") displayName = e.readElementText(); else if (tag == "defaultPitch") defPitch = e.readDouble(); else if (tag == "defaultYOffset") defYOffset = e.readDouble(); else if (tag == "mark") { QString val = e.attribute("value"); QString txt(e.readElementText()); if (val.size() < 1) return false; if (val == "x") xChar = txt[0]; else if (val == "ghost") ghostChar = txt[0]; } else if (tag == "fret") { bool bLetter = e.intAttribute("letter"); QString txt(e.readElementText()); if (bLetter) { if (val >= 0 && val < NUM_OF_LETTERFRETS) displayLetter[val] = txt[0]; } else { if (val >= 0 && val < NUM_OF_DIGITFRETS) displayDigit[val] = txt; } } else { e.unknown(); return false; } } return true; }
void Hairpin::read(XmlReader& e) { foreach(SpannerSegment* seg, spannerSegments()) delete seg; spannerSegments().clear(); int id = e.intAttribute("id", -1); e.addSpanner(id, this); while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") _hairpinType = Type(e.readInt()); else if (tag == "lineWidth") { setLineWidth(Spatium(e.readDouble())); lineWidthStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinHeight") { setHairpinHeight(Spatium(e.readDouble())); hairpinHeightStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinContHeight") { setHairpinContHeight(Spatium(e.readDouble())); hairpinContHeightStyle = PropertyStyle::UNSTYLED; } else if (tag == "hairpinCircledTip") _hairpinCircledTip = e.readInt(); else if (tag == "veloChange") _veloChange = e.readInt(); else if (tag == "dynType") _dynRange = Dynamic::Range(e.readInt()); else if (tag == "useTextLine") _useTextLine = e.readInt(); else if (!TextLine::readProperties(e)) e.unknown(); } // add default text to legacy hairpins if (score()->mscVersion() <= 206 && !_useTextLine) { bool cresc = _hairpinType == Hairpin::Type::CRESCENDO; if (!_beginText) setBeginText(cresc ? "cresc." : "dim."); if (!_continueText) setContinueText(cresc ? "(cresc.)" : "(dim.)"); } }
void RawStruct<RPG::Parameters>::BeginXml(RPG::Parameters& ref, XmlReader& stream) { stream.SetHandler(new WrapperXmlHandler("Parameters", new ParametersXmlHandler(ref))); }
void Button::parse(XmlReader& reader) { // parse xml attributes XmlReader::AttributeIterator iter(reader); while(iter.next()) { const char* attribute = (const char*) iter.getName(); const char* value = (const char*) iter.getValue(); if(parseAttribute(attribute, value)) { continue; } else if(strcmp(attribute, "width") == 0) { if(sscanf(value, "%f", &fixWidth) != 1) { std::stringstream msg; msg << "Couldn't parse width '" << value << "'."; throw std::runtime_error(msg.str()); } } else if(strcmp(attribute, "height") == 0) { if(sscanf(value, "%f", &fixHeight) != 1) { std::stringstream msg; msg << "Couldn't parse height '" << value << "'."; throw std::runtime_error(msg.str()); } } else if(strcmp(attribute, "lower") == 0) { lowerOnClick=true; } else if(strcmp(attribute, "direction") == 0) { // skip } else { std::cerr << "Skipping unknown attribute '" << attribute << "'.\n"; } } // we need 4 child components childs.assign(4, Child()); // parse contents of the xml-element bool parseTooltip = false; int depth = reader.getDepth(); fixWidth = -1; fixHeight = -1; while(reader.read() && reader.getDepth() > depth) { if(reader.getNodeType() == XML_READER_TYPE_ELEMENT) { std::string element = (const char*) reader.getName(); if(element == "image") { if(comp_normal().getComponent() != 0) std::cerr << "Warning: more than 1 component for state " "comp_normal defined.\n"; setChildImage(comp_normal(), reader); } else if(element == "text") { if(comp_normal().getComponent() != 0) std::cerr << "Warning: more than 1 component for state " "comp_normal defined.\n"; setChildText(comp_normal(), reader); } else if(element == "image-hover") { if(comp_hover().getComponent() != 0) std::cerr << "Warning: more than 1 component for state " "comp_hover defined.\n"; setChildImage(comp_hover(), reader); } else if(element == "text-hover") { if(comp_hover().getComponent() != 0) std::cerr << "Warning: more than 1 component for state " "comp_hover defined.\n"; setChildText(comp_hover(), reader); } else if(element == "image-clicked") { if(comp_clicked().getComponent() != 0) std::cerr << "Warning: more than 1 component for state " "comp_clicked defined.\n"; setChildImage(comp_clicked(), reader); } else if(element == "text-clicked") { if(comp_clicked().getComponent() != 0) std::cerr << "Warning: more than 1 component for state " "comp_clicked defined.\n"; setChildText(comp_clicked(), reader); } else if(element == "image-caption") { if(comp_caption().getComponent() != 0) std::cerr << "Warning: more than 1 component for comp_caption " "defined.\n"; setChildImage(comp_caption(), reader); } else if(element == "text-caption") { if(comp_caption().getComponent() != 0) std::cerr << "Warning: more than 1 component for comp_caption " "defined.\n"; setChildText(comp_caption(), reader); } else if (element == "tooltip") { parseTooltip = true; } else { std::cerr << "Skipping unknown element '" << element << "'.\n"; } } else if(reader.getNodeType() == XML_READER_TYPE_END_ELEMENT) { std::string element = (const char*) reader.getName(); if(element == "tooltip") parseTooltip = false; } else if(reader.getNodeType() == XML_READER_TYPE_TEXT) { if(!parseTooltip) continue; const char* p = (const char*) reader.getValue(); // skip trailing spaces while(*p != 0 && isspace(static_cast<unsigned char>(*p))) ++p; bool lastspace = tooltip != ""; for( ; *p != 0; ++p) { if(isspace(static_cast<unsigned char>(*p))) { if(!lastspace) { lastspace = true; tooltip += ' '; } } else { lastspace = false; tooltip += *p; } } } } if(tooltip != "") { tooltip = GUI_TRANSLATE(tooltip); } if(comp_normal().getComponent() == 0) throw std::runtime_error("No component for state comp_normal defined."); reLayout(); }
void OgreImporter::LoadSkeleton(std::string FileName, vector<Bone> &Bones, vector<Animation> &Animations) const { //const aiScene* const m_CurrentScene=this->m_CurrentScene;//make sure, that we can access but not change the scene //Unused.......... //most likely the skeleton file will only end with .skeleton //But this is a xml reader, so we need: .skeleton.xml FileName+=".xml"; DefaultLogger::get()->debug(string("Loading Skeleton: ")+FileName); //Open the File: boost::scoped_ptr<IOStream> File(m_CurrentIOHandler->Open(FileName)); if(NULL==File.get()) throw DeadlyImportError("Failed to open skeleton file "+FileName+"."); //Read the Mesh File: boost::scoped_ptr<CIrrXML_IOStreamReader> mIOWrapper(new CIrrXML_IOStreamReader(File.get())); XmlReader* SkeletonFile = irr::io::createIrrXMLReader(mIOWrapper.get()); if(!SkeletonFile) throw DeadlyImportError(string("Failed to create XML Reader for ")+FileName); //Quick note: Whoever read this should know this one thing: irrXml fucking sucks!!! XmlRead(SkeletonFile); if(string("skeleton")!=SkeletonFile->getNodeName()) throw DeadlyImportError("No <skeleton> node in SkeletonFile: "+FileName); //------------------------------------load bones----------------------------------------- XmlRead(SkeletonFile); if(string("bones")!=SkeletonFile->getNodeName()) throw DeadlyImportError("No bones node in skeleton "+FileName); XmlRead(SkeletonFile); while(string("bone")==SkeletonFile->getNodeName()) { //TODO: Maybe we can have bone ids for the errrors, but normaly, they should never appear, so what.... //read a new bone: Bone NewBone; NewBone.Id=GetAttribute<int>(SkeletonFile, "id"); NewBone.Name=GetAttribute<string>(SkeletonFile, "name"); //load the position: XmlRead(SkeletonFile); if(string("position")!=SkeletonFile->getNodeName()) throw DeadlyImportError("Position is not first node in Bone!"); NewBone.Position.x=GetAttribute<float>(SkeletonFile, "x"); NewBone.Position.y=GetAttribute<float>(SkeletonFile, "y"); NewBone.Position.z=GetAttribute<float>(SkeletonFile, "z"); //Rotation: XmlRead(SkeletonFile); if(string("rotation")!=SkeletonFile->getNodeName()) throw DeadlyImportError("Rotation is not the second node in Bone!"); NewBone.RotationAngle=GetAttribute<float>(SkeletonFile, "angle"); XmlRead(SkeletonFile); if(string("axis")!=SkeletonFile->getNodeName()) throw DeadlyImportError("No axis specified for bone rotation!"); NewBone.RotationAxis.x=GetAttribute<float>(SkeletonFile, "x"); NewBone.RotationAxis.y=GetAttribute<float>(SkeletonFile, "y"); NewBone.RotationAxis.z=GetAttribute<float>(SkeletonFile, "z"); //append the newly loaded bone to the bone list Bones.push_back(NewBone); //Proceed to the next bone: XmlRead(SkeletonFile); } //The bones in the file a not neccesarly ordered by there id's so we do it now: std::sort(Bones.begin(), Bones.end()); //now the id of each bone should be equal to its position in the vector: //so we do a simple check: { bool IdsOk=true; for(int i=0; i<static_cast<signed int>(Bones.size()); ++i)//i is signed, because all Id's are also signed! { if(Bones[i].Id!=i) IdsOk=false; } if(!IdsOk) throw DeadlyImportError("Bone Ids are not valid!"+FileName); } DefaultLogger::get()->debug((Formatter::format(),"Number of bones: ",Bones.size())); //________________________________________________________________________________ //----------------------------load bonehierarchy-------------------------------- if(string("bonehierarchy")!=SkeletonFile->getNodeName()) throw DeadlyImportError("no bonehierarchy node in "+FileName); DefaultLogger::get()->debug("loading bonehierarchy..."); XmlRead(SkeletonFile); while(string("boneparent")==SkeletonFile->getNodeName()) { string Child, Parent; Child=GetAttribute<string>(SkeletonFile, "bone"); Parent=GetAttribute<string>(SkeletonFile, "parent"); unsigned int ChildId, ParentId; ChildId=find(Bones.begin(), Bones.end(), Child)->Id; ParentId=find(Bones.begin(), Bones.end(), Parent)->Id; Bones[ChildId].ParentId=ParentId; Bones[ParentId].Children.push_back(ChildId); XmlRead(SkeletonFile);//i once forget this line, which led to an endless loop, did i mentioned, that irrxml sucks?? } //_____________________________________________________________________________ //--------- Calculate the WorldToBoneSpace Matrix recursivly for all bones: ------------------ BOOST_FOREACH(Bone theBone, Bones) { if(-1==theBone.ParentId) //the bone is a root bone { theBone.CalculateBoneToWorldSpaceMatrix(Bones); } } //_______________________________________________________________________ //---------------------------load animations----------------------------- if(string("animations")==SkeletonFile->getNodeName())//animations are optional values { DefaultLogger::get()->debug("Loading Animations"); XmlRead(SkeletonFile); while(string("animation")==SkeletonFile->getNodeName()) { Animation NewAnimation; NewAnimation.Name=GetAttribute<string>(SkeletonFile, "name"); NewAnimation.Length=GetAttribute<float>(SkeletonFile, "length"); //Load all Tracks XmlRead(SkeletonFile); if(string("tracks")!=SkeletonFile->getNodeName()) throw DeadlyImportError("no tracks node in animation"); XmlRead(SkeletonFile); while(string("track")==SkeletonFile->getNodeName()) { Track NewTrack; NewTrack.BoneName=GetAttribute<string>(SkeletonFile, "bone"); //Load all keyframes; XmlRead(SkeletonFile); if(string("keyframes")!=SkeletonFile->getNodeName()) throw DeadlyImportError("no keyframes node!"); XmlRead(SkeletonFile); while(string("keyframe")==SkeletonFile->getNodeName()) { Keyframe NewKeyframe; NewKeyframe.Time=GetAttribute<float>(SkeletonFile, "time"); //Position: XmlRead(SkeletonFile); if(string("translate")!=SkeletonFile->getNodeName()) throw DeadlyImportError("translate node not first in keyframe"); NewKeyframe.Position.x=GetAttribute<float>(SkeletonFile, "x"); NewKeyframe.Position.y=GetAttribute<float>(SkeletonFile, "y"); NewKeyframe.Position.z=GetAttribute<float>(SkeletonFile, "z"); //Rotation: XmlRead(SkeletonFile); if(string("rotate")!=SkeletonFile->getNodeName()) throw DeadlyImportError("rotate is not second node in keyframe"); float RotationAngle=GetAttribute<float>(SkeletonFile, "angle"); aiVector3D RotationAxis; XmlRead(SkeletonFile); if(string("axis")!=SkeletonFile->getNodeName()) throw DeadlyImportError("No axis for keyframe rotation!"); RotationAxis.x=GetAttribute<float>(SkeletonFile, "x"); RotationAxis.y=GetAttribute<float>(SkeletonFile, "y"); RotationAxis.z=GetAttribute<float>(SkeletonFile, "z"); NewKeyframe.Rotation=aiQuaternion(RotationAxis, RotationAngle); //Scaling: XmlRead(SkeletonFile); if(string("scale")!=SkeletonFile->getNodeName()) throw DeadlyImportError("no scalling key in keyframe!"); NewKeyframe.Scaling.x=GetAttribute<float>(SkeletonFile, "x"); NewKeyframe.Scaling.y=GetAttribute<float>(SkeletonFile, "y"); NewKeyframe.Scaling.z=GetAttribute<float>(SkeletonFile, "z"); NewTrack.Keyframes.push_back(NewKeyframe); XmlRead(SkeletonFile); } NewAnimation.Tracks.push_back(NewTrack); } Animations.push_back(NewAnimation); } } //_____________________________________________________________________________ }
bool GenericDataTypeStruct::loadFromXml( const XmlReader& reader, const XmlElement* pTypeRoot ) { if ( pTypeRoot == nullptr ) { return false; } if ( !isStringEquals( pTypeRoot->name, "struct" ) ) { TIKI_TRACE_ERROR( "[GenericDataStruct(%s)::readFromXml] node has a wrong tag('%s' != 'struct') \n", getName().cStr(), pTypeRoot->name ); return false; } const XmlElement* pChildElement = pTypeRoot->elements; while ( pChildElement != nullptr ) { const bool isField = isStringEquals( pChildElement->name, "field" ); const bool isValue = isStringEquals( pChildElement->name, "value" ); if ( isField || isValue ) { const XmlAttribute* pNameAtt = reader.findAttributeByName( "name", pChildElement ); const XmlAttribute* pTypeAtt = reader.findAttributeByName( "type", pChildElement ); const XmlAttribute* pModeAtt = reader.findAttributeByName( "mode", pChildElement ); const XmlAttribute* pValueAtt = reader.findAttributeByName( "value", pChildElement ); if ( pNameAtt && pTypeAtt ) { const GenericDataType* pType = m_collection.parseType( pTypeAtt->content ); if ( pType == nullptr ) { TIKI_TRACE_WARNING( "[GenericDataStruct(%s)::readFromXml] Type(%s) for field with name '%s' can't be found.\n", getName().cStr(), pTypeAtt->content, pNameAtt->content ); return false; } GenericDataStructField* pValueField = nullptr; const string fieldName = pNameAtt->content; if ( isValue ) { for (uint i = 0u; i < m_fields.getCount(); ++i) { GenericDataStructField& field = m_fields[ i ]; if ( field.name == fieldName ) { pValueField = &field; break; } } if ( pValueField == nullptr ) { TIKI_TRACE_ERROR( "[GenericDataStruct(%s)::readFromXml] field with name '%s' can't found in base class.\n", getName().cStr(), pNameAtt->content ); return false; } } GenericDataStructField& field = (isValue ? *pValueField : m_fields.add()); if ( isField ) { field.name = fieldName; field.pType = pType; field.defaultValue = GenericDataValue( pType ); field.mode = GenericDataTypeMode_ToolAndRuntime; field.isInherited = false; m_alignment = TIKI_MAX( m_alignment, field.pType->getAlignment() ); m_size = alignValue( m_size, field.pType->getAlignment() ); m_size = m_size + field.pType->getSize(); } if ( isValue && field.pType != pType ) { TIKI_TRACE_ERROR( "[GenericDataStruct(%s)::readFromXml] field with name '%s' must have the same type like in base class.\n", getName().cStr(), pNameAtt->content ); return false; } if ( pModeAtt != nullptr ) { if ( !isValue ) { GenericDataTypeMode mode = m_collection.findModeByName( pModeAtt->content ); if ( mode == GenericDataTypeMode_Invalid ) { TIKI_TRACE_WARNING( "[GenericDataStruct(%s)::readFromXml] field with name '%s' has a invalid mode attribute. '%s' is not a valid mode.\n", getName().cStr(), pNameAtt->content, pModeAtt->content ); } else { field.mode = mode; } } else { TIKI_TRACE_WARNING( "[GenericDataStruct(%s)::readFromXml] can't override mode in value(%s).\n", getName().cStr(), pNameAtt->content ); } } if ( pValueAtt != nullptr ) { if ( !m_collection.parseValue( field.defaultValue, pValueAtt->content, pType, this ) ) { TIKI_TRACE_INFO( "[GenericDataStruct(%s)::readFromXml] default value of '%s' can't be parsed.\n", getName().cStr(), pNameAtt->content ); } } } else { TIKI_TRACE_ERROR( "[GenericDataStruct(%s)::readFromXml] field or array has not all required attributes. name and type are required.\n", getName().cStr() ); return false; } } pChildElement = pChildElement->next; } return true; }
void CapKey::readCapx(XmlReader& e) { signature = e.intAttribute("fifths", 0); qDebug("Key %d", signature); e.readNext(); }
void ChordObj::readCapxNotes(XmlReader& e) { while (e.readNextStartElement()) { if (e.name() == "head") { QString pitch = e.attribute("pitch"); QString sstep; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "alter") { sstep = e.attribute("step"); e.readNext(); } else if (tag == "tie") { rightTie = e.attribute("begin") == "true"; e.readNext(); } else e.unknown(); } qDebug("ChordObj::readCapxNotes: pitch '%s' altstep '%s'", qPrintable(pitch), qPrintable(sstep)); int istep = sstep.toInt(); CNote n; n.pitch = pitchStr2Char(pitch); n.explAlteration = 0; n.headType = 0; n.alteration = istep; n.silent = 0; notes.append(n); } else e.unknown(); } }
QVariant getProperty(P_ID id, XmlReader& e) { switch(propertyType(id)) { case P_TYPE::BOOL: return QVariant(bool(e.readInt())); case P_TYPE::SUBTYPE: case P_TYPE::INT: return QVariant(e.readInt()); case P_TYPE::REAL: case P_TYPE::SPATIUM: case P_TYPE::SP_REAL: case P_TYPE::TEMPO: return QVariant(e.readDouble()); case P_TYPE::FRACTION: return QVariant::fromValue(e.readFraction()); case P_TYPE::COLOR: return QVariant(e.readColor()); case P_TYPE::POINT: return QVariant(e.readPoint()); case P_TYPE::SCALE: case P_TYPE::SIZE: return QVariant(e.readSize()); case P_TYPE::STRING: return QVariant(e.readElementText()); case P_TYPE::DIRECTION: { QString value(e.readElementText()); if (value == "up") return QVariant(int(Direction::UP)); else if (value == "down") return QVariant(int(Direction::DOWN)); else if (value == "auto") return QVariant(int(Direction::AUTO)); } break; case P_TYPE::DIRECTION_H: { QString value(e.readElementText()); if (value == "left" || value == "1") return QVariant(int(DirectionH::DH_LEFT)); else if (value == "right" || value == "2") return QVariant(int(DirectionH::DH_RIGHT)); else if (value == "auto") return QVariant(int(DirectionH::DH_AUTO)); } break; case P_TYPE::LAYOUT_BREAK: { QString value(e.readElementText()); if (value == "line") return QVariant(int(LayoutBreak::LayoutBreakType::LINE)); if (value == "page") return QVariant(int(LayoutBreak::LayoutBreakType::PAGE)); if (value == "section") return QVariant(int(LayoutBreak::LayoutBreakType::SECTION)); qDebug("getProperty: invalid P_TYPE::LAYOUT_BREAK: <%s>", qPrintable(value)); } break; case P_TYPE::VALUE_TYPE: { QString value(e.readElementText()); if (value == "offset") return QVariant(int(ValueType::OFFSET_VAL)); else if (value == "user") return QVariant(int(ValueType::USER_VAL)); } break; case P_TYPE::PLACEMENT: { QString value(e.readElementText()); if (value == "above") return QVariant(int(Placement::ABOVE)); else if (value == "below") return QVariant(int(Placement::BELOW)); } break; case P_TYPE::BEAM_MODE: // TODO return QVariant(int(0)); case P_TYPE::GROUPS: { Groups g; g.read(e); return QVariant::fromValue(g); } case P_TYPE::POINT_MM: case P_TYPE::SIZE_MM: case P_TYPE::SYMID: case P_TYPE::TEXT_STYLE: return QVariant(); } return QVariant(); }
void Capella::readCapx(XmlReader& e) { // initialize same variables as read(QFile* fp) f = 0; curPos = 0; author = 0; keywords = 0; comment = 0; nRel = 0; nAbs = 0; unsigned char b = 0; bUseRealSize = b & 1; bAllowCompression = b & 2; bPrintLandscape = b & 16; beamRelMin0 = 0; beamRelMin1 = 0; beamRelMax0 = 0; beamRelMax1 = 0; backgroundChord = new ChordObj(this); // contains graphic objects on the page background bShowBarCount = 0; barNumberFrame = 0; nBarDistX = 0; nBarDistY = 0; // QFont barNumFont = ... // not used ? nFirstPage = 0; leftPageMargins = 0; topPageMargins = 0; rightPageMargins = 0; btmPageMargins = 0; // Now do the equivalent of: // readLayout(); (called only once) // readExtra(); (this is a NOP) // readDrawObjectArray(); // for (unsigned i = 0; i < nSystems; i++) // readSystem(); initCapxLayout(); // read stave layout // read systems while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "info") { qDebug("importCapXml: found info (skipping)"); e.skipCurrentElement(); } else if (tag == "layout") { capxLayout(e); } else if (tag == "gallery") { qDebug("capxLayout: found gallery (skipping)"); e.skipCurrentElement(); } else if (tag == "pageObjects") { backgroundChord->readCapxObjectArray(e); } else if (tag == "barCount") { qDebug("importCapXml: found barCount (skipping)"); e.skipCurrentElement(); } else if (tag == "systems") { capxSystems(e); } else e.unknown(); } }
void PageFormat::read(XmlReader& e, Score* score) { qreal _oddRightMargin = 0.0; qreal _evenRightMargin = 0.0; bool landscape = false; QString type; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "pageFormat") // obsolete setSize(getPaperSize(e.readElementText())); else if (tag == "landscape") // obsolete landscape = e.readInt(); else if (tag == "page-margins") { type = e.attribute("type","both"); qreal lm = 0.0, rm = 0.0, tm = 0.0, bm = 0.0; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); qreal val = e.readDouble() * 0.5 / PPI; if (tag == "left-margin") lm = val; else if (tag == "right-margin") rm = val; else if (tag == "top-margin") tm = val; else if (tag == "bottom-margin") bm = val; else e.unknown(); } _twosided = type == "odd" || type == "even"; if (type == "odd" || type == "both") { _oddLeftMargin = lm; _oddRightMargin = rm; _oddTopMargin = tm; _oddBottomMargin = bm; } if (type == "even" || type == "both") { _evenLeftMargin = lm; _evenRightMargin = rm; _evenTopMargin = tm; _evenBottomMargin = bm; } } else if (tag == "page-height") _size.rheight() = e.readDouble() * 0.5 / PPI; else if (tag == "page-width") _size.rwidth() = e.readDouble() * .5 / PPI; else if (tag == "page-offset") { // obsolete, moved to Score QString val(e.readElementText()); if(score) score->setPageNumberOffset(val.toInt()); } else e.unknown(); } if (landscape) _size.transpose(); qreal w1 = _size.width() - _oddLeftMargin - _oddRightMargin; qreal w2 = _size.width() - _evenLeftMargin - _evenRightMargin; _printableWidth = qMax(w1, w2); // silently adjust right margins }
bool TextLine::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "beginHookHeight") { _beginHookHeight = Spatium(e.readDouble()); _beginHook = true; } else if (tag == "beginHookType") _beginHookType = HookType(e.readInt()); else if (tag == "endHookHeight" || tag == "hookHeight") { // hookHeight is obsolete _endHookHeight = Spatium(e.readDouble()); _endHook = true; } else if (tag == "endHookType") _endHookType = HookType(e.readInt()); else if (tag == "hookUp") // obsolete _endHookHeight *= qreal(-1.0); else if (tag == "beginSymbol" || tag == "symbol") { // "symbol" is obsolete QString text(e.readElementText()); _beginSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); } else if (tag == "continueSymbol") { QString text(e.readElementText()); _continueSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); } else if (tag == "endSymbol") { QString text(e.readElementText()); _endSymbol = text[0].isNumber() ? SymId(text.toInt()) : Sym::name2id(text); } else if (tag == "beginSymbolOffset") _beginSymbolOffset = e.readPoint(); else if (tag == "continueSymbolOffset") _continueSymbolOffset = e.readPoint(); else if (tag == "endSymbolOffset") _endSymbolOffset = e.readPoint(); else if (tag == "lineWidth") _lineWidth = Spatium(e.readDouble()); else if (tag == "lineStyle") _lineStyle = Qt::PenStyle(e.readInt()); else if (tag == "beginTextPlace") _beginTextPlace = readPlacement(e); else if (tag == "continueTextPlace") _continueTextPlace = readPlacement(e); else if (tag == "lineColor") _lineColor = e.readColor(); else if (tag == "beginText") { _beginText = new Text(score()); _beginText->setParent(this); _beginText->read(e); } else if (tag == "continueText") { _continueText = new Text(score()); _continueText->setParent(this); _continueText->read(e); } else if (!SLine::readProperties(e)) { qDebug(" ==readSLineProps: failed"); return false; } return true; }
void TournamentSelection::parseXMLNode(XmlReader& xml, System* system) { if (xml.get_attribute("k")!="") k=atoi(xml.get_attribute("k").c_str()); SelectionMethod::parseXMLNode(xml, system); }
void RawStruct<RPG::TreeMap>::BeginXml(RPG::TreeMap& ref, XmlReader& stream) { stream.SetHandler(new WrapperXmlHandler("TreeMap", new TreeMapXmlHandler(ref))); }
void SlurObj::readCapx(XmlReader& e) { // nothing to be done yet e.skipCurrentElement(); }
void TimeSig::read(XmlReader& e) { int n=0, z1=0, z2=0, z3=0, z4=0; bool old = false; customText = false; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "den") { old = true; n = e.readInt(); } else if (tag == "nom1") { old = true; z1 = e.readInt(); } else if (tag == "nom2") { old = true; z2 = e.readInt(); } else if (tag == "nom3") { old = true; z3 = e.readInt(); } else if (tag == "nom4") { old = true; z4 = e.readInt(); } else if (tag == "subtype") { int i = e.readInt(); if (score()->mscVersion() <= 114) { if (i == 0x40000104) _timeSigType = TimeSigType::FOUR_FOUR; else if (i == 0x40002084) _timeSigType = TimeSigType::ALLA_BREVE; else _timeSigType = TimeSigType::NORMAL; } else _timeSigType = TimeSigType(i); } else if (tag == "showCourtesySig") _showCourtesySig = e.readInt(); else if (tag == "sigN") _sig.setNumerator(e.readInt()); else if (tag == "sigD") _sig.setDenominator(e.readInt()); else if (tag == "stretchN") _stretch.setNumerator(e.readInt()); else if (tag == "stretchD") _stretch.setDenominator(e.readInt()); else if (tag == "textN") setNumeratorString(e.readElementText()); else if (tag == "textD") setDenominatorString(e.readElementText()); else if (tag == "Groups") _groups.read(e); else if (!Element::readProperties(e)) e.unknown(); } if (old) { _sig.set(z1+z2+z3+z4, n); customText = false; } _stretch.reduce(); _needLayout = true; }
QList<BasicDrawObj*> Capella::readCapxDrawObjectArray(XmlReader& e) { QList<BasicDrawObj*> ol; while (e.readNextStartElement()) { if (e.name() == "drawObj") { BasicDrawObj* bdo = 0; while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "basic") { // note: the <basic> element always follows the DrawObject it applies to if (bdo) bdo->readCapx(e); else e.skipCurrentElement(); } else if (tag == "line") { qDebug("readCapxDrawObjectArray: found line (skipping)"); e.skipCurrentElement(); } else if (tag == "rectangle") { qDebug("readCapxDrawObjectArray: found rectangle (skipping)"); e.skipCurrentElement(); } else if (tag == "ellipse") { qDebug("readCapxDrawObjectArray: found ellipse (skipping)"); e.skipCurrentElement(); } else if (tag == "polygon") { qDebug("readCapxDrawObjectArray: found polygon (skipping)"); e.skipCurrentElement(); } else if (tag == "metafile") { qDebug("readCapxDrawObjectArray: found metafile (skipping)"); e.skipCurrentElement(); } else if (tag == "text") { SimpleTextObj* o = new SimpleTextObj(this); bdo = o; // save o to handle the "basic" tag (which sometimes follows) o->readCapx(e); ol.append(o); } else if (tag == "richText") { qDebug("readCapxDrawObjectArray: found richText (skipping)"); e.skipCurrentElement(); } else if (tag == "guitar") { qDebug("readCapxDrawObjectArray: found guitar (skipping)"); e.skipCurrentElement(); } else if (tag == "slur") { SlurObj* o = new SlurObj(this); bdo = o; // save o to handle the "basic" tag (which sometimes follows) o->readCapx(e); ol.append(o); } else if (tag == "wavyLine") { qDebug("readCapxDrawObjectArray: found wavyLine (skipping)"); e.skipCurrentElement(); } else if (tag == "bracket") { qDebug("readCapxDrawObjectArray: found bracket (skipping)"); e.skipCurrentElement(); } else if (tag == "wedge") { WedgeObj* o = new WedgeObj(this); bdo = o; // save o to handle the "basic" tag (which sometimes follows) o->readCapx(e); ol.append(o); } else if (tag == "notelines") { qDebug("readCapxDrawObjectArray: found notelines (skipping)"); e.skipCurrentElement(); } else if (tag == "volta") { VoltaObj* o = new VoltaObj(this); bdo = o; // save o to handle the "basic" tag (which sometimes follows) o->readCapx(e); ol.append(o); } else if (tag == "trill") { TrillObj* o = new TrillObj(this); bdo = o; // save o to handle the "basic" tag (which sometimes follows) o->readCapx(e); ol.append(o); } else if (tag == "transposable") { qDebug("readCapxDrawObjectArray: found transposable (skipping)"); e.skipCurrentElement(); } else if (tag == "group") { qDebug("readCapxDrawObjectArray: found group (skipping)"); e.skipCurrentElement(); } else e.unknown(); } } else e.unknown(); } return ol; }
void Ottava::read(XmlReader& e) { qDeleteAll(spannerSegments()); spannerSegments().clear(); e.addSpanner(e.intAttribute("id", -1), this); while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "subtype") { QString s = e.readElementText(); bool ok; int idx = s.toInt(&ok); if (!ok) { idx = int(Type::OTTAVA_8VA); for (unsigned i = 0; i < sizeof(ottavaDefault)/sizeof(*ottavaDefault); ++i) { if (s == ottavaDefault[i].name) { idx = i; break; } } } else if (score()->mscVersion() <= 114) { //subtype are now in a different order... if (idx == 1) idx = 2; else if (idx == 2) idx = 1; } setOttavaType(Type(idx)); } else if (tag == "numbersOnly") { _numbersOnly = e.readInt(); numbersOnlyStyle = PropertyStyle::UNSTYLED; } else if (tag == "lineWidth") { setLineWidth(Spatium(e.readDouble())); lineWidthStyle = PropertyStyle::UNSTYLED; } else if (tag == "lineStyle") { setLineStyle(Qt::PenStyle(e.readInt())); lineStyleStyle = PropertyStyle::UNSTYLED; } else if (tag == "beginSymbol") { // obsolete beginTextStyle = PropertyStyle::UNSTYLED; QString text(e.readElementText()); setBeginText(QString("<sym>%1</sym>").arg(text[0].isNumber() ? Sym::id2name(SymId(text.toInt())) : text)); } else if (tag == "continueSymbol") { // obsolete continueTextStyle = PropertyStyle::UNSTYLED; QString text(e.readElementText()); setContinueText(QString("<sym>%1</sym>").arg(text[0].isNumber() ? Sym::id2name(SymId(text.toInt())) : text)); } else if (!TextLine::readProperties(e)) e.unknown(); } if (beginText() != propertyDefault(P_ID::BEGIN_TEXT)) beginTextStyle = PropertyStyle::UNSTYLED; if (continueText() != propertyDefault(P_ID::CONTINUE_TEXT)) continueTextStyle = PropertyStyle::UNSTYLED; }
void BasicDrawObj::readCapx(XmlReader& e) { nNotes = e.intAttribute("noteRange", 0); qDebug("nNotes %d", nNotes); e.readNext(); }
void Box::read(XmlReader& e) { _leftMargin = _rightMargin = _topMargin = _bottomMargin = 0.0; bool keepMargins = false; // whether original margins have to be kept when reading old file while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "height") _boxHeight = Spatium(e.readDouble()); else if (tag == "width") _boxWidth = Spatium(e.readDouble()); else if (tag == "topGap") _topGap = e.readDouble(); else if (tag == "bottomGap") _bottomGap = e.readDouble(); else if (tag == "leftMargin") _leftMargin = e.readDouble(); else if (tag == "rightMargin") _rightMargin = e.readDouble(); else if (tag == "topMargin") _topMargin = e.readDouble(); else if (tag == "bottomMargin") _bottomMargin = e.readDouble(); else if (tag == "Text") { Text* t; if (type() == TBOX) { t = static_cast<TBox*>(this)->getText(); t->read(e); } else { t = new Text(score()); t->read(e); add(t); if (score()->mscVersion() <= 114) t->setLayoutToParentWidth(true); } } else if (tag == "Symbol") { Symbol* s = new Symbol(score()); s->read(e); add(s); } else if (tag == "Image") { Image* image = new Image(score()); image->setTrack(score()->curTrack); image->read(e); add(image); } else if (tag == "FretDiagram") { FretDiagram* f = new FretDiagram(score()); f->read(e); add(f); } else if (tag == "LayoutBreak") { LayoutBreak* lb = new LayoutBreak(score()); lb->read(e); add(lb); } else if (tag == "HBox") { HBox* hb = new HBox(score()); hb->read(e); add(hb); keepMargins = true; // in old file, box nesting used outer box margins } else if (tag == "VBox") { VBox* vb = new VBox(score()); vb->read(e); add(vb); keepMargins = true; // in old file, box nesting used outer box margins } else if (Element::readProperties(e)) ; else e.unknown(); } // with .msc versions prior to 1.17, box margins were only used when nesting another box inside this box: // for backward compatibility set them to 0 in all other cases if (score()->mscVersion() < 117 && (type() == HBOX || type() == VBOX) && !keepMargins) { _leftMargin = _rightMargin = _topMargin = _bottomMargin = 0.0; } }
void Capella::readCapxStaveLayout(XmlReader& e, CapStaffLayout* sl, int /*idx*/) { // initialize same variables as readStaveLayout(CapStaffLayout*, int) sl->barlineMode = 0; sl->noteLines = 0; sl->bSmall = 0; // TODO (unclear where this is in the capx file) sl->topDist = 0; sl->btmDist = 0; sl->groupDist = 0; sl->barlineFrom = 0; sl->barlineTo = 0; unsigned char clef = 0; sl->form = Form(clef & 7); sl->line = ClefLine((clef >> 3) & 7); sl->oct = Oct((clef >> 6)); // qDebug(" clef %x form %d, line %d, oct %d", clef, sl->form, sl->line, sl->oct); // Schlagzeuginformation unsigned char b = 0; // ?? TODO ?? sl->soundMapIn and sl->soundMapOut are not used sl->bPercussion = b & 1; // Schlagzeugkanal verwenden sl->bSoundMapIn = b & 2; sl->bSoundMapOut = b & 4; /* if (sl->bSoundMapIn) { // Umleitungstabelle fr Eingabe vom Keyboard uchar iMin = readByte(); Q_UNUSED(iMin); uchar n = readByte(); Q_ASSERT(n > 0 and iMin + n <= 128); f->read(sl->soundMapIn, n); curPos += n; } if (sl->bSoundMapOut) { // Umleitungstabelle fr das Vorspielen unsigned char iMin = readByte(); unsigned char n = readByte(); Q_ASSERT(n > 0 and iMin + n <= 128); f->read(sl->soundMapOut, n); curPos += n; } */ sl->sound = 0; sl->volume = 0; sl->transp = 0; qDebug("readCapxStaveLayout"); sl->descr = e.attribute("description"); while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "notation") { capxNotation(e, sl->barlineMode, sl->barlineFrom, sl->barlineTo); } else if (tag == "distances") { qDebug("readCapxStaveLayout: found distances (skipping)"); e.skipCurrentElement(); } else if (tag == "instrument") { sl->name = e.attribute("name"); sl->abbrev = e.attribute("abbrev"); // elements name and abbrev overrule attributes name and abbrev while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "name") sl->name = e.readElementText(); else if (tag == "abbrev") sl->abbrev = e.readElementText(); else e.unknown(); } } else if (tag == "sound") { sl->sound = e.intAttribute("instr", 0); sl->volume = e.intAttribute("volume", 0); sl->transp = e.intAttribute("transpose", 0); e.readNext(); } else e.unknown(); } qDebug(" descr '%s' name '%s' abbrev '%s'", qPrintable(sl->descr), qPrintable(sl->name), qPrintable(sl->abbrev)); qDebug(" sound %d vol %d transp %d", sl->sound, sl->volume, sl->transp); qDebug("readCapxStaveLayout done"); }
Score::FileError Score::read114(XmlReader& e) { if (parentScore()) setMscVersion(parentScore()->mscVersion()); for (unsigned int i = 0; i < sizeof(style114)/sizeof(*style114); ++i) style()->set(style114[i].idx, style114[i].val); // old text style defaults TextStyle ts = style()->textStyle("Chord Symbol"); ts.setYoff(-4.0); style()->setTextStyle(ts); TempoMap tm; while (e.readNextStartElement()) { e.setTrack(-1); const QStringRef& tag(e.name()); if (tag == "Staff") readStaff(e); else if (tag == "KeySig") { KeySig* ks = new KeySig(this); ks->read(e); customKeysigs.append(ks); } else if (tag == "siglist") _sigmap->read(e, _fileDivision); else if (tag == "programVersion") { _mscoreVersion = e.readElementText(); parseVersion(_mscoreVersion); } else if (tag == "programRevision") _mscoreRevision = e.readInt(); else if (tag == "Mag" || tag == "MagIdx" || tag == "xoff" || tag == "Symbols" || tag == "cursorTrack" || tag == "yoff") e.skipCurrentElement(); // obsolete else if (tag == "tempolist") { // store the tempo list to create invisible tempo text later qreal tempo = e.attribute("fix","2.0").toDouble(); tm.setRelTempo(tempo); while (e.readNextStartElement()) { if (e.name() == "tempo") { int tick = e.attribute("tick").toInt(); double tmp = e.readElementText().toDouble(); tick = (tick * MScore::division + _fileDivision/2) / _fileDivision; auto pos = tm.find(tick); if (pos != tm.end()) tm.erase(pos); tm.setTempo(tick, tmp); } else if (e.name() == "relTempo") e.readElementText(); else e.unknown(); } } else if (tag == "playMode") _playMode = PlayMode(e.readInt()); else if (tag == "SyntiSettings") _synthesizerState.read(e); else if (tag == "Spatium") _style.setSpatium (e.readDouble() * MScore::DPMM); else if (tag == "Division") _fileDivision = e.readInt(); else if (tag == "showInvisible") _showInvisible = e.readInt(); else if (tag == "showFrames") _showFrames = e.readInt(); else if (tag == "showMargins") _showPageborders = e.readInt(); else if (tag == "Style") { qreal sp = _style.spatium(); _style.load(e); // adjust this now so chords render properly on read // other style adjustments can wait until reading is finished if (style(StyleIdx::useGermanNoteNames).toBool()) style()->set(StyleIdx::useStandardNoteNames, false); if (_layoutMode == LayoutMode::FLOAT) { // style should not change spatium in // float mode _style.setSpatium(sp); } } else if (tag == "TextStyle") { TextStyle s; s.read(e); qreal spMM = _style.spatium() / MScore::DPMM; if (s.frameWidthMM() != 0.0) s.setFrameWidth(Spatium(s.frameWidthMM() / spMM)); if (s.paddingWidthMM() != 0.0) s.setPaddingWidth(Spatium(s.paddingWidthMM() / spMM)); \ // convert 1.2 text styles if (s.name() == "Chordname") s.setName("Chord Symbol"); else if (s.name() == "Lyrics odd lines") s.setName("Lyrics Odd Lines"); else if (s.name() == "Lyrics even lines") s.setName("Lyrics Even Lines"); else if (s.name() == "InstrumentsLong") s.setName("Instrument Name (Long)"); else if (s.name() == "InstrumentsShort") s.setName("Instrument Name (Short)"); else if (s.name() == "InstrumentsExcerpt") s.setName("Instrument Name (Part)"); else if (s.name() == "Poet") s.setName("Lyricist"); else if (s.name() == "Technik") s.setName("Technique"); else if (s.name() == "TextLine") s.setName("Text Line"); else if (s.name() == "Tuplets") s.setName("Tuplet"); if (s.name() == "Lyrics Odd Lines" || s.name() == "Lyrics Even Lines") s.setAlign((s.align() & ~ Align(AlignmentFlags::VMASK)) | AlignmentFlags::BASELINE); _style.setTextStyle(s); } else if (tag == "page-layout") { if (_layoutMode != LayoutMode::FLOAT && _layoutMode != LayoutMode::SYSTEM) { PageFormat pf; pf.copy(*pageFormat()); pf.read(e, this); setPageFormat(pf); } else e.skipCurrentElement(); } else if (tag == "copyright" || tag == "rights") { Text* text = new Text(this); text->read(e); text->layout(); setMetaTag("copyright", text->plainText()); delete text; } else if (tag == "movement-number") setMetaTag("movementNumber", e.readElementText()); else if (tag == "movement-title") setMetaTag("movementTitle", e.readElementText()); else if (tag == "work-number") setMetaTag("workNumber", e.readElementText()); else if (tag == "work-title") setMetaTag("workTitle", e.readElementText()); else if (tag == "source") setMetaTag("source", e.readElementText()); else if (tag == "metaTag") { QString name = e.attribute("name"); setMetaTag(name, e.readElementText()); } else if (tag == "Part") { Part* part = new Part(this); part->read114(e); _parts.push_back(part); } else if (tag == "Slur") { Slur* slur = new Slur(this); slur->read(e); addSpanner(slur); } else if ((tag == "HairPin") || (tag == "Ottava") || (tag == "TextLine") || (tag == "Volta") || (tag == "Trill") || (tag == "Pedal")) { Spanner* s = static_cast<Spanner*>(Element::name2Element(tag, this)); s->read(e); if (s->track() == -1) s->setTrack(e.track()); else e.setTrack(s->track()); // update current track if (s->tick() == -1) s->setTick(e.tick()); else e.initTick(s->tick()); // update current tick if (s->track2() == -1) s->setTrack2(s->track()); if (s->ticks() == 0) { delete s; qDebug("zero spanner %s ticks: %d", s->name(), s->ticks()); } else { addSpanner(s); } } else if (tag == "Excerpt") { if (MScore::noExcerpts) e.skipCurrentElement(); else { Excerpt* ex = new Excerpt(this); ex->read(e); _excerpts.append(ex); } } else if (tag == "Beam") { Beam* beam = new Beam(this); beam->read(e); beam->setParent(0); // _beams.append(beam); } else if (tag == "name") setName(e.readElementText()); else e.unknown(); } if (e.error() != XmlStreamReader::NoError) return FileError::FILE_BAD_FORMAT; int n = nstaves(); for (int idx = 0; idx < n; ++idx) { Staff* s = _staves[idx]; int track = idx * VOICES; // check barLineSpan if (s->barLineSpan() > (n - idx)) { qDebug("read114: invalid bar line span %d (max %d)", s->barLineSpan(), n - idx); s->setBarLineSpan(n - idx); } for (auto i : e.clefs(idx)) { int tick = i.first; ClefType clefId = i.second; Measure* m = tick2measure(tick); if (!m) continue; if ((tick == m->tick()) && m->prevMeasure()) m = m->prevMeasure(); Segment* seg = m->getSegment(Segment::Type::Clef, tick); if (seg->element(track)) static_cast<Clef*>(seg->element(track))->setGenerated(false); else { Clef* clef = new Clef(this); clef->setClefType(clefId); clef->setTrack(track); clef->setParent(seg); clef->setGenerated(false); seg->add(clef); } } // create missing KeySig KeyList* km = s->keyList(); for (auto i = km->begin(); i != km->end(); ++i) { int tick = i->first; if (tick < 0) { qDebug("read114: Key tick %d", tick); continue; } Measure* m = tick2measure(tick); if (!m) //empty score break; Segment* seg = m->getSegment(Segment::Type::KeySig, tick); if (seg->element(track)) static_cast<KeySig*>(seg->element(track))->setGenerated(false); else { KeySigEvent ke; ke.setKey(i->second); KeySig* ks = keySigFactory(ke); if (ks) { ks->setParent(seg); ks->setTrack(track); ks->setGenerated(false); seg->add(ks); } } } } for (std::pair<int,Spanner*> p : spanner()) { Spanner* s = p.second; if (s->type() != Element::Type::SLUR) { if (s->type() == Element::Type::VOLTA) { Volta* volta = static_cast<Volta*>(s); volta->setAnchor(Spanner::Anchor::MEASURE); } } if (s->type() == Element::Type::OTTAVA || s->type() == Element::Type::PEDAL || s->type() == Element::Type::TRILL || s->type() == Element::Type::TEXTLINE) { qreal yo = 0; if (s->type() == Element::Type::OTTAVA) { // fix ottava position yo = styleS(StyleIdx::ottavaY).val() * spatium(); if (s->placement() == Element::Placement::BELOW) yo = -yo + s->staff()->height(); } else if (s->type() == Element::Type::PEDAL) { yo = styleS(StyleIdx::pedalY).val() * spatium(); } else if (s->type() == Element::Type::TRILL) { yo = styleS(StyleIdx::trillY).val() * spatium(); } else if (s->type() == Element::Type::TEXTLINE) { yo = -5.0 * spatium(); } if (!s->spannerSegments().isEmpty()) { for (SpannerSegment* seg : s->spannerSegments()) { if (!seg->userOff().isNull()) seg->setUserYoffset(seg->userOff().y() - yo); } } else { s->setUserYoffset(-yo); } } } connectTies(); // // remove "middle beam" flags from first ChordRest in // measure // for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) { int tracks = nstaves() * VOICES; bool first = true; for (int track = 0; track < tracks; ++track) { for (Segment* s = m->first(); s; s = s->next()) { if (s->segmentType() != Segment::Type::ChordRest) continue; ChordRest* cr = static_cast<ChordRest*>(s->element(track)); if (cr) { if(cr->type() == Element::Type::REST) { Rest* r = static_cast<Rest*>(cr); if (!r->userOff().isNull()) { int lineOffset = r->computeLineOffset(); qreal lineDist = r->staff() ? r->staff()->staffType()->lineDistance().val() : 1.0; r->rUserYoffset() -= (lineOffset * .5 * lineDist * r->spatium()); } } if(!first) { switch(cr->beamMode()) { case Beam::Mode::AUTO: case Beam::Mode::BEGIN: case Beam::Mode::END: case Beam::Mode::NONE: break; case Beam::Mode::MID: case Beam::Mode::BEGIN32: case Beam::Mode::BEGIN64: cr->setBeamMode(Beam::Mode::BEGIN); break; case Beam::Mode::INVALID: if (cr->type() == Element::Type::CHORD) cr->setBeamMode(Beam::Mode::AUTO); else cr->setBeamMode(Beam::Mode::NONE); break; } first = false; } } } } } for (MeasureBase* mb = _measures.first(); mb; mb = mb->next()) { if (mb->type() == Element::Type::VBOX) { Box* b = static_cast<Box*>(mb); qreal y = point(styleS(StyleIdx::staffUpperBorder)); b->setBottomGap(y); } } _fileDivision = MScore::division; // // sanity check for barLineSpan and update ottavas // foreach(Staff* staff, _staves) { int barLineSpan = staff->barLineSpan(); int idx = staffIdx(staff); int n = nstaves(); if (idx + barLineSpan > n) { qDebug("bad span: idx %d span %d staves %d", idx, barLineSpan, n); staff->setBarLineSpan(n - idx); } staff->updateOttava(); }
void BasicDurationalObj::readCapxDisplay(XmlReader& e) { invisible = e.attribute("invisible") == "true"; e.readNext(); }
void StaffType::read(XmlReader& e) { QString group = e.attribute("group", fileGroupNames[(int)StaffGroup::STANDARD]); if (group == fileGroupNames[(int)StaffGroup::TAB]) _group = StaffGroup::TAB; else if (group == fileGroupNames[(int)StaffGroup::PERCUSSION]) _group = StaffGroup::PERCUSSION; else if (group == fileGroupNames[(int)StaffGroup::STANDARD]) _group = StaffGroup::STANDARD; else { qDebug("StaffType::read: unknown group: %s", qPrintable(group)); _group = StaffGroup::STANDARD; } while (e.readNextStartElement()) { const QStringRef& tag(e.name()); if (tag == "name") setXmlName(e.readElementText()); else if (tag == "lines") setLines(e.readInt()); else if (tag == "lineDistance") setLineDistance(Spatium(e.readDouble())); else if (tag == "clef") setGenClef(e.readInt()); else if (tag == "slashStyle") setSlashStyle(e.readInt()); else if (tag == "barlines") setShowBarlines(e.readInt()); else if (tag == "timesig") setGenTimesig(e.readInt()); else if (tag == "keysig") _genKeysig = e.readInt(); else if (tag == "ledgerlines") _showLedgerLines = e.readInt(); else if (tag == "durations") setGenDurations(e.readBool()); else if (tag == "durationFontName") setDurationFontName(e.readElementText()); else if (tag == "durationFontSize") setDurationFontSize(e.readDouble()); else if (tag == "durationFontY") setDurationFontUserY(e.readDouble()); else if (tag == "fretFontName") setFretFontName(e.readElementText()); else if (tag == "fretFontSize") setFretFontSize(e.readDouble()); else if (tag == "fretFontY") setFretFontUserY(e.readDouble()); else if (tag == "symbolRepeat") setSymbolRepeat( (TablatureSymbolRepeat) e.readInt() ); else if (tag == "linesThrough") setLinesThrough(e.readBool()); else if (tag == "minimStyle") setMinimStyle( (TablatureMinimStyle) e.readInt() ); else if (tag == "onLines") setOnLines(e.readBool()); else if (tag == "showRests") setShowRests(e.readBool()); else if (tag == "stemsDown") setStemsDown(e.readBool()); else if (tag == "stemsThrough") setStemsThrough(e.readBool()); else if (tag == "upsideDown") setUpsideDown(e.readBool()); else if (tag == "useNumbers") setUseNumbers(e.readBool()); else e.unknown(); } }
bool TextStyleData::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "name") name = e.readElementText(); else if (tag == "family") family = e.readElementText(); else if (tag == "size") size = e.readDouble(); else if (tag == "bold") bold = e.readInt(); else if (tag == "italic") italic = e.readInt(); else if (tag == "underline") underline = e.readInt(); else if (tag == "align") setAlign(Align(e.readInt())); else if (tag == "anchor") // obsolete e.skipCurrentElement(); else if (ElementLayout::readProperties(e)) ; else if (tag == "sizeIsSpatiumDependent" || tag == "spatiumSizeDependent") sizeIsSpatiumDependent = e.readInt(); else if (tag == "frameWidth") { // obsolete hasFrame = true; frameWidthMM = e.readDouble(); } else if (tag == "frameWidthS") { hasFrame = true; frameWidth = Spatium(e.readDouble()); } else if (tag == "frame") hasFrame = e.readInt(); else if (tag == "square") _square = e.readInt(); else if (tag == "paddingWidth") // obsolete paddingWidthMM = e.readDouble(); else if (tag == "paddingWidthS") paddingWidth = Spatium(e.readDouble()); else if (tag == "frameRound") frameRound = e.readInt(); else if (tag == "frameColor") frameColor = e.readColor(); else if (tag == "foregroundColor") foregroundColor = e.readColor(); else if (tag == "backgroundColor") backgroundColor = e.readColor(); else if (tag == "circle") circle = e.readInt(); else if (tag == "systemFlag") systemFlag = e.readInt(); else return false; return true; }
bool Text::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "style") { QString val(e.readElementText()); int st; bool ok; int i = val.toInt(&ok); if (ok) { // obsolete old text styles switch (i) { case 1: i = TEXT_STYLE_UNSTYLED; break; case 2: i = TEXT_STYLE_TITLE; break; case 3: i = TEXT_STYLE_SUBTITLE; break; case 4: i = TEXT_STYLE_COMPOSER; break; case 5: i = TEXT_STYLE_POET; break; case 6: i = TEXT_STYLE_LYRIC1; break; case 7: i = TEXT_STYLE_LYRIC2; break; case 8: i = TEXT_STYLE_FINGERING; break; case 9: i = TEXT_STYLE_INSTRUMENT_LONG; break; case 10: i = TEXT_STYLE_INSTRUMENT_SHORT; break; case 11: i = TEXT_STYLE_INSTRUMENT_EXCERPT; break; case 12: i = TEXT_STYLE_DYNAMICS; break; case 13: i = TEXT_STYLE_TECHNIK; break; case 14: i = TEXT_STYLE_TEMPO; break; case 15: i = TEXT_STYLE_METRONOME; break; case 16: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_COPYRIGHT case 17: i = TEXT_STYLE_MEASURE_NUMBER; break; case 18: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_ODD case 19: i = TEXT_STYLE_FOOTER; break; // TEXT_STYLE_PAGE_NUMBER_EVEN case 20: i = TEXT_STYLE_TRANSLATOR; break; case 21: i = TEXT_STYLE_TUPLET; break; case 22: i = TEXT_STYLE_SYSTEM; break; case 23: i = TEXT_STYLE_STAFF; break; case 24: i = TEXT_STYLE_HARMONY; break; case 25: i = TEXT_STYLE_REHEARSAL_MARK; break; case 26: i = TEXT_STYLE_REPEAT; break; case 27: i = TEXT_STYLE_VOLTA; break; case 28: i = TEXT_STYLE_FRAME; break; case 29: i = TEXT_STYLE_TEXTLINE; break; case 30: i = TEXT_STYLE_GLISSANDO; break; case 31: i = TEXT_STYLE_STRING_NUMBER; break; case 32: i = TEXT_STYLE_OTTAVA; break; case 33: i = TEXT_STYLE_BENCH; break; case 34: i = TEXT_STYLE_HEADER; break; case 35: i = TEXT_STYLE_FOOTER; break; case 0: default: qDebug("Text:readProperties: style %d<%s> invalid", i, qPrintable(val)); i = TEXT_STYLE_UNSTYLED; break; } st = i; } else st = score()->style()->textStyleType(val); if (st == TEXT_STYLE_UNSTYLED) setUnstyled(); else if (st == TEXT_STYLE_UNKNOWN) _styleIndex = st; else setTextStyleType(st); } else if (tag == "styleName") // obsolete, unstyled text e.skipCurrentElement(); // _styleName = val; else if (tag == "data") // obsolete _doc->setHtml(e.readElementText()); else if (tag == "html") { QString s = Xml::htmlToString(e); setHtml(s); } else if (tag == "text") setText(e.readElementText()); else if (tag == "html-data") { QString s = Xml::htmlToString(e); if (score()->mscVersion() <= 114) { s.replace("MScore1", "FreeSerifMscore"); s.replace(QChar(0xe10e), QChar(0x266e)); //natural s.replace(QChar(0xe10c), QChar(0x266f)); // sharp s.replace(QChar(0xe10d), QChar(0x266d)); // flat s.replace(QChar(0xe104), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd5e))), // note2_Sym s.replace(QChar(0xe105), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd5f))); // note4_Sym s.replace(QChar(0xe106), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd60))); // note8_Sym s.replace(QChar(0xe107), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd61))); // note16_Sym s.replace(QChar(0xe108), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd62))); // note32_Sym s.replace(QChar(0xe109), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd63))); // note64_Sym s.replace(QChar(0xe10a), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd6d))); // dot s.replace(QChar(0xe10b), QString("%1%2%3%4").arg(QChar(0xd834)).arg(QChar(0xdd6d)).arg(QChar(0xd834)).arg(QChar(0xdd6d))); // dotdot s.replace(QChar(0xe167), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0b))); // coda s.replace(QChar(0xe168), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0c))); // varcoda s.replace(QChar(0xe169), QString("%1%2").arg(QChar(0xd834)).arg(QChar(0xdd0c))); // segno if (_doc == 0) createDoc(); // import instrument names as unstyled html if (_styleIndex != TEXT_STYLE_INSTRUMENT_SHORT && _styleIndex != TEXT_STYLE_INSTRUMENT_LONG && isSimpleText()) { _doc->setHtml(s); QString s = _doc->toPlainText(); delete _doc; _doc = 0; setText(s); } else { setUnstyled(); setHtml(s); } } else { setHtml(s); } } else if (tag == "subtype") // obsolete e.skipCurrentElement(); else if (tag == "frameWidth") { // obsolete qreal spMM = spatium() / MScore::DPMM; setFrameWidth(Spatium(e.readDouble() / spMM)); } else if (tag == "paddingWidth") { // obsolete qreal spMM = spatium() / MScore::DPMM; setPaddingWidth(Spatium(e.readDouble() / spMM)); } else if (_textStyle.readProperties(e)) ; else if (!Element::readProperties(e)) return false; return true; }
bool Box::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "height") _boxHeight = Spatium(e.readDouble()); else if (tag == "width") _boxWidth = Spatium(e.readDouble()); else if (tag == "topGap") { _topGap = e.readDouble(); if (score()->mscVersion() >= 203) _topGap *= score()->spatium(); } else if (tag == "bottomGap") { _bottomGap = e.readDouble(); if (score()->mscVersion() >= 203) _bottomGap *= score()->spatium(); } else if (tag == "leftMargin") _leftMargin = e.readDouble(); else if (tag == "rightMargin") _rightMargin = e.readDouble(); else if (tag == "topMargin") _topMargin = e.readDouble(); else if (tag == "bottomMargin") _bottomMargin = e.readDouble(); else if (tag == "Text") { Text* t; if (type() == Element::Type::TBOX) { t = static_cast<TBox*>(this)->text(); t->read(e); } else { t = new Text(score()); t->read(e); if (t->isEmpty()) { qDebug("read empty text"); } else add(t); } } else if (tag == "Symbol") { Symbol* s = new Symbol(score()); s->read(e); add(s); } else if (tag == "Image") { if (MScore::noImages) e.skipCurrentElement(); else { Image* image = new Image(score()); image->setTrack(e.track()); image->read(e); add(image); } } else if (tag == "FretDiagram") { FretDiagram* f = new FretDiagram(score()); f->read(e); add(f); } else if (tag == "LayoutBreak") { LayoutBreak* lb = new LayoutBreak(score()); lb->read(e); add(lb); } else if (tag == "HBox") { HBox* hb = new HBox(score()); hb->read(e); add(hb); } else if (tag == "VBox") { VBox* vb = new VBox(score()); vb->read(e); add(vb); } else if (Element::readProperties(e)) ; else return false; return true; }
bool ElementLayout::readProperties(XmlReader& e) { const QStringRef& tag(e.name()); if (tag == "halign") { const QString& val(e.readElementText()); _align &= ~(AlignmentFlags::HCENTER | AlignmentFlags::RIGHT); if (val == "center") _align |= AlignmentFlags::HCENTER; else if (val == "right") _align |= AlignmentFlags::RIGHT; else if (val == "left") ; else qDebug("Text::readProperties: unknown alignment: <%s>", qPrintable(val)); } else if (tag == "valign") { const QString& val(e.readElementText()); _align &= ~(AlignmentFlags::VCENTER | AlignmentFlags::BOTTOM | AlignmentFlags::BASELINE); if (val == "center") _align |= AlignmentFlags::VCENTER; else if (val == "bottom") _align |= AlignmentFlags::BOTTOM; else if (val == "baseline") _align |= AlignmentFlags::BASELINE; else if (val == "top") ; else qDebug("Text::readProperties: unknown alignment: <%s>", qPrintable(val)); } else if (tag == "xoffset") { qreal xo = e.readDouble(); if (offsetType() == OffsetType::ABS) xo /= INCH; setXoff(xo); } else if (tag == "yoffset") { qreal yo = e.readDouble(); if (offsetType() == OffsetType::ABS) yo /= INCH; setYoff(yo); } else if (tag == "rxoffset") // obsolete e.readDouble(); else if (tag == "ryoffset") // obsolete e.readDouble(); else if (tag == "offsetType") { const QString& val(e.readElementText()); OffsetType ot = OffsetType::ABS; if (val == "spatium" || val == "1") ot = OffsetType::SPATIUM; if (ot != offsetType()) { setOffsetType(ot); if (ot == OffsetType::ABS) _offset /= INCH; // convert spatium -> inch else _offset *= INCH; // convert inch -> spatium } } else return false; return true; }
void RawStruct<std::vector<RPG::MoveCommand> >::BeginXml(std::vector<RPG::MoveCommand>& obj, XmlReader& stream) { stream.SetHandler(new MoveCommandVectorXmlHandler(obj)); }