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
remotes/origin/KDE/4.1
Pino Toscano 18 years ago
parent f817bde307
commit af05a86e04
  1. 21
      generators/xps/generator_xps.cpp

@ -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:

Loading…
Cancel
Save