void Polygon::initialize(QXmlStreamReader& xml, UnitsType units) { while (!xml.atEnd() && !xml.hasError()) { xml.readNext(); if (xml.isStartElement()) { if (xml.name() == "PolyBegin") { m_polyBegin.rx() = toInch( getDoubleAttribute(xml, "PolyBegin", "x"), units); m_polyBegin.ry() = toInch( getDoubleAttribute(xml, "PolyBegin", "y"), units); } else if (isSubstitutionGroupPolyStep(xml.name())) { PolyStep *p = PolyStepFactory().create(xml.name()); p->initialize(xml, units); m_polySteps.append(p); } } else if (isEndElementWithName(xml, "Polygon") || // </Polygon> the end isEndElementWithName(xml, "Cutout")) { // another possible name if (!isClosedShape()) { throw new InvalidElementError("Polygon"); } return; } } }
void Features::initialize(QXmlStreamReader& xml, UnitsType units) { m_xform = NULL; m_feature = NULL; while (!xml.atEnd() && !xml.hasError()) { xml.readNext(); if (xml.isStartElement()) { if (xml.name() == "Xform") { m_xform = new Xform(); m_xform->initialize(xml); } else if (xml.name() == "Location") { m_location = QPointF( toInch(getDoubleAttribute(xml, "Location", "x"), units), toInch(getDoubleAttribute(xml, "Location", "y"), units)); } else if (isSubstitutionGroupFeature(xml.name())) { m_feature = FeatureFactory().create(xml.name()); m_feature->initialize(xml, units); } } else if (isEndElementWithName(xml, "Features")) { // </Features> if (m_feature == NULL) { throw new InvalidElementError("Features"); } return; } } }
qreal KoUnit::toUserValue(qreal ptValue) const { switch (m_type) { case Millimeter: return toMillimeter(ptValue); case Centimeter: return toCentimeter(ptValue); case Decimeter: return toDecimeter(ptValue); case Inch: return toInch(ptValue); case Pica: return toPica(ptValue); case Cicero: return toCicero(ptValue); case Pixel: return ptValue * m_pixelConversion; case Point: default: return toPoint(ptValue); } }