1
0
mirror of https://github.com/QtExcel/QXlsx.git synced 2025-01-30 05:02:52 +08:00

Clang-tidy fixes

This commit is contained in:
Daniel Nicoletti 2024-12-30 12:10:20 -03:00 committed by Daniel Nicoletti
parent fda6b806e2
commit d5af39d46d
9 changed files with 21 additions and 38 deletions

View File

@ -20,9 +20,7 @@ AbstractOOXmlFilePrivate::AbstractOOXmlFilePrivate(
AbstractOOXmlFilePrivate::~AbstractOOXmlFilePrivate()
{
if (relationships) {
delete relationships;
}
delete relationships;
}
/*!

View File

@ -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"));

View File

@ -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);
}
}

View File

@ -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

View File

@ -196,7 +196,10 @@ Format::Format(const Format &other)
*/
Format &Format::operator=(const Format &other)
{
d = other.d;
if (this != &other) // Self-assignment check [cert-oop54-cpp]
{
this->d = other.d;
}
return *this;
}

View File

@ -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<RichStringPrivate *>(this);
auto rs = const_cast<RichStringPrivate *>(this);
QByteArray bytes;
if (fragmentTexts.size() == 1) {
bytes = fragmentTexts[0].toUtf8();

View File

@ -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);
}
@ -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);

View File

@ -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"));

View File

@ -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());