From 96c78eae6facd44125fcb5b69a9ba15917eef3d5 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 16 Dec 2013 00:18:03 +0100 Subject: [PATCH] odt: Seems styles.xml and meta.xml are not mandatory At least libreoffice opens the file from bug 324241 that has neither of them. With this change we open it too, it looks crap when compared to libreoffice, but that's just because our ooo generator needs to die in favour of a calligra one. BUGS: 324241 FIXED-IN: 4.11.5 --- generators/ooo/converter.cpp | 2 +- generators/ooo/document.cpp | 34 ++++++++++++++-------------------- generators/ooo/styleparser.cpp | 6 ++++++ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/generators/ooo/converter.cpp b/generators/ooo/converter.cpp index 5c150457c..1124e2a51 100644 --- a/generators/ooo/converter.cpp +++ b/generators/ooo/converter.cpp @@ -585,4 +585,4 @@ bool Converter::convertAnnotation( QTextCursor *cursor, const QDomElement &eleme emit addAnnotation( annotation, position, position + 3 ); return true; -} \ No newline at end of file +} diff --git a/generators/ooo/document.cpp b/generators/ooo/document.cpp index 4fe5538fc..51d0765a5 100644 --- a/generators/ooo/document.cpp +++ b/generators/ooo/document.cpp @@ -65,28 +65,22 @@ bool Document::open() mContent = file->data(); } - if ( !entries.contains( "styles.xml" ) ) { - setError( i18n( "Invalid document structure (styles.xml is missing)" ) ); - return false; - } - - file = static_cast( directory->entry( "styles.xml" ) ); - if ( mManifest->testIfEncrypted( "styles.xml" ) ) { - mStyles = mManifest->decryptFile( "styles.xml", file->data() ); - } else { - mStyles = file->data(); - } - - if ( !entries.contains( "meta.xml" ) ) { - setError( i18n( "Invalid document structure (meta.xml is missing)" ) ); - return false; + if ( entries.contains( "styles.xml" ) ) { + file = static_cast( directory->entry( "styles.xml" ) ); + if ( mManifest->testIfEncrypted( "styles.xml" ) ) { + mStyles = mManifest->decryptFile( "styles.xml", file->data() ); + } else { + mStyles = file->data(); + } } - file = static_cast( directory->entry( "meta.xml" ) ); - if ( mManifest->testIfEncrypted( "meta.xml" ) ) { - mMeta = mManifest->decryptFile( "meta.xml", file->data() ); - } else { - mMeta = file->data(); + if ( entries.contains( "meta.xml" ) ) { + file = static_cast( directory->entry( "meta.xml" ) ); + if ( mManifest->testIfEncrypted( "meta.xml" ) ) { + mMeta = mManifest->decryptFile( "meta.xml", file->data() ); + } else { + mMeta = file->data(); + } } if ( entries.contains( "Pictures" ) ) { diff --git a/generators/ooo/styleparser.cpp b/generators/ooo/styleparser.cpp index 57c710fbd..220b121b0 100644 --- a/generators/ooo/styleparser.cpp +++ b/generators/ooo/styleparser.cpp @@ -70,6 +70,9 @@ bool StyleParser::parseContentFile() bool StyleParser::parseStyleFile() { + if ( mDocument->styles().isEmpty() ) + return true; + QXmlSimpleReader reader; QXmlInputSource source; @@ -106,6 +109,9 @@ bool StyleParser::parseStyleFile() bool StyleParser::parseMetaFile() { + if ( mDocument->meta().isEmpty() ) + return true; + QXmlSimpleReader reader; QXmlInputSource source;