From f05656e19bd91b9f2526a168c0532e0425916a64 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 17:48:03 +0300 Subject: [PATCH 01/40] Add the Cppcheck file extension --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3be43cf..2c4af03 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,5 @@ lib/* *.idb *.ncb *.suo + +*.cppcheck From 33327d79ae45f57dc0d46fc6ec0e72a062ddf349 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 20:01:06 +0300 Subject: [PATCH 02/40] Add Cppcheck folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2c4af03..7ca0e1c 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ lib/* *.suo *.cppcheck +/*-cppcheck-build-dir From aaaea07f2156f35f8684b29d86670672bbb156cf Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 20:03:03 +0300 Subject: [PATCH 03/40] Fix error: using typedef-name after 'class' using typedef-name 'using QStringList = class QList' after 'class' --- src/officeopenxml/opc/opcutils_p.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/officeopenxml/opc/opcutils_p.h b/src/officeopenxml/opc/opcutils_p.h index 0e79633..ca6563f 100644 --- a/src/officeopenxml/opc/opcutils_p.h +++ b/src/officeopenxml/opc/opcutils_p.h @@ -37,8 +37,9 @@ #include -class QString; -class QStringList; +#include +#include + namespace QtOfficeOpenXml { namespace Opc { From e3aec4e38f6bb5d2e0342bfa30e004f95d9064de Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 20:05:23 +0300 Subject: [PATCH 04/40] Fix error: invalid conversion from 'int' to 'const char*' ref: https://github.com/dbzhang800/QtOfficeOpenXml/issues/4 --- src/officeopenxml/sml/smlworkbook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/officeopenxml/sml/smlworkbook.cpp b/src/officeopenxml/sml/smlworkbook.cpp index dfa8e13..dccc415 100644 --- a/src/officeopenxml/sml/smlworkbook.cpp +++ b/src/officeopenxml/sml/smlworkbook.cpp @@ -37,7 +37,7 @@ QString Workbook::bookView(const QString &attribute) const return QString(); if (!bookViews_raw[0].contains(attribute)) return QString(); - return bookViews_raw[0][attribute].toInt(); + return QString::fromStdString(bookViews_raw[0][attribute].toStdString()); } void Workbook::setBookView(const QString &attribute, const QString &val) From 9c0ad4e634f850d49d69e2482d7af94e70b61b7c Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 21:32:07 +0300 Subject: [PATCH 05/40] Port QStringRef (deprecated) to QStringView --- src/officeopenxml/mce/mcexmlstreamreader.cpp | 48 +++++++++++++++++++ src/officeopenxml/mce/mcexmlstreamreader.h | 18 +++++-- .../opc/opcpartbasedpackageproperties.cpp | 4 ++ 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/officeopenxml/mce/mcexmlstreamreader.cpp b/src/officeopenxml/mce/mcexmlstreamreader.cpp index 2a84344..49f384b 100644 --- a/src/officeopenxml/mce/mcexmlstreamreader.cpp +++ b/src/officeopenxml/mce/mcexmlstreamreader.cpp @@ -455,7 +455,11 @@ QXmlStreamReader::TokenType XmlStreamReader::readNext() //Figure out whether this element's requires is satisfied. bool ok = true; +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + QStringView nsPrefixString = d->reader->attributes().value(QLatin1String("Requires")); +#else QStringRef nsPrefixString = d->reader->attributes().value(QLatin1String("Requires")); +#endif if (!nsPrefixString.isEmpty()) { QStringList nsPrefixList = nsPrefixString.toString().split(QRegularExpression(QStringLiteral("[ \\t\\r\\n]+"))); foreach (QString nsPrefix, nsPrefixList) { @@ -593,7 +597,11 @@ QXmlStreamReader::TokenType XmlStreamReaderPrivate::doReadNext_1() if (!nonUnderstoodNamespaces.isEmpty()) { //Find out non-understood and ignorable namespaces. +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + QStringView nsPrefixString = reader->attributes().value(QLatin1String(mcNamespace), QLatin1String("Ignorable")); +#else QStringRef nsPrefixString = reader->attributes().value(QLatin1String(mcNamespace), QLatin1String("Ignorable")); +#endif if (!nsPrefixString.isEmpty()) { QStringList nsPrefixList = nsPrefixString.toString().split(QRegularExpression(QStringLiteral("[ \\t\\r\\n]+"))); foreach (QString nsPrefix, nsPrefixList) { @@ -621,7 +629,11 @@ QXmlStreamReader::TokenType XmlStreamReaderPrivate::doReadNext_1() break; //Deal with ProcessContent attribute. +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + QStringView pcAttribValue = reader->attributes().value(QLatin1String(mcNamespace), QLatin1String("ProcessContent")); +#else QStringRef pcAttribValue = reader->attributes().value(QLatin1String(mcNamespace), QLatin1String("ProcessContent")); +#endif if (!pcAttribValue.isEmpty()) { QStringList pcNameList = pcAttribValue.toString().split(QRegularExpression(QStringLiteral("[ \\t\\r\\n]+"))); foreach (const QString pcName, pcNameList) { @@ -802,7 +814,11 @@ bool XmlStreamReader::isStandaloneDocument() const version string as specified in the XML declaration. Otherwise an empty string is returned. */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::documentVersion() const +#else QStringRef XmlStreamReader::documentVersion() const +#endif { Q_D(const XmlStreamReader); return d->reader->documentVersion(); @@ -812,7 +828,11 @@ QStringRef XmlStreamReader::documentVersion() const encoding string as specified in the XML declaration. Otherwise an empty string is returned. */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::documentEncoding() const +#else QStringRef XmlStreamReader::documentEncoding() const +#endif { Q_D(const XmlStreamReader); return d->reader->documentEncoding(); @@ -919,7 +939,11 @@ QString XmlStreamReader::readElementText(QXmlStreamReader::ReadElementTextBehavi \sa namespaceUri(), qualifiedName() */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::name() const +#else QStringRef XmlStreamReader::name() const +#endif { Q_D(const XmlStreamReader); return d->reader->name(); @@ -930,7 +954,11 @@ QStringRef XmlStreamReader::name() const \sa name(), qualifiedName() */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::namespaceUri() const +#else QStringRef XmlStreamReader::namespaceUri() const +#endif { Q_D(const XmlStreamReader); return d->reader->namespaceUri(); @@ -939,7 +967,11 @@ QStringRef XmlStreamReader::namespaceUri() const /*! Returns the qualified name of a StartElement or EndElement; */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::qualifiedName() const +#else QStringRef XmlStreamReader::qualifiedName() const +#endif { Q_D(const XmlStreamReader); return d->reader->qualifiedName(); @@ -949,7 +981,11 @@ QStringRef XmlStreamReader::qualifiedName() const \sa name(), qualifiedName() */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::prefix() const +#else QStringRef XmlStreamReader::prefix() const +#endif { Q_D(const XmlStreamReader); return d->reader->prefix(); @@ -958,7 +994,11 @@ QStringRef XmlStreamReader::prefix() const /*! Returns the data of a ProcessingInstruction. */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::processingInstructionData() const +#else QStringRef XmlStreamReader::processingInstructionData() const +#endif { Q_D(const XmlStreamReader); return d->reader->processingInstructionData(); @@ -967,7 +1007,11 @@ QStringRef XmlStreamReader::processingInstructionData() const /*! Returns the target of a ProcessingInstruction. */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::processingInstructionTarget() const +#else QStringRef XmlStreamReader::processingInstructionTarget() const +#endif { Q_D(const XmlStreamReader); return d->reader->processingInstructionTarget(); @@ -976,7 +1020,11 @@ QStringRef XmlStreamReader::processingInstructionTarget() const /*! Returns the text of Characters, Comment, DTD, or EntityReference. */ +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) +QStringView XmlStreamReader::text() const +#else QStringRef XmlStreamReader::text() const +#endif { Q_D(const XmlStreamReader); return d->reader->text(); diff --git a/src/officeopenxml/mce/mcexmlstreamreader.h b/src/officeopenxml/mce/mcexmlstreamreader.h index 184a24f..94cba91 100644 --- a/src/officeopenxml/mce/mcexmlstreamreader.h +++ b/src/officeopenxml/mce/mcexmlstreamreader.h @@ -77,9 +77,13 @@ class Q_OFFICEOPENXML_EXPORT XmlStreamReader inline bool isProcessingInstruction() const { return tokenType() == QXmlStreamReader::ProcessingInstruction; } bool isStandaloneDocument() const; +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + QStringView documentVersion() const; + QStringView documentEncoding() const; +#else QStringRef documentVersion() const; QStringRef documentEncoding() const; - +#endif qint64 lineNumber() const; qint64 columnNumber() const; qint64 characterOffset() const; @@ -87,7 +91,15 @@ class Q_OFFICEOPENXML_EXPORT XmlStreamReader QXmlStreamAttributes attributes() const; QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour = QXmlStreamReader::ErrorOnUnexpectedElement); - +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + QStringView name() const; + QStringView namespaceUri() const; + QStringView qualifiedName() const; + QStringView prefix() const; + QStringView processingInstructionTarget() const; + QStringView processingInstructionData() const; + QStringView text() const; +#else QStringRef name() const; QStringRef namespaceUri() const; QStringRef qualifiedName() const; @@ -95,7 +107,7 @@ class Q_OFFICEOPENXML_EXPORT XmlStreamReader QStringRef processingInstructionTarget() const; QStringRef processingInstructionData() const; QStringRef text() const; - +#endif QXmlStreamNamespaceDeclarations namespaceDeclarations() const; void raiseError(const QString& message = QString()); diff --git a/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp b/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp index 9642f46..7acbcb8 100644 --- a/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp +++ b/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp @@ -114,7 +114,11 @@ void PartBasedPackageProperties::doLoadFromXml(QIODevice *device) while (!reader.atEnd()) { if (reader.readNextStartElement()) { +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + const QStringView name = reader.name(); +#else const QStringRef name = reader.name(); +#endif //Todo, "keywords" support lang attribute. for (int idx=0; idx<16; ++idx) { if (name == QLatin1String(propertiesNameTable[idx])) { From b37bb8a042461e5385c3a7486cf66f443ff08c72 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 21:38:45 +0300 Subject: [PATCH 06/40] Add QVectorIterator class declaration --- src/officeopenxml/mce/mcexmlstreamreader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/officeopenxml/mce/mcexmlstreamreader.cpp b/src/officeopenxml/mce/mcexmlstreamreader.cpp index 49f384b..a00ef33 100644 --- a/src/officeopenxml/mce/mcexmlstreamreader.cpp +++ b/src/officeopenxml/mce/mcexmlstreamreader.cpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace QtOfficeOpenXml { namespace Mce { From f6c17c987747251648421537bb333614577b4f0e Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 22:45:59 +0300 Subject: [PATCH 07/40] Port QFileInfo::created() (deprecated) to QFileInfo::birthTime() --- src/3rdParty/karchive/src/karchive.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/3rdParty/karchive/src/karchive.cpp b/src/3rdParty/karchive/src/karchive.cpp index 1b3371b..10b4502 100644 --- a/src/3rdParty/karchive/src/karchive.cpp +++ b/src/3rdParty/karchive/src/karchive.cpp @@ -234,9 +234,15 @@ bool KArchive::addLocalFile(const QString &fileName, const QString &destName) if (symLinkTarget.isEmpty()) { // Mac or Windows symLinkTarget = fileInfo.symLinkTarget(); } + QDateTime fileWasCreated; +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + fileWasCreated = fileInfo.birthTime(); +#else + fileWasCreated = fileInfo.created(); +#endif return writeSymLink(destName, symLinkTarget, fileInfo.owner(), fileInfo.group(), fi.st_mode, fileInfo.lastRead(), fileInfo.lastModified(), - fileInfo.created()); + fileWasCreated); }/*end if*/ qint64 size = fileInfo.size(); @@ -249,9 +255,14 @@ bool KArchive::addLocalFile(const QString &fileName, const QString &destName) //qWarning() << "couldn't open file " << fileName; return false; } - + QDateTime fileWasCreated; +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + fileWasCreated = fileInfo.birthTime(); +#else + fileWasCreated = fileInfo.created(); +#endif if (!prepareWriting(destName, fileInfo.owner(), fileInfo.group(), size, - fi.st_mode, fileInfo.lastRead(), fileInfo.lastModified(), fileInfo.created())) { + fi.st_mode, fileInfo.lastRead(), fileInfo.lastModified(), fileWasCreated)) { //qWarning() << " prepareWriting" << destName << "failed"; return false; } From 3542e3aada27e294a39be8ee7e8f9c39925840d6 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 22:48:24 +0300 Subject: [PATCH 08/40] Port qSort() (deprecated) to std::sort() --- src/3rdParty/karchive/src/karchive.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/3rdParty/karchive/src/karchive.cpp b/src/3rdParty/karchive/src/karchive.cpp index 10b4502..b395e38 100644 --- a/src/3rdParty/karchive/src/karchive.cpp +++ b/src/3rdParty/karchive/src/karchive.cpp @@ -885,9 +885,11 @@ bool KArchiveDirectory::copyTo(const QString &dest, bool recursiveCopy) const } } } while (!dirStack.isEmpty()); - +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + std::sort(fileList.begin(), fileList.end(), sortByPosition); // sort on d->pos, so we have a linear access +#else qSort(fileList.begin(), fileList.end(), sortByPosition); // sort on d->pos, so we have a linear access - +#endif for (QList::const_iterator it = fileList.constBegin(), end = fileList.constEnd(); it != end; ++it) { const KArchiveFile *f = *it; From 51a58882503dd5e97c41c8f1b1f751562d5aea81 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 23:17:46 +0300 Subject: [PATCH 09/40] Port QDateTime::toTime_t() (deprecated) to QDateTime::toSecsSinceEpoch() --- src/3rdParty/karchive/src/kzip.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/3rdParty/karchive/src/kzip.cpp b/src/3rdParty/karchive/src/kzip.cpp index c2d0d31..911465d 100644 --- a/src/3rdParty/karchive/src/kzip.cpp +++ b/src/3rdParty/karchive/src/kzip.cpp @@ -76,7 +76,13 @@ static uint transformFromMsDos(const char *buffer) QDate qd(y, o, d); QDateTime dt(qd, qt); - return dt.toTime_t(); + uint retVal; +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + retVal = dt.toSecsSinceEpoch(); +#else + retVal = dt.toTime_t() +#endif + return retVal; } // == parsing routines for zip headers @@ -930,7 +936,11 @@ bool KZip::closeArchive() extfield[4] = 1 | 2 | 4; // specify flags from local field // (unless I misread the spec) // provide only modification time +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + unsigned long time = (unsigned long)it.value()->date().toSecsSinceEpoch(); +#else unsigned long time = (unsigned long)it.value()->date().toTime_t(); +#endif extfield[5] = char(time); extfield[6] = char(time >> 8); extfield[7] = char(time >> 16); @@ -1032,9 +1042,15 @@ bool KZip::doPrepareWriting(const QString &name, const QString &user, return false; } +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + uint atime = accessTime.toSecsSinceEpoch(); + uint mtime = modificationTime.toSecsSinceEpoch(); + uint ctime = creationTime.toSecsSinceEpoch(); +#else uint atime = accessTime.toTime_t(); uint mtime = modificationTime.toTime_t(); uint ctime = creationTime.toTime_t(); +#endif // Find or create parent dir KArchiveDirectory *parentDir = rootDir(); From a0b689d4f9655daa629fd90ddbb44d87d54fd49c Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Thu, 15 Jun 2023 23:40:32 +0300 Subject: [PATCH 10/40] Port QDateTime::fromTime_t() (deprecated) Port QDateTime::fromTime_t() (deprecated) to QDateTime::fromSecsSinceEpoch(time_t) --- src/3rdParty/karchive/src/karchive.cpp | 8 +++++++- src/3rdParty/karchive/src/kzip.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/3rdParty/karchive/src/karchive.cpp b/src/3rdParty/karchive/src/karchive.cpp index b395e38..e494639 100644 --- a/src/3rdParty/karchive/src/karchive.cpp +++ b/src/3rdParty/karchive/src/karchive.cpp @@ -526,7 +526,13 @@ QDateTime KArchivePrivate::time_tToDateTime(uint time_t) if (time_t == uint(-1)) { return QDateTime(); } - return QDateTime::fromTime_t(time_t); + QDateTime retVal; +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + retVal = QDateTime::fromSecsSinceEpoch(time_t); +#else + retVal = QDateTime::fromTime_t(time_t); +#endif + return retVal; } //////////////////////////////////////////////////////////////////////// diff --git a/src/3rdParty/karchive/src/kzip.cpp b/src/3rdParty/karchive/src/kzip.cpp index 911465d..a9bc54e 100644 --- a/src/3rdParty/karchive/src/kzip.cpp +++ b/src/3rdParty/karchive/src/kzip.cpp @@ -937,7 +937,7 @@ bool KZip::closeArchive() // (unless I misread the spec) // provide only modification time #if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) - unsigned long time = (unsigned long)it.value()->date().toSecsSinceEpoch(); + unsigned long time = static_cast(it.value()->date().toSecsSinceEpoch()); // Convert 64 to 32 bits! #else unsigned long time = (unsigned long)it.value()->date().toTime_t(); #endif From 1b2b6add6ab88f9acf8785302b41f1fc5bb5f5fa Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 00:02:33 +0300 Subject: [PATCH 11/40] Port Qt enum values (deprecated) to QLocale enum values --- src/officeopenxml/opc/opcpartbasedpackageproperties.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp b/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp index 7acbcb8..c30b33f 100644 --- a/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp +++ b/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp @@ -203,10 +203,18 @@ QDateTime PartBasedPackageProperties::dateTimeProperty(PropertyEnum pe) const dt = QDateTime::fromString(dt_string, Qt::TextDate); if (dt.isNull()) dt = QDateTime::fromString(dt_string, Qt::RFC2822Date); +#if (QT_VERSION >= QT_VERSION_CHECK(5,13,0)) + QLocale ql; + if (dt.isNull()) + dt = ql.toDateTime(dt_string, QLocale::LongFormat); + if (dt.isNull()) + dt = ql.toDateTime(dt_string, QLocale::ShortFormat); +#else if (dt.isNull()) dt = QDateTime::fromString(dt_string, Qt::SystemLocaleLongDate); if (dt.isNull()) dt = QDateTime::fromString(dt_string, Qt::SystemLocaleShortDate); +#endif return dt; } From d03b5874d3210835c1b52e2eac60e48d10ffbf4c Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 11:25:18 +0300 Subject: [PATCH 12/40] CWE: 398. Missing member copy Member variable 'MceXmlElementStateData::extensionElements' is not assigned in the copy constructor. Member variable 'MceXmlElementStateData::namespacePrefixes' is not assigned in the copy constructor. --- src/officeopenxml/mce/mcexmlstreamreader_p.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/officeopenxml/mce/mcexmlstreamreader_p.h b/src/officeopenxml/mce/mcexmlstreamreader_p.h index d1be8e9..11e2b0d 100644 --- a/src/officeopenxml/mce/mcexmlstreamreader_p.h +++ b/src/officeopenxml/mce/mcexmlstreamreader_p.h @@ -89,6 +89,8 @@ class MceXmlElementStateData : public QSharedData MceXmlElementStateData(const MceXmlElementStateData &other) :QSharedData(other), ignorableNamespaces(other.ignorableNamespaces) , processContentNeededElements(other.processContentNeededElements) + , extensionElements(other.extensionElements) + , namespacePrefixes(other.namespacePrefixes) {} ~MceXmlElementStateData(){} From b5fe0bc30b69818b7e9c442480ae3f30e29cfd9d Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 11:36:18 +0300 Subject: [PATCH 13/40] CWE: 398. Parameter passed By Value Parameter 'transitional' is passed by value. --- src/officeopenxml/ooxml/ooxmlschames_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/officeopenxml/ooxml/ooxmlschames_p.h b/src/officeopenxml/ooxml/ooxmlschames_p.h index 3eaa410..bea9ce1 100644 --- a/src/officeopenxml/ooxml/ooxmlschames_p.h +++ b/src/officeopenxml/ooxml/ooxmlschames_p.h @@ -44,7 +44,7 @@ namespace Ooxml { struct OoxmlSchamesData { - OoxmlSchamesData(int id, const QString transitional, const QString &strict=QString(), const QString &prefix=QString()) : + OoxmlSchamesData(int id, const QString &transitional, const QString &strict=QString(), const QString &prefix=QString()) : id(id), prefix(prefix), strict(strict), transitional(transitional) {} From 26d0a2ee4de1400d9bd421ec5a08ab86bd6e0fb5 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 11:42:48 +0300 Subject: [PATCH 14/40] CWE: 398. Parameter passed by value Parameter 'type' is passed by value. --- src/officeopenxml/opc/opcpackagepart.cpp | 2 +- src/officeopenxml/opc/opcpackagepart_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/officeopenxml/opc/opcpackagepart.cpp b/src/officeopenxml/opc/opcpackagepart.cpp index 12981d9..2cda877 100644 --- a/src/officeopenxml/opc/opcpackagepart.cpp +++ b/src/officeopenxml/opc/opcpackagepart.cpp @@ -36,7 +36,7 @@ namespace Opc { * \internal */ -PackagePartPrivate::PackagePartPrivate(const QString &partName, const QString type, PackagePart *q, Package *package) +PackagePartPrivate::PackagePartPrivate(const QString &partName, const QString &type, PackagePart *q, Package *package) :q_ptr(q), package(package), partName(partName), contentType(type), relationshipHelper(0) { diff --git a/src/officeopenxml/opc/opcpackagepart_p.h b/src/officeopenxml/opc/opcpackagepart_p.h index 69109ad..c11ed6c 100644 --- a/src/officeopenxml/opc/opcpackagepart_p.h +++ b/src/officeopenxml/opc/opcpackagepart_p.h @@ -46,7 +46,7 @@ class OFFICEOPENXML_AUTOTEST_EXPORT PackagePartPrivate Q_DECLARE_PUBLIC(PackagePart) public: - PackagePartPrivate(const QString &partName, const QString type, PackagePart *q, Package *package); + PackagePartPrivate(const QString &partName, const QString &type, PackagePart *q, Package *package); virtual ~PackagePartPrivate(); void ensureRelationship() const; bool isRelationshipPart() const; From e12b0e2433545bb9e1522ad22ea3847ae353fe22 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 11:51:26 +0300 Subject: [PATCH 15/40] CWE: 398. Uninit member var Member variable 'XmlStreamReaderPrivate::extensionElementDepth' is not initialized in the constructor. --- src/officeopenxml/mce/mcexmlstreamreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/officeopenxml/mce/mcexmlstreamreader.cpp b/src/officeopenxml/mce/mcexmlstreamreader.cpp index a00ef33..bd9c19a 100644 --- a/src/officeopenxml/mce/mcexmlstreamreader.cpp +++ b/src/officeopenxml/mce/mcexmlstreamreader.cpp @@ -182,7 +182,7 @@ void MceXmlElementState::addNamespacePrefix(const QString &prefix, const QString } XmlStreamReaderPrivate::XmlStreamReaderPrivate(QXmlStreamReader *reader, XmlStreamReader *q): - mceParseFlags(0), hasFoundRootElement(false), reader(reader), q_ptr(q) + mceParseFlags(0), extensionElementDepth(0), hasFoundRootElement(false), reader(reader), q_ptr(q) { } From 53a6585f446e3207678c2d3f5caa0acae5987028 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 12:03:03 +0300 Subject: [PATCH 16/40] CWE: 398. Parameter passed by value Parameter 'type' is passed by value. --- src/officeopenxml/opc/opczippackagepart.cpp | 2 +- src/officeopenxml/opc/opczippackagepart_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/officeopenxml/opc/opczippackagepart.cpp b/src/officeopenxml/opc/opczippackagepart.cpp index 4f91832..e02017e 100644 --- a/src/officeopenxml/opc/opczippackagepart.cpp +++ b/src/officeopenxml/opc/opczippackagepart.cpp @@ -38,7 +38,7 @@ namespace Opc { * \class QtOfficeOpenXml::Opc::ZipPackagePartPrivate * \internal */ -ZipPackagePartPrivate::ZipPackagePartPrivate(const QString &partName, const QString type, PackagePart *q, Package *package) +ZipPackagePartPrivate::ZipPackagePartPrivate(const QString &partName, const QString &type, PackagePart *q, Package *package) :PackagePartPrivate(partName, type, q, package), zipFileEntry(0), device(0) { } diff --git a/src/officeopenxml/opc/opczippackagepart_p.h b/src/officeopenxml/opc/opczippackagepart_p.h index 98ab85a..414a476 100644 --- a/src/officeopenxml/opc/opczippackagepart_p.h +++ b/src/officeopenxml/opc/opczippackagepart_p.h @@ -48,7 +48,7 @@ namespace Opc { class ZipPackagePartPrivate : public PackagePartPrivate { public: - ZipPackagePartPrivate(const QString &partName, const QString type, PackagePart *q, Package *package); + ZipPackagePartPrivate(const QString &partName, const QString &type, PackagePart *q, Package *package); KZip *zipArchive; const KZipFileEntry *zipFileEntry; From 6191f3b38793a0f7719ddb8d1956e9748d41b2bd Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 12:08:22 +0300 Subject: [PATCH 17/40] CWE: 398. Uninit member var Member variable 'LargeDocumentWriterPrivate::package' is not initialized in the constructor. --- src/officeopenxml/sml/smllargedocumentwriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/officeopenxml/sml/smllargedocumentwriter.cpp b/src/officeopenxml/sml/smllargedocumentwriter.cpp index d8296bd..ef90190 100644 --- a/src/officeopenxml/sml/smllargedocumentwriter.cpp +++ b/src/officeopenxml/sml/smllargedocumentwriter.cpp @@ -30,7 +30,7 @@ namespace QtOfficeOpenXml { namespace Sml { LargeDocumentWriterPrivate::LargeDocumentWriterPrivate(LargeDocumentWriter *q) : - isClosed(false), ooxmlSchameType(Ooxml::TransitionalSchame), + isClosed(false), ooxmlSchameType(Ooxml::TransitionalSchame), package(nullptr), q_ptr(q) { } From 6f3f5ca815227d6bcae62b7361f900ad0faa4f97 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 12:48:36 +0300 Subject: [PATCH 18/40] CWE: 398. Uninit member var Member variable 'ZipPackagePartPrivate::zipArchive' is not initialized in the constructor. --- src/officeopenxml/opc/opczippackagepart.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/officeopenxml/opc/opczippackagepart.cpp b/src/officeopenxml/opc/opczippackagepart.cpp index e02017e..96e17c2 100644 --- a/src/officeopenxml/opc/opczippackagepart.cpp +++ b/src/officeopenxml/opc/opczippackagepart.cpp @@ -39,7 +39,7 @@ namespace Opc { * \internal */ ZipPackagePartPrivate::ZipPackagePartPrivate(const QString &partName, const QString &type, PackagePart *q, Package *package) - :PackagePartPrivate(partName, type, q, package), zipFileEntry(0), device(0) + :PackagePartPrivate(partName, type, q, package), zipArchive(0), zipFileEntry(0), device(0) { } From 1ffca09c4cc931249a2487069d6dd9c1d2ed5be4 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 12:50:23 +0300 Subject: [PATCH 19/40] CWE: 398. Uninit member var Member variable 'LargeDocumentReaderPrivate::package' is not initialized in the constructor. --- src/officeopenxml/sml/smllargedocumentreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/officeopenxml/sml/smllargedocumentreader.cpp b/src/officeopenxml/sml/smllargedocumentreader.cpp index b38be82..5fc861c 100644 --- a/src/officeopenxml/sml/smllargedocumentreader.cpp +++ b/src/officeopenxml/sml/smllargedocumentreader.cpp @@ -32,7 +32,7 @@ namespace QtOfficeOpenXml { namespace Sml { LargeDocumentReaderPrivate::LargeDocumentReaderPrivate(LargeDocumentReader *q) : - ooxmlSchameType(Ooxml::TransitionalSchame), + ooxmlSchameType(Ooxml::TransitionalSchame), package(0), q_ptr(q) { } From 005c76e325987d0171e5108f857d04f2cd02aa3f Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 14:30:22 +0300 Subject: [PATCH 20/40] Fix error: invalid conversion from 'int' to 'QTextDocument::FindFlag' --- examples/officeopenxml/opc_package_viewer/binedit.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.h b/examples/officeopenxml/opc_package_viewer/binedit.h index 1e8698f..92271e4 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.h +++ b/examples/officeopenxml/opc_package_viewer/binedit.h @@ -88,7 +88,7 @@ class BinEdit : public QAbstractScrollArea bool isReadOnly() const; int find(const QByteArray &pattern, int from = 0, - QTextDocument::FindFlags findFlags = 0); + QTextDocument::FindFlags findFlags = QTextDocument::FindFlags()); void selectAll(); void clear(); @@ -110,7 +110,7 @@ class BinEdit : public QAbstractScrollArea public Q_SLOTS: void highlightSearchResults(const QByteArray &pattern, - QTextDocument::FindFlags findFlags = 0); + QTextDocument::FindFlags findFlags = QTextDocument::FindFlags()); void copy(bool raw = false); void setNewWindowRequestAllowed(bool c); From 75bfafd1d8b9a34da325630b04534bd1b1ff878a Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 15:12:07 +0300 Subject: [PATCH 21/40] Port QFontMetrics::width() (obsolete) Port QFontMetrics::width() (obsolete) to QFontMetrics::horizontalAdvance() --- .../opc_package_viewer/binedit.cpp | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.cpp b/examples/officeopenxml/opc_package_viewer/binedit.cpp index d02312f..e717227 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.cpp +++ b/examples/officeopenxml/opc_package_viewer/binedit.cpp @@ -130,19 +130,41 @@ void BinEdit::init() m_descent = fm.descent(); m_ascent = fm.ascent(); m_lineHeight = fm.lineSpacing(); + +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + m_charWidth = fm.horizontalAdvance(QChar(QLatin1Char('M'))); + m_margin = m_charWidth; + m_columnWidth = 2 * m_charWidth + fm.horizontalAdvance(QChar(QLatin1Char(' '))); +#else m_charWidth = fm.width(QChar(QLatin1Char('M'))); m_margin = m_charWidth; m_columnWidth = 2 * m_charWidth + fm.width(QChar(QLatin1Char(' '))); +#endif + m_numLines = m_size / m_bytesPerLine + 1; m_numVisibleLines = viewport()->height() / m_lineHeight; m_textWidth = m_bytesPerLine * m_charWidth + m_charWidth; +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + int m_numberWidth = fm.horizontalAdvance(QChar(QLatin1Char('9'))); +#else int m_numberWidth = fm.width(QChar(QLatin1Char('9'))); +#endif m_labelWidth = 2*m_addressBytes * m_numberWidth + (m_addressBytes - 1)/2 * m_charWidth; int expectedCharWidth = m_columnWidth / 3; const char *hex = "0123456789abcdef"; m_isMonospacedFont = true; + +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + while (*hex) { + if (fm.horizontalAdvance(QLatin1Char(*hex)) != expectedCharWidth) { + m_isMonospacedFont = false; + break; + } + ++hex; + } +#else while (*hex) { if (fm.width(QLatin1Char(*hex)) != expectedCharWidth) { m_isMonospacedFont = false; @@ -150,7 +172,21 @@ void BinEdit::init() } ++hex; } +#endif + + +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + if (m_isMonospacedFont && fm.horizontalAdvance(QLatin1String("M M ")) != m_charWidth * 4) { + // On Qt/Mac, monospace font widths may have a fractional component + // This breaks the assumption that width("MMM") == width('M') * 3 + m_isMonospacedFont = false; + m_columnWidth = fm.horizontalAdvance(QLatin1String("MMM")); + m_labelWidth = m_addressBytes == 4 + ? fm.horizontalAdvance(QLatin1String("MMMM:MMMM")) + : fm.horizontalAdvance(QLatin1String("MMMM:MMMM:MMMM:MMMM")); + } +#else if (m_isMonospacedFont && fm.width(QLatin1String("M M ")) != m_charWidth * 4) { // On Qt/Mac, monospace font widths may have a fractional component // This breaks the assumption that width("MMM") == width('M') * 3 @@ -161,6 +197,7 @@ void BinEdit::init() ? fm.width(QLatin1String("MMMM:MMMM")) : fm.width(QLatin1String("MMMM:MMMM:MMMM:MMMM")); } +#endif horizontalScrollBar()->setRange(0, 2 * m_margin + m_bytesPerLine * m_columnWidth + m_labelWidth + m_textWidth - viewport()->width()); @@ -506,7 +543,11 @@ int BinEdit::posAt(const QPoint &pos) const QChar qc(QLatin1Char(dataAt(dataPos))); if (!qc.isPrint()) qc = 0xB7; +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + x -= fontMetrics().horizontalAdvance(qc); +#else x -= fontMetrics().width(qc); +#endif if (x <= 0) break; } @@ -830,20 +871,36 @@ void BinEdit::paintEvent(QPaintEvent *e) if (color.isValid()) { painter.fillRect(item_x - m_charWidth/2, y-m_ascent, m_columnWidth, m_lineHeight, color); +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth + + fm.horizontalAdvance(printable.left(c)); + painter.fillRect(printable_item_x, y-m_ascent, + fm.horizontalAdvance(printable.at(c)), + m_lineHeight, color); +#else int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth + fm.width(printable.left(c)); painter.fillRect(printable_item_x, y-m_ascent, fm.width(printable.at(c)), m_lineHeight, color); +#endif } if (!isFullySelected && pos >= selStart && pos <= selEnd) { selectionRect |= QRect(item_x - m_charWidth/2, y-m_ascent, m_columnWidth, m_lineHeight); +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth + + fm.horizontalAdvance(printable.left(c)); + printableSelectionRect |= QRect(printable_item_x, y-m_ascent, + fm.horizontalAdvance(printable.at(c)), + m_lineHeight); +#else int printable_item_x = -xoffset + m_margin + m_labelWidth + m_bytesPerLine * m_columnWidth + m_charWidth + fm.width(printable.left(c)); printableSelectionRect |= QRect(printable_item_x, y-m_ascent, fm.width(printable.at(c)), m_lineHeight); +#endif } } } @@ -878,8 +935,13 @@ void BinEdit::paintEvent(QPaintEvent *e) painter.drawRect(cursorRect.adjusted(0, 0, 0, -1)); painter.restore(); if (m_hexCursor && m_cursorVisible) { +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + if (m_lowNibble) + cursorRect.adjust(fm.horizontalAdvance(itemString.left(1)), 0, 0, 0); +#else if (m_lowNibble) cursorRect.adjust(fm.width(itemString.left(1)), 0, 0, 0); +#endif painter.fillRect(cursorRect, Qt::red); painter.save(); painter.setClipRect(cursorRect); @@ -893,8 +955,13 @@ void BinEdit::paintEvent(QPaintEvent *e) if (isFullySelected) { painter.save(); +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + painter.fillRect(text_x, y-m_ascent, fm.horizontalAdvance(printable), m_lineHeight, + palette().highlight()); +#else painter.fillRect(text_x, y-m_ascent, fm.width(printable), m_lineHeight, palette().highlight()); +#endif painter.setPen(palette().highlightedText().color()); painter.drawText(text_x, y, printable); painter.restore(); @@ -911,10 +978,17 @@ void BinEdit::paintEvent(QPaintEvent *e) } if (cursor >= 0 && !printable.isEmpty()) { +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + QRect cursorRect(text_x + fm.horizontalAdvance(printable.left(cursor)), + y-m_ascent, + fm.horizontalAdvance(printable.at(cursor)), + m_lineHeight); +#else QRect cursorRect(text_x + fm.width(printable.left(cursor)), y-m_ascent, fm.width(printable.at(cursor)), m_lineHeight); +#endif painter.save(); if (m_hexCursor || !m_cursorVisible) { painter.setPen(Qt::red); From 5ea752e9f21dbe4b100755a8bcbb53a6efbd4afa Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 15:18:45 +0300 Subject: [PATCH 22/40] Port QWheelEvent::delta() (obsolete) Port QWheelEvent::delta() (obsolete) to QWheelEvent::pixelDelta()::y() --- examples/officeopenxml/opc_package_viewer/binedit.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.cpp b/examples/officeopenxml/opc_package_viewer/binedit.cpp index e717227..bcbbb40 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.cpp +++ b/examples/officeopenxml/opc_package_viewer/binedit.cpp @@ -498,7 +498,11 @@ void BinEdit::changeEvent(QEvent *e) void BinEdit::wheelEvent(QWheelEvent *e) { if (e->modifiers() & Qt::ControlModifier) { +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + const int delta = e->pixelDelta().y(); +#else const int delta = e->delta(); +#endif if (delta < 0) zoomOut(); else if (delta > 0) From 1a373f2a3bcfdd10855aa387206b4bb847fd4eb0 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 15:32:58 +0300 Subject: [PATCH 23/40] Fix error: conversion from 'int' to 'QChar' is ambiguous --- examples/officeopenxml/opc_package_viewer/binedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.cpp b/examples/officeopenxml/opc_package_viewer/binedit.cpp index bcbbb40..88b556b 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.cpp +++ b/examples/officeopenxml/opc_package_viewer/binedit.cpp @@ -546,7 +546,7 @@ int BinEdit::posAt(const QPoint &pos) const break; QChar qc(QLatin1Char(dataAt(dataPos))); if (!qc.isPrint()) - qc = 0xB7; + qc = QChar(0xB7); #if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) x -= fontMetrics().horizontalAdvance(qc); #else @@ -832,7 +832,7 @@ void BinEdit::paintEvent(QPaintEvent *e) break; QChar qc(QLatin1Char(dataAt(pos, isOld))); if (qc.unicode() >= 127 || !qc.isPrint()) - qc = 0xB7; + qc = QChar(0xB7); printable += qc; } } else { From 6198311ace98f6117c7d94497f76f844762478e7 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 15:39:28 +0300 Subject: [PATCH 24/40] Port QWheelEvent::delta() (obsolete) Port QWheelEvent::delta() (obsolete) to QWheelEvent::angleDelta()::y() --- examples/officeopenxml/opc_package_viewer/imagewidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/officeopenxml/opc_package_viewer/imagewidget.cpp b/examples/officeopenxml/opc_package_viewer/imagewidget.cpp index b34e87b..0890bf6 100644 --- a/examples/officeopenxml/opc_package_viewer/imagewidget.cpp +++ b/examples/officeopenxml/opc_package_viewer/imagewidget.cpp @@ -245,8 +245,11 @@ void ImageWidget::wheelEvent(QWheelEvent *event) if (d->m_wheelScaleEnabled) { //Disable auto fit!! d->m_autoAdjustEnabled = false; - +#if (QT_VERSION >= QT_VERSION_CHECK(5,15,14)) + double numDegrees = -event->angleDelta().y() / 8.0; +#else double numDegrees = -event->delta() / 8.0; +#endif double numSteps = numDegrees / 15.0; double factor = pow(1.125, numSteps); From 1e5617d48c0f62c71c5267ed32213b419687588d Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Fri, 16 Jun 2023 15:42:10 +0300 Subject: [PATCH 25/40] Port QString::SkipEmptyParts (obsolete) Port QString::SkipEmptyParts (obsolete) to Qt::SkipEmptyParts --- examples/officeopenxml/opc_packages_diff/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/officeopenxml/opc_packages_diff/mainwindow.cpp b/examples/officeopenxml/opc_packages_diff/mainwindow.cpp index d4fcfbf..82b092c 100644 --- a/examples/officeopenxml/opc_packages_diff/mainwindow.cpp +++ b/examples/officeopenxml/opc_packages_diff/mainwindow.cpp @@ -142,7 +142,7 @@ void MainWindow::onRunButtonClicked() return; } - QStringList args = ui->diffArgumentsEdit->text().split(QRegularExpression("\\s+"), QString::SkipEmptyParts); + QStringList args = ui->diffArgumentsEdit->text().split(QRegularExpression("\\s+"), Qt::SkipEmptyParts); for (int i=0; ipath(); From 47c2ec4a57e5d91fd5160fd1cc047d1139a07c9d Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 20:05:22 +0300 Subject: [PATCH 26/40] Fixed implicitly cast to the bool type. The 'm_cursorPosition + 1' value is implicitly cast to the bool type. --- examples/officeopenxml/opc_package_viewer/binedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.cpp b/examples/officeopenxml/opc_package_viewer/binedit.cpp index 88b556b..a4dc32f 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.cpp +++ b/examples/officeopenxml/opc_package_viewer/binedit.cpp @@ -1408,7 +1408,7 @@ void BinEdit::keyPressEvent(QKeyEvent *e) } else { if (c.unicode() >= 128 || !c.isPrint()) continue; - changeData(m_cursorPosition, c.unicode(), m_cursorPosition + 1); + changeData(m_cursorPosition, c.unicode(), true); setCursorPosition(m_cursorPosition + 1); } setBlinkingCursorEnabled(true); From 04e05b646507fc5158b43429f251c120486ee5c3 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 20:22:27 +0300 Subject: [PATCH 27/40] Fixed m_pixmapItem initialization The member of a class m_pixmapItem are not initialized inside the constructor --- examples/officeopenxml/opc_package_viewer/imagewidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/officeopenxml/opc_package_viewer/imagewidget.cpp b/examples/officeopenxml/opc_package_viewer/imagewidget.cpp index 0890bf6..d462bf4 100644 --- a/examples/officeopenxml/opc_package_viewer/imagewidget.cpp +++ b/examples/officeopenxml/opc_package_viewer/imagewidget.cpp @@ -64,6 +64,7 @@ ImageWidgetPrivate::ImageWidgetPrivate(ImageWidget *q) : m_scaleMax = 64; m_wheelScaleEnabled = true; m_autoAdjustEnabled = false; + m_pixmapItem = nullptr; } /*! From 3a8881ba3fa679133e6371511b7dad7da41d6add Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 20:26:32 +0300 Subject: [PATCH 28/40] Maybe 'else' keyword is missing. --- src/3rdParty/karchive/src/karchive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdParty/karchive/src/karchive.cpp b/src/3rdParty/karchive/src/karchive.cpp index e494639..82b3f5c 100644 --- a/src/3rdParty/karchive/src/karchive.cpp +++ b/src/3rdParty/karchive/src/karchive.cpp @@ -172,7 +172,7 @@ bool KArchive::close() closeSucceeded = d->saveFile->commit(); delete d->saveFile; d->saveFile = 0; - } if (d->deviceOwned) { + } else if (d->deviceOwned) { delete d->dev; // we created it ourselves in open() } From bcf04be5ee6ba9a1c0568bc19ec1505801f1f6b7 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 20:37:55 +0300 Subject: [PATCH 29/40] Fixed expression A part of conditional expression is always true: data.constData(). --- src/3rdParty/karchive/src/karchive.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/3rdParty/karchive/src/karchive.cpp b/src/3rdParty/karchive/src/karchive.cpp index 82b3f5c..16541a1 100644 --- a/src/3rdParty/karchive/src/karchive.cpp +++ b/src/3rdParty/karchive/src/karchive.cpp @@ -327,9 +327,11 @@ bool KArchive::writeFile(const QString &name, const QByteArray &data, // Write data // Note: if data is null, don't call write, it would terminate the KCompressionDevice - if (data.constData() && size && !writeData(data.constData(), size)) { - //qWarning() << "writeData failed"; - return false; + if (!data.isNull() && !data.isEmpty()) { + if (!writeData(data.constData(), size)) { + //qWarning() << "writeData failed"; + return false; + } } if (!finishWriting(size)) { From 0a26284f8e09854dd6fd07cf7b4f76f0135625eb Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 20:49:16 +0300 Subject: [PATCH 30/40] Fixed CWE: 398. Uninit member The members of a class 'result', 'filter' are not initialized inside the constructor. --- src/3rdParty/karchive/src/kcompressiondevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdParty/karchive/src/kcompressiondevice.cpp b/src/3rdParty/karchive/src/kcompressiondevice.cpp index 4f7bba0..fa9e938 100644 --- a/src/3rdParty/karchive/src/kcompressiondevice.cpp +++ b/src/3rdParty/karchive/src/kcompressiondevice.cpp @@ -45,7 +45,7 @@ class KCompressionDevice::Private Private() : bNeedHeader(true), bSkipHeaders(false), bOpenedUnderlyingDevice(false), bIgnoreData(false), - type(KCompressionDevice::None) {} + result(KFilterBase::Result()), filter(nullptr), type(KCompressionDevice::None) {} bool bNeedHeader; bool bSkipHeaders; bool bOpenedUnderlyingDevice; From 5ec98dc25d59698d4f497f75a5195b31fcfde004 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 20:55:06 +0300 Subject: [PATCH 31/40] Fixed pointer check after use The 'd->m_currentFile' pointer was utilized before it was verified against nullptr. --- src/3rdParty/karchive/src/kzip.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdParty/karchive/src/kzip.cpp b/src/3rdParty/karchive/src/kzip.cpp index a9bc54e..6685a1f 100644 --- a/src/3rdParty/karchive/src/kzip.cpp +++ b/src/3rdParty/karchive/src/kzip.cpp @@ -1202,6 +1202,7 @@ bool KZip::doPrepareWriting(const QString &name, const QString &user, bool KZip::doFinishWriting(qint64 size) { + Q_ASSERT(d->m_currentFile); if (d->m_currentFile->encoding() == 8) { // Finish (void)d->m_currentDev->write(0, 0); @@ -1210,7 +1211,6 @@ bool KZip::doFinishWriting(qint64 size) // If 0, d->m_currentDev was device() - don't delete ;) d->m_currentDev = 0; - Q_ASSERT(d->m_currentFile); //qDebug() << "fileName: " << d->m_currentFile->path(); //qDebug() << "getpos (at): " << device()->pos(); d->m_currentFile->setSize(size); From 2cb5f3d0f7496f5125e94240e6cfa8e803cbd5c7 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 22:18:03 +0300 Subject: [PATCH 32/40] Fixed an odd precise comparison. It's probably better to use a comparison with defined precision or use special functions. --- examples/officeopenxml/opc_package_viewer/binedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.cpp b/examples/officeopenxml/opc_package_viewer/binedit.cpp index a4dc32f..a9b9fa6 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.cpp +++ b/examples/officeopenxml/opc_package_viewer/binedit.cpp @@ -1294,7 +1294,7 @@ QString BinEdit::toolTip(const QHelpEvent *helpEvent) const asDouble(selStart, doubleValueOld, true); str << tableRowStartC << tr("double value:") << numericTableRowSepC << doubleValue << tableRowEndC; - if (doubleValue != doubleValueOld) + if (qFuzzyCompare(doubleValue, doubleValueOld)) str << tableRowStartC << tr("Previous double value:") << numericTableRowSepC << doubleValueOld << tableRowEndC; str << ""; @@ -1308,7 +1308,7 @@ QString BinEdit::toolTip(const QHelpEvent *helpEvent) const asFloat(selStart, floatValueOld, true); str << tableRowStartC << tr("float value:") << numericTableRowSepC << floatValue << tableRowEndC; - if (floatValue != floatValueOld) + if (qFuzzyCompare(floatValue, floatValueOld)) str << tableRowStartC << tr("Previous float value:") << numericTableRowSepC << floatValueOld << tableRowEndC; From 41659b1aa8c838916be6d2e8d9a8f5f7185ac7d5 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 22:21:24 +0300 Subject: [PATCH 33/40] Fixed 'false' value is implicitly cast to the integer type. --- examples/officeopenxml/opc_package_viewer/binedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.cpp b/examples/officeopenxml/opc_package_viewer/binedit.cpp index a9b9fa6..67858ae 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.cpp +++ b/examples/officeopenxml/opc_package_viewer/binedit.cpp @@ -89,7 +89,7 @@ BinEdit::BinEdit(QWidget *parent) m_addressBytes = 4; init(); m_unmodifiedState = 0; - m_readOnly = false; + m_readOnly = 0; m_hexCursor = true; m_cursorPosition = 0; m_anchorPosition = 0; From 20a1b9004721a37e2c3a1215717c9f2b7fea18fd Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 22:33:46 +0300 Subject: [PATCH 34/40] Fixed an odd precise comparison. It's probably better to use a comparison with defined precision or use special functions. --- examples/officeopenxml/opc_package_viewer/imagewidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/officeopenxml/opc_package_viewer/imagewidget.cpp b/examples/officeopenxml/opc_package_viewer/imagewidget.cpp index d462bf4..c9e0b8f 100644 --- a/examples/officeopenxml/opc_package_viewer/imagewidget.cpp +++ b/examples/officeopenxml/opc_package_viewer/imagewidget.cpp @@ -196,7 +196,7 @@ bool ImageWidget::isMouseWheelEnabled() const */ void ImageWidget::setCurrentScale(double factor) { - if (factor == 0) { + if (qFuzzyCompare(factor, 0)) { if (!d->m_autoAdjustEnabled) { d->m_autoAdjustEnabled = true; d->doAutoFit(); From 4843be6180bbb632030894cba3bdbfecdef33f6e Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Sun, 18 Jun 2023 23:14:19 +0300 Subject: [PATCH 35/40] Fixed comparison of integers of different types --- src/officeopenxml/sml/smlcell.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/officeopenxml/sml/smlcell.cpp b/src/officeopenxml/sml/smlcell.cpp index 6eb6728..a676b35 100644 --- a/src/officeopenxml/sml/smlcell.cpp +++ b/src/officeopenxml/sml/smlcell.cpp @@ -59,7 +59,7 @@ Cell::CellType Cell::cellType() const Q_D(const Cell); if (d->attrs_raw.contains(QStringLiteral("t"))) { QString t = d->attrs_raw[QStringLiteral("t")]; - for (int i=0; i Date: Mon, 19 Jun 2023 00:28:10 +0300 Subject: [PATCH 36/40] Update README.md Add commands for Windows Qt MINGW and MSVC --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8fe0778..660f870 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,15 @@ Microsoft Office and can be used in any platform that **Qt 5.2** or newer suppor * Put the source code in any directory you like -* Run following command at the toplevel directory of the project +* Run following command at the toplevel directory of the project: + +| | Windows Qt MINGW | Windows Qt MSVC | +|--------------------|----------------------------|---------------------| +| ```qmake``` | ```qmake``` | ```qmake``` | +| ```make``` | ```mingw32-make``` | ```nmake``` | +| | ```mingw32-make check``` | ```nmake check``` | +| ```make install``` | ```mingw32-make install``` | ```nmake install``` | -``` - qmake - make - make install -``` The library, the header files, and others will be installed to your system. From 3d1eab6e7c8a7d097f1ab12b893923703d57d4c7 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Mon, 19 Jun 2023 00:56:25 +0300 Subject: [PATCH 37/40] Fix error: unknown type name 'QDateTime' Fix error: unknown type name 'QDateTime' [clang-diagnostic-error] --- src/3rdParty/karchive/src/karchiveentry.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/3rdParty/karchive/src/karchiveentry.h b/src/3rdParty/karchive/src/karchiveentry.h index aad6840..a827d61 100644 --- a/src/3rdParty/karchive/src/karchiveentry.h +++ b/src/3rdParty/karchive/src/karchiveentry.h @@ -25,6 +25,7 @@ #include #include +#include #ifdef Q_OS_WIN #include // mode_t From 20b0e0c94bd854ab49f48cc32a3ee03cde419653 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Mon, 19 Jun 2023 15:01:29 +0300 Subject: [PATCH 38/40] Fixed(?): value 'PE_ContentType' not handled in switch warning: enumeration value 'PE_ContentType' not handled in switch [- Wswitch] Maybe this enumeration value must be here --- src/officeopenxml/opc/opcpartbasedpackageproperties.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp b/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp index c30b33f..607f08f 100644 --- a/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp +++ b/src/officeopenxml/opc/opcpartbasedpackageproperties.cpp @@ -155,6 +155,7 @@ void PartBasedPackageProperties::doSaveToXml(QIODevice *device) switch (pe) { case PE_Category: case PE_ContentStatus: + case PE_ContentType: case PE_Keywords: case PE_LastModifiedBy: case PE_LastPrinted: From f1abaa491add16b9fa87c0ad3482569f8dd00738 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Wed, 21 Jun 2023 23:05:58 +0300 Subject: [PATCH 39/40] Revert "Fixed an odd precise comparison." This reverts commit 2cb5f3d0f7496f5125e94240e6cfa8e803cbd5c7. --- examples/officeopenxml/opc_package_viewer/binedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.cpp b/examples/officeopenxml/opc_package_viewer/binedit.cpp index 67858ae..09add45 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.cpp +++ b/examples/officeopenxml/opc_package_viewer/binedit.cpp @@ -1294,7 +1294,7 @@ QString BinEdit::toolTip(const QHelpEvent *helpEvent) const asDouble(selStart, doubleValueOld, true); str << tableRowStartC << tr("double value:") << numericTableRowSepC << doubleValue << tableRowEndC; - if (qFuzzyCompare(doubleValue, doubleValueOld)) + if (doubleValue != doubleValueOld) str << tableRowStartC << tr("Previous double value:") << numericTableRowSepC << doubleValueOld << tableRowEndC; str << ""; @@ -1308,7 +1308,7 @@ QString BinEdit::toolTip(const QHelpEvent *helpEvent) const asFloat(selStart, floatValueOld, true); str << tableRowStartC << tr("float value:") << numericTableRowSepC << floatValue << tableRowEndC; - if (qFuzzyCompare(floatValue, floatValueOld)) + if (floatValue != floatValueOld) str << tableRowStartC << tr("Previous float value:") << numericTableRowSepC << floatValueOld << tableRowEndC; From e5ce85d9e1ef162e30a17a29d2bc5fc9406d3544 Mon Sep 17 00:00:00 2001 From: Oleksii Gaienko Date: Wed, 21 Jun 2023 23:10:35 +0300 Subject: [PATCH 40/40] Fixed an odd precise comparison. It's probably better to use a comparison with defined precision or use special functions. Fixed me error. --- examples/officeopenxml/opc_package_viewer/binedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/officeopenxml/opc_package_viewer/binedit.cpp b/examples/officeopenxml/opc_package_viewer/binedit.cpp index 09add45..4ec4b2e 100644 --- a/examples/officeopenxml/opc_package_viewer/binedit.cpp +++ b/examples/officeopenxml/opc_package_viewer/binedit.cpp @@ -1294,7 +1294,7 @@ QString BinEdit::toolTip(const QHelpEvent *helpEvent) const asDouble(selStart, doubleValueOld, true); str << tableRowStartC << tr("double value:") << numericTableRowSepC << doubleValue << tableRowEndC; - if (doubleValue != doubleValueOld) + if (!qFuzzyCompare(doubleValue, doubleValueOld)) str << tableRowStartC << tr("Previous double value:") << numericTableRowSepC << doubleValueOld << tableRowEndC; str << ""; @@ -1308,7 +1308,7 @@ QString BinEdit::toolTip(const QHelpEvent *helpEvent) const asFloat(selStart, floatValueOld, true); str << tableRowStartC << tr("float value:") << numericTableRowSepC << floatValue << tableRowEndC; - if (floatValue != floatValueOld) + if (!qFuzzyCompare(floatValue, floatValueOld)) str << tableRowStartC << tr("Previous float value:") << numericTableRowSepC << floatValueOld << tableRowEndC;