Apache OpenOffice (AOO) Bugzilla – Issue 43995
word perfect detection throws unexpected exception for detection of unknown formats
Last modified: 2013-08-07 14:41:36 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.
Created attachment 23292 [details] stacktrace
Created attachment 23294 [details] example file
.
It has something to do with how we handle an OLE2 stream. Looking towards it.
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. :-)
JA: on Solaris loading such a file gives an unhandled exception: --> soffice crashes; changing priority
JA: modified version info as this issue is a regression which has been introduced by cws libwpdupgrade
JA: added myself to cc list
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
Created attachment 23347 [details] Possible patch to handle better exceptions in WPXSvInputStream class
FWIW, with this patch it behaves perfectly for me so ...
Created attachment 23357 [details] The above mentioned patch with some two more checks
The latest patch is solving the issue. Sorry for the regression we introduced. Fridrich
Reassigned to SBA.
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.
JA->SBA: ...and please load that math document on SolarisSparc because that cashed the application...
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.
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.
AS->SBA: Please verify this task on the cws fkwfinal1 again. THX. re-open issue and reassign to sba@openoffice.org
reassign to sba@openoffice.org
reset resolution to FIXED
SBA: Reopened to reassign.
SBA->JA: Welcome back. Please take over.
SBA: Set to "fixed" again.
*** Issue 45309 has been marked as a duplicate of this issue. ***
SBA: Reopened again...
...back to me...
SBA: Set to fixed.
SBA: Verified in CWS fwkfinal1.
*** Issue 45860 has been marked as a duplicate of this issue. ***
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