a_cooper General User

Joined: 06 May 2008 Posts: 11
|
Posted: Wed May 07, 2008 2:00 pm Post subject: HowTo get Document Properties from Calc, Impress, PDF [Java] |
|
|
OpenOffice.org 2.4.0, running on XP Pro, Java 1.6
I am trying to read the document properties (title, subject, author, keywords) from Word, Excel, PowerPoint and PDF documents using a Java program that utilitizes the OOo libraries.
I have successfully been able to get the doc properties from a MS Word file. However, I have hit a roadblock with Excel and haven't attempted PowerPoint or PDF yet. I am getting a nullPointerException when I call the getDocumentInfo() method on the object of type XDocumentInfoSupplier.
Here is the offending code. A valid XSpreadsheetDocument is being passed into the function:
| Code: |
private XPropertySet getDocumentProperties(XSpreadsheetDocument theDoc) {
XDocumentInfoSupplier xDocumentInfo = (XDocumentInfoSupplier) UnoRuntime.queryInterface(XDocumentInfoSupplier.class, theDoc);
Object oDocumentInfo = xDocumentInfo.getDocumentInfo(); // throws Null Pointer here!
XPropertySet pDocumentInfo = (XPropertySet)UnoRunTime.queryInterface(XPropertySet.class, oDocumentInfo); // never gets here
return pDocumentInfo;
}
|
Thanks for looking and thanks for any help you can give. |
|