Bug 281166

Summary: Testcase where .doc import gives message "Could not open xxx.doc. Reason: Internal error"
Product: [Applications] calligrawords Reporter: Thomas Fischer <fischer>
Component: docAssignee: Matus Uzak <matus.uzak>
Status: RESOLVED FIXED    
Severity: normal CC: matus.uzak, sebsauer, swathi.vegesna999
Priority: NOR    
Version: 2.4-snapshots   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Test case where import fails

Description Thomas Fischer 2011-09-01 11:33:45 UTC
Version:           2.4-snapshots (using KDE 4.6.5) 
OS:                Linux

Opening attached file as downloaded from http://yia.org.ua/apl/partnership_indetification_5.doc gives error message:

Could not open
/tmp/partnership_indetification_5.doc.
Reason: Internal error


Reproducible: Didn't try

Steps to Reproduce:
Open attached file.

Actual Results:  
See error message appearing immediately.

Expected Results:  
File should be opened just as LibreOffice does.
Comment 1 Thomas Fischer 2011-09-01 11:34:31 UTC
Created attachment 63284 [details]
Test case where import fails
Comment 2 Sebastian Sauer 2011-09-02 09:03:30 UTC
Easy fix for the problem;

diff --git a/filters/words/msword-odf/wv2/src/styles.cpp b/filters/words/msword-odf/wv2/src/styles.cpp
index fcc0902..e7d93e2 100644
--- a/filters/words/msword-odf/wv2/src/styles.cpp
+++ b/filters/words/msword-odf/wv2/src/styles.cpp
@@ -377,7 +377,7 @@ bool STD::readStyleName( const U16 stdfSize, const U16 stdBytesLeft, OLEStreamRe
         //Each name, whether primary or alternate, MUST NOT be empty and MUST
         //be unique within all names in the stylesheet.
 
-        if ( ((length * 2) > stdBytesLeft) || (length == 0) ) {
+        if ( ((length * 2) > stdBytesLeft) /*|| (length == 0)*/ ) {
             wvlog << "xstzName length invalid";
             return false;
         }

The proper fix would be to figure out why the xstzName has a length of zero what is according to the specs invalid. Maybe that just means that we need to skip + ignore the style? Or maybe it means we need to use an generated name (so, it's a defined but unused style)? Or there is still some undocumented thing going on :-/
Comment 3 Matus Uzak 2011-09-08 17:00:56 UTC
I'm getting the "Invalid File Format" message.
Comment 4 Matus Uzak 2011-09-09 14:19:06 UTC
Git commit 7cb94839a9ba53f7c297f31ad5d148f697bdda28 by Matus Uzak.
Committed on 09/09/2011 at 16:14.
Pushed by uzak into branch 'master'.

DOC: Updated processing of invalid user defined styles.

* If the only problem of a user defined style is an invalid style name, let's generate a unique style name for it.
  We could use the corresponding default style, but a lot of modifications would be required for both wv2 and handlers.
  Let's keep it simple.

BUG:281166

M  +40   -38   filters/words/msword-odf/wv2/src/styles.cpp
M  +15   -4    filters/words/msword-odf/wv2/src/styles.h

http://commits.kde.org/calligra/7cb94839a9ba53f7c297f31ad5d148f697bdda28
Comment 5 swathi 2011-09-13 12:33:20 UTC
In git commit 79697867a34448f3472bbd3243247cb141ee11bf ,test data opens fine .