"com.sun.star.frame.Desktop",
xComponentContext));
//System.out.println("Loading document "+url);
FTPClient ftp = new FTPClient();
if(!host.equals("localhost")){
//ftp connexion
ftp.setRemoteHost(host);
ftp.connect();
ftp.login(ftpuser, ftpPasswd);
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.setType(FTPTransferType.BINARY);
try{
ftp.mkdir(remoteFolder);
}catch(Exception e){}
ftp.chdir(remoteFolder);
ftp.put(url,"presentation.ppt");
url = remoteFolderFullPath+"/"+remoteFolder+"/presentation.ppt";
}
PropertyValue[] loadProps = new PropertyValue[2];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
// open the document
XComponent component = xcomponentloader
.loadComponentFromURL(url,
"_blank", 0, loadProps);
//System.out.println("Document Opened");
// filter
loadProps = new PropertyValue[4];
// type of image
loadProps[0] = new PropertyValue();
loadProps[0].Name = "MediaType";
loadProps[0].Value = "image/png";
// Height and width
PropertyValue[] filterDatas = new PropertyValue[4];
for(int i = 0; i<4 ; i++){
filterDatas[i] = new PropertyValue();
}
filterDatas[0].Name = "PixelWidth";
filterDatas[0].Value = new Integer(width);
filterDatas[1].Name = "PixelHeight";
filterDatas[1].Value = new Integer(height);
filterDatas[2].Name = "LogicalWidth";
filterDatas[2].Value = new Integer(2000);
filterDatas[3].Name = "LogicalHeight";
filterDatas[3].Value = new Integer(2000);
XDrawPagesSupplier pagesSupplier = (XDrawPagesSupplier) UnoRuntime
.queryInterface(XDrawPagesSupplier.class, component);
//System.out.println(pagesSupplier.toString());
XDrawPages pages = pagesSupplier.getDrawPages();
int nbPages = pages.getCount();
for (int i = 0; i < nbPages; i++) {
XDrawPage page = (XDrawPage) UnoRuntime.queryInterface(
com.sun.star.drawing.XDrawPage.class, pages
.getByIndex(i));
XNamed xPageName = (XNamed)UnoRuntime.queryInterface(XNamed.class,page);
xPageName.setName("slide"+(i+1));
//if(!xPageName.getName().equals("slide"+(i+1)) && !xPageName.getName().equals("page"+(i+1)))
//xPageName.setName((i+1)+"-"+xPageName.getName());
Object GraphicExportFilter = xMultiComponentFactory
.createInstanceWithContext(
"com.sun.star.drawing.GraphicExportFilter",
xComponentContext);
XExporter xExporter = (XExporter) UnoRuntime
.queryInterface(XExporter.class,
GraphicExportFilter);
XComponent xComp = (XComponent) UnoRuntime
.queryInterface(XComponent.class, page);
xExporter.setSourceDocument(xComp);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "URL";
loadProps[1].Value = remoteFolderFullPath+remoteFolder+"/"+xPageName.getName()+".png";
loadProps[2] = new PropertyValue();
loadProps[2].Name = "FilterData";
loadProps[2].Value = filterDatas;
loadProps[3] = new PropertyValue();
loadProps[3].Name = "Quality";
loadProps[3].Value = new Integer(100);
XFilter xFilter = (XFilter) UnoRuntime.queryInterface(XFilter.class, GraphicExportFilter);
xFilter.filter(loadProps);
System.out.println(xPageName.getName()+".png");
//System.out.println("Page saved to url "+loadProps[1].Value);
}
if(!host.equals("localhost")){
String[] files = ftp.dir();
for (int i = 0; i < files.length; i++){
//System.out.println("Transfer of "+files[i]+ "to "+destinationFolder+"/"+files[i]);
if(!files[i].equals("presentation.ppt"))
ftp.get(destinationFolder+"/"+files[i],files[i]);
ftp.delete(files[i]);
}
ftp.chdir("..");
ftp.rmdir(remoteFolder);
ftp.quit();
}
//System.out.println("Closing Document");
component.dispose();
//System.out.println("Document close");