Load from XML
| 1673 | |
| 1674 | //! Load from XML |
| 1675 | bool Histogram::load(XmlStreamReader* reader, bool preview) { |
| 1676 | Q_D(Histogram); |
| 1677 | |
| 1678 | if (!readBasicAttributes(reader)) |
| 1679 | return false; |
| 1680 | |
| 1681 | QXmlStreamAttributes attribs; |
| 1682 | QString str; |
| 1683 | |
| 1684 | while (!reader->atEnd()) { |
| 1685 | reader->readNext(); |
| 1686 | if (reader->isEndElement() && reader->name() == QLatin1String("Histogram")) |
| 1687 | break; |
| 1688 | |
| 1689 | if (!reader->isStartElement()) |
| 1690 | continue; |
| 1691 | |
| 1692 | if (reader->name() == QLatin1String("comment")) { |
| 1693 | if (!readCommentElement(reader)) |
| 1694 | return false; |
| 1695 | } else if (!preview && reader->name() == QLatin1String("general")) { |
| 1696 | attribs = reader->attributes(); |
| 1697 | |
| 1698 | READ_COLUMN(dataColumn); |
| 1699 | READ_INT_VALUE("type", type, Histogram::Type); |
| 1700 | READ_INT_VALUE("orientation", orientation, Histogram::Orientation); |
| 1701 | READ_INT_VALUE("normalization", normalization, Histogram::Normalization); |
| 1702 | READ_INT_VALUE("binningMethod", binningMethod, Histogram::BinningMethod); |
| 1703 | READ_INT_VALUE("binCount", binCount, int); |
| 1704 | READ_DOUBLE_VALUE("binWidth", binWidth); |
| 1705 | READ_INT_VALUE("autoBinRanges", autoBinRanges, bool); |
| 1706 | READ_DOUBLE_VALUE("binRangesMin", binRangesMin); |
| 1707 | READ_DOUBLE_VALUE("binRangesMax", binRangesMax); |
| 1708 | READ_INT_VALUE_DIRECT("plotRangeIndex", m_cSystemIndex, int); |
| 1709 | READ_INT_VALUE("legendVisible", legendVisible, bool); |
| 1710 | |
| 1711 | str = attribs.value(QStringLiteral("visible")).toString(); |
| 1712 | if (str.isEmpty()) |
| 1713 | reader->raiseMissingAttributeWarning(QStringLiteral("visible")); |
| 1714 | else |
| 1715 | d->setVisible(str.toInt()); |
| 1716 | |
| 1717 | // prior to XML version 12, Histogram used its own enum for the orientation instead of the enum in WorksheetElement |
| 1718 | // which had a different order of values ("{Vertical, Horizontal}" in Histogram vs. "{Horizontal, Vertical}" in WorksheetElement) |
| 1719 | // and we need to map from the old to the new values |
| 1720 | if (Project::xmlVersion() < 12) { |
| 1721 | const int orientation = static_cast<int>(d->orientation); |
| 1722 | if (orientation == 0) |
| 1723 | d->orientation = Orientation::Vertical; |
| 1724 | else if (orientation == 1) |
| 1725 | d->orientation = Orientation::Horizontal; |
| 1726 | } |
| 1727 | } else if (!preview && reader->name() == QLatin1String("line")) { |
| 1728 | d->line->load(reader, preview); |
| 1729 | } else if (!preview && reader->name() == QLatin1String("symbols")) |
| 1730 | d->symbol->load(reader, preview); |
| 1731 | else if (!preview && reader->name() == QLatin1String("values")) |
| 1732 | d->value->load(reader, preview); |
nothing calls this directly
no test coverage detected