Apache OpenOffice (AOO) Bugzilla – Issue 100944
Crash after exporting to Excel
Last modified: 2017-05-20 10:29:23 UTC
ab->fs: As discussed, this is a follow up issue to: http://www.openoffice.org/issues/show_bug.cgi?id=100834 Please look there for the description how to reproduce. This issue covers problem 2. mentioned there. While re- producing I got a stack, I will attach to this issue.
Created attachment 61453 [details] Stack found while reproducing problem (starting macro must be finished to avoid Basic related problem)
Created attachment 61615 [details] stripped version of the test case
The attached document i100944.ods contains a stripped-down version of the test case originally attached to issue issue 100834. Just open the document, and press the "Export" button, to reproduce the crash.
fs->r_rethmann: Uhm, your SaveDocAsExcel is does a *very* nasty thing: oDoc.getDrawPages.getByIndex(0).Forms.dispose() That's the source of all evil: never ever (NEVER EVER!) dispose an object which you do not own! And in this case, you certainly do not own the forms collection. I can probably fix the crash, but you will definitely need to adjust your macro to reach what you intended to reach (which I assume is "removing all form controls from the document").
fixed in CWS dba32b find more information about this CWS, like when it is available in the master builds, in EIS, the Environment Information System: http://eis.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fdba32b
Okay, the script doesn't crash OOo anymore. I am not sure the resulting Excel document is okay, I know too little about Excel. In OpenOffice.org, a form control is a duality of a form control model (the ones you see in the form navigator), and control shapes in the drawing layer, which are associated with a control model. The script removes all control models (and all logical forms) from the document, but the shapes remain. When saving this as Calc document, this would result in a document corruption (but one which OOo will silently deal with). I do not know whether the resulting Excel documents are also corrupted. A clean solution to remove all form controls from the document would mean to - iterate over all shapes in the draw page - check which shape supports the XControlShape interface - remove this shape from the document - finally remove and dispose (which is allowed then, since removal made you the owner) all elements of the DrawPage.Forms (*not* the Forms object itself) This would leave you with a consistent document.
@fs: You are right, disposing the form element was nasty. Sorry for that. I've changed that in my code according to your suggestion. After deleting the shapes (which also automatically deletes the controls) I don't have to delete any forms. Empty forms won't get exported to Excel anyways. Thanks for your help!
fs->msc: please verify in CWS dba32b
re-opening, crashs again in most recent CWS build. Moving to CWS dba32e.
back to me
fixed in DEV300.m50, which is where dba32b was integrated. Seems my very last test on this CWS (before it was integrated) used an obsolete version (well possible given the build hassle we had), so it was indeed fixed in this CWS, as originally claimed.