Issue 43995 - word perfect detection throws unexpected exception for detection of unknown formats
Summary: word perfect detection throws unexpected exception for detection of unknown ...
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: 680m83
Hardware: All All
: P2 Trivial (vote)
Target Milestone: ---
Assignee: stefan.baltzer
QA Contact: issues@sw
URL:
Keywords:
: 45309 45860 (view as issue list)
Depends on:
Blocks:
 
Reported: 2005-03-03 13:50 UTC by andreas.schluens
Modified: 2013-08-07 14:41 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
stacktrace (2.87 KB, text/plain)
2005-03-03 13:52 UTC, andreas.schluens
no flags Details
example file (63.00 KB, application/vnd.sun.xml.math)
2005-03-03 13:53 UTC, andreas.schluens
no flags Details
Possible patch to handle better exceptions in WPXSvInputStream class (2.10 KB, patch)
2005-03-04 14:19 UTC, fridrich.strba
no flags Details | Diff
The above mentioned patch with some two more checks (2.60 KB, patch)
2005-03-04 15:37 UTC, fridrich.strba
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description andreas.schluens 2005-03-03 13:50:57 UTC
If the deep detection of the libwpd will be called with an unknown format (e.g. *.smf) 
it throws a css.io.NotConnectedException (see attached stack trace too).
For a detection component it's not allowed to throw any exception excepting 
runtime exceptions. It has to return an empty string value as result in case the 
incoming stream contains an unsupported format.
Comment 1 andreas.schluens 2005-03-03 13:52:36 UTC
Created attachment 23292 [details]
stacktrace
Comment 2 andreas.schluens 2005-03-03 13:53:22 UTC
Created attachment 23294 [details]
example file
Comment 3 rene 2005-03-03 13:58:19 UTC
. 
Comment 4 fridrich.strba 2005-03-03 15:52:49 UTC
It has something to do with how we handle an OLE2 stream. Looking towards it.
Comment 5 Mathias_Bauer 2005-03-04 12:37:52 UTC
The fix seems to be trivial. 

In WPXInputStream * WPXSvInputStream::getDocumentOLEStream()

you open a stream by calling

mxChildStream = mxChildStorage->OpenSotStream(
			rtl::OUString::createFromAscii( "PerfectOffice_MAIN" ),
			STREAM_STD_READ );

If the storage is another format you will of course not get a valid stream, so
before using this stream you must check it. A possible fix is:

WPXInputStream * WPXSvInputStream::getDocumentOLEStream()
{
	SvStream *pStream = utl::UcbStreamHelper::CreateStream( mxStream );
	mxChildStorage = new SotStorage( pStream, TRUE );
	mxChildStream = mxChildStorage->OpenSotStream(
			rtl::OUString::createFromAscii( "PerfectOffice_MAIN" ),
			STREAM_STD_READ );

        if ( !mxChildStream->GetError() )
        {
            Reference < XInputStream > xContents = new
utl::OSeekableInputStreamWrapper( mxChildStream );
            if (xContents.is())
                return new WPXSvInputStream( xContents );
        }    

        return NULL;
}

But of course YMMV. :-)
Comment 6 Joost Andrae 2005-03-04 13:15:37 UTC
JA: on Solaris loading such a file gives an unhandled exception: --> soffice
crashes; changing priority
Comment 7 Joost Andrae 2005-03-04 13:17:07 UTC
JA: modified version info as this issue is a regression which has been
introduced by cws libwpdupgrade
Comment 8 Joost Andrae 2005-03-04 13:18:39 UTC
JA: added myself to cc list
Comment 9 fridrich.strba 2005-03-04 14:15:50 UTC
fridrich_strba->mba: this fix was the first thing we were thinking about. We
tried it and also we added a redundant try ... catch in the constructor to
prevent mxStream->getLength() to throw an unhandled exception.
After these changes, the WordPerfectImportFilter::detect(...) gives a good
result, nevertheless, when the stream is handled to the next deep detection
service (I assume), one gets Read-Error, could not read the file.
For the while, I did not manage to track down what happens with the stream and why.
Any suggestion is welcome
Comment 10 fridrich.strba 2005-03-04 14:19:37 UTC
Created attachment 23347 [details]
Possible patch to handle better exceptions in WPXSvInputStream class
Comment 11 mmeeks 2005-03-04 15:32:46 UTC
FWIW, with this patch it behaves perfectly for me so ...
Comment 12 fridrich.strba 2005-03-04 15:37:33 UTC
Created attachment 23357 [details]
The above mentioned patch with some two more checks
Comment 13 fridrich.strba 2005-03-04 15:43:29 UTC
The latest patch is solving the issue. Sorry for the regression we introduced.
Fridrich
Comment 14 michael.ruess 2005-03-06 11:13:16 UTC
Reassigned to SBA.
Comment 15 Joost Andrae 2005-03-06 15:29:34 UTC
JA->AS: could you please take care about the integration of that patch and could
you then send this issue back to SBA when there's a CWS available? AFAIK SBA
doesn't know much about the context of this issue and I would volunteer to QA it
but as far as I'll be offsite (at least for CeBIT trade fair) someone else needs
to test it. Reassigned from SBA to you.

JA->SBA: what to test:
When ffortpf.smf is loaded then the filter dialog needs to appear because this
Math storage contains wrong header information. Additionally a file load test is
needed because Writer file detection was modified by integrating CWS
libwpdupgrade. Because of the size of this filter additional file load
performance tests may be of use (maybe MT could help you to automate this via
API) but that's secondary. Please ask Jack to redo his wpd tests again.
Comment 16 Joost Andrae 2005-03-06 15:31:34 UTC
JA->SBA: ...and please load that math document on SolarisSparc because that
cashed the application...
Comment 17 andreas.schluens 2005-03-07 10:42:25 UTC
AS: The patch was applied successfully ... excepting the "seek(0...)" command. 
This seek problem was solved more generic inside the type detection framework, 
which calls such detect services. That isnt a problem of this special detector ... it's 
a problem of the following used detector.
Comment 18 fridrich.strba 2005-03-07 18:45:23 UTC
Just FYI: the problem we had was with documents that are OLE documents and who
pass through our TypeDetection. To test whether the problem is solved, it is
enough to take an MS Word or Excell document, strip out the extension and try to
load it. There was no problem while loading any other non-OLE document. The
typedetection worked alway well with WordPerfect OLE documents too.
Libwpd project has a test suite with a lot of documents that can be checked out
from libwpd's CVS: http://sourceforge.net/cvs/?group_id=62662 Module "regression"
Thanks for your work in order to help us to solve this problem.
Comment 19 andreas.schluens 2005-03-15 06:42:06 UTC
AS->SBA: Please verify this task on the cws fkwfinal1 again. THX.

re-open issue and reassign to sba@openoffice.org
Comment 20 andreas.schluens 2005-03-15 06:42:11 UTC
reassign to sba@openoffice.org
Comment 21 andreas.schluens 2005-03-15 06:42:16 UTC
reset resolution to FIXED
Comment 22 stefan.baltzer 2005-03-18 11:49:14 UTC
SBA: Reopened to reassign.
Comment 23 stefan.baltzer 2005-03-18 11:50:09 UTC
SBA->JA: Welcome back. Please take over.
Comment 24 stefan.baltzer 2005-03-18 11:50:36 UTC
SBA: Set to "fixed" again.
Comment 25 oc 2005-03-18 11:54:25 UTC
*** Issue 45309 has been marked as a duplicate of this issue. ***
Comment 26 stefan.baltzer 2005-03-18 15:13:31 UTC
SBA: Reopened again...
Comment 27 stefan.baltzer 2005-03-18 15:14:01 UTC
...back to me...
Comment 28 stefan.baltzer 2005-03-18 15:14:35 UTC
SBA: Set to fixed.
Comment 29 stefan.baltzer 2005-03-18 15:15:15 UTC
SBA: Verified in CWS fwkfinal1.
Comment 30 Mathias_Bauer 2005-03-23 16:09:34 UTC
*** Issue 45860 has been marked as a duplicate of this issue. ***
Comment 31 andreas.schluens 2005-04-06 09:26:12 UTC
*** Issue 45860 has been marked as a duplicate of this issue. ***
Comment 32 stefan.baltzer 2005-06-22 10:02:00 UTC
SBA: OK in 680m106. Closed.
Note: Unfortunately, now "the next" module (database) throws an unhandled
exception when trying to load this file. 
=> Follow-up issue 51088 with target OOo 2.01