Skip to content

Commit

Permalink
Clang-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dantti committed Dec 30, 2024
1 parent fda6b80 commit 658670e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 34 deletions.
3 changes: 1 addition & 2 deletions QXlsx/source/xlsxchart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
6 changes: 3 additions & 3 deletions QXlsx/source/xlsxdrawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
8 changes: 0 additions & 8 deletions QXlsx/source/xlsxdrawinganchor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ void DrawingAnchor::loadXmlObjectConnectionShape(QXmlStreamReader &reader)
break;
}
}

return;
}

void DrawingAnchor::loadXmlObjectGraphicFrame(QXmlStreamReader &reader)
Expand Down Expand Up @@ -362,8 +360,6 @@ void DrawingAnchor::loadXmlObjectGraphicFrame(QXmlStreamReader &reader)
break;
}
}

return;
}

void DrawingAnchor::loadXmlObjectGroupShape(QXmlStreamReader &reader)
Expand Down Expand Up @@ -404,8 +400,6 @@ void DrawingAnchor::loadXmlObjectPicture(QXmlStreamReader &reader)
break;
}
}

return;
}

void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader)
Expand Down Expand Up @@ -600,8 +594,6 @@ void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader)
}
//*/

return;
}

void DrawingAnchor::saveXmlPos(QXmlStreamWriter &writer, const QPoint &pos) const
Expand Down
17 changes: 8 additions & 9 deletions QXlsx/source/xlsxrichstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -105,20 +108,16 @@ bool RichString::isRichString() const
*/
bool RichString::isNull() const
{
return d->fragmentTexts.size() == 0;
return d->fragmentTexts.isEmpty();
}

/*!
Returns true is this is an empty string.
*/
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(); });
}

/*!
Expand Down Expand Up @@ -210,7 +209,7 @@ Format RichString::fragmentFormat(int index) const
QByteArray RichStringPrivate::idKey() const
{
if (_dirty) {
RichStringPrivate *rs = const_cast<RichStringPrivate *>(this);
auto rs = const_cast<RichStringPrivate *>(this);
QByteArray bytes;
if (fragmentTexts.size() == 1) {
bytes = fragmentTexts[0].toUtf8();
Expand Down
5 changes: 3 additions & 2 deletions QXlsx/source/xlsxsharedstrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<XlsxColor>();
auto color = format.property(FormatPrivate::P_Font_Color).value<XlsxColor>();
color.saveToXml(writer);
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion QXlsx/source/xlsxworkbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
9 changes: 0 additions & 9 deletions QXlsx/source/xlsxworksheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 658670e

Please sign in to comment.