Commit da5fdc15 authored by Fabio Bas's avatar Fabio Bas Committed by Albert Astals Cid
Browse files

XPS: fix multipiece image loading

Turns out some files contain images saved in the xps archive as a directory containing multiple pieces, the first one being the image itself and the second one being empty.
Of course this is quite a weird way to save an image, but it seems that it still is valid and other viewers are able to load it correctly.
This change fixes the loading of multipiece images.

(cherry picked from commit 3506fb2e)
parent 3e919b42
......@@ -520,12 +520,6 @@ static const KArchiveEntry *loadEntry(KZip *archive, const QString &fileName, Qt
return nullptr;
}
static const KZipFileEntry *loadFile(KZip *archive, const QString &fileName, Qt::CaseSensitivity cs)
{
const KArchiveEntry *entry = loadEntry(archive, fileName, cs);
return entry->isFile() ? static_cast<const KZipFileEntry *>(entry) : nullptr;
}
/**
\return The name of a resource from the \p fileName
*/
......@@ -1491,7 +1485,7 @@ QImage XpsPage::loadImageFromFile(const QString &fileName)
}
QString absoluteFileName = absolutePath(entryPath(m_fileName), fileName);
const KZipFileEntry *imageFile = loadFile(m_file->xpsArchive(), absoluteFileName, Qt::CaseInsensitive);
const KArchiveEntry *imageFile = loadEntry(m_file->xpsArchive(), absoluteFileName, Qt::CaseInsensitive);
if (!imageFile) {
// image not found
return QImage();
......@@ -1509,7 +1503,7 @@ QImage XpsPage::loadImageFromFile(const QString &fileName)
*/
QImage image;
QByteArray data = imageFile->data();
QByteArray data = readFileOrDirectoryParts(imageFile);
QBuffer buffer(&data);
buffer.open(QBuffer::ReadOnly);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment