From 658670e9b007c38f701750864acd31d47940bd90 Mon Sep 17 00:00:00 2001 From: Daniel Nicoletti Date: Mon, 30 Dec 2024 12:10:20 -0300 Subject: [PATCH] Clang-fixes --- QXlsx/source/xlsxchart.cpp | 3 +-- QXlsx/source/xlsxdrawing.cpp | 6 +++--- QXlsx/source/xlsxdrawinganchor.cpp | 8 -------- QXlsx/source/xlsxrichstring.cpp | 17 ++++++++--------- QXlsx/source/xlsxsharedstrings.cpp | 5 +++-- QXlsx/source/xlsxworkbook.cpp | 2 +- QXlsx/source/xlsxworksheet.cpp | 9 --------- 7 files changed, 16 insertions(+), 34 deletions(-) diff --git a/QXlsx/source/xlsxchart.cpp b/QXlsx/source/xlsxchart.cpp index 7bb3391c..b5ae1599 100644 --- a/QXlsx/source/xlsxchart.cpp +++ b/QXlsx/source/xlsxchart.cpp @@ -1076,8 +1076,7 @@ void ChartPrivate::saveXmlScatterChart(QXmlStreamWriter &writer) const XlsxAxis::T_Val, XlsxAxis::Left, 1, 0, axisNames[XlsxAxis::Left])); } - int axisListSize = axisList.size(); - Q_ASSERT(axisListSize == 2); + Q_ASSERT(axisList.size() == 2); for (int i = 0; i < axisList.size(); ++i) { writer.writeEmptyElement(QStringLiteral("c:axId")); diff --git a/QXlsx/source/xlsxdrawing.cpp b/QXlsx/source/xlsxdrawing.cpp index 56199e34..8fdf2086 100644 --- a/QXlsx/source/xlsxdrawing.cpp +++ b/QXlsx/source/xlsxdrawing.cpp @@ -63,15 +63,15 @@ bool Drawing::loadFromXmlFile(QIODevice *device) if (reader.tokenType() == QXmlStreamReader::StartElement) { if (reader.name() == QLatin1String("absoluteAnchor")) // CT_AbsoluteAnchor { - DrawingAbsoluteAnchor *anchor = new DrawingAbsoluteAnchor(this); + auto *anchor = new DrawingAbsoluteAnchor(this); anchor->loadFromXml(reader); } else if (reader.name() == QLatin1String("oneCellAnchor")) // CT_OneCellAnchor { - DrawingOneCellAnchor *anchor = new DrawingOneCellAnchor(this); + auto *anchor = new DrawingOneCellAnchor(this); anchor->loadFromXml(reader); } else if (reader.name() == QLatin1String("twoCellAnchor")) // CT_TwoCellAnchor { - DrawingTwoCellAnchor *anchor = new DrawingTwoCellAnchor(this); + auto *anchor = new DrawingTwoCellAnchor(this); anchor->loadFromXml(reader); } } diff --git a/QXlsx/source/xlsxdrawinganchor.cpp b/QXlsx/source/xlsxdrawinganchor.cpp index 30f294da..4dc3de4e 100644 --- a/QXlsx/source/xlsxdrawinganchor.cpp +++ b/QXlsx/source/xlsxdrawinganchor.cpp @@ -323,8 +323,6 @@ void DrawingAnchor::loadXmlObjectConnectionShape(QXmlStreamReader &reader) break; } } - - return; } void DrawingAnchor::loadXmlObjectGraphicFrame(QXmlStreamReader &reader) @@ -362,8 +360,6 @@ void DrawingAnchor::loadXmlObjectGraphicFrame(QXmlStreamReader &reader) break; } } - - return; } void DrawingAnchor::loadXmlObjectGroupShape(QXmlStreamReader &reader) @@ -404,8 +400,6 @@ void DrawingAnchor::loadXmlObjectPicture(QXmlStreamReader &reader) break; } } - - return; } void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader) @@ -600,8 +594,6 @@ void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader) } //*/ - - return; } void DrawingAnchor::saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const diff --git a/QXlsx/source/xlsxrichstring.cpp b/QXlsx/source/xlsxrichstring.cpp index d019aaeb..3f1ef21a 100644 --- a/QXlsx/source/xlsxrichstring.cpp +++ b/QXlsx/source/xlsxrichstring.cpp @@ -72,7 +72,10 @@ RichString::~RichString() */ RichString &RichString::operator=(const RichString &other) { - this->d = other.d; + if (this != &other) // Self-assignment check [cert-oop54-cpp] + { + this->d = other.d; + } return *this; } @@ -105,7 +108,7 @@ bool RichString::isRichString() const */ bool RichString::isNull() const { - return d->fragmentTexts.size() == 0; + return d->fragmentTexts.isEmpty(); } /*! @@ -113,12 +116,8 @@ bool RichString::isNull() const */ bool RichString::isEmtpy() const { - for (const auto &str : d->fragmentTexts) { - if (!str.isEmpty()) - return false; - } - - return true; + return std::all_of(d->fragmentTexts.begin(), d->fragmentTexts.end(), + [](const QString &str) { return str.isEmpty(); }); } /*! @@ -210,7 +209,7 @@ Format RichString::fragmentFormat(int index) const QByteArray RichStringPrivate::idKey() const { if (_dirty) { - RichStringPrivate *rs = const_cast(this); + auto rs = const_cast(this); QByteArray bytes; if (fragmentTexts.size() == 1) { bytes = fragmentTexts[0].toUtf8(); diff --git a/QXlsx/source/xlsxsharedstrings.cpp b/QXlsx/source/xlsxsharedstrings.cpp index 476ede28..dd087af0 100644 --- a/QXlsx/source/xlsxsharedstrings.cpp +++ b/QXlsx/source/xlsxsharedstrings.cpp @@ -169,7 +169,7 @@ void SharedStrings::writeRichStringPart_rPr(QXmlStreamWriter &writer, const Form } if (format.hasProperty(FormatPrivate::P_Font_Color)) { - XlsxColor color = format.property(FormatPrivate::P_Font_Color).value(); + auto color = format.property(FormatPrivate::P_Font_Color).value(); color.saveToXml(writer); } @@ -369,7 +369,8 @@ bool SharedStrings::loadFromXmlFile(QIODevice *device) if (token == QXmlStreamReader::StartElement) { if (reader.name() == QLatin1String("sst")) { QXmlStreamAttributes attributes = reader.attributes(); - if ((hasUniqueCountAttr = attributes.hasAttribute(QLatin1String("uniqueCount")))) + hasUniqueCountAttr = attributes.hasAttribute(QLatin1String("uniqueCount")); + if (hasUniqueCountAttr) count = attributes.value(QLatin1String("uniqueCount")).toInt(); } else if (reader.name() == QLatin1String("si")) { readString(reader); diff --git a/QXlsx/source/xlsxworkbook.cpp b/QXlsx/source/xlsxworkbook.cpp index 39a0981f..c8953a6a 100644 --- a/QXlsx/source/xlsxworkbook.cpp +++ b/QXlsx/source/xlsxworkbook.cpp @@ -514,7 +514,7 @@ void Workbook::saveToXmlFile(QIODevice *device) const } writer.writeEndElement(); // sheets - if (d->externalLinks.size() > 0) { + if (!d->externalLinks.isEmpty()) { writer.writeStartElement(QStringLiteral("externalReferences")); for (int i = 0; i < d->externalLinks.size(); ++i) { writer.writeEmptyElement(QStringLiteral("externalReference")); diff --git a/QXlsx/source/xlsxworksheet.cpp b/QXlsx/source/xlsxworksheet.cpp index ca3e8197..b3b2e8ba 100644 --- a/QXlsx/source/xlsxworksheet.cpp +++ b/QXlsx/source/xlsxworksheet.cpp @@ -1654,15 +1654,6 @@ void WorksheetPrivate::saveXmlCellData(QXmlStreamWriter &writer, cell->value().toBool() ? QStringLiteral("1") : QStringLiteral("0")); } else if (cell->cellType() == Cell::DateType) // 'd' { - // dev67 - - double num = cell->value().toDouble(); - bool is1904 = q->workbook()->isDate1904(); - if (!is1904 && num > 60) // for mac os excel - { - num = num - 1; - } - // number type. see for 18.18.11 ST_CellType (Cell Type) more information. writer.writeAttribute(QStringLiteral("t"), QStringLiteral("n")); writer.writeTextElement(QStringLiteral("v"), cell->value().toString());