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

svn path=/trunk/KDE/kdegraphics/okular/; revision=977958
remotes/origin/KDE/4.3
Tobias Koenig 17 years ago
parent 913c95f58f
commit ea8c21630b
  1. 12
      generators/ooo/converter.cpp
  2. 6
      generators/ooo/document.cpp
  3. 1
      generators/ooo/formatproperty.cpp

@ -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 )
{
}

Loading…
Cancel
Save