Qbs: fix build clang, mingw

This commit is contained in:
Jakub Melka 2021-12-14 19:28:38 +01:00
parent 0a35c95aa7
commit 92f4055d05
34 changed files with 81 additions and 82 deletions

View File

@ -984,7 +984,7 @@ QStringList GeneratedBase::getFormattedTextWithLayout(QString firstPrefix, QStri
int usedLength = indent + qMax(firstPrefix.length(), prefix.length());
int length = 80 - usedLength;
QString testText(length, QChar('A'));
int width = fontMetrics.width(testText);
int width = fontMetrics.horizontalAdvance(testText);
QTextLayout layout(text, font);
layout.setCacheEnabled(false);

View File

@ -101,12 +101,12 @@ void MainWindow::on_actionAdd_JBIG2_image_triggered()
{
QImage image(imageData.getWidth(), imageData.getHeight(), QImage::Format_Mono);
const uchar* sourceData = reinterpret_cast<const uchar*>(imageData.getData().constData());
Q_ASSERT(imageData.getData().size() == image.byteCount());
Q_ASSERT(imageData.getData().size() == image.sizeInBytes());
std::transform(sourceData, sourceData + imageData.getData().size(), image.bits(), [](const uchar value) { return value; });
addImage(file.fileName() + QString(", Decoded in %1 [msec]").arg(time), qMove(image));
}
}
catch (pdf::PDFException exception)
catch (const pdf::PDFException& exception)
{
QMessageBox::critical(this, tr("Error"), exception.getMessage());
}

View File

@ -9,17 +9,20 @@ Pdf4QtLibrary {
Depends { name: "openjpeg" }
Depends { name: "lcms" }
Depends {
condition: qbs.toolchain.contains("gcc")
condition: qbs.toolchain.contains("gcc") && !qbs.toolchain.contains("mingw")
name: "tbb"
}
Depends {
condition: qbs.hostOS.contains("linux")
name: "fontconfig"
}
Properties {
condition: qbs.toolchain.contains("msvc") || qbs.toolchain.contains("clang")
cpp.cxxFlags: "/bigobj"
}
Properties {
condition: qbs.hostOS.contains("windows")
cpp.defines: "PDF4QTLIB_LIBRARY"
cpp.cxxFlags: "/bigobj"
}
files: [
@ -38,7 +41,7 @@ Pdf4QtLibrary {
Depends { name: "openjpeg" }
Depends { name: "lcms" }
Depends {
condition: qbs.toolchain.contains("gcc")
condition: qbs.toolchain.contains("gcc") && !qbs.toolchain.contains("mingw")
name: "tbb"
}
Depends {

View File

@ -164,7 +164,7 @@ PDFAlgorithmLongestCommonSubsequenceBase::SequenceItemRanges PDFAlgorithmLongest
PDFAlgorithmLongestCommonSubsequenceBase::SequenceItemFlags PDFAlgorithmLongestCommonSubsequenceBase::collectFlags(const SequenceItemRange& range)
{
SequenceItemFlags flags = 0;
SequenceItemFlags flags = SequenceItemFlags();
for (auto it = range.first; it != range.second; ++it)
{

View File

@ -1410,7 +1410,7 @@ void PDFAnnotationManager::drawAnnotation(const PageAnnotation& annotation,
drawAnnotationUsingAppearanceStream(annotation, appearanceStreamObject, pagePointToDevicePointMatrix, page, cms, painter);
}
}
catch (PDFException exception)
catch (const PDFException& exception)
{
errors.push_back(PDFRenderError(RenderErrorType::Error, exception.getMessage()));
}

View File

@ -684,7 +684,7 @@ PDFDocumentSecurityStore PDFDocumentSecurityStore::parse(const PDFObject& object
}
}
}
catch (PDFException)
catch (const PDFException&)
{
return PDFDocumentSecurityStore();
}

View File

@ -1491,7 +1491,7 @@ void PDFCMSManager::setDocument(const PDFDocument* document)
content = m_document->getDecodedStream(outputProfileObject.getStream());
}
}
catch (PDFException)
catch (const PDFException&)
{
continue;
}

View File

@ -642,4 +642,15 @@ std::vector<QByteArray> PDFDocumentDataLoaderDecorator::readStringArray(const PD
return std::vector<QByteArray>();
}
const PDFObject& PDFObjectStorage::getObject(const PDFObject& object) const
{
if (object.isReference())
{
// Try to dereference the object
return getObject(object.getReference());
}
return object;
}
} // namespace pdf

View File

@ -598,18 +598,6 @@ const PDFObject& PDFDocument::getObjectByReference(PDFObjectReference reference)
return m_pdfObjectStorage.getObject(reference);
}
inline
const PDFObject& PDFObjectStorage::getObject(const PDFObject& object) const
{
if (object.isReference())
{
// Try to dereference the object
return getObject(object.getReference());
}
return object;
}
inline
const PDFDictionary* PDFObjectStorage::getDictionaryFromObject(const PDFObject& object) const
{

View File

@ -91,7 +91,7 @@ PDFOperationResult PDFDocumentManipulator::assemble(const AssembledPages& pages)
// Optimize document - remove unused objects and shrink object storage
finalizeDocument(&mergedDocument);
}
catch (PDFException exception)
catch (const PDFException& exception)
{
return exception.getMessage();
}

View File

@ -162,7 +162,7 @@ void PDFDocumentReader::checkHeader(const QByteArray& buffer)
}
}
const PDFInteger PDFDocumentReader::findXrefTableOffset(const QByteArray& buffer)
PDFInteger PDFDocumentReader::findXrefTableOffset(const QByteArray& buffer)
{
const int startXRefPosition = findFromEnd(PDF_START_OF_XREF_MARK, buffer, PDF_FOOTER_SCAN_LIMIT);
if (startXRefPosition == FIND_NOT_FOUND_RESULT)
@ -271,7 +271,7 @@ PDFObject PDFDocumentReader::readDamagedTrailerDictionary() const
object = PDFObjectManipulator::merge(object, trailerDictionaryObject, PDFObjectManipulator::RemoveNullObjects);
}
}
catch (PDFException)
catch (const PDFException&)
{
// Do nothing...
}
@ -299,7 +299,7 @@ PDFDocumentReader::Result PDFDocumentReader::processReferenceTableEntries(PDFXRe
QMutexLocker lock(&m_mutex);
objects[entry.reference.objectNumber] = PDFObjectStorage::Entry(entry.reference.generation, object);
}
catch (PDFException exception)
catch (const PDFException& exception)
{
QMutexLocker lock(&m_mutex);
@ -518,7 +518,7 @@ void PDFDocumentReader::processObjectStreams(PDFXRefTable* xrefTable, PDFObjectS
}
}
}
catch (PDFException exception)
catch (const PDFException& exception)
{
QMutexLocker lock(&m_mutex);
m_result = Result::Failed;
@ -711,7 +711,7 @@ bool PDFDocumentReader::restoreObjects(std::map<PDFObjectReference, PDFObject>&
}
}
}
catch (PDFException)
catch (const PDFException&)
{
// Do nothing
succesfull = false;

View File

@ -98,7 +98,7 @@ private:
void checkFooter(const QByteArray& buffer);
void checkHeader(const QByteArray& buffer);
const PDFInteger findXrefTableOffset(const QByteArray& buffer);
PDFInteger findXrefTableOffset(const QByteArray& buffer);
Result processReferenceTableEntries(PDFXRefTable* xrefTable, const std::vector<PDFXRefTable::Entry>& occupiedEntries, PDFObjectStorage::PDFObjects& objects);
Result processSecurityHandler(const PDFObject& trailerDictionaryObject, const std::vector<PDFXRefTable::Entry>& occupiedEntries, PDFObjectStorage::PDFObjects& objects);
void processObjectStreams(PDFXRefTable* xrefTable, PDFObjectStorage::PDFObjects& objects);

View File

@ -2146,7 +2146,7 @@ QByteArray PDFEncoding::convertToEncoding(const QString& string, Encoding encodi
ushort unicode = character.unicode();
unsigned char converted = 0;
for (int i = 0; i < table->size(); ++i)
for (size_t i = 0; i < table->size(); ++i)
{
if (unicode == (*table)[static_cast<unsigned char>(i)])
{
@ -2353,6 +2353,9 @@ const encoding::EncodingTable* PDFEncoding::getTableForEncoding(Encoding encodin
case Encoding::MacOsRoman:
return &pdf::encoding::MAC_OS_ENCODING_CONVERSION_TABLE;
default:
break;
}
// Unknown encoding?

View File

@ -315,7 +315,7 @@ public:
GlyphIndices glyphIndices);
virtual ~PDFSimpleFont() override = default;
const PDFEncoding::Encoding getEncodingType() const { return m_encodingType; }
PDFEncoding::Encoding getEncodingType() const { return m_encodingType; }
const encoding::EncodingTable* getEncoding() const { return &m_encoding; }
const GlyphIndices* getGlyphIndices() const { return &m_glyphIndices; }

View File

@ -404,7 +404,7 @@ private:
PDFFormField::FieldFlags m_flags;
Options m_options;
Qt::Alignment m_textAlignment = 0;
Qt::Alignment m_textAlignment = Qt::Alignment();
int m_topIndex = 0;
int m_currentIndex = 0;
std::set<int> m_selection;
@ -828,7 +828,7 @@ PDFFormFieldPointer PDFFormField::parse(const PDFObjectStorage* storage, PDFObje
{
PDFInteger maxLengthDefault = 0;
QByteArray defaultAppearance;
Qt::Alignment alignment = 0;
Qt::Alignment alignment = Qt::Alignment();
if (PDFFormFieldText* parentTextField = dynamic_cast<PDFFormFieldText*>(parentField))
{
@ -3776,7 +3776,7 @@ void PDFListBoxPseudowidget::draw(AnnotationDrawParameters& parameters, bool edi
QColor highlightColor = getAdjustedColor(palette.color(QPalette::Highlight));
QRectF rect(0, 0, m_widgetRect.width(), m_lineSpacing);
for (int i = m_topIndex; i < m_options.size(); ++i)
for (int i = m_topIndex; i < int(m_options.size()); ++i)
{
if (m_selection.count(i))
{
@ -3912,7 +3912,7 @@ bool PDFListBoxPseudowidget::hasContinuousSelection() const
return false;
}
return *m_selection.rbegin() - *m_selection.begin() + 1 == m_selection.size();
return *m_selection.rbegin() - *m_selection.begin() + 1 == int(m_selection.size());
}
int PDFListBoxPseudowidget::getValidIndex(int index) const

View File

@ -351,7 +351,7 @@ private:
QByteArray m_defaultAppearance;
/// Text field alignment
Qt::Alignment m_alignment = 0;
Qt::Alignment m_alignment = Qt::Alignment();
/// Default style
QString m_defaultStyle;

View File

@ -1865,7 +1865,7 @@ PDFFunction::FunctionResult PDFPostScriptFunction::apply(const_iterator x_1, con
return PDFTranslationContext::tr("Stack contains more values, than output size (%1 remains) (PostScript function).").arg(stack.size());
}
}
catch (PDFPostScriptFunction::PDFPostScriptFunctionException exception)
catch (const PDFPostScriptFunction::PDFPostScriptFunctionException& exception)
{
return exception.getMessage();
}

View File

@ -368,8 +368,8 @@ QVariant PDFOutlineTreeItemModel::data(const QModelIndex& index, int role) const
case Qt::DisplayRole:
return outlineItem->getTitle();
case Qt::TextColorRole:
return outlineItem->getTextColor();
case Qt::ForegroundRole:
return QBrush(outlineItem->getTextColor());
case Qt::FontRole:
{

View File

@ -22,7 +22,7 @@
namespace pdf
{
static constexpr const std::array glyphNameToUnicode = {
static constexpr const std::array<std::pair<QChar, const char*>, 4285> glyphNameToUnicode = {
std::pair<QChar, const char*>{ QChar(0x0041), "A" }, // Character 'A' Letter, Uppercase
std::pair<QChar, const char*>{ QChar(0x00C6), "AE" }, // Character 'Æ' Letter, Uppercase
std::pair<QChar, const char*>{ QChar(0x01FC), "AEacute" }, // Character 'Ǽ' Letter, Uppercase

View File

@ -278,7 +278,7 @@ void PDFPageContentProcessor::initializeProcessor()
m_deviceRGBColorSpace = PDFAbstractColorSpace::createDeviceColorSpaceByName(m_colorSpaceDictionary, m_document, COLOR_SPACE_NAME_DEVICE_RGB);
m_deviceCMYKColorSpace = PDFAbstractColorSpace::createDeviceColorSpaceByName(m_colorSpaceDictionary, m_document, COLOR_SPACE_NAME_DEVICE_CMYK);
}
catch (PDFException exception)
catch (const PDFException& exception)
{
m_errorList.append(PDFRenderError(RenderErrorType::Error, exception.getMessage()));
@ -687,7 +687,7 @@ void PDFPageContentProcessor::processContent(const QByteArray& content)
}
}
}
catch (PDFException exception)
catch (const PDFException& exception)
{
// If we get exception when parsing, and parser position is not advanced,
// then we must advance it manually, otherwise we get infinite loop.
@ -715,7 +715,7 @@ void PDFPageContentProcessor::processContentStream(const PDFStream* stream)
processContent(content);
}
catch (PDFException exception)
catch (const PDFException& exception)
{
m_operands.clear();
m_errorList.append(PDFRenderError(RenderErrorType::Error, exception.getMessage()));
@ -904,7 +904,8 @@ void PDFPageContentProcessor::processPathPainting(const QPainterPath& path, bool
const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern();
if (!lineDashPattern.isSolid())
{
stroker.setDashPattern(QVector<PDFReal>::fromStdVector(lineDashPattern.getDashArray()));
const auto& dashArray = lineDashPattern.getDashArray();
stroker.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
stroker.setDashOffset(lineDashPattern.getDashOffset());
}
QPainterPath strokedPath = stroker.createStroke(path);
@ -951,7 +952,8 @@ void PDFPageContentProcessor::processPathPainting(const QPainterPath& path, bool
const PDFLineDashPattern& lineDashPattern = m_graphicState.getLineDashPattern();
if (!lineDashPattern.isSolid())
{
stroker.setDashPattern(QVector<PDFReal>::fromStdVector(lineDashPattern.getDashArray()));
const auto& dashArray = lineDashPattern.getDashArray();
stroker.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
stroker.setDashOffset(lineDashPattern.getDashOffset());
}
QPainterPath strokedPath = stroker.createStroke(path);
@ -2698,7 +2700,7 @@ void PDFPageContentProcessor::operatorTextSetFontAndFontSize(PDFOperandName font
m_graphicState.setTextFontSize(fontSize);
updateGraphicState();
}
catch (PDFException)
catch (const PDFException&)
{
m_graphicState.setTextFont(nullptr);
m_graphicState.setTextFontSize(fontSize);
@ -3977,7 +3979,7 @@ PDFPageContentProcessor::PDFSoftMaskDefinition PDFPageContentProcessor::PDFSoftM
{
result.m_transferFunction = PDFFunction::createFunction(processor->getDocument(), softMask->get("TR"));
}
catch (PDFException)
catch (const PDFException&)
{
processor->reportRenderError(RenderErrorType::Error, PDFTranslationContext::tr("Invalid soft mask transfer function."));
}

View File

@ -135,7 +135,9 @@ QPen PDFPainterBase::getCurrentPenImpl() const
else
{
pen.setStyle(Qt::CustomDashLine);
pen.setDashPattern(QVector<PDFReal>::fromStdVector(lineDashPattern.getDashArray()));
const auto& dashArray = lineDashPattern.getDashArray();
pen.setDashPattern(QVector<PDFReal>(dashArray.begin(), dashArray.end()));
pen.setDashOffset(lineDashPattern.getDashOffset());
}

View File

@ -787,6 +787,7 @@ PDFObject PDFParser::getObject()
shift();
return PDFObject::createArray(std::move(arraySharedPointer));
}
return PDFObject::createNull();
}
case PDFLexicalAnalyzer::TokenType::DictionaryStart:
{
@ -902,6 +903,7 @@ PDFObject PDFParser::getObject()
shift();
return PDFObject::createDictionary(std::move(dictionarySharedPointer));
}
return PDFObject::createNull();
}
case PDFLexicalAnalyzer::TokenType::Null:

View File

@ -1484,7 +1484,7 @@ PDFMesh PDFRadialShading::createMesh(const PDFMeshQualitySettings& settings, con
QLineF xAxisLine(p1m.x(), 0, p2m.x(), 0);
QPointF intersectionPoint;
if (radiusInterpolationLine.intersect(xAxisLine, &intersectionPoint) != QLineF::NoIntersection)
if (radiusInterpolationLine.intersects(xAxisLine, &intersectionPoint) != QLineF::NoIntersection)
{
xl = qBound(meshingRectangle.left() - r1, intersectionPoint.x(), xl);
}
@ -1509,7 +1509,7 @@ PDFMesh PDFRadialShading::createMesh(const PDFMeshQualitySettings& settings, con
QLineF xAxisLine(p1m.x(), 0, p2m.x(), 0);
QPointF intersectionPoint;
if (radiusInterpolationLine.intersect(xAxisLine, &intersectionPoint) != QLineF::NoIntersection)
if (radiusInterpolationLine.intersects(xAxisLine, &intersectionPoint) != QLineF::NoIntersection)
{
xr = qBound(xr, intersectionPoint.x(), meshingRectangle.right() + r2);
}

View File

@ -2033,7 +2033,7 @@ void pdf::PDFPublicKeySignatureHandler::addTrustedCertificates(X509_STORE* store
#ifdef Q_OS_WIN
if (m_parameters.useSystemCertificateStore)
{
HCERTSTORE certStore = CertOpenSystemStore(NULL, L"ROOT");
HCERTSTORE certStore = CertOpenSystemStore(0, L"ROOT");
PCCERT_CONTEXT context = nullptr;
if (certStore)
{
@ -2059,7 +2059,7 @@ pdf::PDFCertificateStore::CertificateEntries pdf::PDFCertificateStore::getSystem
CertificateEntries result;
#ifdef Q_OS_WIN
HCERTSTORE certStore = CertOpenSystemStore(NULL, L"ROOT");
HCERTSTORE certStore = CertOpenSystemStore(0, L"ROOT");
PCCERT_CONTEXT context = nullptr;
if (certStore)
{

View File

@ -359,13 +359,6 @@ QByteArray PDFLzwDecodeFilter::apply(const QByteArray& data,
{
const PDFDictionary* dictionary = dereferencedParameters.getDictionary();
PDFInteger predictor = 1;
const PDFObject& predictorObject = objectFetcher(dictionary->get("Predictor"));
if (predictorObject.isInt())
{
predictor = predictorObject.getInteger();
}
const PDFObject& earlyChangeObject = objectFetcher(dictionary->get("EarlyChange"));
if (earlyChangeObject.isInt())
{
@ -385,19 +378,6 @@ QByteArray PDFFlateDecodeFilter::apply(const QByteArray& data,
{
Q_UNUSED(securityHandler);
const PDFObject& dereferencedParameters = objectFetcher(parameters);
if (dereferencedParameters.isDictionary())
{
const PDFDictionary* dictionary = dereferencedParameters.getDictionary();
PDFInteger predictor = 1;
const PDFObject& predictorObject = objectFetcher(dictionary->get("Predictor"));
if (predictorObject.isInt())
{
predictor = predictorObject.getInteger();
}
}
PDFStreamPredictor predictor = PDFStreamPredictor::createPredictor(objectFetcher, parameters);
return predictor.apply(uncompress(data));
}

View File

@ -3229,7 +3229,7 @@ void PDFInkMapper::createSpotColors(bool activate)
{
colorSpacePointer = PDFAbstractColorSpace::createColorSpace(colorSpaceDictionary, m_document, m_document->getObject(colorSpaceDictionary->getValue(csIndex)));
}
catch (PDFException)
catch (const PDFException&)
{
// Ignore invalid color spaces
continue;

View File

@ -254,8 +254,14 @@ class PDFIntegerRange
public:
explicit inline constexpr PDFIntegerRange(T begin, T end) : m_begin(begin), m_end(end) { }
struct Iterator : public std::iterator<std::random_access_iterator_tag, T, ptrdiff_t, T*, T&>
struct Iterator
{
using iterator_category = std::random_access_iterator_tag;
using difference_type = ptrdiff_t;
using value_type = T;
using pointer = T*;
using reference = T&;
inline Iterator() : value(T(0)) { }
inline Iterator(T value) : value(value) { }

View File

@ -11466,7 +11466,7 @@ void PDFXFAEngineImpl::setDocument(const PDFModifiedDocument& document, PDFForm*
m_template = xfa::XFA_template::parse(document.firstChildElement("template"));
}
}
catch (PDFException)
catch (const PDFException&)
{
// Just clear once again - if some errorneous data
// were read, we want to clear them.

View File

@ -55,7 +55,7 @@ pdf::PDFOperationResult AudioBookCreator::createAudioBook(const Settings& settin
QString trimmedText = item.text.trimmed();
if (!trimmedText.isEmpty())
{
textStream << trimmedText << endl;
textStream << trimmedText << Qt::endl;
}
}

View File

@ -49,9 +49,9 @@ AudioBookPlugin::AudioBookPlugin() :
m_actionMoveSelectionUp(nullptr),
m_actionMoveSelectionDown(nullptr),
m_actionCreateAudioBook(nullptr),
m_actionClear(nullptr),
m_audioTextStreamDockWidget(nullptr),
m_audioTextStreamEditorModel(nullptr),
m_actionClear(nullptr)
m_audioTextStreamEditorModel(nullptr)
{
}

View File

@ -308,6 +308,8 @@ QVariant InkCoverageStatisticsModel::data(const QModelIndex& index, int role) co
Q_ASSERT(false);
break;
}
break;
}
case Qt::BackgroundColorRole:

View File

@ -355,7 +355,7 @@ void OutputPreviewWidget::paintEvent(QPaintEvent* event)
QString textCoverage = QString("%1 %").arg(locale.toString(coverage * 100.0, 'f', 2));
const int textRight = triangleLeft - rowHeight / 4;
const int textWidth = painter.fontMetrics().width(textCoverage);
const int textWidth = painter.fontMetrics().horizontalAdvance(textCoverage);
const int textStart = textRight - textWidth;
QRect textRect(textStart, yCoordinate - halfHeight, textWidth + 1, rowHeight);

View File

@ -362,7 +362,7 @@ int PDFToolAudioBook::createAudioBook(const PDFToolOptions& options, pdf::PDFDoc
{
if (item.flags.testFlag(pdf::PDFDocumentTextFlow::PageStart) && options.textSpeechMarkPageNumbers)
{
textStream << QString("<bookmark mark=\"%1\"/>").arg(item.text) << endl;
textStream << QString("<bookmark mark=\"%1\"/>").arg(item.text) << Qt::endl;
}
if (!item.text.isEmpty())

View File

@ -215,7 +215,7 @@ int PDFToolFetchImages::execute(const PDFToolOptions& options)
formatter.writeTableColumn("page-no", locale.toString(image.pageIndex + 1), Qt::AlignRight);
formatter.writeTableColumn("width", locale.toString(image.image.width()), Qt::AlignRight);
formatter.writeTableColumn("height", locale.toString(image.image.height()), Qt::AlignRight);
formatter.writeTableColumn("size", locale.toString(image.image.byteCount()), Qt::AlignRight);
formatter.writeTableColumn("size", locale.toString(image.image.sizeInBytes()), Qt::AlignRight);
formatter.writeTableColumn("stored-to", image.fileName);
formatter.endTableRow();
@ -259,7 +259,7 @@ PDFToolAbstractApplication::Options PDFToolFetchImages::getOptionsFlags() const
void PDFToolFetchImages::onImageExtracted(pdf::PDFInteger pageIndex, pdf::PDFInteger order, const QImage& image)
{
QCryptographicHash hasher(QCryptographicHash::Sha512);
hasher.addData(reinterpret_cast<const char*>(image.bits()), image.byteCount());
hasher.addData(reinterpret_cast<const char*>(image.bits()), image.sizeInBytes());
QByteArray hash = hasher.result();
QMutexLocker lock(&m_mutex);