示例#1
0
void Symbol::read(XmlReader& e)
{
    QPointF pos;
    while (e.readNextStartElement()) {
        const QStringRef& tag(e.name());
        if (tag == "name") {
            QString val(e.readElementText());
            SymId symId = Sym::name2id(val);
            if (val != "noSym") {
                if (symId == SymId::noSym) {
                    // if symbol name not found, fall back to user names
                    // TODO : does it make sense? user names are probably localized
                    symId = Sym::userName2id(val);
                    // if not found, look into old names
                    if (symId == SymId::noSym)
                        symId = Sym::oldName2id(val);
                    if (symId == SymId::noSym) {
                        qDebug("unknown symbol <%s>, falling back to no symbol", qPrintable(val));
                        // set a default symbol, or layout() will crash
                        symId = SymId::noSym;
                    }
                }
            }
            setSym(symId);
        }
        else if (tag == "font")
            _scoreFont = ScoreFont::fontFactory(e.readElementText());
        else if (tag == "Symbol") {
            Symbol* s = new Symbol(score());
            s->read(e);
            s->adjustReadPos();
            add(s);
        }
        else if (tag == "Image") {
            if (MScore::noImages)
                e.skipCurrentElement();
            else {
                Image* image = new Image(score());
                image->read(e);
                add(image);
            }
        }
        else if (tag == "small" || tag == "subtype")    // obsolete
            e.skipCurrentElement();
        else if (!BSymbol::readProperties(e))
            e.unknown();
    }
    setPos(pos);
}
示例#2
0
void Symbol::read(XmlReader& e)
      {
      QPointF pos;
      SymId s = noSym;

      while (e.readNextStartElement()) {
            const QStringRef& tag(e.name());
            if (tag == "name") {
                  QString val(e.readElementText());
                  if (val == "acc dot")               // compatibility hack
                        val = "accordion.accDot";
                  else if (val == "acc old ee")
                        val = "accordion.accOldEE";
                  s = Sym::name2id(val);
                  if (s == noSym) {
                        // if symbol name not found, fall back to mnames
                        s = Sym::userName2id(val);
                        if (s == noSym) {
                              qDebug("unknown symbol <%s> (%d symbols), falling back to default symbol",
                                 qPrintable(val), symbols[0].size());
                              // set a default symbol, or layout() will crash
                              s = s1miHeadSym;
                              }
                        }
                  }
            else if (tag == "Symbol") {
                  Symbol* s = new Symbol(score());
                  s->read(e);
                  s->adjustReadPos();
                  add(s);
                  }
            else if (tag == "Image") {
                  Image* image = new Image(score());
                  QString path;
                  image->read(e);
                  add(image);
                  }
            else if (tag == "small" || tag == "subtype")
                  ;
            else if (!BSymbol::readProperties(e))
                  e.unknown();
            }
      if (s == noSym)
            qDebug("unknown symbol");
      setPos(pos);
      setSym(s);
      }