import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySetInfo; import com.sun.star.drawing.XDrawPage; import com.sun.star.drawing.XDrawPages; import com.sun.star.drawing.XDrawPagesSupplier; import com.sun.star.drawing.XShape; import com.sun.star.drawing.XShapes; import com.sun.star.frame.XComponentLoader; import com.sun.star.lang.XComponent; import com.sun.star.lib.uno.adapter.ByteArrayToXInputStreamAdapter; import com.sun.star.uno.UnoRuntime; import net.sf.jooreports.openoffice.connection.OpenOfficeConnection; import net.sf.jooreports.openoffice.connection.OpenOfficeException; import net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection; import org.apache.commons.io.IOUtils; import org.springframework.core.io.FileSystemResourceLoader; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; public class NameBug { // Why is there no useful constructor for PropertyValue? protected static PropertyValue property(String _name,Object _value) { PropertyValue propertyValue=new PropertyValue(); propertyValue.Name=_name; propertyValue.Value=_value; return(propertyValue); } public static void main(String _arg[]) throws Exception { OpenOfficeConnection connection=new SocketOpenOfficeConnection("localhost",2002); connection.connect(); XComponentLoader desktop=connection.getDesktop(); ResourceLoader resourceLoader=new FileSystemResourceLoader(); Resource badName=resourceLoader.getResource("bad-name.odp"); try { XComponent xImpress=desktop.loadComponentFromURL("private:stream","_blank",0,new PropertyValue[] { property("Hidden",Boolean.TRUE), property("InputStream",new ByteArrayToXInputStreamAdapter(IOUtils.toByteArray(badName.getInputStream()))) }); try { XDrawPagesSupplier xDrawPagesSupplier=(XDrawPagesSupplier)UnoRuntime.queryInterface(XDrawPagesSupplier.class,xImpress); XDrawPages xDrawPages=xDrawPagesSupplier.getDrawPages(); XDrawPage xDrawPage=(XDrawPage)UnoRuntime.queryInterface(XDrawPage.class,xDrawPages.getByIndex(0)); XShapes xShapes=(XShapes)UnoRuntime.queryInterface(XShapes.class,xDrawPage); int shapeCount=xShapes.getCount(); System.out.println("shapeCount="+shapeCount); for (int i=0;i