Apache OpenOffice (AOO) Bugzilla – Issue 85875
Hang on Disposing XComponent/XDesktop
Last modified: 2013-07-30 02:38:24 UTC
Hello, I am using OO to convert PPTs/ODPs to multiple PDFs(generating a pdf per slide of PPT). I use C# as my programming language. I use this utility from a windows service to convert PPTs to PDFs and I always make sure that OO is not called from multiple threads. I have written the following code to do so. but when ever i try to dispose/terminate some thing(such as xcomponent/xdesktop object) OO hangs. Please note that this code is working on Windows XP and problem occurs only to Win2K3. I have looked into bug 79541 as well but this does not help either because the hang seems like OS specific now. I have tried using XCloseable's close as well but it also hangs. The code follows: XComponent xComponent = null; XComponentLoader xComponentLoader = null; try { // Get the component Loader for the OO. xComponentLoader = this.GetComponentLoader(); PropertyValue[] loadProps = new PropertyValue[1]; PropertyValue asHidden = new PropertyValue(); string pptPath = “file:///C:/Test.ppt”; asHidden.Name = "Hidden"; asHidden.Value = new uno.Any(true); loadProps[0] = asHidden; xComponent = xComponentLoader.loadComponentFromURL(pptPath, "_blank", 0, loadProps); unoidl.com.sun.star.drawing.XDrawPagesSupplier xDrawPagesSupplier = (unoidl.com.sun.star.drawing.XDrawPagesSupplier)xComponent; // XDrawPages inherits from com.sun.star.container.XIndexAccess unoidl.com.sun.star.drawing.XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages(); // get the page count for standard pages int slideCount = xDrawPages.getCount(); xComponent.dispose(); // The following way is very slow, but i could not find a better // way to do this. for (int index = 0; index < slideCount; ++index) { pdfOutPath += outFileName + "_" + index + ".pdf"; ooOutPath = ToOOURL(pdfOutPath); xComponent = xComponentLoader.loadComponentFromURL(pptPath, "_blank", 0, loadProps); while (xComponent == null) { /Let the component load. System.Threading.Thread.Sleep(1000); } xDrawPagesSupplier = (unoidl.com.sun.star.drawing.XDrawPagesSupplier) xComponent; // XDrawPages inherits from com.sun.star.container.XIndexAccess xDrawPages = xDrawPagesSupplier.getDrawPages(); XStorable xstorable = (XStorable)xComponent; // Remove all the slides except this one. for (int removeSlide = slideCount - 1; removeSlide >= 0; --removeSlide) { if (removeSlide != index) { unoidl.com.sun.star.drawing.XDrawPage removePage = (unoidl.com.sun.star.drawing.XDrawPage) xDrawPages.getByIndex(removeSlide).Value; // Remove the Slide. xDrawPages.remove(removePage); } } PropertyValue[] props = new PropertyValue[1]; props[0] = new PropertyValue(); props[0].Name = "FilterName"; props[0].Value = new uno.Any(“impress_pdf_export”); // Store to the given path. xstorable.storeToURL(ooOutPath, props); xComponent.dispose(); // This line causes problem } } catch (System.Exception e) { string errorStr = "Can't Convert Using Open Office"; } finally { // Quit Open Office. ((XDesktop)xComponentLoader).terminate(); // This line as well. } [/b]
query the XComponent or XCloseable and use close
change prio, no P1 please use default priorities if you are not sure which you have to use.
jsc -> as: maybe you want to comment this issue. I would say the right approach is to use XCloseable as mentioned before. But anyway the office shouldn't crash.
I have the same issue when running on Windows 2003. Using XCloseable calls Dispose anyway, which then hangs without returning and with no exception.
Hi, i had the same problem. If I do the disposal in a new thread, then it seems to work. I hope that helps. Regards, Markus p.s.: Below the code I use. try { new Thread() { public void run() { xComponent.dispose() } }.start(); } catch (Exception e) { e.printStackTrace(); }
Reset assignee on issues not touched by assignee in more than 1000 days.