Example #1
0
bool ElementLayout::readProperties(XmlReader& e)
      {
      const QStringRef& tag(e.name());

      if (tag == "halign") {
            const QString& val(e.readElementText());
            _align &= ~(ALIGN_HCENTER | ALIGN_RIGHT);
            if (val == "center")
                  _align |= ALIGN_HCENTER;
            else if (val == "right")
                  _align |= ALIGN_RIGHT;
            else if (val == "left")
                  ;
            else
                  qDebug("Text::readProperties: unknown alignment: <%s>", qPrintable(val));
            }
      else if (tag == "valign") {
            const QString& val(e.readElementText());
            _align &= ~(ALIGN_VCENTER | ALIGN_BOTTOM | ALIGN_BASELINE);
            if (val == "center")
                  _align |= ALIGN_VCENTER;
            else if (val == "bottom")
                  _align |= ALIGN_BOTTOM;
            else if (val == "baseline")
                  _align |= ALIGN_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;
      }
Example #2
0
bool ElementLayout::readProperties(XmlReader* r)
      {
      MString8 tag = r->tag();
      QString val;
      int i;
      qreal d;

      if (r->readString("halign", &val)) {
            _align &= ~(ALIGN_HCENTER | ALIGN_RIGHT);
            if (val == "center")
                  _align |= ALIGN_HCENTER;
            else if (val == "right")
                  _align |= ALIGN_RIGHT;
            else if (val == "left") {
                  ;
                  }
            }
      else if (r->readString("valign", &val)) {
            _align &= ~(ALIGN_VCENTER | ALIGN_BOTTOM | ALIGN_BASELINE);
            if (val == "center")
                  _align |= ALIGN_VCENTER;
            else if (val == "bottom")
                  _align |= ALIGN_BOTTOM;
            else if (val == "baseline")
                  _align |= ALIGN_BASELINE;
            else if (val == "top") {
                  ;
                  }
            }
      else if (r->readReal("xoffset", &d)) {
            if (offsetType() == OFFSET_ABS)
                  d /= INCH;
            setXoff(d);
            }
      else if (r->readReal("yoffset", &d)) {
            if (offsetType() == OFFSET_ABS)
                  d /= INCH;
            setYoff(d);
            }
      else if (r->readReal("rxoffset", &d))
            setRxoff(d);
      else if (r->readReal("ryoffset", &d))
            setRyoff(val.toDouble());
      else if (r->readInt("offsetType", &i)) {
            OffsetType ot = (OffsetType)i;
            if (ot != offsetType()) {
                  setOffsetType(ot);
                  if (ot == OFFSET_ABS) {
                        _xoff /= INCH;
                        _yoff /= INCH;
                        }
                  else {
                        _xoff *= INCH;
                        _yoff *= INCH;
                        }
                  }
            }
      else
            return false;
      return true;
      }