MCPcopy Create free account
hub / github.com/KDE/labplot / saveToXmlFile

Method saveToXmlFile

src/3rdparty/QXlsx/source/xlsxsharedstrings.cpp:192–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192void SharedStrings::saveToXmlFile(QIODevice *device) const
193{
194 QXmlStreamWriter writer(device);
195
196 if (m_stringList.size() != m_stringTable.size()) {
197 //Duplicated string items exist in m_stringList
198 //Clean up can not be done here, as the indices
199 //have been used when we save the worksheets part.
200 }
201
202 writer.writeStartDocument(QStringLiteral("1.0"), true);
203 writer.writeStartElement(QStringLiteral("sst"));
204 writer.writeAttribute(QStringLiteral("xmlns"), QStringLiteral("http://schemas.openxmlformats.org/spreadsheetml/2006/main"));
205 writer.writeAttribute(QStringLiteral("count"), QString::number(m_stringCount));
206 writer.writeAttribute(QStringLiteral("uniqueCount"), QString::number(m_stringList.size()));
207
208 for (const RichString &string : m_stringList) {
209 writer.writeStartElement(QStringLiteral("si"));
210 if (string.isRichString()) {
211 //Rich text string
212 for (int i=0; i<string.fragmentCount(); ++i) {
213 writer.writeStartElement(QStringLiteral("r"));
214 if (string.fragmentFormat(i).hasFontData()) {
215 writer.writeStartElement(QStringLiteral("rPr"));
216 writeRichStringPart_rPr(writer, string.fragmentFormat(i));
217 writer.writeEndElement();// rPr
218 }
219 writer.writeStartElement(QStringLiteral("t"));
220 if (isSpaceReserveNeeded(string.fragmentText(i)))
221 writer.writeAttribute(QStringLiteral("xml:space"), QStringLiteral("preserve"));
222 writer.writeCharacters(string.fragmentText(i));
223 writer.writeEndElement();// t
224
225 writer.writeEndElement(); //r
226 }
227 } else {
228 writer.writeStartElement(QStringLiteral("t"));
229 QString pString = string.toPlainString();
230 if (isSpaceReserveNeeded(pString))
231 writer.writeAttribute(QStringLiteral("xml:space"), QStringLiteral("preserve"));
232 writer.writeCharacters(pString);
233 writer.writeEndElement();//t
234 }
235 writer.writeEndElement();//si
236 }
237
238 writer.writeEndElement(); //sst
239 writer.writeEndDocument();
240}
241
242void SharedStrings::readString(QXmlStreamReader &reader)
243{

Callers

nothing calls this directly

Calls 8

isSpaceReserveNeededFunction · 0.85
fragmentCountMethod · 0.80
hasFontDataMethod · 0.80
fragmentFormatMethod · 0.80
fragmentTextMethod · 0.80
toPlainStringMethod · 0.80
sizeMethod · 0.45
isRichStringMethod · 0.45

Tested by

no test coverage detected