* @date 09.07.2007
*/
public ITextDocumentImage constructNewImage(GraphicInfo graphicInfo) throws TextException {
try {
if(xMultiServiceFactory == null)
throw new TextException("OpenOffice.org XMultiServiceFactory inteface not valid.");
if(xBitmapContainer == null)
xBitmapContainer = (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class,
xMultiServiceFactory.createInstance("com.sun.star.drawing.BitmapTable"));
XTextContent xImage = (XTextContent)UnoRuntime.queryInterface(XTextContent.class,
xMultiServiceFactory.createInstance("com.sun.star.text.TextGraphicObject"));
XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xImage);
String tempId = "tempImageId"+System.currentTimeMillis();
xBitmapContainer.insertByName(tempId, graphicInfo.getUrl());
String internalURL = AnyConverter.toString(xBitmapContainer.getByName(tempId));
xProps.setPropertyValue("AnchorType", graphicInfo.getAnchor());
xProps.setPropertyValue("GraphicURL", internalURL);
xProps.setPropertyValue("Width", Integer.valueOf(graphicInfo.getWidth()));
xProps.setPropertyValue("Height", Integer.valueOf(graphicInfo.getHeight()));
xProps.setPropertyValue("HoriOrient", Short.valueOf(graphicInfo.getHorizontalAlignment()));
xProps.setPropertyValue("VertOrient", Short.valueOf(graphicInfo.getVerticalAlignment()));
ITextDocumentImage textDocumentImage = new TextDocumentImage(textDocument, xImage, graphicInfo);
if(imageToImageIds == null)
imageToImageIds = new HashMap<ITextDocumentImage,String>();
imageToImageIds.put(textDocumentImage, tempId);
return textDocumentImage;
}
catch(Exception exception) {
TextException textException = new TextException(exception.getMessage());
textException.initCause(exception);
throw textException;
}
}