Commit ea8c2163 authored by Tobias Koenig's avatar Tobias Koenig

Make parsing ODT files more robust if page width/height is wrong or missing

svn path=/trunk/KDE/kdegraphics/okular/; revision=977958
parent 913c95f5
......@@ -128,8 +128,16 @@ QTextDocument* Converter::convert( const QString &fileName )
*/
const QString masterLayout = mStyleInformation->masterPageName();
const PageFormatProperty property = mStyleInformation->pageProperty( masterLayout );
mTextDocument->setPageSize( QSize( qRound( property.width() / 72.0 * Okular::Utils::dpiX() ),
qRound( property.height() / 72.0 * Okular::Utils::dpiY() ) ) );
int pageWidth = qRound(property.width() / 72.0 * Okular::Utils::dpiX());
int pageHeight = qRound(property.height() / 72.0 * Okular::Utils::dpiY());
if ( pageWidth == 0 )
pageWidth = 600;
if ( pageHeight == 0 )
pageHeight = 800;
mTextDocument->setPageSize( QSize( pageWidth, pageHeight ) );
QTextFrameFormat frameFormat;
frameFormat.setMargin( qRound( property.margin() ) );
......
......@@ -52,7 +52,7 @@ bool Document::open()
// we should really get the file names from the manifest, but for now, we only care
// if the manifest says the files are encrypted.
if ( !entries.contains( "content.xml" ) ) {
setError( i18n( "Invalid document structure (content.xml is missing)" ) );
return false;
......@@ -97,9 +97,9 @@ bool Document::open()
file = static_cast<const KArchiveFile*>( imagesDirectory->entry( imagesEntries[ i ] ) );
QString fullPath = QString( "Pictures/%1" ).arg( imagesEntries[ i ] );
if ( mManifest->testIfEncrypted( fullPath ) ) {
mImages.insert( fullPath, mManifest->decryptFile( fullPath, file->data() ) );
mImages.insert( fullPath, mManifest->decryptFile( fullPath, file->data() ) );
} else {
mImages.insert( fullPath, file->data() );
mImages.insert( fullPath, file->data() );
}
}
}
......
......@@ -288,6 +288,7 @@ void StyleFormatProperty::setTableCellFormat( const TableCellFormatProperty &for
}
PageFormatProperty::PageFormatProperty()
: mHeight( 0.0 ), mWidth( 0.0 )
{
}
......
Markdown is supported
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