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. 15
      generators/xps/generator_xps.cpp

@ -1104,13 +1104,24 @@ QImage XpsPage::loadImageFromFile( const QString &fileName )
return QImage(); return QImage();
} }
// TODO: consider case-insensitiveness (eg image.png vs existing image.PNG) QString absoluteFileName = absolutePath( entryPath( m_fileName ), fileName );
const QString absoluteFileName = absolutePath( entryPath( m_fileName ), fileName );
const KZipFileEntry* imageFile = static_cast< const KZipFileEntry * >( m_file->xpsArchive()->directory()->entry( absoluteFileName ) ); const KZipFileEntry* imageFile = static_cast< const KZipFileEntry * >( m_file->xpsArchive()->directory()->entry( absoluteFileName ) );
if ( !imageFile ) {
// 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 ) { if ( !imageFile ) {
// image not found // image not found
return QImage(); return QImage();
} }
}
/* WORKAROUND: /* WORKAROUND:
XPS standard requires to use 96dpi for images which doesn't have dpi specified (in file). When Qt loads such an image, XPS standard requires to use 96dpi for images which doesn't have dpi specified (in file). When Qt loads such an image,

Loading…
Cancel
Save