Load from XML
| 1787 | |
| 1788 | //! Load from XML |
| 1789 | bool Worksheet::load(XmlStreamReader* reader, bool preview) { |
| 1790 | if (!readBasicAttributes(reader)) |
| 1791 | return false; |
| 1792 | |
| 1793 | Q_D(Worksheet); |
| 1794 | |
| 1795 | // clear the theme that was potentially set in init() in order to correctly load here the worksheets without any theme used |
| 1796 | d->theme.clear(); |
| 1797 | |
| 1798 | QXmlStreamAttributes attribs; |
| 1799 | QString str; |
| 1800 | |
| 1801 | while (!reader->atEnd()) { |
| 1802 | reader->readNext(); |
| 1803 | if (reader->isEndElement() && reader->name() == QLatin1String("worksheet")) |
| 1804 | break; |
| 1805 | |
| 1806 | if (!reader->isStartElement()) |
| 1807 | continue; |
| 1808 | |
| 1809 | if (reader->name() == QLatin1String("comment")) { |
| 1810 | if (!readCommentElement(reader)) |
| 1811 | return false; |
| 1812 | } else if (!preview && reader->name() == QLatin1String("theme")) { |
| 1813 | attribs = reader->attributes(); |
| 1814 | d->theme = attribs.value(QStringLiteral("name")).toString(); |
| 1815 | } else if (!preview && reader->name() == QLatin1String("geometry")) { |
| 1816 | attribs = reader->attributes(); |
| 1817 | |
| 1818 | str = attribs.value(QStringLiteral("x")).toString(); |
| 1819 | if (str.isEmpty()) |
| 1820 | reader->raiseMissingAttributeWarning(QStringLiteral("x")); |
| 1821 | else |
| 1822 | d->pageRect.setX(str.toDouble()); |
| 1823 | |
| 1824 | str = attribs.value(QStringLiteral("y")).toString(); |
| 1825 | if (str.isEmpty()) |
| 1826 | reader->raiseMissingAttributeWarning(QStringLiteral("y")); |
| 1827 | else |
| 1828 | d->pageRect.setY(str.toDouble()); |
| 1829 | |
| 1830 | str = attribs.value(QStringLiteral("width")).toString(); |
| 1831 | if (str.isEmpty()) |
| 1832 | reader->raiseMissingAttributeWarning(QStringLiteral("width")); |
| 1833 | else |
| 1834 | d->pageRect.setWidth(str.toDouble()); |
| 1835 | |
| 1836 | str = attribs.value(QStringLiteral("height")).toString(); |
| 1837 | if (str.isEmpty()) |
| 1838 | reader->raiseMissingAttributeWarning(QStringLiteral("height")); |
| 1839 | else |
| 1840 | d->pageRect.setHeight(str.toDouble()); |
| 1841 | |
| 1842 | READ_INT_VALUE("useViewSize", useViewSize, int); |
| 1843 | READ_INT_VALUE("zoomFit", zoomFit, ZoomFit); |
| 1844 | } else if (!preview && reader->name() == QLatin1String("layout")) { |
| 1845 | attribs = reader->attributes(); |
| 1846 |
nothing calls this directly
no test coverage detected