In case an image is not found, try uppercasing its extension and looking for it again.

(yay for case-insensitive contexts!)

svn path=/trunk/KDE/kdegraphics/okular/; revision=825261
This commit is contained in:
Pino Toscano 2008-06-27 17:42:42 +00:00
parent f817bde307
commit af05a86e04

View file

@ -1104,12 +1104,23 @@ QImage XpsPage::loadImageFromFile( const QString &fileName )
return QImage();
}
// TODO: consider case-insensitiveness (eg image.png vs existing image.PNG)
const QString absoluteFileName = absolutePath( entryPath( m_fileName ), fileName );
const KZipFileEntry* imageFile = static_cast<const KZipFileEntry *>(m_file->xpsArchive()->directory()->entry( absoluteFileName ));
QString absoluteFileName = absolutePath( entryPath( m_fileName ), fileName );
const KZipFileEntry* imageFile = static_cast< const KZipFileEntry * >( m_file->xpsArchive()->directory()->entry( absoluteFileName ) );
if ( !imageFile ) {
// image not found
return QImage();
// image not found, try uppercasing the extension
const int dotPos = absoluteFileName.lastIndexOf( QLatin1Char( '.' ) );
const QChar lastChar = absoluteFileName.at( absoluteFileName.count() - 1 );
if ( dotPos != -1 ) {
for ( int i = dotPos + 1; i < absoluteFileName.count(); ++i ) {
absoluteFileName[i] = absoluteFileName[i].toUpper();
}
imageFile = static_cast< const KZipFileEntry * >( m_file->xpsArchive()->directory()->entry( absoluteFileName ) );
}
if ( !imageFile ) {
// image not found
return QImage();
}
}
/* WORKAROUND: