############################################################################## ################## Serialization/Deserialization ########################### ##############################################################################
| 1113 | // ################## Serialization/Deserialization ########################### |
| 1114 | // ############################################################################## |
| 1115 | void Matrix::save(QXmlStreamWriter* writer) const { |
| 1116 | Q_D(const Matrix); |
| 1117 | DEBUG(Q_FUNC_INFO); |
| 1118 | writer->writeStartElement(QStringLiteral("matrix")); |
| 1119 | writeBasicAttributes(writer); |
| 1120 | writeCommentElement(writer); |
| 1121 | |
| 1122 | // formula |
| 1123 | writer->writeStartElement(QStringLiteral("formula")); |
| 1124 | writer->writeCharacters(d->formula); |
| 1125 | writer->writeEndElement(); |
| 1126 | |
| 1127 | // format |
| 1128 | writer->writeStartElement(QStringLiteral("format")); |
| 1129 | writer->writeAttribute(QStringLiteral("mode"), QString::number(static_cast<int>(d->mode))); |
| 1130 | writer->writeAttribute(QStringLiteral("headerFormat"), QString::number(static_cast<int>(d->headerFormat))); |
| 1131 | writer->writeAttribute(QStringLiteral("numericFormat"), QChar::fromLatin1(d->numericFormat)); |
| 1132 | writer->writeAttribute(QStringLiteral("precision"), QString::number(d->precision)); |
| 1133 | writer->writeEndElement(); |
| 1134 | |
| 1135 | // dimensions |
| 1136 | writer->writeStartElement(QStringLiteral("dimension")); |
| 1137 | writer->writeAttribute(QStringLiteral("x_start"), QString::number(d->xStart)); |
| 1138 | writer->writeAttribute(QStringLiteral("x_end"), QString::number(d->xEnd)); |
| 1139 | writer->writeAttribute(QStringLiteral("y_start"), QString::number(d->yStart)); |
| 1140 | writer->writeAttribute(QStringLiteral("y_end"), QString::number(d->yEnd)); |
| 1141 | writer->writeEndElement(); |
| 1142 | |
| 1143 | // vector with row heights |
| 1144 | writer->writeStartElement(QStringLiteral("row_heights")); |
| 1145 | const char* data = reinterpret_cast<const char*>(d->rowHeights.constData()); |
| 1146 | int size = d->rowHeights.size() * sizeof(int); |
| 1147 | writer->writeCharacters(QLatin1String(QByteArray::fromRawData(data, size).toBase64())); |
| 1148 | writer->writeEndElement(); |
| 1149 | |
| 1150 | // vector with column widths |
| 1151 | writer->writeStartElement(QStringLiteral("column_widths")); |
| 1152 | data = reinterpret_cast<const char*>(d->columnWidths.constData()); |
| 1153 | size = d->columnWidths.size() * sizeof(int); |
| 1154 | writer->writeCharacters(QLatin1String(QByteArray::fromRawData(data, size).toBase64())); |
| 1155 | writer->writeEndElement(); |
| 1156 | |
| 1157 | const auto columnCount = this->columnCount(); |
| 1158 | |
| 1159 | // columns |
| 1160 | DEBUG(" mode = " << static_cast<int>(d->mode)) |
| 1161 | switch (d->mode) { |
| 1162 | case AbstractColumn::ColumnMode::Double: |
| 1163 | size = d->rowCount() * sizeof(double); |
| 1164 | for (int i = 0; i < columnCount; ++i) { |
| 1165 | data = reinterpret_cast<const char*>(static_cast<QVector<QVector<double>>*>(d->data)->at(i).constData()); |
| 1166 | writer->writeStartElement(QStringLiteral("column")); |
| 1167 | writer->writeCharacters(QLatin1String(QByteArray::fromRawData(data, size).toBase64())); |
| 1168 | writer->writeEndElement(); |
| 1169 | } |
| 1170 | break; |
| 1171 | case AbstractColumn::ColumnMode::Text: |
| 1172 | size = d->rowCount() * sizeof(QString); |
nothing calls this directly
no test coverage detected