|
|
@ -23,118 +23,113 @@ |
|
|
|
** |
|
|
|
****************************************************************************/ |
|
|
|
#include "xlsxstyles_p.h" |
|
|
|
#include "xlsxformat.h" |
|
|
|
#include "xlsxxmlwriter_p.h" |
|
|
|
#include "xlsxformat_p.h" |
|
|
|
#include <QFile> |
|
|
|
#include <QMap> |
|
|
|
#include <QDataStream> |
|
|
|
#include <QDebug> |
|
|
|
#include <QBuffer> |
|
|
|
|
|
|
|
namespace QXlsx { |
|
|
|
|
|
|
|
|
|
|
|
Styles::Styles(QObject *parent) : |
|
|
|
QObject(parent) |
|
|
|
Styles::Styles() |
|
|
|
{ |
|
|
|
m_fill_count = 0; |
|
|
|
m_borders_count = 0; |
|
|
|
m_font_count = 0; |
|
|
|
//Add default Format
|
|
|
|
addFormat(createFormat()); |
|
|
|
//Add another fill format
|
|
|
|
QSharedPointer<FillData> fill = QSharedPointer<FillData>(new FillData); |
|
|
|
fill->pattern = Format::PatternGray125; |
|
|
|
m_fillsList.append(fill); |
|
|
|
m_fillsHash[fill->_key] = fill; |
|
|
|
} |
|
|
|
|
|
|
|
Styles::~Styles() |
|
|
|
{ |
|
|
|
qDeleteAll(m_formats); |
|
|
|
} |
|
|
|
|
|
|
|
Format *Styles::addFormat() |
|
|
|
Format *Styles::createFormat() |
|
|
|
{ |
|
|
|
Format *format = new Format(); |
|
|
|
m_createdFormatsList.append(QSharedPointer<Format>(format)); |
|
|
|
|
|
|
|
m_formats.append(format); |
|
|
|
return format; |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* This function should be called after worksheet written finished, |
|
|
|
* which means the order of the Formats used have been known to us. |
|
|
|
Assign index to Font/Fill/Border and Format |
|
|
|
*/ |
|
|
|
void Styles::prepareStyles() |
|
|
|
void Styles::addFormat(Format *format) |
|
|
|
{ |
|
|
|
m_xf_formats = Format::xfFormats(); |
|
|
|
m_dxf_formats = Format::dxfFormats(); |
|
|
|
|
|
|
|
if (m_xf_formats.isEmpty()) |
|
|
|
m_xf_formats.append(this->addFormat()); |
|
|
|
//fonts
|
|
|
|
QMap<QByteArray, int> fontsKeyCache; |
|
|
|
foreach (Format *format, m_xf_formats) { |
|
|
|
const QByteArray &key = format->fontKey(); |
|
|
|
if (fontsKeyCache.contains(key)) { |
|
|
|
//Font has already been used.
|
|
|
|
format->setFontIndex(fontsKeyCache[key]); |
|
|
|
format->setFontRedundant(true); |
|
|
|
} else { |
|
|
|
int index = fontsKeyCache.size(); |
|
|
|
fontsKeyCache[key] = index; |
|
|
|
format->setFontIndex(index); |
|
|
|
format->setFontRedundant(false); |
|
|
|
} |
|
|
|
} |
|
|
|
m_font_count = fontsKeyCache.size(); |
|
|
|
|
|
|
|
//borders
|
|
|
|
QMap<QByteArray, int> bordersKeyCache; |
|
|
|
foreach (Format *format, m_xf_formats) { |
|
|
|
const QByteArray &key = format->borderKey(); |
|
|
|
if (bordersKeyCache.contains(key)) { |
|
|
|
//Border has already been used.
|
|
|
|
format->setBorderIndex(bordersKeyCache[key]); |
|
|
|
format->setBorderRedundant(true); |
|
|
|
} else { |
|
|
|
int index = bordersKeyCache.size(); |
|
|
|
bordersKeyCache[key] = index; |
|
|
|
format->setBorderIndex(index); |
|
|
|
format->setBorderRedundant(false); |
|
|
|
if (!format) |
|
|
|
return; |
|
|
|
|
|
|
|
//Font
|
|
|
|
if (!format->fontIndexValid()) { |
|
|
|
if (!m_fontsHash.contains(format->fontKey())) { |
|
|
|
QSharedPointer<FontData> font = QSharedPointer<FontData>(new FontData(format->d_func()->fontData)); |
|
|
|
font->_index = m_fontsList.size(); //Assign proper index
|
|
|
|
m_fontsList.append(font); |
|
|
|
m_fontsHash[font->_key] = font; |
|
|
|
} |
|
|
|
format->setFontIndex(m_fontsHash[format->fontKey()]->_index); |
|
|
|
} |
|
|
|
m_borders_count = bordersKeyCache.size(); |
|
|
|
|
|
|
|
//fills
|
|
|
|
QMap<QByteArray, int> fillsKeyCache; |
|
|
|
// The user defined fill properties start from 2 since there are 2
|
|
|
|
// default fills: patternType="none" and patternType="gray125".
|
|
|
|
{ |
|
|
|
QByteArray key; |
|
|
|
QDataStream stream(&key, QIODevice::WriteOnly); |
|
|
|
stream<<QColor()<<QColor()<<Format::PatternNone; |
|
|
|
fillsKeyCache[key] = 0; |
|
|
|
//Fill
|
|
|
|
if (!format->fillIndexValid()) { |
|
|
|
if (!m_fillsHash.contains(format->fillKey())) { |
|
|
|
QSharedPointer<FillData> fill = QSharedPointer<FillData>(new FillData(format->d_func()->fillData)); |
|
|
|
fill->_index = m_fillsList.size(); //Assign proper index
|
|
|
|
m_fillsList.append(fill); |
|
|
|
m_fillsHash[fill->_key] = fill; |
|
|
|
} |
|
|
|
{ |
|
|
|
QByteArray key; |
|
|
|
QDataStream stream(&key, QIODevice::WriteOnly); |
|
|
|
stream<<QColor()<<QColor()<<Format::PatternGray125; |
|
|
|
fillsKeyCache[key] = 1; |
|
|
|
} |
|
|
|
foreach (Format *format, m_xf_formats) { |
|
|
|
const QByteArray &key = format->fillKey(); |
|
|
|
if (fillsKeyCache.contains(key)) { |
|
|
|
//Border has already been used.
|
|
|
|
format->setFillIndex(fillsKeyCache[key]); |
|
|
|
format->setFillRedundant(true); |
|
|
|
format->setFillIndex(m_fillsHash[format->fillKey()]->_index); |
|
|
|
} |
|
|
|
|
|
|
|
//Border
|
|
|
|
if (!format->borderIndexValid()) { |
|
|
|
if (!m_bordersHash.contains(format->borderKey())) { |
|
|
|
QSharedPointer<BorderData> border = QSharedPointer<BorderData>(new BorderData(format->d_func()->borderData)); |
|
|
|
border->_index = m_bordersList.size(); //Assign proper index
|
|
|
|
m_bordersList.append(border); |
|
|
|
m_bordersHash[border->_key] = border; |
|
|
|
} |
|
|
|
format->setBorderIndex(m_bordersHash[format->borderKey()]->_index); |
|
|
|
} |
|
|
|
|
|
|
|
//Format
|
|
|
|
if (format->isDxfFormat()) { |
|
|
|
if (!format->dxfIndexValid()) { |
|
|
|
if (!m_dxf_formatsHash.contains(format->formatKey())) { |
|
|
|
format->setDxfIndex(m_dxf_formatsList.size()); |
|
|
|
m_dxf_formatsList.append(format); |
|
|
|
m_dxf_formatsHash[format->formatKey()] = format; |
|
|
|
} else { |
|
|
|
int index = fillsKeyCache.size(); |
|
|
|
fillsKeyCache[key] = index; |
|
|
|
format->setFillIndex(index); |
|
|
|
format->setFillRedundant(false); |
|
|
|
format->setDxfIndex(m_dxf_formatsHash[format->formatKey()]->dxfIndex()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (!format->xfIndexValid()) { |
|
|
|
if (!m_xf_formatsHash.contains(format->formatKey())) { |
|
|
|
format->setXfIndex(m_xf_formatsList.size()); |
|
|
|
m_xf_formatsList.append(format); |
|
|
|
m_xf_formatsHash[format->formatKey()] = format; |
|
|
|
} else { |
|
|
|
format->setXfIndex(m_xf_formatsHash[format->formatKey()]->xfIndex()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
m_fill_count = fillsKeyCache.size(); |
|
|
|
} |
|
|
|
|
|
|
|
void Styles::clearExtraFormatInfo() |
|
|
|
QByteArray Styles::saveToXmlData() |
|
|
|
{ |
|
|
|
foreach (Format *format, m_formats) |
|
|
|
format->clearExtraInfos(); |
|
|
|
QByteArray data; |
|
|
|
QBuffer buffer(&data); |
|
|
|
buffer.open(QIODevice::WriteOnly); |
|
|
|
saveToXmlFile(&buffer); |
|
|
|
|
|
|
|
return data; |
|
|
|
} |
|
|
|
|
|
|
|
void Styles::saveToXmlFile(QIODevice *device) |
|
|
@ -185,101 +180,111 @@ void Styles::saveToXmlFile(QIODevice *device) |
|
|
|
writer.writeEndDocument(); |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
not consider dxf format. |
|
|
|
*/ |
|
|
|
void Styles::writeFonts(XmlStreamWriter &writer) |
|
|
|
{ |
|
|
|
|
|
|
|
writer.writeStartElement(QStringLiteral("fonts")); |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_font_count)); |
|
|
|
foreach (Format *format, m_xf_formats) { |
|
|
|
if (format->hasFont()) { |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_fontsList.count())); |
|
|
|
for (int i=0; i<m_fontsList.size(); ++i) { |
|
|
|
QSharedPointer<FontData> font = m_fontsList[i]; |
|
|
|
|
|
|
|
writer.writeStartElement(QStringLiteral("font")); |
|
|
|
if (format->fontBold()) |
|
|
|
if (font->bold) |
|
|
|
writer.writeEmptyElement(QStringLiteral("b")); |
|
|
|
if (format->fontItalic()) |
|
|
|
if (font->italic) |
|
|
|
writer.writeEmptyElement(QStringLiteral("i")); |
|
|
|
if (format->fontStrikeOut()) |
|
|
|
if (font->strikeOut) |
|
|
|
writer.writeEmptyElement(QStringLiteral("strike")); |
|
|
|
if (format->fontOutline()) |
|
|
|
if (font->outline) |
|
|
|
writer.writeEmptyElement(QStringLiteral("outline")); |
|
|
|
if (format->fontShadow()) |
|
|
|
if (font->shadow) |
|
|
|
writer.writeEmptyElement(QStringLiteral("shadow")); |
|
|
|
if (format->fontUnderline() != Format::FontUnderlineNone) { |
|
|
|
if (font->underline != Format::FontUnderlineNone) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("u")); |
|
|
|
if (format->fontUnderline() == Format::FontUnderlineDouble) |
|
|
|
if (font->underline == Format::FontUnderlineDouble) |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("double")); |
|
|
|
else if (format->fontUnderline() == Format::FontUnderlineSingleAccounting) |
|
|
|
else if (font->underline == Format::FontUnderlineSingleAccounting) |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("singleAccounting")); |
|
|
|
else if (format->fontUnderline() == Format::FontUnderlineDoubleAccounting) |
|
|
|
else if (font->underline == Format::FontUnderlineDoubleAccounting) |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("doubleAccounting")); |
|
|
|
} |
|
|
|
if (format->fontScript() != Format::FontScriptNormal) { |
|
|
|
if (font->scirpt != Format::FontScriptNormal) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("vertAligh")); |
|
|
|
if (format->fontScript() == Format::FontScriptSuper) |
|
|
|
if (font->scirpt == Format::FontScriptSuper) |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("superscript")); |
|
|
|
else |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QStringLiteral("subscript")); |
|
|
|
} |
|
|
|
|
|
|
|
if (!format->isDxfFormat()) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("sz")); |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QString::number(format->fontSize())); |
|
|
|
} |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QString::number(font->size)); |
|
|
|
|
|
|
|
//font color
|
|
|
|
if (format->theme()) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("color")); |
|
|
|
writer.writeAttribute(QStringLiteral("theme"), QString::number(format->theme())); |
|
|
|
} else if (format->colorIndexed()) { |
|
|
|
if (font->color.isValid()) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("color")); |
|
|
|
writer.writeAttribute(QStringLiteral("indexed"), QString::number(format->colorIndexed())); |
|
|
|
} else if (format->fontColor().isValid()) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("color")); |
|
|
|
QString color = format->fontColor().name(); |
|
|
|
QString color = font->color.name(); |
|
|
|
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+color.mid(1));//remove #
|
|
|
|
} else if (!format->isDxfFormat()) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("color")); |
|
|
|
writer.writeAttribute(QStringLiteral("theme"), QStringLiteral("1")); |
|
|
|
} |
|
|
|
|
|
|
|
if (!format->isDxfFormat()) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("name")); |
|
|
|
writer.writeAttribute(QStringLiteral("val"), format->fontName()); |
|
|
|
writer.writeAttribute(QStringLiteral("val"), font->name); |
|
|
|
writer.writeEmptyElement(QStringLiteral("family")); |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QString::number(format->fontFamily())); |
|
|
|
if (format->fontName() == QLatin1String("Calibri")) { |
|
|
|
writer.writeAttribute(QStringLiteral("val"), QString::number(font->family)); |
|
|
|
if (font->name == QLatin1String("Calibri")) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("scheme")); |
|
|
|
writer.writeAttribute(QStringLiteral("val"), format->fontScheme()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
writer.writeAttribute(QStringLiteral("val"), font->scheme); |
|
|
|
} |
|
|
|
|
|
|
|
// if (!format->isDxfFormat()) {
|
|
|
|
// writer.writeEmptyElement(QStringLiteral("sz"));
|
|
|
|
// writer.writeAttribute(QStringLiteral("val"), QString::number(format->fontSize()));
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //font color
|
|
|
|
// if (format->theme()) {
|
|
|
|
// writer.writeEmptyElement(QStringLiteral("color"));
|
|
|
|
// writer.writeAttribute(QStringLiteral("theme"), QString::number(format->theme()));
|
|
|
|
// } else if (format->colorIndexed()) {
|
|
|
|
// writer.writeEmptyElement(QStringLiteral("color"));
|
|
|
|
// writer.writeAttribute(QStringLiteral("indexed"), QString::number(format->colorIndexed()));
|
|
|
|
// } else if (format->fontColor().isValid()) {
|
|
|
|
// writer.writeEmptyElement(QStringLiteral("color"));
|
|
|
|
// QString color = format->fontColor().name();
|
|
|
|
// writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+color.mid(1));//remove #
|
|
|
|
// } else if (!format->isDxfFormat()) {
|
|
|
|
// writer.writeEmptyElement(QStringLiteral("color"));
|
|
|
|
// writer.writeAttribute(QStringLiteral("theme"), QStringLiteral("1"));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (!format->isDxfFormat()) {
|
|
|
|
// writer.writeEmptyElement(QStringLiteral("name"));
|
|
|
|
// writer.writeAttribute(QStringLiteral("val"), format->fontName());
|
|
|
|
// writer.writeEmptyElement(QStringLiteral("family"));
|
|
|
|
// writer.writeAttribute(QStringLiteral("val"), QString::number(format->fontFamily()));
|
|
|
|
// if (format->fontName() == QLatin1String("Calibri")) {
|
|
|
|
// writer.writeEmptyElement(QStringLiteral("scheme"));
|
|
|
|
// writer.writeAttribute(QStringLiteral("val"), format->fontScheme());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
writer.writeEndElement(); //font
|
|
|
|
} |
|
|
|
} |
|
|
|
writer.writeEndElement();//fonts
|
|
|
|
} |
|
|
|
|
|
|
|
void Styles::writeFills(XmlStreamWriter &writer) |
|
|
|
{ |
|
|
|
writer.writeStartElement(QStringLiteral("fills")); |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_fill_count)); |
|
|
|
//wirte two default fill first
|
|
|
|
writer.writeStartElement(QStringLiteral("fill")); |
|
|
|
writer.writeEmptyElement(QStringLiteral("patternFill")); |
|
|
|
writer.writeAttribute(QStringLiteral("patternType"), QStringLiteral("none")); |
|
|
|
writer.writeEndElement();//fill
|
|
|
|
writer.writeStartElement(QStringLiteral("fill")); |
|
|
|
writer.writeEmptyElement(QStringLiteral("patternFill")); |
|
|
|
writer.writeAttribute(QStringLiteral("patternType"), QStringLiteral("gray125")); |
|
|
|
writer.writeEndElement();//fill
|
|
|
|
foreach (Format *format, m_xf_formats) { |
|
|
|
if (format->hasFill()) { |
|
|
|
writeFill(writer, format); |
|
|
|
} |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_fillsList.size())); |
|
|
|
|
|
|
|
for (int i=0; i<m_fillsList.size(); ++i) { |
|
|
|
QSharedPointer<FillData> fill = m_fillsList[i]; |
|
|
|
writeFill(writer, fill.data()); |
|
|
|
} |
|
|
|
writer.writeEndElement(); //fills
|
|
|
|
} |
|
|
|
|
|
|
|
void Styles::writeFill(XmlStreamWriter &writer, Format *format) |
|
|
|
void Styles::writeFill(XmlStreamWriter &writer, FillData *fill) |
|
|
|
{ |
|
|
|
static QMap<int, QString> patternStrings; |
|
|
|
if (patternStrings.isEmpty()) { |
|
|
@ -305,14 +310,14 @@ void Styles::writeFill(XmlStreamWriter &writer, Format *format) |
|
|
|
|
|
|
|
writer.writeStartElement(QStringLiteral("fill")); |
|
|
|
writer.writeStartElement(QStringLiteral("patternFill")); |
|
|
|
writer.writeAttribute(QStringLiteral("patternType"), patternStrings[format->fillPattern()]); |
|
|
|
if (format->patternForegroundColor().isValid()) { |
|
|
|
writer.writeAttribute(QStringLiteral("patternType"), patternStrings[fill->pattern]); |
|
|
|
if (fill->fgColor.isValid()) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("fgColor")); |
|
|
|
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+format->patternForegroundColor().name().mid(1)); |
|
|
|
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+fill->fgColor.name().mid(1)); |
|
|
|
} |
|
|
|
if (format->patternBackgroundColor().isValid()) { |
|
|
|
if (fill->bgColor.isValid()) { |
|
|
|
writer.writeEmptyElement(QStringLiteral("bgColor")); |
|
|
|
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+format->patternBackgroundColor().name().mid(1)); |
|
|
|
writer.writeAttribute(QStringLiteral("rgb"), QStringLiteral("FF")+fill->bgColor.name().mid(1)); |
|
|
|
} |
|
|
|
|
|
|
|
writer.writeEndElement();//patternFill
|
|
|
@ -322,29 +327,29 @@ void Styles::writeFill(XmlStreamWriter &writer, Format *format) |
|
|
|
void Styles::writeBorders(XmlStreamWriter &writer) |
|
|
|
{ |
|
|
|
writer.writeStartElement(QStringLiteral("borders")); |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_borders_count)); |
|
|
|
foreach (Format *format, m_xf_formats) { |
|
|
|
if (format->hasBorders()) { |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_bordersList.count())); |
|
|
|
for (int i=0; i<m_bordersList.size(); ++i) { |
|
|
|
QSharedPointer<BorderData> border = m_bordersList[i]; |
|
|
|
|
|
|
|
writer.writeStartElement(QStringLiteral("border")); |
|
|
|
if (format->diagonalBorderType() == Format::DiagonalBorderUp) { |
|
|
|
if (border->diagonalType == Format::DiagonalBorderUp) { |
|
|
|
writer.writeAttribute(QStringLiteral("diagonalUp"), QStringLiteral("1")); |
|
|
|
} else if (format->diagonalBorderType() == Format::DiagonalBorderDown) { |
|
|
|
} else if (border->diagonalType == Format::DiagonalBorderDown) { |
|
|
|
writer.writeAttribute(QStringLiteral("diagonalDown"), QStringLiteral("1")); |
|
|
|
} else if (format->DiagnoalBorderBoth) { |
|
|
|
} else if (border->diagonalType == Format::DiagnoalBorderBoth) { |
|
|
|
writer.writeAttribute(QStringLiteral("diagonalUp"), QStringLiteral("1")); |
|
|
|
writer.writeAttribute(QStringLiteral("diagonalDown"), QStringLiteral("1")); |
|
|
|
} |
|
|
|
writeSubBorder(writer, QStringLiteral("left"), format->leftBorderStyle(), format->leftBorderColor()); |
|
|
|
writeSubBorder(writer, QStringLiteral("right"), format->rightBorderStyle(), format->rightBorderColor()); |
|
|
|
writeSubBorder(writer, QStringLiteral("top"), format->topBorderStyle(), format->topBorderColor()); |
|
|
|
writeSubBorder(writer, QStringLiteral("bottom"), format->bottomBorderStyle(), format->bottomBorderColor()); |
|
|
|
writeSubBorder(writer, QStringLiteral("left"), border->left, border->leftColor); |
|
|
|
writeSubBorder(writer, QStringLiteral("right"), border->right, border->rightColor); |
|
|
|
writeSubBorder(writer, QStringLiteral("top"), border->top, border->topColor); |
|
|
|
writeSubBorder(writer, QStringLiteral("bottom"), border->bottom, border->bottomColor); |
|
|
|
|
|
|
|
if (!format->isDxfFormat()) { |
|
|
|
writeSubBorder(writer, QStringLiteral("diagonal"), format->diagonalBorderStyle(), format->diagonalBorderColor()); |
|
|
|
} |
|
|
|
// if (!format->isDxfFormat()) {
|
|
|
|
writeSubBorder(writer, QStringLiteral("diagonal"), border->diagonal, border->diagonalColor); |
|
|
|
// }
|
|
|
|
writer.writeEndElement();//border
|
|
|
|
} |
|
|
|
} |
|
|
|
writer.writeEndElement();//borders
|
|
|
|
} |
|
|
|
|
|
|
@ -386,8 +391,8 @@ void Styles::writeSubBorder(XmlStreamWriter &writer, const QString &type, int st |
|
|
|
void Styles::writeCellXfs(XmlStreamWriter &writer) |
|
|
|
{ |
|
|
|
writer.writeStartElement(QStringLiteral("cellXfs")); |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_xf_formats.size())); |
|
|
|
foreach (Format *format, m_xf_formats) { |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_xf_formatsList.size())); |
|
|
|
foreach (Format *format, m_xf_formatsList) { |
|
|
|
int num_fmt_id = format->numberFormat(); |
|
|
|
int font_id = format->fontIndex(); |
|
|
|
int fill_id = format->fillIndex(); |
|
|
@ -436,12 +441,27 @@ void Styles::writeCellXfs(XmlStreamWriter &writer) |
|
|
|
void Styles::writeDxfs(XmlStreamWriter &writer) |
|
|
|
{ |
|
|
|
writer.writeStartElement(QStringLiteral("dxfs")); |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_dxf_formats.size())); |
|
|
|
foreach (Format *format, m_dxf_formats) { |
|
|
|
writer.writeAttribute(QStringLiteral("count"), QString::number(m_dxf_formatsList.size())); |
|
|
|
foreach (Format *format, m_dxf_formatsList) { |
|
|
|
writer.writeStartElement(QStringLiteral("dxf")); |
|
|
|
writer.writeEndElement();//dxf
|
|
|
|
} |
|
|
|
writer.writeEndElement(); //dxfs
|
|
|
|
} |
|
|
|
|
|
|
|
QSharedPointer<Styles> Styles::loadFromXmlFile(QIODevice *device) |
|
|
|
{ |
|
|
|
|
|
|
|
return QSharedPointer<Styles>(new Styles); |
|
|
|
} |
|
|
|
|
|
|
|
QSharedPointer<Styles> Styles::loadFromXmlData(const QByteArray &data) |
|
|
|
{ |
|
|
|
QBuffer buffer; |
|
|
|
buffer.setData(data); |
|
|
|
buffer.open(QIODevice::ReadOnly); |
|
|
|
|
|
|
|
return loadFromXmlFile(&buffer); |
|
|
|
} |
|
|
|
|
|
|
|
} //namespace QXlsx
|
|
|
|