IDocumentDescriptor documentDescriptor) throws DocumentException {
XComponent xComponent = null;
PropertyValue[] properties = new PropertyValue[1];
try {
if (inputStream == null)
throw new DocumentException(
"The submitted input stream is not valid."); //$NON-NLS-1$
if (xComponentLoader == null || !officeConnection.isConnected())
xComponentLoader = constructComponentLoader();
checkMaxOpenDocuments(serviceProvider);
// begin task is done in class ByteArrayXInputStreamAdapter
// if(officeProgressMonitor != null)
// officeProgressMonitor.beginTask(Messages.getString("DocumentService_monitor_message_preparing_loading"), IOfficeProgressMonitor.WORK_UNKNOWN); //$NON-NLS-1$
ByteArrayXInputStreamAdapter byteArrayToXInputStreamAdapter = new ByteArrayXInputStreamAdapter(
inputStream, officeProgressMonitor);
properties[0] = new PropertyValue(
"InputStream", -1, byteArrayToXInputStreamAdapter, PropertyState.DIRECT_VALUE); //$NON-NLS-1$
properties = DocumentDescriptorTransformer
.documentDescriptor2PropertyValues(properties,
documentDescriptor);
if (frame == null)
xComponent = xComponentLoader.loadComponentFromURL(
"private:stream", "_blank", 0, properties); //$NON-NLS-1$ //$NON-NLS-2$
else
xComponent = xComponentLoader
.loadComponentFromURL(
"private:stream", frame.getXFrame().getName(), FrameSearchFlag.ALL, properties); //$NON-NLS-1$
} catch (Throwable throwable) {
throw new DocumentException(throwable);
}
if (officeProgressMonitor != null)
officeProgressMonitor.beginSubTask(Messages
.getString("DocumentService_monitor_investigating")); //$NON-NLS-1$
IDocument document = DocumentLoader.getDocument(xComponent,
serviceProvider, properties);
if (document != null) {
if (officeProgressMonitor != null) {
officeProgressMonitor
.beginSubTask(Messages
.getString("DocumentService_monitor_loading_completed")); //$NON-NLS-1$
officeProgressMonitor.done();
}
return document;
}
throw new DocumentException("The document can not be loaded."); //$NON-NLS-1$
}