Issue #22: Fix compilation warnings

This commit is contained in:
Jakub Melka 2022-07-31 18:32:57 +02:00
parent b30150a503
commit e310efb763
70 changed files with 424 additions and 435 deletions

View File

@ -102,9 +102,9 @@ QObject* Serializer::load(const QDomElement& element, QObject* parent)
// Find, if property was serialized
QDomElement propertyElement;
QDomNodeList children = element.childNodes();
for (int i = 0; i < children.count(); ++i)
for (int iChild = 0; iChild < children.count(); ++iChild)
{
QDomNode child = children.item(i);
QDomNode child = children.item(iChild);
if (child.isElement())
{
QDomElement childElement = child.toElement();
@ -129,14 +129,14 @@ QObject* Serializer::load(const QDomElement& element, QObject* parent)
else if (property.userType() == qMetaTypeId<QObjectList>())
{
QObjectList objectList;
QDomNodeList children = propertyElement.childNodes();
for (int i = 0; i < children.count(); ++i)
QDomNodeList subChildren = propertyElement.childNodes();
for (int iChild = 0; iChild < subChildren.count(); ++iChild)
{
QDomNode node = children.item(i);
QDomNode node = subChildren.item(iChild);
if (node.isElement())
{
QDomElement element = node.toElement();
if (QObject* object = Serializer::load(element, deserializedObject))
QDomElement nodeElement = node.toElement();
if (QObject* object = Serializer::load(nodeElement, deserializedObject))
{
objectList.append(object);
}
@ -1481,12 +1481,12 @@ void XFACodeGenerator::loadClasses(const QDomDocument& document)
Class myClass;
QDomElement element = child.toElement();
QDomElement childElement = child.toElement();
// Class name
myClass.className = element.attribute("name");
myClass.className = childElement.attribute("name");
QDomElement valueElement = element.firstChildElement("value");
QDomElement valueElement = childElement.firstChildElement("value");
if (!valueElement.isNull())
{
QString valueType = valueElement.attribute("type");
@ -1494,7 +1494,7 @@ void XFACodeGenerator::loadClasses(const QDomDocument& document)
}
// Attributes
QDomNodeList attributes = element.elementsByTagName("property");
QDomNodeList attributes = childElement.elementsByTagName("property");
const int attributeCount = attributes.size();
for (int ai = 0; ai < attributeCount; ++ai)
{
@ -1513,7 +1513,7 @@ void XFACodeGenerator::loadClasses(const QDomDocument& document)
}
// Subnodes
QDomNodeList subnodes = element.elementsByTagName("item");
QDomNodeList subnodes = childElement.elementsByTagName("item");
const int subnodeCount = subnodes.size();
for (int ai = 0; ai < subnodeCount; ++ai)
{
@ -1613,11 +1613,11 @@ const XFACodeGenerator::Type* XFACodeGenerator::createType(QString id, QString n
auto it = m_types.find(adjustedId);
if (it == m_types.end())
{
Type type;
type.id = adjustedId;
type.typeName = simpleType;
Type typeObject;
typeObject.id = adjustedId;
typeObject.typeName = simpleType;
if (type.typeName.isEmpty())
if (typeObject.typeName.isEmpty())
{
QString typeName = name.toUpper();
QString finalTypeName = typeName;
@ -1631,12 +1631,12 @@ const XFACodeGenerator::Type* XFACodeGenerator::createType(QString id, QString n
m_usedTypes.insert(finalTypeName);
QString enumValues = enumValuesString.remove(QChar::Space);
type.enumValues = enumValues.split("|");
typeObject.enumValues = enumValues.split("|");
type.typeName = finalTypeName;
typeObject.typeName = finalTypeName;
}
it = m_types.insert(std::make_pair(type.id, type)).first;
it = m_types.insert(std::make_pair(typeObject.id, typeObject)).first;
}
return &it->second;

View File

@ -85,12 +85,12 @@ void MainWindow::on_actionAdd_JBIG2_image_triggered()
if (file.open(QFile::ReadOnly))
{
m_directory = QFileInfo(file).filePath();
QByteArray data = file.readAll();
QByteArray fileContentData = file.readAll();
file.close();
try
{
pdf::PDFJBIG2Decoder decoder(data, QByteArray(), this);
pdf::PDFJBIG2Decoder decoder(fileContentData, QByteArray(), this);
QElapsedTimer timer;
timer.start();

View File

@ -17,6 +17,8 @@
win32-msvc*: {
QMAKE_CXXFLAGS += /std:c++latest /utf-8 /bigobj
QMAKE_CXXFLAGS_WARN_ON -= -W3
QMAKE_CXXFLAGS_WARN_ON += -W4 -wd5054 -wd4127 -wd4702
}
win32-*g++|unix: {

View File

@ -142,11 +142,11 @@ QModelIndex DifferencesDockWidget::findResultIndex(size_t index) const
const int childCount = model->rowCount(parentIndex);
for (int j = 0; j < childCount; ++j)
{
QModelIndex childIndex = parentIndex.child(j, 0);
QVariant data = childIndex.data(Qt::UserRole);
if (data.isValid())
QModelIndex childIndex = model->index(j, 0, parentIndex);
QVariant childUserData = childIndex.data(Qt::UserRole);
if (childUserData.isValid())
{
if (data.toULongLong() == index)
if (childUserData.toULongLong() == index)
{
return childIndex;
}
@ -294,11 +294,11 @@ void DifferencesDockWidget::onCurrentItemChanged(QTreeWidgetItem* current, QTree
}
pdf::PDFTemporaryValueChange guard(&m_disableChangeSelectedResultIndex, true);
QVariant data = current->data(0, Qt::UserRole);
QVariant childUserData = current->data(0, Qt::UserRole);
if (data.isValid())
if (childUserData.isValid())
{
m_diffNavigator->select(data.toULongLong());
m_diffNavigator->select(childUserData.toULongLong());
}
}

View File

@ -149,7 +149,7 @@ MainWindow::MainWindow(QWidget* parent) :
ui->menuToolbars->addAction(toolbar->toggleViewAction());
}
connect(&m_mapper, QOverload<int>::of(&QSignalMapper::mapped), this, &MainWindow::onMappedActionTriggered);
connect(&m_mapper, &QSignalMapper::mappedInt, this, &MainWindow::onMappedActionTriggered);
QList<QAction*> actions = findChildren<QAction*>();
for (QAction* action : actions)

View File

@ -173,7 +173,7 @@ MainWindow::MainWindow(QWidget* parent) :
ui->menuToolbars->addAction(toolbar->toggleViewAction());
}
connect(&m_mapper, QOverload<int>::of(&QSignalMapper::mapped), this, &MainWindow::onMappedActionTriggered);
connect(&m_mapper, &QSignalMapper::mappedInt, this, &MainWindow::onMappedActionTriggered);
connect(ui->documentItemsView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &MainWindow::updateActions);
QList<QAction*> actions = findChildren<QAction*>();
@ -743,11 +743,11 @@ void MainWindow::performOperation(Operation operation)
}
pdf::PDFDocumentWriter writer(nullptr);
pdf::PDFOperationResult result = writer.write(filename, document, isDocumentFileAlreadyExisting);
pdf::PDFOperationResult writeResult = writer.write(filename, document, isDocumentFileAlreadyExisting);
if (!result)
if (!writeResult)
{
QMessageBox::critical(this, tr("Error"), result.getErrorMessage());
QMessageBox::critical(this, tr("Error"), writeResult.getErrorMessage());
return;
}
}
@ -808,11 +808,14 @@ void MainWindow::performOperation(Operation operation)
{
QModelIndex rootIndex = ui->documentItemsView->rootIndex();
QModelIndex firstIndex = rootIndex.child(0, 0);
QModelIndex lastIndex = rootIndex.child(rootIndex.model()->rowCount() - 1, 0);
QItemSelection selection(firstIndex, lastIndex);
if (rootIndex.isValid())
{
QModelIndex firstIndex = rootIndex.model()->index(0, 0, rootIndex);
QModelIndex lastIndex = rootIndex.model()->index(rootIndex.model()->rowCount() - 1, 0, rootIndex);
QItemSelection selection(firstIndex, lastIndex);
ui->documentItemsView->selectionModel()->select(selection, QItemSelectionModel::Toggle);
ui->documentItemsView->selectionModel()->select(selection, QItemSelectionModel::Toggle);
}
break;
}

View File

@ -214,8 +214,7 @@ QPixmap PageItemDelegate::getPageImagePixmap(const PageGroupItem* item, QRect re
QMatrix matrix = pdf::PDFRenderer::createMediaBoxToDevicePointMatrix(rotatedMediaBox, drawRect, groupItem.pageAdditionalRotation);
QPainter painter(&pixmap);
painter.setWorldMatrixEnabled(true);
painter.setWorldMatrix(matrix);
painter.setWorldTransform(QTransform(matrix));
painter.translate(0, image.height());
painter.scale(1.0, -1.0);
painter.drawImage(0, 0, image);

View File

@ -1070,9 +1070,9 @@ bool PageItemModel::dropMimeData(const QMimeData* data, Qt::DropAction action, i
QDataStream stream(&serializedData, QIODevice::ReadOnly);
while (!stream.atEnd())
{
int row = -1;
stream >> row;
rows.push_back(row);
int currentRow = -1;
stream >> currentRow;
rows.push_back(currentRow);
}
std::sort(rows.begin(), rows.end());

View File

@ -181,18 +181,18 @@ PDFActionPtr PDFAction::parseImpl(const PDFObjectStorage* storage, PDFObject obj
std::vector<PDFObjectReference> annotations;
std::vector<QString> fieldNames;
const PDFObject& object = dictionary->get("T");
if (object.isReference())
const PDFObject& objectT = dictionary->get("T");
if (objectT.isReference())
{
annotations = { object.getReference() };
annotations = { objectT.getReference() };
}
else if (object.isString())
else if (objectT.isString())
{
fieldNames = { loader.readTextString(object, QString()) };
fieldNames = { loader.readTextString(objectT, QString()) };
}
else if (object.isArray())
else if (objectT.isArray())
{
const PDFArray* items = object.getArray();
const PDFArray* items = objectT.getArray();
for (size_t i = 0; i < items->getCount(); ++i)
{
const PDFObject& itemObject = items->getItem(i);
@ -219,9 +219,9 @@ PDFActionPtr PDFAction::parseImpl(const PDFObjectStorage* storage, PDFObject obj
std::pair<const char*, PDFActionNamed::NamedActionType>{ "LastPage", PDFActionNamed::NamedActionType::LastPage }
};
QByteArray name = loader.readNameFromDictionary(dictionary, "N");
QByteArray actionNamed = loader.readNameFromDictionary(dictionary, "N");
PDFActionNamed::NamedActionType actionType = loader.readEnumByName(dictionary->get("N"), types.cbegin(), types.cend(), PDFActionNamed::NamedActionType::Custom);
return PDFActionPtr(new PDFActionNamed(actionType, qMove(name)));
return PDFActionPtr(new PDFActionNamed(actionType, qMove(actionNamed)));
}
else if (name == "SetOCGState")
{

View File

@ -439,7 +439,7 @@ void PDFCreateLineTypeTool::drawPage(QPainter* painter,
QPointF mousePoint = pagePointToDevicePointMatrix.inverted().map(m_pickTool->getSnappedPoint());
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
QPen pen(m_strokeColor);
QBrush brush(m_fillColor, Qt::SolidPattern);
@ -552,7 +552,7 @@ void PDFCreateEllipseTool::drawPage(QPainter* painter,
QPointF mousePoint = pagePointToDevicePointMatrix.inverted().map(m_pickTool->getSnappedPoint());
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
QPen pen(m_strokeColor);
QBrush brush(m_fillColor, Qt::SolidPattern);
@ -624,7 +624,7 @@ void PDFCreateFreehandCurveTool::drawPage(QPainter* painter,
return;
}
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
QPen pen(m_strokeColor);
pen.setWidthF(m_penWidth);
@ -791,7 +791,7 @@ void PDFCreateStampTool::drawPage(QPainter* painter,
const PDFPage* page = getDocument()->getCatalog()->getPage(pageIndex);
QRectF rectangle = m_stampAnnotation.getRectangle();
QMatrix matrix = getProxy()->getAnnotationManager()->prepareTransformations(pagePointToDevicePointMatrix, painter->device(), m_stampAnnotation.getFlags(), page, rectangle);
painter->setWorldMatrix(matrix, true);
painter->setWorldTransform(QTransform(matrix), true);
AnnotationDrawParameters parameters;
parameters.painter = painter;

View File

@ -202,10 +202,10 @@ void PDFAlgorithmLongestCommonSubsequence<Iterator, Comparator>::perform()
const size_t index1 = i1 - 1;
const size_t index2 = i2 - 1;
auto it1 = std::next(m_it1, index1);
auto it2 = std::next(m_it2, index2);
auto cit1 = std::next(m_it1, index1);
auto cit2 = std::next(m_it2, index2);
if (m_comparator(*it1, *it2))
if (m_comparator(*cit1, *cit2))
{
item.index1 = index1;
item.index2 = index2;

View File

@ -1468,7 +1468,7 @@ void PDFAnnotationManager::drawAnnotationDirect(const PageAnnotation& annotation
{
PDFPainterStateGuard guard(painter);
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
AnnotationDrawParameters parameters;
parameters.painter = painter;
parameters.annotation = annotation.annotation.data();
@ -1758,8 +1758,8 @@ void PDFWidgetAnnotationManager::mousePressEvent(QWidget* widget, QMouseEvent* e
// Show context menu?
if (event->button() == Qt::RightButton)
{
PDFWidget* widget = m_proxy->getWidget();
std::vector<PDFInteger> currentPages = widget->getDrawWidget()->getCurrentPages();
PDFWidget* pdfWidget = m_proxy->getWidget();
std::vector<PDFInteger> currentPages = pdfWidget->getDrawWidget()->getCurrentPages();
if (!hasAnyPageAnnotation(currentPages))
{
@ -1797,7 +1797,7 @@ void PDFWidgetAnnotationManager::mousePressEvent(QWidget* widget, QMouseEvent* e
if (m_editableAnnotation.isValid())
{
QMenu menu(tr("Annotation"), widget);
QMenu menu(tr("Annotation"), pdfWidget);
QAction* showPopupAction = menu.addAction(tr("Show Popup Window"));
QAction* copyAction = menu.addAction(tr("Copy to Multiple Pages"));
QAction* editAction = menu.addAction(tr("Edit"));
@ -1807,7 +1807,7 @@ void PDFWidgetAnnotationManager::mousePressEvent(QWidget* widget, QMouseEvent* e
connect(editAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onEditAnnotation);
connect(deleteAction, &QAction::triggered, this, &PDFWidgetAnnotationManager::onDeleteAnnotation);
m_editableAnnotationGlobalPosition = widget->mapToGlobal(event->pos());
m_editableAnnotationGlobalPosition = pdfWidget->mapToGlobal(event->pos());
menu.exec(m_editableAnnotationGlobalPosition);
}
}
@ -2167,7 +2167,7 @@ void PDFWidgetAnnotationManager::createWidgetsForMarkupAnnotations(QWidget* pare
title = markupAnnotation->getSubject();
}
QString dateTimeString = markupAnnotation->getCreationDate().toLocalTime().toString(Qt::SystemLocaleLongDate);
QString dateTimeString = QLocale::system().toString(markupAnnotation->getCreationDate().toLocalTime(), QLocale::LongFormat);
title = QString("%1 (%2)").arg(title, dateTimeString).trimmed();
groupBox->setStyleSheet(style);
@ -2899,18 +2899,18 @@ void PDFHighlightAnnotation::draw(AnnotationDrawParameters& parameters) const
bool leadingEdge = true;
for (PDFReal x = lineGeometryInfo.transformedLine.p1().x(); x < lineGeometryInfo.transformedLine.p2().x(); x+= markSize)
{
QLineF line;
QLineF edgeLine;
if (leadingEdge)
{
line = QLineF(x, 0.0, x + markSize, markSize);
edgeLine = QLineF(x, 0.0, x + markSize, markSize);
}
else
{
// Falling edge
line = QLineF(x, markSize, x + markSize, 0.0);
edgeLine = QLineF(x, markSize, x + markSize, 0.0);
}
QLineF transformedLine = lineGeometryInfo.LCStoGCS.map(line);
QLineF transformedLine = lineGeometryInfo.LCStoGCS.map(edgeLine);
painter.drawLine(transformedLine);
leadingEdge = !leadingEdge;
}

View File

@ -613,8 +613,6 @@ PDFPageLabel PDFPageLabel::parse(PDFInteger pageIndex, const PDFObjectStorage* s
{
throw PDFException(PDFTranslationContext::tr("Expected page label dictionary."));
}
return PDFPageLabel();
}
const PDFDocumentSecurityStore::SecurityStoreItem* PDFDocumentSecurityStore::getItem(const QByteArray& hash) const
@ -646,10 +644,10 @@ PDFDocumentSecurityStore PDFDocumentSecurityStore::parse(const PDFObject& object
result.reserve(references.size());
for (const PDFObjectReference& reference : references)
{
PDFObject object = document->getObjectByReference(reference);
if (object.isStream())
PDFObject objectWithStream = document->getObjectByReference(reference);
if (objectWithStream.isStream())
{
result.emplace_back(document->getDecodedStream(object.getStream()));
result.emplace_back(document->getDecodedStream(objectWithStream.getStream()));
}
}

View File

@ -669,7 +669,6 @@ uint32_t PDFCCITTFaxDecoder::getCode(const PDFCCITTCode* codes, size_t codeCount
}
throw PDFException(PDFTranslationContext::tr("Invalid CCITT run length code word."));
return 0;
}
CCITT_2D_Code_Mode PDFCCITTFaxDecoder::get2DMode()
@ -692,7 +691,6 @@ CCITT_2D_Code_Mode PDFCCITTFaxDecoder::get2DMode()
}
throw PDFException(PDFTranslationContext::tr("Invalid CCITT 2D mode."));
return Invalid;
}
} // namespace pdf

View File

@ -825,10 +825,10 @@ cmsBool PDFLittleCMS::optimizePipeline(cmsPipeline** Lut, cmsUInt32Number Intent
s2.x0 = low;
s2.x1 = high;
for (cmsUInt32Number i = 0; i < gridPoints; ++i)
for (cmsUInt32Number iPt = 0; iPt < gridPoints; ++iPt)
{
const cmsFloat32Number x = i * factor;
s2.SampledPoints[i] = cmsEvalToneCurveFloat(curve, interpolate(x, 0.0, 1.0, low, high));
const cmsFloat32Number x = iPt * factor;
s2.SampledPoints[iPt] = cmsEvalToneCurveFloat(curve, interpolate(x, 0.0, 1.0, low, high));
}
s3.Type = type;

View File

@ -32,21 +32,6 @@
namespace pdf
{
static PDFColorComponent getDeterminant(const PDFColorComponentMatrix_3x3& matrix)
{
const PDFColorComponent a_11 = matrix.getValue(0, 0);
const PDFColorComponent a_12 = matrix.getValue(0, 1);
const PDFColorComponent a_13 = matrix.getValue(0, 2);
const PDFColorComponent a_21 = matrix.getValue(1, 0);
const PDFColorComponent a_22 = matrix.getValue(1, 1);
const PDFColorComponent a_23 = matrix.getValue(1, 2);
const PDFColorComponent a_31 = matrix.getValue(2, 0);
const PDFColorComponent a_32 = matrix.getValue(2, 1);
const PDFColorComponent a_33 = matrix.getValue(2, 2);
return -a_13* a_22 * a_31 + a_12 * a_23 * a_31 + a_13 * a_21 * a_32 - a_11 * a_23 * a_32 - a_12 * a_21 * a_33 + a_11 * a_22 * a_33;
}
PDFColorComponentMatrix_3x3 getInverseMatrix(const PDFColorComponentMatrix_3x3& matrix)
{
const PDFColorComponent a_11 = matrix.getValue(0, 0);
@ -388,7 +373,7 @@ QImage PDFAbstractColorSpace::getImage(const PDFImageData& imageData,
fillRGBBuffer(inputColors, outputColors.data(), intent, cms, reporter);
const unsigned char* transformedLine = outputColors.data();
for (unsigned int i = 0; i < imageWidth; ++i)
for (unsigned int ii = 0; ii < imageWidth; ++ii)
{
*outputLine++ = *transformedLine++;
*outputLine++ = *transformedLine++;
@ -1144,7 +1129,6 @@ PDFColorSpacePointer PDFAbstractColorSpace::createColorSpaceImpl(const PDFDictio
}
throw PDFException(PDFTranslationContext::tr("Invalid color space."));
return PDFColorSpacePointer();
}
PDFColorSpacePointer PDFAbstractColorSpace::createDeviceColorSpaceByNameImpl(const PDFDictionary* colorSpaceDictionary,
@ -1210,7 +1194,6 @@ PDFColorSpacePointer PDFAbstractColorSpace::createDeviceColorSpaceByNameImpl(con
}
throw PDFException(PDFTranslationContext::tr("Invalid color space."));
return PDFColorSpacePointer();
}
/// Conversion matrix from XYZ space to RGB space. Values are taken from this article:
@ -2168,9 +2151,9 @@ QColor PDFSeparationColorSpace::getColor(const PDFColor& color, const PDFCMS* cm
if (result)
{
PDFColor color;
std::for_each(outputColor.cbegin(), outputColor.cend(), [&color](double value) { color.push_back(static_cast<float>(value)); });
return m_alternateColorSpace->getColor(color, cms, intent, reporter, false);
PDFColor inputColor;
std::for_each(outputColor.cbegin(), outputColor.cend(), [&inputColor](double value) { inputColor.push_back(static_cast<float>(value)); });
return m_alternateColorSpace->getColor(inputColor, cms, intent, reporter, false);
}
else
{
@ -2403,9 +2386,9 @@ QColor PDFDeviceNColorSpace::getColor(const PDFColor& color, const PDFCMS* cms,
if (result)
{
PDFColor color;
std::for_each(outputColor.cbegin(), outputColor.cend(), [&color](double value) { color.push_back(static_cast<float>(value)); });
return m_alternateColorSpace->getColor(color, cms, intent, reporter, false);
PDFColor inputColor2;
std::for_each(outputColor.cbegin(), outputColor.cend(), [&inputColor2](double value) { inputColor2.push_back(static_cast<float>(value)); });
return m_alternateColorSpace->getColor(inputColor2, cms, intent, reporter, false);
}
else
{

View File

@ -244,7 +244,7 @@ void PDFDiff::performPageMatching(const std::vector<PDFDiffPageContext>& leftPre
auto it = pageMatches.find(left.pageIndex);
if (it != pageMatches.cend())
{
return it->second == right.pageIndex;
return it->second == static_cast<size_t>(right.pageIndex);
}
return false;

View File

@ -249,14 +249,14 @@ QRectF PDFDocumentDataLoaderDecorator::readRectangle(const PDFObject& object, co
std::array<PDFReal, 4> items;
for (size_t i = 0; i < 4; ++i)
{
const PDFObject& object = m_storage->getObject(array->getItem(i));
if (object.isReal())
const PDFObject& currentObject = m_storage->getObject(array->getItem(i));
if (currentObject.isReal())
{
items[i] = object.getReal();
items[i] = currentObject.getReal();
}
else if (object.isInt())
else if (currentObject.isInt())
{
items[i] = object.getInteger();
items[i] = currentObject.getInteger();
}
else
{

View File

@ -363,7 +363,7 @@ PDFDocumentManipulator::ProcessedPages PDFDocumentManipulator::collectObjectsAnd
documentBuilder.mergeNames(m_mergedObjects[MOT_Names], namesReference);
m_outlines[documentIndex] = outlineReference;
Q_ASSERT(references.size() == std::distance(it, itEnd));
Q_ASSERT(references.size() == size_t(std::distance(it, itEnd)));
auto referenceIt = references.begin();
for (auto currentIt = it; currentIt != itEnd; ++currentIt, ++referenceIt)

View File

@ -368,7 +368,6 @@ PDFDocumentReader::Result PDFDocumentReader::processSecurityHandler(const PDFObj
if (encryptObject.isReference())
{
encryptObjectReference = encryptObject.getReference();
PDFObjectReference encryptObjectReference = encryptObject.getReference();
if (static_cast<size_t>(encryptObjectReference.objectNumber) < objects.size() && objects[encryptObjectReference.objectNumber].generation == encryptObjectReference.generation)
{
encryptObject = objects[encryptObjectReference.objectNumber].object;
@ -506,12 +505,12 @@ void PDFDocumentReader::processObjectStreams(PDFXRefTable* xrefTable, PDFObjectS
const PDFInteger offset = objectNumberAndOffset[i].second;
parser.seek(offset);
PDFObject object = parser.getObject();
PDFObject currentObject = parser.getObject();
auto predicate = [objectNumber, objectStreamReference](const PDFXRefTable::Entry& entry) -> bool { return entry.reference.objectNumber == objectNumber && entry.objectStream == objectStreamReference; };
if (std::find_if(objectStreamEntries.cbegin(), objectStreamEntries.cend(), predicate) != objectStreamEntries.cend())
{
QMutexLocker lock(&m_mutex);
objects[objectNumber].object = qMove(object);
objects[objectNumber].object = qMove(currentObject);
}
else
{

View File

@ -758,7 +758,7 @@ QColor PDFDrawWidgetProxy::getPaperColor()
void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::Features features)
{
painter->fillRect(rect, Qt::lightGray);
QMatrix baseMatrix = painter->worldMatrix();
QTransform baseMatrix = painter->worldTransform();
// Use current paper color (it can be a bit different from white)
QColor paperColor = getPaperColor();
@ -787,8 +787,8 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::F
timer.start();
const PDFPage* page = m_controller->getDocument()->getCatalog()->getPage(item.pageIndex);
QMatrix matrix = createPagePointToDevicePointMatrix(page, placedRect) * baseMatrix;
compiledPage->draw(painter, page->getCropBox(), matrix, features, groupInfo.transparency);
QTransform matrix = QTransform(createPagePointToDevicePointMatrix(page, placedRect)) * baseMatrix;
compiledPage->draw(painter, page->getCropBox(), matrix.toAffine(), features, groupInfo.transparency);
PDFTextLayoutGetter layoutGetter = m_textLayoutCompiler->getTextLayoutLazy(item.pageIndex);
// Draw text blocks/text lines, if it is enabled
@ -848,7 +848,7 @@ void PDFDrawWidgetProxy::drawPages(QPainter* painter, QRect rect, PDFRenderer::F
for (IDocumentDrawInterface* drawInterface : m_drawInterfaces)
{
painter->save();
drawInterface->drawPage(painter, item.pageIndex, compiledPage, layoutGetter, matrix, drawInterfaceErrors);
drawInterface->drawPage(painter, item.pageIndex, compiledPage, layoutGetter, matrix.toAffine(), drawInterfaceErrors);
painter->restore();
}
}

View File

@ -170,14 +170,14 @@ PDFFileSpecification PDFFileSpecification::parse(const PDFObjectStorage* storage
const PDFArray* relatedFileArray = relatedFileArrayObject.getArray();
const size_t relatedFilesCount = relatedFileArray->getCount() / 2;
RelatedFiles& relatedFiles = result.m_relatedFiles[key];
relatedFiles.reserve(relatedFilesCount);
for (size_t i = 0; i < relatedFilesCount; ++i)
RelatedFiles& currentRelatedFiles = result.m_relatedFiles[key];
currentRelatedFiles.reserve(relatedFilesCount);
for (size_t ii = 0; ii < relatedFilesCount; ++ii)
{
RelatedFile relatedFile;
relatedFile.name = loader.readString(relatedFileArray->getItem(2 * i));
relatedFile.fileReference = loader.readReference(relatedFileArray->getItem(2 * i + 1));
relatedFiles.emplace_back(qMove(relatedFile));
relatedFile.name = loader.readString(relatedFileArray->getItem(2 * ii));
relatedFile.fileReference = loader.readReference(relatedFileArray->getItem(2 * ii + 1));
currentRelatedFiles.emplace_back(qMove(relatedFile));
}
}
}
@ -499,9 +499,9 @@ PDFCollectionNavigator PDFCollectionNavigator::parse(const PDFObjectStorage* sto
PDFObject layoutObject = storage->getObject(dictionary->get("Layout"));
if (layoutObject.isArray())
{
for (const PDFObject& object : *layoutObject.getArray())
for (const PDFObject& objectInLayourObjects : *layoutObject.getArray())
{
result.m_layouts |= getLayout(object);
result.m_layouts |= getLayout(objectInLayourObjects);
}
}
else

View File

@ -1330,24 +1330,24 @@ PDFFontPointer PDFFont::createFont(const PDFObject& object, const PDFDocument* d
// Try to load data from the encoding
if (!FT_Set_Charmap(face, charMap))
{
for (size_t i = 0; i < simpleFontEncodingTable.size(); ++i)
for (size_t iTable = 0; iTable < simpleFontEncodingTable.size(); ++iTable)
{
FT_UInt glyphIndex = FT_Get_Char_Index(face, static_cast<FT_ULong>(i));
FT_UInt glyphIndex = FT_Get_Char_Index(face, static_cast<FT_ULong>(iTable));
if (glyphIndex == 0)
{
glyphIndex = FT_Get_Char_Index(face, static_cast<FT_ULong>(i + 0xF000));
glyphIndex = FT_Get_Char_Index(face, static_cast<FT_ULong>(iTable + 0xF000));
}
if (glyphIndex == 0)
{
glyphIndex = FT_Get_Char_Index(face, static_cast<FT_ULong>(i + 0xF100));
glyphIndex = FT_Get_Char_Index(face, static_cast<FT_ULong>(iTable + 0xF100));
}
if (glyphIndex > 0)
{
// Fill the glyph index array
glyphIndexArray[i] = glyphIndex;
glyphIndexArray[iTable] = glyphIndex;
// Set mapping to unicode
char buffer[128] = { };
@ -1362,7 +1362,7 @@ PDFFontPointer PDFFont::createFont(const PDFObject& object, const PDFDocument* d
if (!character.isNull())
{
encoding = PDFEncoding::Encoding::Custom;
simpleFontEncodingTable[i] = character;
simpleFontEncodingTable[iTable] = character;
}
}
}
@ -1563,21 +1563,21 @@ PDFFontPointer PDFFont::createFont(const PDFObject& object, const PDFDocument* d
}
const PDFDictionary* charProcsDictionary = charProcs.getDictionary();
PDFInteger firstChar = fontLoader.readIntegerFromDictionary(fontDictionary, "FirstChar", -1);
PDFInteger lastChar = fontLoader.readIntegerFromDictionary(fontDictionary, "LastChar", -1);
const PDFInteger firstCharF3 = fontLoader.readIntegerFromDictionary(fontDictionary, "FirstChar", -1);
const PDFInteger lastCharF3 = fontLoader.readIntegerFromDictionary(fontDictionary, "LastChar", -1);
if (firstChar < 0 || lastChar > 255 || firstChar > lastChar)
if (firstCharF3 < 0 || lastCharF3 > 255 || firstCharF3 > lastCharF3)
{
throw PDFException(PDFTranslationContext::tr("Invalid Type 3 font character range (from %1 to %2).").arg(firstChar).arg(lastChar));
throw PDFException(PDFTranslationContext::tr("Invalid Type 3 font character range (from %1 to %2).").arg(firstCharF3).arg(lastCharF3));
}
const PDFObject& encoding = document->getObject(fontDictionary->get("Encoding"));
if (!encoding.isDictionary())
const PDFObject& encodingF3 = document->getObject(fontDictionary->get("Encoding"));
if (!encodingF3.isDictionary())
{
throw PDFException(PDFTranslationContext::tr("Invalid Type 3 font encoding."));
}
const PDFDictionary* encodingDictionary = encoding.getDictionary();
const PDFDictionary* encodingDictionary = encodingF3.getDictionary();
const PDFObject& differences = document->getObject(encodingDictionary->get("Differences"));
if (!differences.isArray())
{
@ -1631,8 +1631,8 @@ PDFFontPointer PDFFont::createFont(const PDFObject& object, const PDFDocument* d
toUnicodeCMap = PDFFontCMap::createFromData(decodedStream);
}
std::vector<PDFReal> widths = fontLoader.readNumberArrayFromDictionary(fontDictionary, "Widths");
return PDFFontPointer(new PDFType3Font(qMove(fontDescriptor), firstChar, lastChar, fontMatrix, qMove(characterContentStreams), qMove(widths), document->getObject(fontDictionary->get("Resources")), qMove(toUnicodeCMap)));
std::vector<PDFReal> widthsF3 = fontLoader.readNumberArrayFromDictionary(fontDictionary, "Widths");
return PDFFontPointer(new PDFType3Font(qMove(fontDescriptor), firstCharF3, lastCharF3, fontMatrix, qMove(characterContentStreams), qMove(widthsF3), document->getObject(fontDictionary->get("Resources")), qMove(toUnicodeCMap)));
}
default:
@ -1974,7 +1974,6 @@ PDFFontCMap PDFFontCMap::createFromName(const QByteArray& name)
}
throw PDFException(PDFTranslationContext::tr("Can't load CID font mapping named '%1'.").arg(QString::fromLatin1(name)));
return PDFFontCMap();
}
PDFFontCMap PDFFontCMap::createFromData(const QByteArray& data)
@ -2014,7 +2013,6 @@ PDFFontCMap PDFFontCMap::createFromData(const QByteArray& data)
}
throw PDFException(PDFTranslationContext::tr("Can't fetch code from CMap definition."));
return std::pair<unsigned int, unsigned int>();
};
auto fetchCID = [] (const PDFLexicalAnalyzer::Token& currentToken) -> CID
@ -2025,7 +2023,6 @@ PDFFontCMap PDFFontCMap::createFromData(const QByteArray& data)
}
throw PDFException(PDFTranslationContext::tr("Can't fetch CID from CMap definition."));
return 0;
};
auto fetchUnicode = [](const PDFLexicalAnalyzer::Token& currentToken) -> CID
@ -2213,7 +2210,7 @@ std::vector<CID> PDFFontCMap::interpret(const QByteArray& byteArray) const
result.reserve(byteArray.size() / m_maxKeyLength);
unsigned int value = 0;
int scannedBytes = 0;
unsigned int scannedBytes = 0;
for (int i = 0, size = byteArray.size(); i < size; ++i)
{

View File

@ -1355,7 +1355,7 @@ void PDFFormManager::wheelEvent(QWidget* widget, QWheelEvent* event)
return;
}
MouseEventInfo info = getMouseEventInfo(widget, event->pos());
MouseEventInfo info = getMouseEventInfo(widget, event->position().toPoint());
if (info.isValid())
{
Q_ASSERT(info.editor);
@ -1965,13 +1965,13 @@ void PDFFormFieldAbstractButtonEditor::mousePressEvent(QWidget* widget, QMouseEv
void PDFFormFieldPushButtonEditor::click()
{
if (const PDFAction* action = m_formManager->getAction(PDFAnnotationAdditionalActions::MousePressed, getFormWidget()))
if (const PDFAction* mousePressAction = m_formManager->getAction(PDFAnnotationAdditionalActions::MousePressed, getFormWidget()))
{
emit m_formManager->actionTriggered(action);
emit m_formManager->actionTriggered(mousePressAction);
}
else if (const PDFAction* action = m_formManager->getAction(PDFAnnotationAdditionalActions::Default, getFormWidget()))
else if (const PDFAction* defaultAction = m_formManager->getAction(PDFAnnotationAdditionalActions::Default, getFormWidget()))
{
emit m_formManager->actionTriggered(action);
emit m_formManager->actionTriggered(defaultAction);
}
}
@ -2707,14 +2707,14 @@ void PDFListBoxPseudowidget::draw(AnnotationDrawParameters& parameters, bool edi
if (edit)
{
pdf::PDFPainterStateGuard guard(painter);
pdf::PDFPainterStateGuard guard2(painter);
painter->setPen(getAdjustedColor(Qt::black));
painter->setBrush(Qt::NoBrush);
painter->drawRect(parameters.boundingRectangle);
}
painter->setClipRect(parameters.boundingRectangle, Qt::IntersectClip);
painter->setWorldMatrix(matrix, true);
painter->setWorldTransform(QTransform(matrix), true);
painter->setPen(getAdjustedColor(m_textColor));
painter->setFont(m_font);
@ -2739,7 +2739,7 @@ void PDFListBoxPseudowidget::draw(AnnotationDrawParameters& parameters, bool edi
if (edit && m_currentIndex == i)
{
pdf::PDFPainterStateGuard guard(painter);
pdf::PDFPainterStateGuard guard2(painter);
painter->setBrush(Qt::NoBrush);
painter->setPen(Qt::DotLine);
painter->drawRect(rect);

View File

@ -326,8 +326,6 @@ PDFFunctionPtr PDFFunction::createFunctionImpl(const PDFDocument* document, cons
throw PDFException(PDFParsingContext::tr("Invalid function type: %1.").arg(functionType));
}
}
return nullptr;
}
PDFSampledFunction::PDFSampledFunction(uint32_t m, uint32_t n,

View File

@ -82,7 +82,7 @@ void PDFIconTheme::prepareTheme()
stream.setGenerateByteOrderMark(true);
for (const QString& text : infoList)
{
stream << text << endl;
stream << text << Qt::endl;
}
}
file.close();

View File

@ -139,18 +139,18 @@ PDFImage PDFImage::createImage(const PDFDocument* document,
}
// We must alter decode, because it has opposite meaning (it is transparency)
std::vector<PDFReal> decode = softMaskImage.m_imageData.getDecode();
if (decode.size() < 2)
std::vector<PDFReal> adjustedDecode = softMaskImage.m_imageData.getDecode();
if (adjustedDecode.size() < 2)
{
decode = { 0.0, 1.0};
adjustedDecode = { 0.0, 1.0};
}
std::swap(decode[0], decode[1]);
std::swap(adjustedDecode[0], adjustedDecode[1]);
// Create soft mask from image
maskingType = PDFImageData::MaskingType::SoftMask;
image.m_softMask = qMove(softMaskImage.m_imageData);
image.m_softMask.setMaskingType(PDFImageData::MaskingType::None);
image.m_softMask.setDecode(qMove(decode));
image.m_softMask.setDecode(qMove(adjustedDecode));
}
}
else if (dictionary->hasKey("SMask"))
@ -409,12 +409,12 @@ PDFImage PDFImage::createImage(const PDFDocument* document,
opj_set_warning_handler(codec, warningCallback, &imageData);
opj_set_error_handler(codec, errorCallback, &imageData);
opj_stream_t* stream = opj_stream_create(content.size(), OPJ_TRUE);
opj_stream_set_user_data(stream, &imageData, nullptr);
opj_stream_set_user_data_length(stream, content.size());
opj_stream_set_read_function(stream, &PDFJPEG2000ImageData::read);
opj_stream_set_seek_function(stream, &PDFJPEG2000ImageData::seek);
opj_stream_set_skip_function(stream, &PDFJPEG2000ImageData::skip);
opj_stream_t* opjStream = opj_stream_create(content.size(), OPJ_TRUE);
opj_stream_set_user_data(opjStream, &imageData, nullptr);
opj_stream_set_user_data_length(opjStream, content.size());
opj_stream_set_read_function(opjStream, &PDFJPEG2000ImageData::read);
opj_stream_set_seek_function(opjStream, &PDFJPEG2000ImageData::seek);
opj_stream_set_skip_function(opjStream, &PDFJPEG2000ImageData::skip);
// Reset the stream position, clear the data
imageData.position = 0;
@ -427,13 +427,13 @@ PDFImage PDFImage::createImage(const PDFDocument* document,
{
// Try to read the header
if (opj_read_header(stream, codec, &jpegImage))
if (opj_read_header(opjStream, codec, &jpegImage))
{
if (opj_set_decode_area(codec, jpegImage, decompressParameters.DA_x0, decompressParameters.DA_y0, decompressParameters.DA_x1, decompressParameters.DA_y1))
{
if (opj_decode(codec, stream, jpegImage))
if (opj_decode(codec, opjStream, jpegImage))
{
if (opj_end_decompress(codec, stream))
if (opj_end_decompress(codec, opjStream))
{
}
@ -442,10 +442,10 @@ PDFImage PDFImage::createImage(const PDFDocument* document,
}
}
opj_stream_destroy(stream);
opj_stream_destroy(opjStream);
opj_destroy_codec(codec);
stream = nullptr;
opjStream = nullptr;
codec = nullptr;
// If we have a valid image, then adjust it

View File

@ -678,11 +678,11 @@ QVariant PDFThumbnailsItemModel::data(const QModelIndex& index, int role) const
return QVariant();
}
const int page = index.row();
const int pageIndex = index.row();
switch (role)
{
case Qt::DisplayRole:
return QString::number(page + 1);
return QString::number(pageIndex + 1);
case Qt::DecorationRole:
{

View File

@ -2408,7 +2408,7 @@ void PDFJBIG2Decoder::processHalftoneRegion(const PDFJBIG2SegmentHeader& header)
}
}
if (PLANE.getWidth() != HGW || PLANE.getHeight() != HGH)
if (uint32_t(PLANE.getWidth()) != HGW || uint32_t(PLANE.getHeight()) != HGH)
{
throw PDFException(PDFTranslationContext::tr("JBIG2 invalid halftone grayscale bit plane image."));
}
@ -2508,8 +2508,8 @@ void PDFJBIG2Decoder::processGenericRegion(const PDFJBIG2SegmentHeader& header)
QByteArray endSequence(2, 0);
if (!parameters.MMR)
{
endSequence[0] = char(0xFF);
endSequence[1] = char(0xAC);
endSequence[0] = unsigned char(0xFF);
endSequence[1] = unsigned char(0xAC);
}
int endPosition = stream->indexOf(endSequence);
@ -2610,7 +2610,7 @@ void PDFJBIG2Decoder::processGenericRefinementRegion(const PDFJBIG2SegmentHeader
throw PDFException(PDFTranslationContext::tr("JBIG2 - invalid referred segments (%1) for generic refinement region.").arg(referredSegments.size()));
}
if (GRREFERENCE.getWidth() != field.width || GRREFERENCE.getHeight() != field.height)
if (uint32_t(GRREFERENCE.getWidth()) != field.width || uint32_t(GRREFERENCE.getHeight()) != field.height)
{
throw PDFException(PDFTranslationContext::tr("JBIG2 - invalid referred bitmap size [%1 x %2] instead of [%3 x %4] for generic refinement region.").arg(GRREFERENCE.getWidth()).arg(GRREFERENCE.getHeight()).arg(field.width).arg(field.height));
}
@ -2843,7 +2843,6 @@ PDFJBIG2Bitmap PDFJBIG2Decoder::getBitmap(const uint32_t segmentIndex, bool remo
}
throw PDFException(PDFTranslationContext::tr("JBIG2 bitmap segment %1 not found.").arg(segmentIndex));
return result;
}
PDFJBIG2Bitmap PDFJBIG2Decoder::readBitmap(PDFJBIG2BitmapDecodingParameters& parameters)
@ -3147,8 +3146,6 @@ PDFJBIG2Bitmap PDFJBIG2Decoder::readBitmap(PDFJBIG2BitmapDecodingParameters& par
return bitmap;
}
return PDFJBIG2Bitmap();
}
PDFJBIG2Bitmap PDFJBIG2Decoder::readRefinementBitmap(PDFJBIG2BitmapRefinementDecodingParameters& parameters)
@ -3635,8 +3632,6 @@ int32_t PDFJBIG2Decoder::checkInteger(std::optional<int32_t> value)
{
throw PDFException(PDFTranslationContext::tr("JBIG2 can't read integer."));
}
return 0;
}
PDFJBIG2Bitmap::PDFJBIG2Bitmap() :
@ -3942,9 +3937,9 @@ std::vector<const PDFJBIG2Bitmap*> PDFJBIG2ReferencedSegments::getSymbolBitmaps(
for (const PDFJBIG2SymbolDictionary* dictionary : symbolDictionaries)
{
const std::vector<PDFJBIG2Bitmap>& bitmaps = dictionary->getBitmaps();
result.reserve(result.size() + bitmaps.size());
for (const PDFJBIG2Bitmap& bitmap : bitmaps)
const std::vector<PDFJBIG2Bitmap>& dictionaryBitmaps = dictionary->getBitmaps();
result.reserve(result.size() + dictionaryBitmaps.size());
for (const PDFJBIG2Bitmap& bitmap : dictionaryBitmaps)
{
result.push_back(&bitmap);
}
@ -3959,9 +3954,9 @@ std::vector<const PDFJBIG2Bitmap*> PDFJBIG2ReferencedSegments::getPatternBitmaps
for (const PDFJBIG2PatternDictionary* dictionary : patternDictionaries)
{
const std::vector<PDFJBIG2Bitmap>& bitmaps = dictionary->getBitmaps();
result.reserve(result.size() + bitmaps.size());
for (const PDFJBIG2Bitmap& bitmap : bitmaps)
const std::vector<PDFJBIG2Bitmap>& dictionaryBitmaps = dictionary->getBitmaps();
result.reserve(result.size() + dictionaryBitmaps.size());
for (const PDFJBIG2Bitmap& bitmap : dictionaryBitmaps)
{
result.push_back(&bitmap);
}
@ -3980,8 +3975,6 @@ PDFJBIG2HuffmanDecoder PDFJBIG2ReferencedSegments::getUserTable(PDFBitReader* re
{
throw PDFException(PDFTranslationContext::tr("JBIG2 invalid user huffman code table."));
}
return PDFJBIG2HuffmanDecoder();
}
} // namespace pdf

View File

@ -476,11 +476,11 @@ PDFObject PDFObjectManipulator::removeDuplicitReferencesInArrays(PDFObject objec
PDFArray array;
std::set<PDFObjectReference> usedReferences;
for (const PDFObject& object : *object.getArray())
for (const PDFObject& arrayObject : *object.getArray())
{
if (object.isReference())
if (arrayObject.isReference())
{
PDFObjectReference reference = object.getReference();
PDFObjectReference reference = arrayObject.getReference();
if (!usedReferences.count(reference))
{
usedReferences.insert(reference);
@ -489,7 +489,7 @@ PDFObject PDFObjectManipulator::removeDuplicitReferencesInArrays(PDFObject objec
}
else
{
array.appendItem(removeDuplicitReferencesInArrays(object));
array.appendItem(removeDuplicitReferencesInArrays(arrayObject));
}
}

View File

@ -343,9 +343,9 @@ void PDFObjectClassifier::classify(const PDFDocument* document)
if (const PDFDictionary* xobjectDictionary = document->getDictionaryFromObject(resourcesDictionary->get("XObject")))
{
const size_t count = xobjectDictionary->getCount();
for (size_t i = 0; i < count; ++i)
for (size_t xObjectIndex = 0; xObjectIndex < count; ++xObjectIndex)
{
const PDFObject& item = xobjectDictionary->getValue(i);
const PDFObject& item = xobjectDictionary->getValue(xObjectIndex);
if (item.isReference() && hasObject(item.getReference()))
{
if (const PDFDictionary* xobjectItemDictionary = document->getDictionaryFromObject(item))

View File

@ -37,10 +37,10 @@ PDFOptionalContentProperties PDFOptionalContentProperties::create(const PDFDocum
for (const PDFObjectReference& reference : properties.m_allOptionalContentGroups)
{
const PDFObject& object = document->getStorage().getObject(reference);
if (!object.isNull())
const PDFObject& currentObject = document->getStorage().getObject(reference);
if (!currentObject.isNull())
{
properties.m_optionalContentGroups[reference] = PDFOptionalContentGroup::create(document, object);
properties.m_optionalContentGroups[reference] = PDFOptionalContentGroup::create(document, currentObject);
}
}
@ -548,7 +548,6 @@ PDFOptionalContentMembershipObject PDFOptionalContentMembershipObject::create(co
{
// Something strange occured - either we should have an array, or we should have a reference to the OCG
throw PDFException(PDFTranslationContext::tr("Invalid optional content visibility expression."));
return std::unique_ptr<Node>(nullptr);
}
};

View File

@ -35,22 +35,22 @@ PDFPageInheritableAttributes PDFPageInheritableAttributes::parse(const PDFPageIn
{
PDFDocumentDataLoaderDecorator loader(storage);
const PDFDictionary* dictionary = dereferencedDictionary.getDictionary();
if (dictionary->hasKey("MediaBox"))
const PDFDictionary* pageAttributesDictionary = dereferencedDictionary.getDictionary();
if (pageAttributesDictionary->hasKey("MediaBox"))
{
result.m_mediaBox = loader.readRectangle(dictionary->get("MediaBox"), result.getMediaBox());
result.m_mediaBox = loader.readRectangle(pageAttributesDictionary->get("MediaBox"), result.getMediaBox());
}
if (dictionary->hasKey("CropBox"))
if (pageAttributesDictionary->hasKey("CropBox"))
{
result.m_cropBox = loader.readRectangle(dictionary->get("CropBox"), result.getCropBox());
result.m_cropBox = loader.readRectangle(pageAttributesDictionary->get("CropBox"), result.getCropBox());
}
if (dictionary->hasKey("Resources"))
if (pageAttributesDictionary->hasKey("Resources"))
{
result.m_resources = dictionary->get("Resources");
result.m_resources = pageAttributesDictionary->get("Resources");
}
if (dictionary->hasKey("Rotate"))
if (pageAttributesDictionary->hasKey("Rotate"))
{
PDFInteger rotation = loader.readInteger(dictionary->get("Rotate"), 0);
PDFInteger rotation = loader.readInteger(pageAttributesDictionary->get("Rotate"), 0);
// PDF specification says, that angle can be multiple of 90, so we can have here
// for example, 450° (90° * 5), or even negative angles. We must get rid of them.

View File

@ -358,7 +358,7 @@ void PDFCreatePCElementImageTool::drawPage(QPainter* painter,
{
PDFPainterStateGuard guard(painter);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(Qt::DotLine);
painter->setBrush(Qt::NoBrush);
@ -492,7 +492,7 @@ void PDFCreatePCElementDotTool::drawPage(QPainter* painter,
QPointF point = pagePointToDevicePointMatrix.inverted().map(m_pickTool->getSnappedPoint());
PDFPainterStateGuard guard(painter);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(m_element->getPen());
painter->setBrush(m_element->getBrush());
@ -708,7 +708,7 @@ void PDFCreatePCElementTextTool::drawPage(QPainter* painter,
parameters.key.first = PDFAppeareanceStreams::Appearance::Normal;
parameters.invertColors = getProxy()->getFeatures().testFlag(PDFRenderer::InvertColors);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
m_textEditWidget->draw(parameters, true);
}
}

View File

@ -282,7 +282,7 @@ void PDFPageContentElementRectangle::drawPage(QPainter* painter,
}
PDFPainterStateGuard guard(painter);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setRenderHint(QPainter::Antialiasing);
@ -965,7 +965,7 @@ void PDFPageContentElementLine::drawPage(QPainter* painter,
}
PDFPainterStateGuard guard(painter);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setRenderHint(QPainter::Antialiasing);
@ -1147,7 +1147,7 @@ void PDFPageContentImageElement::drawPage(QPainter* painter,
}
PDFPainterStateGuard guard(painter);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setRenderHint(QPainter::Antialiasing);
if (m_renderer->isValid())
@ -1274,7 +1274,7 @@ void PDFPageContentElementDot::drawPage(QPainter* painter,
}
PDFPainterStateGuard guard(painter);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(getPen());
painter->setBrush(getBrush());
@ -1362,7 +1362,7 @@ void PDFPageContentElementFreehandCurve::drawPage(QPainter* painter,
}
PDFPainterStateGuard guard(painter);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setRenderHint(QPainter::Antialiasing);
@ -2133,11 +2133,11 @@ void PDFPageContentElementManipulator::performOperation(Operation operation)
qreal yTop = representativeRect.bottom();
for (PDFPageContentElement* element : manipulatedElements)
{
const PDFInteger row = elementToRow[element];
const PDFInteger column = elementToColumn[element];
const PDFInteger currentRow = elementToRow[element];
const PDFInteger currentColumn = elementToColumn[element];
const qreal xOffset = cellOffsetX[column];
const qreal yOffset = cellOffsetY[row];
const qreal xOffset = cellOffsetX[currentColumn];
const qreal yOffset = cellOffsetY[currentRow];
QRectF boundingBox = element->getBoundingBox();
QPointF offset(xLeft + xOffset - boundingBox.left(), yTop - yOffset - boundingBox.bottom());
@ -2395,7 +2395,7 @@ void PDFPageContentElementTextBox::drawPage(QPainter* painter,
}
PDFPainterStateGuard guard(painter);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->setPen(getPen());
painter->setBrush(getBrush());
painter->setFont(font);

View File

@ -627,7 +627,6 @@ void PDFPageContentProcessor::processContent(const QByteArray& content)
dataLength = -1;
// We will try to use stream filter hint
PDFDocumentDataLoaderDecorator loader(m_document);
QByteArray filterName = loader.readNameFromDictionary(dictionary, "Filter");
if (!filterName.isEmpty())
{
@ -1088,14 +1087,14 @@ void PDFPageContentProcessor::processTillingPatternPainting(const PDFTilingPatte
{
for (PDFInteger row = 0; row < rows; ++row)
{
PDFPageContentProcessorGraphicStateSaveRestoreGuard guard(this);
PDFPageContentProcessorGraphicStateSaveRestoreGuard guard3(this);
QMatrix transformationMatrix = baseTransformationMatrix;
transformationMatrix.translate(tilingArea.left(), tilingArea.top());
transformationMatrix.translate(column * xStep, row * yStep);
QMatrix patternMatrix = transformationMatrix * m_pagePointToDevicePointMatrix;
PDFTemporaryValueChange patternMatrixGuard(&m_patternBaseMatrix, patternMatrix);
QMatrix currentPatternMatrix = transformationMatrix * m_pagePointToDevicePointMatrix;
PDFTemporaryValueChange patternMatrixGuard(&m_patternBaseMatrix, currentPatternMatrix);
m_graphicState.setCurrentTransformationMatrix(transformationMatrix);
updateGraphicState();
@ -1611,8 +1610,6 @@ QPointF PDFPageContentProcessor::getCurrentPoint() const
{
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Current point of path is not set. Path is empty."));
}
return QPointF();
}
void PDFPageContentProcessor::updateGraphicState()
@ -2129,8 +2126,6 @@ PDFReal PDFPageContentProcessor::readOperand<PDFReal>(size_t index) const
{
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Can't read operand (real number) on index %1. Only %2 operands provided.").arg(index + 1).arg(m_operands.size()));
}
return 0.0;
}
template<>
@ -2153,8 +2148,6 @@ PDFInteger PDFPageContentProcessor::readOperand<PDFInteger>(size_t index) const
{
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Can't read operand (integer) on index %1. Only %2 operands provided.").arg(index + 1).arg(m_operands.size()));
}
return 0;
}
template<>
@ -2177,8 +2170,6 @@ PDFPageContentProcessor::PDFOperandName PDFPageContentProcessor::readOperand<PDF
{
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Can't read operand (name) on index %1. Only %2 operands provided.").arg(index + 1).arg(m_operands.size()));
}
return PDFOperandName();
}
@ -2202,8 +2193,6 @@ PDFPageContentProcessor::PDFOperandString PDFPageContentProcessor::readOperand<P
{
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Can't read operand (string) on index %1. Only %2 operands provided.").arg(index + 1).arg(m_operands.size()));
}
return PDFOperandString();
}
void PDFPageContentProcessor::operatorMoveCurrentPoint(PDFReal x, PDFReal y)
@ -3051,10 +3040,10 @@ void PDFPageContentProcessor::operatorPaintXObject(PDFOperandName name)
// According to the specification, XObjects are skipped entirely, as no operator was invoked.
if (streamDictionary->hasKey("OC"))
{
const PDFObject& object = streamDictionary->get("OC");
if (object.isReference())
const PDFObject& optionalContentObject = streamDictionary->get("OC");
if (optionalContentObject.isReference())
{
if (isContentSuppressedByOC(object.getReference()))
if (isContentSuppressedByOC(optionalContentObject.getReference()))
{
return;
}
@ -3304,7 +3293,7 @@ void PDFPageContentProcessor::drawText(const TextSequence& textSequence)
if (item.characterContentStream && (fill || stroke))
{
PDFPageContentProcessorStateGuard guard(this);
PDFPageContentProcessorStateGuard guard2(this);
// We must clear operands, because we are processing a new content stream
m_operands.clear();

View File

@ -863,8 +863,6 @@ private:
{
throw PDFRendererException(RenderErrorType::Error, PDFTranslationContext::tr("Invalid color component count. Provided %1, required %2.").arg(operandCount).arg(colorSpaceComponentCount));
}
return QColor();
}
/// Converts PDF line cap to Qt's pen cap style. Function always succeeds,

View File

@ -329,9 +329,9 @@ void PDFPainter::performImagePainting(const QImage& image)
// 1) Transformed rectangle is not skewed or deformed (so vectors (0, 1) and (1, 0) are orthogonal)
// 2) We are shrinking the image
QMatrix matrix = m_painter->worldMatrix();
QLineF mappedWidthVector = matrix.map(QLineF(0, 0, 1, 0));
QLineF mappedHeightVector = matrix.map(QLineF(0, 0, 0, 1));
QTransform transform = m_painter->worldTransform();
QLineF mappedWidthVector = transform.map(QLineF(0, 0, 1, 0));
QLineF mappedHeightVector = transform.map(QLineF(0, 0, 0, 1));
qreal angle = mappedWidthVector.angleTo(mappedHeightVector);
if (qFuzzyCompare(angle, 90.0))
{
@ -351,15 +351,15 @@ void PDFPainter::performImagePainting(const QImage& image)
}
}
QMatrix imageTransform(1.0 / adjustedImage.width(), 0, 0, 1.0 / adjustedImage.height(), 0, 0);
QMatrix worldMatrix = imageTransform * m_painter->worldMatrix();
QTransform imageTransform(1.0 / adjustedImage.width(), 0, 0, 1.0 / adjustedImage.height(), 0, 0);
QTransform worldTransform = imageTransform * m_painter->worldTransform();
// Because Qt uses opposite axis direction than PDF, then we must transform the y-axis
// to the opposite (so the image is then unchanged)
worldMatrix.translate(0, adjustedImage.height());
worldMatrix.scale(1, -1);
worldTransform.translate(0, adjustedImage.height());
worldTransform.scale(1, -1);
m_painter->setWorldMatrix(worldMatrix);
m_painter->setWorldTransform(worldTransform);
m_painter->drawImage(0, 0, adjustedImage);
m_painter->restore();
@ -368,7 +368,7 @@ void PDFPainter::performImagePainting(const QImage& image)
void PDFPainter::performMeshPainting(const PDFMesh& mesh)
{
m_painter->save();
m_painter->setWorldMatrix(QMatrix());
m_painter->setWorldTransform(QTransform());
mesh.paint(m_painter, getEffectiveFillingAlpha());
m_painter->restore();
}
@ -391,7 +391,7 @@ void PDFPainter::performRestoreGraphicState(ProcessOrder order)
void PDFPainter::setWorldMatrix(const QMatrix& matrix)
{
m_painter->setWorldMatrix(matrix, false);
m_painter->setWorldTransform(QTransform(matrix), false);
}
void PDFPainter::setCompositionMode(QPainter::CompositionMode mode)
@ -514,7 +514,7 @@ void PDFPrecompiledPage::draw(QPainter* painter,
Q_ASSERT(pagePointToDevicePointMatrix.isInvertible());
painter->save();
painter->setWorldMatrix(QMatrix());
painter->setWorldTransform(QTransform());
painter->setOpacity(opacity);
if (features.testFlag(PDFRenderer::ClipToCropBox))
@ -554,15 +554,15 @@ void PDFPrecompiledPage::draw(QPainter* painter,
painter->save();
QMatrix imageTransform(1.0 / image.width(), 0, 0, 1.0 / image.height(), 0, 0);
QMatrix worldMatrix = imageTransform * painter->worldMatrix();
QTransform imageTransform(1.0 / image.width(), 0, 0, 1.0 / image.height(), 0, 0);
QTransform worldTransform = imageTransform * painter->worldTransform();
// Jakub Melka: Because Qt uses opposite axis direction than PDF, then we must transform the y-axis
// to the opposite (so the image is then unchanged)
worldMatrix.translate(0, image.height());
worldMatrix.scale(1, -1);
worldTransform.translate(0, image.height());
worldTransform.scale(1, -1);
painter->setWorldMatrix(worldMatrix);
painter->setWorldTransform(worldTransform);
painter->drawImage(0, 0, image);
painter->restore();
break;
@ -573,7 +573,7 @@ void PDFPrecompiledPage::draw(QPainter* painter,
const MeshPaintData& data = m_meshes[instruction.dataIndex];
painter->save();
painter->setWorldMatrix(pagePointToDevicePointMatrix);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix));
data.mesh.paint(painter, data.alpha);
painter->restore();
break;
@ -599,7 +599,7 @@ void PDFPrecompiledPage::draw(QPainter* painter,
case InstructionType::SetWorldMatrix:
{
painter->setWorldMatrix(m_matrices[instruction.dataIndex] * pagePointToDevicePointMatrix);
painter->setWorldTransform(QTransform(m_matrices[instruction.dataIndex] * pagePointToDevicePointMatrix));
break;
}
@ -643,8 +643,8 @@ void PDFPrecompiledPage::redact(QPainterPath redactPath, const QMatrix& matrix,
{
case InstructionType::DrawPath:
{
QMatrix matrix = worldMatrixStack.top().inverted();
QPainterPath mappedRedactPath = matrix.map(redactPath);
QMatrix currentMatrix = worldMatrixStack.top().inverted();
QPainterPath mappedRedactPath = currentMatrix.map(redactPath);
PathPaintData& path = m_paths[instruction.dataIndex];
path.path = path.path.subtracted(mappedRedactPath);
break;
@ -655,16 +655,16 @@ void PDFPrecompiledPage::redact(QPainterPath redactPath, const QMatrix& matrix,
ImageData& data = m_images[instruction.dataIndex];
QImage& image = data.image;
QMatrix imageTransform(1.0 / image.width(), 0, 0, 1.0 / image.height(), 0, 0);
QMatrix worldMatrix = imageTransform * worldMatrixStack.top();
QTransform imageTransform(1.0 / image.width(), 0, 0, 1.0 / image.height(), 0, 0);
QTransform worldTransform = imageTransform * QTransform(worldMatrixStack.top());
// Jakub Melka: Because Qt uses opposite axis direction than PDF, then we must transform the y-axis
// to the opposite (so the image is then unchanged)
worldMatrix.translate(0, image.height());
worldMatrix.scale(1, -1);
worldTransform.translate(0, image.height());
worldTransform.scale(1, -1);
QPainter painter(&image);
painter.setWorldMatrix(worldMatrix.inverted());
painter.setWorldTransform(worldTransform.inverted());
painter.drawPath(redactPath);
painter.end();
break;
@ -676,8 +676,8 @@ void PDFPrecompiledPage::redact(QPainterPath redactPath, const QMatrix& matrix,
case InstructionType::Clip:
{
QMatrix matrix = worldMatrixStack.top().inverted();
QPainterPath mappedRedactPath = matrix.map(redactPath);
QMatrix currentMatrix = worldMatrixStack.top().inverted();
QPainterPath mappedRedactPath = currentMatrix.map(redactPath);
m_clips[instruction.dataIndex].clipPath = m_clips[instruction.dataIndex].clipPath.subtracted(mappedRedactPath);
break;
}
@ -982,12 +982,12 @@ PDFPrecompiledPage::GraphicPieceInfos PDFPrecompiledPage::calculateGraphicPieceI
shadingTestImage.fill(Qt::transparent);
QMatrix pagePointToDevicePointMatrix;
QTransform pagePointToDevicePointMatrix;
pagePointToDevicePointMatrix.scale(shadingTestImage.width() / mediaBox.width(), -shadingTestImage.height() / mediaBox.height());
{
QPainter painter(&shadingTestImage);
painter.setWorldMatrix(pagePointToDevicePointMatrix);
painter.setWorldTransform(pagePointToDevicePointMatrix);
data.mesh.paint(&painter, data.alpha);
}

View File

@ -143,12 +143,9 @@ PDFPatternPtr PDFPattern::createPattern(const PDFDictionary* colorSpaceDictionar
default:
throw PDFException(PDFTranslationContext::tr("Invalid pattern."));
}
return PDFPatternPtr();
}
throw PDFException(PDFTranslationContext::tr("Invalid pattern."));
return PDFPatternPtr();
}
PDFPatternPtr PDFPattern::createShadingPattern(const PDFDictionary* colorSpaceDictionary,
@ -503,9 +500,6 @@ PDFPatternPtr PDFPattern::createShadingPattern(const PDFDictionary* colorSpaceDi
throw PDFException(PDFTranslationContext::tr("Invalid shading pattern type (%1).").arg(static_cast<PDFInteger>(shadingType)));
}
}
throw PDFException(PDFTranslationContext::tr("Invalid shading."));
return PDFPatternPtr();
}
class PDFFunctionShadingSampler : public PDFShadingSampler
@ -1682,8 +1676,8 @@ PDFMesh PDFRadialShading::createMesh(const PDFMeshQualitySettings& settings,
const PDFReal x1 = rightItem.first;
const PDFColor mixedColor = PDFAbstractColorSpace::mixColors(leftItem.second, rightItem.second, 0.5);
const PDFReal angleStep = 2 * M_PI / SLICES;
const PDFReal r0 = rLine.pointAt((x0 - p1m.x()) / rlength).y();
const PDFReal r1 = rLine.pointAt((x1 - p1m.x()) / rlength).y();
const PDFReal cr0 = rLine.pointAt((x0 - p1m.x()) / rlength).y();
const PDFReal cr1 = rLine.pointAt((x1 - p1m.x()) / rlength).y();
PDFReal angle0 = 0;
for (int i = 0; i < SLICES; ++i)
@ -1694,15 +1688,15 @@ PDFMesh PDFRadialShading::createMesh(const PDFMeshQualitySettings& settings,
const PDFReal cos1 = std::cos(angle1);
const PDFReal sin1 = std::sin(angle1);
QPointF p1(x0 + cos0 * r0, sin0 * r0);
QPointF p2(x1 + cos0 * r1, sin0 * r1);
QPointF p3(x1 + cos1 * r1, sin1 * r1);
QPointF p4(x0 + cos1 * r0, sin1 * r0);
QPointF cp1(x0 + cos0 * cr0, sin0 * cr0);
QPointF cp2(x1 + cos0 * cr1, sin0 * cr1);
QPointF cp3(x1 + cos1 * cr1, sin1 * cr1);
QPointF cp4(x0 + cos1 * cr0, sin1 * cr0);
uint32_t v1 = mesh.addVertex(p1);
uint32_t v2 = mesh.addVertex(p2);
uint32_t v3 = mesh.addVertex(p3);
uint32_t v4 = mesh.addVertex(p4);
uint32_t v1 = mesh.addVertex(cp1);
uint32_t v2 = mesh.addVertex(cp2);
uint32_t v3 = mesh.addVertex(cp3);
uint32_t v4 = mesh.addVertex(cp4);
QColor color = m_colorSpace->getColor(mixedColor, cms, intent, reporter, true);
mesh.addQuad(v1, v2, v3, v4, color.rgb());

View File

@ -1775,9 +1775,9 @@ QByteArray PDFStandardSecurityHandler::createHash_r6(const QByteArray& input, co
uint8_t byte = E[i];
int currentRemainder = 1;
for (uint8_t i = 0; i < 8; ++i)
for (uint8_t iRemainder = 0; iRemainder < 8; ++iRemainder)
{
if ((byte >> i) & 1)
if ((byte >> iRemainder) & 1)
{
remainderAccumulator += currentRemainder;
}
@ -2444,7 +2444,7 @@ PDFSecurityHandler::AuthorizationResult PDFPublicKeySecurityHandler::authenticat
openssl_ptr<EVP_PKEY> key(keyPtr, EVP_PKEY_free);
openssl_ptr<X509> certificate(certificatePtr, X509_free);
openssl_ptr<STACK_OF(X509)> certificates(certificatesPtr, sk_X509_free);
openssl_ptr<STACK_OF(X509)> certificates2(certificatesPtr, sk_X509_free);
for (const auto& recipientItem : recipients)
{

View File

@ -614,18 +614,18 @@ void PDFPublicKeySignatureHandler::verifyCertificate(PDFSignatureVerificationRes
// We will add certificate info for all certificates
const int count = sk_X509_num(certificates);
for (int i = 0; i < count; ++i)
for (int ii = 0; ii < count; ++ii)
{
result.addCertificateInfo(getCertificateInfo(sk_X509_value(certificates, i)));
result.addCertificateInfo(getCertificateInfo(sk_X509_value(certificates, ii)));
}
}
else
{
STACK_OF(X509)* validChain = X509_STORE_CTX_get0_chain(context);
const int count = sk_X509_num(validChain);
for (int i = 0; i < count; ++i)
for (int ii = 0; ii < count; ++ii)
{
result.addCertificateInfo(getCertificateInfo(sk_X509_value(validChain, i)));
result.addCertificateInfo(getCertificateInfo(sk_X509_value(validChain, ii)));
}
}
X509_STORE_CTX_cleanup(context);
@ -754,11 +754,11 @@ void PDFPublicKeySignatureHandler::verifySignature(PDFSignatureVerificationResul
if (BIO* dataBio = PKCS7_dataInit(pkcs7, inputBuffer))
{
// Now, we must read from bio to calculate digests (digest is returned)
std::array<char, 16384> buffer = { };
std::array<char, 16384> bioReadBuffer = { };
int bytesRead = 0;
do
{
bytesRead = BIO_read(dataBio, buffer.data(), int(buffer.size()));
bytesRead = BIO_read(dataBio, bioReadBuffer.data(), int(bioReadBuffer.size()));
} while (bytesRead > 0);
STACK_OF(PKCS7_SIGNER_INFO)* signerInfo = PKCS7_get_signer_info(pkcs7);
@ -1185,18 +1185,18 @@ void PDFSignatureHandler_ETSI_base::verifyCertificateCAdES(PDFSignatureVerificat
// We will add certificate info for all certificates
const int count = sk_X509_num(usedCertificates);
for (int i = 0; i < count; ++i)
for (int ii = 0; ii < count; ++ii)
{
result.addCertificateInfo(getCertificateInfo(sk_X509_value(usedCertificates, i)));
result.addCertificateInfo(getCertificateInfo(sk_X509_value(usedCertificates, ii)));
}
}
else
{
STACK_OF(X509)* validChain = X509_STORE_CTX_get0_chain(context);
const int count = sk_X509_num(validChain);
for (int i = 0; i < count; ++i)
for (int ii = 0; ii < count; ++ii)
{
result.addCertificateInfo(getCertificateInfo(sk_X509_value(validChain, i)));
result.addCertificateInfo(getCertificateInfo(sk_X509_value(validChain, ii)));
}
}
X509_STORE_CTX_cleanup(context);
@ -1702,8 +1702,8 @@ void PDFCertificateInfo::serialize(QDataStream& stream) const
void PDFCertificateInfo::deserialize(QDataStream& stream)
{
int persist_version = 0;
stream >> persist_version;
int persistVersionDeserialized = 0;
stream >> persistVersionDeserialized;
stream >> m_version;
stream >> m_keySize;
stream >> m_publicKey;
@ -1808,8 +1808,8 @@ void PDFCertificateStore::CertificateEntry::serialize(QDataStream& stream) const
void PDFCertificateStore::CertificateEntry::deserialize(QDataStream& stream)
{
int persist_version = 0;
stream >> persist_version;
int persistVersionDeserialized = 0;
stream >> persistVersionDeserialized;
stream >> type;
stream >> info;
}
@ -1932,8 +1932,8 @@ void PDFCertificateStore::serialize(QDataStream& stream) const
void PDFCertificateStore::deserialize(QDataStream& stream)
{
int persist_version = 0;
stream >> persist_version;
int persistVersionDeserialized = 0;
stream >> persistVersionDeserialized;
stream >> m_certificates;
}

View File

@ -112,14 +112,14 @@ QByteArray PDFAscii85DecodeFilter::apply(const QByteArray& data,
scannedChars.fill(84);
scannedChars[0] = scannedChar - 33;
int validBytes = 0;
for (auto it = std::next(scannedChars.begin()); it != scannedChars.end(); ++it)
for (auto it2 = std::next(scannedChars.begin()); it2 != scannedChars.end(); ++it2)
{
uint32_t character = getChar();
if (character == STREAM_END)
{
break;
}
*it = character - 33;
*it2 = character - 33;
++validBytes;
}
@ -762,7 +762,6 @@ PDFStreamPredictor PDFStreamPredictor::createPredictor(const PDFObjectFetcher& o
}
throw PDFException(PDFTranslationContext::tr("Invalid property '%1' of the stream predictor parameters.").arg(QString::fromLatin1(key)));
return 0;
};
int predictor = getInteger("Predictor", 1, 15, 1);
@ -797,7 +796,6 @@ QByteArray PDFStreamPredictor::apply(const QByteArray& data) const
}
throw PDFException(PDFTranslationContext::tr("Invalid predictor algorithm."));
return QByteArray();
}
QByteArray PDFStreamPredictor::applyPNGPredictor(const QByteArray& data) const

View File

@ -577,11 +577,11 @@ PDFStructureTree PDFStructureTree::parse(const PDFObjectStorage* storage, PDFObj
if (dereferencedObject.isArray())
{
std::vector<PDFObjectReference> references;
for (const PDFObject& object : *dereferencedObject.getArray())
for (const PDFObject& objectInArray : *dereferencedObject.getArray())
{
if (object.isReference())
if (objectInArray.isReference())
{
references.emplace_back(object.getReference());
references.emplace_back(objectInArray.getReference());
}
}

View File

@ -655,14 +655,14 @@ void PDFTextEditPseudowidget::draw(AnnotationDrawParameters& parameters, bool ed
if (edit)
{
pdf::PDFPainterStateGuard guard(painter);
pdf::PDFPainterStateGuard guard2(painter);
painter->setPen(getAdjustedColor(Qt::black));
painter->setBrush(Qt::NoBrush);
painter->drawRect(parameters.boundingRectangle);
}
painter->setClipRect(parameters.boundingRectangle, Qt::IntersectClip);
painter->setWorldMatrix(createTextBoxTransformMatrix(edit), true);
painter->setWorldTransform(QTransform(createTextBoxTransformMatrix(edit)), true);
painter->setPen(getAdjustedColor(Qt::black));
if (isComb())

View File

@ -371,17 +371,17 @@ PDFTextSelection PDFTextLayout::createTextSelection(PDFInteger pageIndex, const
std::swap(pointA, pointB);
}
QRectF rect = boundingBoxPath.controlPointRect();
QRectF boundingBoxPathBBRect = boundingBoxPath.controlPointRect();
// If start point is above the text block, move start point to the left.
if (rect.bottom() < pointA.y())
if (boundingBoxPathBBRect.bottom() < pointA.y())
{
pointA.setX(rect.left());
pointA.setX(boundingBoxPathBBRect.left());
isTopPointAboveText = true;
}
if (rect.top() > pointB.y())
if (boundingBoxPathBBRect.top() > pointB.y())
{
pointB.setX(rect.right());
pointB.setX(boundingBoxPathBBRect.right());
isBottomPointBelowText = true;
}
}

View File

@ -2036,35 +2036,35 @@ void PDFTransparencyRenderer::processSoftMask(const PDFDictionary* softMask)
softMaskRenderer.setGraphicsState(graphicState);
softMaskRenderer.processForm(softMaskDefinition.getFormStream());
const PDFFloatBitmap& renderedSoftMask = softMaskRenderer.endPaint();
PDFFloatBitmap softMask;
PDFFloatBitmap createdSoftMask;
switch (softMaskDefinition.getType())
{
case pdf::PDFPageContentProcessor::PDFSoftMaskDefinition::Type::Alpha:
softMask = renderedSoftMask.extractOpacityChannel();
createdSoftMask = renderedSoftMask.extractOpacityChannel();
break;
case pdf::PDFPageContentProcessor::PDFSoftMaskDefinition::Type::Luminosity:
softMask = renderedSoftMask.extractLuminosityChannel();
createdSoftMask = renderedSoftMask.extractLuminosityChannel();
break;
default:
case pdf::PDFPageContentProcessor::PDFSoftMaskDefinition::Type::Invalid:
reportRenderError(RenderErrorType::Error, PDFTranslationContext::tr("Invalid soft mask type."));
softMask = renderedSoftMask.extractOpacityChannel();
createdSoftMask = renderedSoftMask.extractOpacityChannel();
break;
}
if (const PDFFunction* function = softMaskDefinition.getTransferFunction())
{
const size_t width = softMask.getWidth();
const size_t height = softMask.getHeight();
const size_t width = createdSoftMask.getWidth();
const size_t height = createdSoftMask.getHeight();
for (size_t y = 0; y < height; ++y)
{
for (size_t x = 0; x < width; ++x)
{
PDFColorBuffer pixel = softMask.getPixel(x, y);
PDFColorBuffer pixel = createdSoftMask.getPixel(x, y);
PDFReal sourceValue = pixel[0];
PDFReal targetValue = sourceValue;
@ -2080,7 +2080,7 @@ void PDFTransparencyRenderer::processSoftMask(const PDFDictionary* softMask)
}
}
getPainterState()->softMask = PDFTransparencySoftMask(false, qMove(softMask));
getPainterState()->softMask = PDFTransparencySoftMask(false, qMove(createdSoftMask));
}
}
@ -3274,19 +3274,19 @@ void PDFInkMapper::createSpotColors(bool activate)
if (!deviceNColorSpace->isNone())
{
const PDFDeviceNColorSpace::Colorants& colorants = deviceNColorSpace->getColorants();
for (size_t i = 0; i < colorants.size(); ++i)
for (size_t ii = 0; ii < colorants.size(); ++ii)
{
const PDFDeviceNColorSpace::ColorantInfo& colorantInfo = colorants[i];
const PDFDeviceNColorSpace::ColorantInfo& colorantInfo = colorants[ii];
if (!containsSpotColor(colorantInfo.name) && !containsProcessColor(colorantInfo.name))
{
PDFColor color;
color.resize(deviceNColorSpace->getColorComponentCount());
color[i] = 1.0f;
color[ii] = 1.0f;
ColorInfo info;
info.name = colorantInfo.name;
info.textName = PDFEncoding::convertTextString(info.name);
info.colorSpaceIndex = uint32_t(i);
info.colorSpaceIndex = uint32_t(ii);
info.colorSpace = colorSpacePointer;
info.spotColorIndex = uint32_t(m_spotColors.size());
info.color = cms ? deviceNColorSpace->getColor(color, cms.get(), pdf::RenderingIntent::Perceptual, &renderErrorReporter, true) : nullptr;

View File

@ -447,7 +447,7 @@ void PDFFindTextTool::performSearch()
else
{
// Use regular expression search
QRegularExpression::PatternOptions patternOptions = QRegularExpression::UseUnicodePropertiesOption | QRegularExpression::OptimizeOnFirstUsageOption;
QRegularExpression::PatternOptions patternOptions = QRegularExpression::UseUnicodePropertiesOption;
if (!m_parameters.isCaseSensitive)
{
patternOptions |= QRegularExpression::CaseInsensitiveOption;
@ -1577,13 +1577,13 @@ void PDFSelectTableTool::keyPressEvent(QWidget* widget, QKeyEvent* event)
// Detect, if whole block can be in some text cell
const PDFTextBlock& textBlock = textBlocks[i];
QRectF textRect = textBlock.getBoundingBox().boundingRect();
auto it = std::find_if(tableCells.begin(), tableCells.end(), [textRect](const auto& cell) { return cell.rectangle.contains(textRect); });
if (it != tableCells.end())
auto itBlockCell = std::find_if(tableCells.begin(), tableCells.end(), [textRect](const auto& cell) { return cell.rectangle.contains(textRect); });
if (itBlockCell != tableCells.end())
{
// Jakub Melka: whole block is contained in the cell
PDFTextSelection blockSelection = m_textLayout.selectBlock(i, m_pageIndex, QColor());
QString text = m_textLayout.getTextFromSelection(blockSelection, m_pageIndex);
TableCell& cell = *it;
TableCell& cell = *itBlockCell;
cell.text = QString("%1 %2").arg(cell.text, text).trimmed();
continue;
}
@ -1594,13 +1594,13 @@ void PDFSelectTableTool::keyPressEvent(QWidget* widget, QKeyEvent* event)
const PDFTextLine& textLine = textLines[j];
QRectF boundingRect = textLine.getBoundingBox().boundingRect();
auto it = std::find_if(tableCells.begin(), tableCells.end(), [boundingRect](const auto& cell) { return cell.rectangle.contains(boundingRect); });
if (it != tableCells.end())
auto itLineCell = std::find_if(tableCells.begin(), tableCells.end(), [boundingRect](const auto& cell) { return cell.rectangle.contains(boundingRect); });
if (itLineCell != tableCells.end())
{
// Jakub Melka: whole block is contained in the cell
PDFTextSelection blockSelection = m_textLayout.selectLineInBlock(i, j, m_pageIndex, QColor());
QString text = m_textLayout.getTextFromSelection(blockSelection, m_pageIndex);
TableCell& cell = *it;
TableCell& cell = *itLineCell;
cell.text = QString("%1 %2").arg(cell.text, text).trimmed();
continue;
}

View File

@ -9945,9 +9945,9 @@ private:
{
void translate(PDFReal dx, PDFReal dy) { nominalExtent.translate(dx, dy); }
void updatePresence(xfa::XFA_BaseNode::PRESENCE presence)
void updatePresence(xfa::XFA_BaseNode::PRESENCE nodePresence)
{
switch (presence)
switch (nodePresence)
{
case xfa::XFA_BaseNode::PRESENCE::Visible:
break;
@ -11670,10 +11670,10 @@ void PDFXFAEngineImpl::setDocument(const PDFModifiedDocument& document, PDFForm*
xfaData["template"] = m_document->getDecodedStream(xfaObject.getStream());
}
QDomDocument document;
if (document.setContent(xfaData["template"]))
QDomDocument templateDocument;
if (templateDocument.setContent(xfaData["template"]))
{
m_template = xfa::XFA_template::parse(document.firstChildElement("template"));
m_template = xfa::XFA_template::parse(templateDocument.firstChildElement("template"));
}
}
catch (const PDFException&)
@ -11715,7 +11715,7 @@ void PDFXFAEngineImpl::draw(const QMatrix& pagePointToDevicePointMatrix,
PDFPainterStateGuard guard(painter);
painter->setRenderHint(QPainter::Antialiasing);
painter->setWorldMatrix(pagePointToDevicePointMatrix, true);
painter->setWorldTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->translate(0, page->getMediaBox().height());
painter->scale(1.0, -1.0);
painter->fillRect(page->getMediaBox(), Qt::white);
@ -11723,7 +11723,7 @@ void PDFXFAEngineImpl::draw(const QMatrix& pagePointToDevicePointMatrix,
const LayoutItems& items = it->second;
for (const LayoutItem& item : items)
{
PDFPainterStateGuard guard(painter);
PDFPainterStateGuard guard2(painter);
drawItemDraw(item.draw, errors, item.nominalExtent, item.paragraphSettingsIndex, item.captionParagraphSettingsIndex, painter);
drawItemField(item.field, errors, item.nominalExtent, item.paragraphSettingsIndex, item.captionParagraphSettingsIndex, painter);
drawItemSubform(item.subform, errors, item.nominalExtent, painter);
@ -12296,10 +12296,10 @@ void PDFXFAEngineImpl::drawUiTextEdit(const xfa::XFA_textEdit* textEdit,
font.setHintingPreference(QFont::PreferNoHinting);
charFormat.setFont(font, QTextCharFormat::FontPropertiesAll);
QTextCursor cursor(block);
cursor.setPosition(block.position() + formatRange.start, QTextCursor::MoveAnchor);
cursor.setPosition(block.position() + formatRange.start + formatRange.length, QTextCursor::KeepAnchor);
cursor.mergeCharFormat(charFormat);
QTextCursor blockCursor(block);
blockCursor.setPosition(block.position() + formatRange.start, QTextCursor::MoveAnchor);
blockCursor.setPosition(block.position() + formatRange.start + formatRange.length, QTextCursor::KeepAnchor);
blockCursor.mergeCharFormat(charFormat);
}
block = block.next();
@ -12336,8 +12336,8 @@ void PDFXFAEngineImpl::drawUiTextEdit(const xfa::XFA_textEdit* textEdit,
break;
}
QString text = QString(text[i]);
painter->drawText(combRect, Qt::AlignCenter, text);
QString textLine = QString(text[i]);
painter->drawText(combRect, Qt::AlignCenter, textLine);
combRect.translate(combWidth, 0.0);
}

View File

@ -284,11 +284,11 @@ void PDFXRefTable::readXRefTable(PDFParsingContext* context, const QByteArray& b
PDFInteger count = indexArray[2 * i + 1];
const PDFInteger lastObjectIndex = firstObjectNumber + count - 1;
const PDFInteger desiredSize = lastObjectIndex + 1;
const PDFInteger currentDesiredSize = lastObjectIndex + 1;
if (static_cast<PDFInteger>(m_entries.size()) < desiredSize)
if (static_cast<PDFInteger>(m_entries.size()) < currentDesiredSize)
{
m_entries.resize(desiredSize);
m_entries.resize(currentDesiredSize);
}
for (PDFInteger objectNumber = firstObjectNumber; objectNumber <= lastObjectIndex; ++ objectNumber)

View File

@ -258,7 +258,7 @@ void PDFAdvancedFindWidget::performSearch()
else
{
// Use regular expression search
QRegularExpression::PatternOptions patternOptions = QRegularExpression::UseUnicodePropertiesOption | QRegularExpression::OptimizeOnFirstUsageOption;
QRegularExpression::PatternOptions patternOptions = QRegularExpression::UseUnicodePropertiesOption;
if (!m_parameters.isCaseSensitive)
{
patternOptions |= QRegularExpression::CaseInsensitiveOption;

View File

@ -538,7 +538,7 @@ void PDFDocumentPropertiesDialog::onFontsFinished()
{
if (!m_fontTreeWidgetItems.empty())
{
std::sort(m_fontTreeWidgetItems.begin(), m_fontTreeWidgetItems.end(), [](QTreeWidgetItem* left, QTreeWidgetItem* right) { return left->data(0, Qt::DisplayRole) < right->data(0, Qt::DisplayRole); });
std::sort(m_fontTreeWidgetItems.begin(), m_fontTreeWidgetItems.end(), [](QTreeWidgetItem* left, QTreeWidgetItem* right) { return left->data(0, Qt::DisplayRole).toString() < right->data(0, Qt::DisplayRole).toString(); });
for (QTreeWidgetItem* item : m_fontTreeWidgetItems)
{
ui->fontsTreeWidget->addTopLevelItem(item);

View File

@ -138,7 +138,7 @@ QSize PDFEncryptionStrengthHintWidget::getTextSizeHint() const
for (const auto& levelItem : m_levels)
{
width = qMax(width, fontMetrics.width(levelItem.text));
width = qMax(width, fontMetrics.horizontalAdvance(levelItem.text));
}
return QSize(width, height);

View File

@ -672,7 +672,7 @@ void PDFProgramController::performPrint()
Q_ASSERT(page);
QRectF mediaBox = page->getRotatedMediaBox();
QRectF paperRect = printer.paperRect();
QRectF paperRect = printer.pageLayout().fullRectPixels(printer.resolution());
QSizeF scaledSize = mediaBox.size().scaled(paperRect.size(), Qt::KeepAspectRatio);
mediaBox.setSize(scaledSize);
mediaBox.moveCenter(paperRect.center());
@ -1518,7 +1518,7 @@ void PDFProgramController::updateFileInfo(const QString& fileName)
m_fileInfo.path = fileInfo.path();
m_fileInfo.fileSize = fileInfo.size();
m_fileInfo.writable = fileInfo.isWritable();
m_fileInfo.creationTime = fileInfo.created();
m_fileInfo.creationTime = fileInfo.birthTime();
m_fileInfo.lastModifiedTime = fileInfo.lastModified();
m_fileInfo.lastReadTime = fileInfo.lastRead();
}
@ -2050,13 +2050,13 @@ void PDFProgramController::onActionDeveloperCreateInstaller()
if (configFile.open(QFile::WriteOnly | QFile::Truncate))
{
QTextStream stream(&configFile);
stream << "TEMPLATE = aux" << endl << endl;
stream << "INSTALLER_NAME = $$PWD/instpdf4qt" << endl;
stream << "INPUT = $$PWD/config/config.xml $$PWD/packages" << endl;
stream << "pdfforqtinstaller.input = INPUT" << endl;
stream << "pdfforqtinstaller.output = $$INSTALLER_NAME" << endl;
stream << QString("pdfforqtinstaller.commands = %1/binarycreator -c $$PWD/config/config.xml -p $$PWD/packages ${QMAKE_FILE_OUT}").arg(binaryCreatorDirectory) << endl;
stream << "pdfforqtinstaller.CONFIG += target_predeps no_link combine" << endl << endl;
stream << "TEMPLATE = aux" << Qt::endl << Qt::endl;
stream << "INSTALLER_NAME = $$PWD/instpdf4qt" << Qt::endl;
stream << "INPUT = $$PWD/config/config.xml $$PWD/packages" << Qt::endl;
stream << "pdfforqtinstaller.input = INPUT" << Qt::endl;
stream << "pdfforqtinstaller.output = $$INSTALLER_NAME" << Qt::endl;
stream << QString("pdfforqtinstaller.commands = %1/binarycreator -c $$PWD/config/config.xml -p $$PWD/packages ${QMAKE_FILE_OUT}").arg(binaryCreatorDirectory) << Qt::endl;
stream << "pdfforqtinstaller.CONFIG += target_predeps no_link combine" << Qt::endl << Qt::endl;
stream << "QMAKE_EXTRA_COMPILERS += pdfforqtinstaller";
configFile.close();
}

View File

@ -441,14 +441,14 @@ void PDFSidebarWidget::updateSignatures(const std::vector<pdf::PDFSignatureVerif
QDateTime signingDate = signature.getSignatureDate();
if (signingDate.isValid())
{
QTreeWidgetItem* item = new QTreeWidgetItem(rootItem, QStringList(QString("Signing date/time: %2").arg(signingDate.toString(Qt::DefaultLocaleShortDate))));
QTreeWidgetItem* item = new QTreeWidgetItem(rootItem, QStringList(QString("Signing date/time: %2").arg(QLocale::system().toString(signingDate, QLocale::ShortFormat))));
item->setIcon(0, infoIcon);
}
QDateTime timestampDate = signature.getTimestampDate();
if (timestampDate.isValid())
{
QTreeWidgetItem* item = new QTreeWidgetItem(rootItem, QStringList(QString("Timestamp: %2").arg(timestampDate.toString(Qt::DefaultLocaleShortDate))));
QTreeWidgetItem* item = new QTreeWidgetItem(rootItem, QStringList(QString("Timestamp: %2").arg(QLocale::system().toString(timestampDate, QLocale::ShortFormat))));
item->setIcon(0, infoIcon);
}
@ -529,13 +529,13 @@ void PDFSidebarWidget::updateSignatures(const std::vector<pdf::PDFSignatureVerif
if (notValidBefore.isValid())
{
QTreeWidgetItem* item = new QTreeWidgetItem(certRoot, QStringList(QString("Valid from: %2").arg(notValidBefore.toString(Qt::DefaultLocaleShortDate))));
QTreeWidgetItem* item = new QTreeWidgetItem(certRoot, QStringList(QString("Valid from: %2").arg(QLocale::system().toString(notValidBefore, QLocale::ShortFormat))));
item->setIcon(0, infoIcon);
}
if (notValidAfter.isValid())
{
QTreeWidgetItem* item = new QTreeWidgetItem(certRoot, QStringList(QString("Valid to: %2").arg(notValidAfter.toString(Qt::DefaultLocaleShortDate))));
QTreeWidgetItem* item = new QTreeWidgetItem(certRoot, QStringList(QString("Valid to: %2").arg(QLocale::system().toString(notValidAfter, QLocale::ShortFormat))));
item->setIcon(0, infoIcon);
}
@ -693,10 +693,10 @@ void PDFSidebarWidget::onSignatureCustomContextMenuRequested(const QPoint& pos)
{
if (QTreeWidgetItem* item = ui->signatureTreeWidget->itemAt(pos))
{
QVariant data = item->data(0, Qt::UserRole);
if (data.isValid())
QVariant itemData = item->data(0, Qt::UserRole);
if (itemData.isValid())
{
const pdf::PDFCertificateInfo& info = m_certificateInfos.at(data.toInt());
const pdf::PDFCertificateInfo& info = m_certificateInfos.at(itemData.toInt());
if (!m_certificateStore->contains(info))
{
QMenu menu;

View File

@ -676,12 +676,12 @@ void PDFViewerSettingsDialog::updateTrustedCertificatesTable()
if (notValidBefore.isValid())
{
ui->trustedCertificateStoreTableWidget->setItem(i, 3, new QTableWidgetItem(notValidBefore.toString(Qt::DefaultLocaleShortDate)));
ui->trustedCertificateStoreTableWidget->setItem(i, 3, new QTableWidgetItem(QLocale::system().toString(notValidBefore, QLocale::ShortFormat)));
}
if (notValidAfter.isValid())
{
ui->trustedCertificateStoreTableWidget->setItem(i, 4, new QTableWidgetItem(notValidAfter.toString(Qt::DefaultLocaleShortDate)));
ui->trustedCertificateStoreTableWidget->setItem(i, 4, new QTableWidgetItem(QLocale::system().toString(notValidAfter, QLocale::ShortFormat)));
}
}

View File

@ -236,7 +236,7 @@ void DimensionsPlugin::drawPage(QPainter* painter,
painter->setPen(qMove(pen));
painter->setBrush(QBrush(brushColor, isArea ? Qt::SolidPattern : Qt::DiagCrossPattern));
painter->setMatrix(pagePointToDevicePointMatrix, true);
painter->setTransform(QTransform(pagePointToDevicePointMatrix), true);
painter->drawPolygon(polygon.data(), int(polygon.size()), Qt::OddEvenFill);
painter->restore();

View File

@ -245,9 +245,9 @@ void ObjectViewerWidget::updateUi()
}
else
{
QByteArray data = m_document->getDecodedStream(stream);
data.replace('\r', ' ');
QByteArray percentEncodedData = data.toPercentEncoding(m_printableCharacters);
QByteArray dataToBeAdjusted = m_document->getDecodedStream(stream);
dataToBeAdjusted.replace('\r', ' ');
QByteArray percentEncodedData = dataToBeAdjusted.toPercentEncoding(m_printableCharacters);
ui->contentTextBrowser->setText(QString::fromLatin1(percentEncodedData));
ui->stackedWidget->setCurrentWidget(ui->contentTextBrowserPage);
}

View File

@ -98,7 +98,7 @@ private:
Statistics m_statistics;
std::vector<QRect> m_colorBoxes;
size_t m_selectedColorBox = -1;
size_t m_selectedColorBox = std::numeric_limits<size_t>::max();
};
} // namespace pdfplugin

View File

@ -312,12 +312,12 @@ QVariant InkCoverageStatisticsModel::data(const QModelIndex& index, int role) co
break;
}
case Qt::BackgroundColorRole:
case Qt::BackgroundRole:
{
if (index.column() >= LastStandardColumn && getChannelColumn(index.column()) == ChannelColumnColorant)
{
const int channelIndex = getChannelIndex(index.column());
return m_inkCoverageResults.sumInfo[channelIndex].color;
return QBrush(m_inkCoverageResults.sumInfo[channelIndex].color);
}
break;

View File

@ -358,9 +358,9 @@ void OutputPreviewWidget::paintEvent(QPaintEvent* event)
const int textWidth = painter.fontMetrics().horizontalAdvance(textCoverage);
const int textStart = textRight - textWidth;
QRect textRect(textStart, yCoordinate - halfHeight, textWidth + 1, rowHeight);
QRect currentTextRect(textStart, yCoordinate - halfHeight, textWidth + 1, rowHeight);
painter.setPen(Qt::black);
painter.drawText(textRect, Qt::AlignVCenter | Qt::AlignLeft | Qt::TextSingleLine, textCoverage);
painter.drawText(currentTextRect, Qt::AlignVCenter | Qt::AlignLeft | Qt::TextSingleLine, textCoverage);
}
}

View File

@ -154,45 +154,45 @@ void PDFExamplesGenerator::generateAnnotationsExample()
builder.createAnnotationSquare(page5, QRectF(50, 250, 50, 50), 3.0, Qt::green, QColor(), "Title3", "Subject3", "Contents - green filling");
{
pdf::PDFObjectReference page5 = builder.appendPage(QRectF(0, 0, 400, 400));
pdf::PDFObjectReference page5a = builder.appendPage(QRectF(0, 0, 400, 400));
{
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5, QRectF(50, 50, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5a, QRectF(50, 50, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
builder.setAnnotationBorderStyle(annotation, pdf::PDFAnnotationBorder::Style::Solid, 2.718);
builder.setAnnotationColor(annotation, Qt::black);
builder.updateAnnotationAppearanceStreams(annotation);
}
{
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5, QRectF(50, 150, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5a, QRectF(50, 150, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
builder.setAnnotationBorderStyle(annotation, pdf::PDFAnnotationBorder::Style::Underline, 2.718);
builder.setAnnotationColor(annotation, Qt::black);
builder.updateAnnotationAppearanceStreams(annotation);
}
{
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5, QRectF(50, 250, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5a, QRectF(50, 250, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
builder.setAnnotationBorderStyle(annotation, pdf::PDFAnnotationBorder::Style::Inset, 2.718);
builder.setAnnotationColor(annotation, Qt::black);
builder.updateAnnotationAppearanceStreams(annotation);
}
{
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5, QRectF(150, 50, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5a, QRectF(150, 50, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
builder.setAnnotationBorderStyle(annotation, pdf::PDFAnnotationBorder::Style::Beveled, 2.718);
builder.setAnnotationColor(annotation, Qt::black);
builder.updateAnnotationAppearanceStreams(annotation);
}
{
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5, QRectF(150, 150, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5a, QRectF(150, 150, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
builder.setAnnotationBorderStyle(annotation, pdf::PDFAnnotationBorder::Style::Dashed, 2.718);
builder.setAnnotationColor(annotation, Qt::black);
builder.updateAnnotationAppearanceStreams(annotation);
}
{
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5, QRectF(150, 250, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
pdf::PDFObjectReference annotation = builder.createAnnotationSquare(page5a, QRectF(150, 250, 50, 50), 3.0, Qt::green, Qt::red, "Title1", "Subject1", "Contents - green filling, red boundary");
builder.setAnnotationBorder(annotation, 5.0, 3.0, 2.0);
builder.setAnnotationColor(annotation, Qt::black);
builder.updateAnnotationAppearanceStreams(annotation);
@ -244,33 +244,33 @@ void PDFExamplesGenerator::generateAnnotationsExample()
pdf::PDFObjectReference page13 = builder.appendPage(QRectF(0, 0, 400, 400));
{
QPolygonF polygon;
polygon << QPointF(50, 50);
polygon << QPointF(50, 100);
polygon << QPointF(100, 50);
builder.createAnnotationInk(page13, polygon, 2.0, Qt::red, "Title", "Subject", "Contents");
QPolygonF polygonInk;
polygonInk << QPointF(50, 50);
polygonInk << QPointF(50, 100);
polygonInk << QPointF(100, 50);
builder.createAnnotationInk(page13, polygonInk, 2.0, Qt::red, "Title", "Subject", "Contents");
}
{
QPolygonF polygon;
polygon << QPointF(50, 50);
polygon << QPointF(50, 100);
polygon << QPointF(100, 50);
polygon.translate(150, 0);
builder.createAnnotationInk(page13, polygon, 2.0, Qt::red, "Title", "Subject", "Contents");
QPolygonF polygonInk;
polygonInk << QPointF(50, 50);
polygonInk << QPointF(50, 100);
polygonInk << QPointF(100, 50);
polygonInk.translate(150, 0);
builder.createAnnotationInk(page13, polygonInk, 2.0, Qt::red, "Title", "Subject", "Contents");
}
{
pdf::Polygons polygons;
QPolygonF polygon;
polygon << QPointF(50, 50);
polygon << QPointF(50, 100);
polygon << QPointF(100, 50);
polygon << QPointF(50, 50);
polygon.translate(0, 150);
polygons.push_back(polygon);
polygon.translate(150, 0);
polygons.push_back(polygon);
builder.createAnnotationInk(page13, polygons, 2.0, Qt::red, "Title", "Subject", "Contents");
pdf::Polygons polygonInk;
QPolygonF polygonPart;
polygonPart << QPointF(50, 50);
polygonPart << QPointF(50, 100);
polygonPart << QPointF(100, 50);
polygonPart << QPointF(50, 50);
polygonPart.translate(0, 150);
polygonInk.push_back(polygonPart);
polygonPart.translate(150, 0);
polygonInk.push_back(polygonPart);
builder.createAnnotationInk(page13, polygonInk, 2.0, Qt::red, "Title", "Subject", "Contents");
}
pdf::PDFObjectReference page14 = builder.appendPage(QRectF(0, 0, 400, 400));

View File

@ -381,19 +381,19 @@ PDFToolOptions PDFToolAbstractApplication::getOptions(QCommandLineParser* parser
QString dateFormat = parser->value("date-format");
if (dateFormat == "short")
{
options.outputDateFormat = Qt::DefaultLocaleShortDate;
options.outputDateFormat = PDFToolOptions::LocaleShortDate;
}
else if (dateFormat == "long")
{
options.outputDateFormat = Qt::DefaultLocaleLongDate;
options.outputDateFormat = PDFToolOptions::LocaleLongDate;
}
else if (dateFormat == "iso")
{
options.outputDateFormat = Qt::ISODate;
options.outputDateFormat = PDFToolOptions::ISODate;
}
else if (dateFormat == "rfc2822")
{
options.outputDateFormat = Qt::RFC2822Date;
options.outputDateFormat = PDFToolOptions::RFC2822Date;
}
else if (!dateFormat.isEmpty())
{
@ -972,6 +972,26 @@ PDFToolOptions PDFToolAbstractApplication::getOptions(QCommandLineParser* parser
return options;
}
QString PDFToolAbstractApplication::convertDateTimeToString(const QDateTime& dateTime, PDFToolOptions::DateFormat dateFormat)
{
switch (dateFormat)
{
case PDFToolOptions::LocaleShortDate:
return QLocale::system().toString(dateTime, QLocale::ShortFormat);
case PDFToolOptions::LocaleLongDate:
return QLocale::system().toString(dateTime, QLocale::LongFormat);
case PDFToolOptions::ISODate:
return dateTime.toString(Qt::ISODate);
case PDFToolOptions::RFC2822Date:
return dateTime.toString(Qt::RFC2822Date);
default:
break;
}
Q_ASSERT(false);
return QLocale::system().toString(dateTime, QLocale::ShortFormat);
}
bool PDFToolAbstractApplication::readDocument(const PDFToolOptions& options, pdf::PDFDocument& document, QByteArray* sourceData, bool authorizeOwnerOnly)
{
bool isFirstPasswordAttempt = true;

View File

@ -44,12 +44,20 @@ struct PDFToolTranslationContext
struct PDFToolOptions
{
enum DateFormat
{
LocaleShortDate,
LocaleLongDate,
ISODate,
RFC2822Date
};
// For option 'ConsoleFormat'
PDFOutputFormatter::Style outputStyle = PDFOutputFormatter::Style::Text;
QString outputCodec = "UTF-8";
// For option 'DateFormat'
Qt::DateFormat outputDateFormat = Qt::DefaultLocaleShortDate;
DateFormat outputDateFormat = LocaleShortDate;
// For option 'OpenDocument'
QString document;
@ -252,6 +260,8 @@ public:
void initializeCommandLineParser(QCommandLineParser* parser) const;
PDFToolOptions getOptions(QCommandLineParser* parser) const;
static QString convertDateTimeToString(const QDateTime& dateTime, PDFToolOptions::DateFormat dateFormat);
protected:
/// Tries to read the document. If document is successfully read, true is returned,
/// if error occurs, then false is returned. Optionally, original document content

View File

@ -380,7 +380,7 @@ int PDFToolAudioBook::createAudioBook(const PDFToolOptions& options, pdf::PDFDoc
if (showText)
{
textStream << item.text << endl;
textStream << item.text << Qt::endl;
}
}
}

View File

@ -111,12 +111,12 @@ int PDFToolCertStore::execute(const PDFToolOptions& options)
if (notValidBefore.isValid())
{
notValidBeforeText = notValidBefore.toString(options.outputDateFormat);
notValidBeforeText = convertDateTimeToString(notValidBefore, options.outputDateFormat);
}
if (notValidAfter.isValid())
{
notValidAfterText = notValidAfter.toString(options.outputDateFormat);
notValidAfterText = convertDateTimeToString(notValidAfter, options.outputDateFormat);
}
formatter.beginTableRow("certificate", ref);

View File

@ -87,8 +87,8 @@ int PDFToolInfoApplication::execute(const PDFToolOptions& options)
writeProperty("author", PDFToolTranslationContext::tr("Author"), info->author);
writeProperty("creator", PDFToolTranslationContext::tr("Creator"), info->creator);
writeProperty("producer", PDFToolTranslationContext::tr("Producer"), info->producer);
writeProperty("creation-date", PDFToolTranslationContext::tr("Creation date"), info->creationDate.toLocalTime().toString(options.outputDateFormat));
writeProperty("modified-date", PDFToolTranslationContext::tr("Modified date"), info->modifiedDate.toLocalTime().toString(options.outputDateFormat));
writeProperty("creation-date", PDFToolTranslationContext::tr("Creation date"), convertDateTimeToString(info->creationDate.toLocalTime(), options.outputDateFormat));
writeProperty("modified-date", PDFToolTranslationContext::tr("Modified date"), convertDateTimeToString(info->modifiedDate.toLocalTime(), options.outputDateFormat));
writeProperty("version", PDFToolTranslationContext::tr("Version"), QString::fromLatin1(document.getVersion()));
QString trapped;
@ -155,7 +155,7 @@ int PDFToolInfoApplication::execute(const PDFToolOptions& options)
{
QString key = QString::fromLatin1(item.first);
QVariant valueVariant = item.second;
QString value = (valueVariant.type() == QVariant::DateTime) ? valueVariant.toDateTime().toLocalTime().toString(options.outputDateFormat) : valueVariant.toString();
QString value = (valueVariant.type() == QVariant::DateTime) ? convertDateTimeToString(valueVariant.toDateTime().toLocalTime(), options.outputDateFormat) : valueVariant.toString();
writeProperty("custom-property", key, value);
}
}

View File

@ -139,9 +139,9 @@ int PDFToolInfoFonts::execute(const PDFToolOptions& options)
if (plusPos == 6)
{
isSubset = true;
for (int i = 0; i < 6; ++i)
for (int iFontName = 0; iFontName < 6; ++iFontName)
{
QChar character = fontName[i];
QChar character = fontName[iFontName];
if (!character.isLetter() || !character.isUpper())
{
isSubset = false;

View File

@ -165,8 +165,8 @@ int PDFToolVerifySignaturesApplication::execute(const PDFToolOptions& options)
formatter.writeTableColumn("common-name", commonName);
formatter.writeTableColumn("cert-status", options.verificationOmitCertificateCheck ? PDFToolTranslationContext::tr("Skipped") : signature.getCertificateStatusText());
formatter.writeTableColumn("signature-status", signature.getSignatureStatusText());
formatter.writeTableColumn("signing-date", signature.getSignatureDate().isValid() ? signature.getSignatureDate().toLocalTime().toString(options.outputDateFormat) : QString());
formatter.writeTableColumn("timestamp-date", signature.getTimestampDate().isValid() ? signature.getTimestampDate().toLocalTime().toString(options.outputDateFormat) : QString());
formatter.writeTableColumn("signing-date", signature.getSignatureDate().isValid() ? convertDateTimeToString(signature.getSignatureDate().toLocalTime(), options.outputDateFormat) : QString());
formatter.writeTableColumn("timestamp-date", signature.getTimestampDate().isValid() ? convertDateTimeToString(signature.getTimestampDate().toLocalTime(), options.outputDateFormat) : QString());
formatter.writeTableColumn("hash-algorithm", signature.getHashAlgorithms().join(", ").toUpper());
formatter.writeTableColumn("handler", QString::fromLatin1(signature.getSignatureHandler()));
formatter.writeTableColumn("whole-signed", signature.hasFlag(pdf::PDFSignatureVerificationResult::Warning_Signature_NotCoveredBytes) ? PDFToolTranslationContext::tr("No") : PDFToolTranslationContext::tr("Yes"));
@ -182,11 +182,11 @@ int PDFToolVerifySignaturesApplication::execute(const PDFToolOptions& options)
formatter.endl();
formatter.beginHeader("details", PDFToolTranslationContext::tr("Details"));
int i = 1;
int ii = 1;
for (const pdf::PDFSignatureVerificationResult& signature : signatures)
{
formatter.endl();
formatter.beginHeader("signature", PDFToolTranslationContext::tr("%1 #%2").arg(getTypeName(signature)).arg(i), i);
formatter.beginHeader("signature", PDFToolTranslationContext::tr("%1 #%2").arg(getTypeName(signature)).arg(ii), ii);
const pdf::PDFCertificateInfos& certificateInfos = signature.getCertificateInfos();
const pdf::PDFCertificateInfo* certificateInfo = !certificateInfos.empty() ? &certificateInfos.front() : nullptr;
@ -194,8 +194,8 @@ int PDFToolVerifySignaturesApplication::execute(const PDFToolOptions& options)
formatter.writeText("common-name", PDFToolTranslationContext::tr("Signed by: %1").arg(commonName));
formatter.writeText("certificate-status", PDFToolTranslationContext::tr("Certificate status: %1").arg(options.verificationOmitCertificateCheck ? PDFToolTranslationContext::tr("Skipped") : signature.getCertificateStatusText()));
formatter.writeText("signature-status", PDFToolTranslationContext::tr("Signature status: %1").arg(signature.getSignatureStatusText()));
formatter.writeText("signing-date", PDFToolTranslationContext::tr("Signing date: %1").arg(signature.getSignatureDate().isValid() ? signature.getSignatureDate().toLocalTime().toString(options.outputDateFormat) : QString()));
formatter.writeText("timestamp-date", PDFToolTranslationContext::tr("Timestamp date: %1").arg(signature.getTimestampDate().isValid() ? signature.getTimestampDate().toLocalTime().toString(options.outputDateFormat) : QString()));
formatter.writeText("signing-date", PDFToolTranslationContext::tr("Signing date: %1").arg(signature.getSignatureDate().isValid() ? convertDateTimeToString(signature.getSignatureDate().toLocalTime(), options.outputDateFormat) : QString()));
formatter.writeText("timestamp-date", PDFToolTranslationContext::tr("Timestamp date: %1").arg(signature.getTimestampDate().isValid() ? convertDateTimeToString(signature.getTimestampDate().toLocalTime(), options.outputDateFormat) : QString()));
formatter.writeText("hash-algorithm", PDFToolTranslationContext::tr("Hash algorithm: %1").arg(signature.getHashAlgorithms().join(", ").toUpper()));
formatter.writeText("handler", PDFToolTranslationContext::tr("Handler: %1").arg(QString::fromLatin1(signature.getSignatureHandler())));
formatter.writeText("whole-signed", PDFToolTranslationContext::tr("Is whole document signed: %1").arg(signature.hasFlag(pdf::PDFSignatureVerificationResult::Warning_Signature_NotCoveredBytes) ? PDFToolTranslationContext::tr("No") : PDFToolTranslationContext::tr("Yes")));
@ -307,7 +307,7 @@ int PDFToolVerifySignaturesApplication::execute(const PDFToolOptions& options)
{
formatter.beginTableRow("valid-from");
formatter.writeTableColumn("description", PDFToolTranslationContext::tr("Valid from"));
formatter.writeTableColumn("value", notValidBefore.toString(options.outputDateFormat));
formatter.writeTableColumn("value", convertDateTimeToString(notValidBefore, options.outputDateFormat));
formatter.endTableRow();
}
@ -315,7 +315,7 @@ int PDFToolVerifySignaturesApplication::execute(const PDFToolOptions& options)
{
formatter.beginTableRow("valid-to");
formatter.writeTableColumn("description", PDFToolTranslationContext::tr("Valid to"));
formatter.writeTableColumn("value", notValidAfter.toString(options.outputDateFormat));
formatter.writeTableColumn("value", convertDateTimeToString(notValidAfter, options.outputDateFormat));
formatter.endTableRow();
}
@ -373,7 +373,7 @@ int PDFToolVerifySignaturesApplication::execute(const PDFToolOptions& options)
}
formatter.endHeader();
++i;
++ii;
}
formatter.endHeader();

View File

@ -1,4 +1,6 @@
CURRENT:
- Issue #21: Table selection tool
- Issue #22: Solve compilation warnings
V: 1.2.1 30.6.2022
- Issue #17: Public key security handler

View File

@ -30,6 +30,11 @@
#include <regex>
#ifdef PDF4QT_COMPILER_MSVC
#pragma warning(push)
#pragma warning(disable:4125)
#endif
class LexicalAnalyzerTest : public QObject
{
Q_OBJECT
@ -1153,6 +1158,10 @@ QString LexicalAnalyzerTest::getStringFromTokens(const std::vector<pdf::PDFLexic
return QString("{ %1 }").arg(stringTokens.join(", "));
}
#ifdef PDF4QT_COMPILER_MSVC
#pragma warning(pop)
#endif
QTEST_APPLESS_MAIN(LexicalAnalyzerTest)
#include "tst_lexicalanalyzertest.moc"