[Java, SImpress] Save XDrawPage, Get Fullscreen presentation

Discuss the presentation application

[Java, SImpress] Save XDrawPage, Get Fullscreen presentation

Postby Bpinaquy » Mon Sep 21, 2015 4:32 pm

I'm trying to control a simpress presentation with a java program. I can get the next effect of my presentation but only when it's not fullscreen. If I put my PropertyValue "IsFullScreen" to "TRUE", my presentation.isRunning() return false, and my xSlideShowController is null.

Code: Select all   Expand viewCollapse view
    XComponent xComponent=null;
    XPresentation2 presentation2 =null;
    try {
        // get the remote office component context
        XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
        xComponent = openPresentation(xContext, url);
        XPresentationSupplier presentationSupplier = UnoRuntime.queryInterface(XPresentationSupplier.class, xComponent);
        XPresentation presentation = presentationSupplier.getPresentation();
        presentation2 = UnoRuntime.queryInterface(XPresentation2.class, presentation);
        PropertyValue[] aPresentationArgs = new PropertyValue[3];

            aPresentationArgs[0] = new PropertyValue();
            aPresentationArgs[0].Name = "IsAlwaysOnTop";
            aPresentationArgs[0].Value = Boolean.TRUE;

            aPresentationArgs[1] = new PropertyValue();
            aPresentationArgs[1].Name = "IsFullScreen";
            aPresentationArgs[1].Value = Boolean.TRUE;

            aPresentationArgs[2] = new PropertyValue();
            aPresentationArgs[2].Name = "IsAutomatic";
            aPresentationArgs[2].Value = Boolean.TRUE;


        presentation2.startWithArguments(aPresentationArgs);
        System.out.println(presentation2.isRunning()); ==> False
        if(presentation2==null)System.out.println("presentation2 null");



    }
    catch( Exception e) {
        e.printStackTrace(System.err);
        System.exit(1);
    }

   if (presentation2.isRunning()) {
       xSlideShowController = presentation2.getController();
       if(xSlideShowController==null)System.out.println("xSlideShowController null"); ==> Null
   }




I would like to save in a file the next slide. I tried this but my XStorable is null.


Code: Select all   Expand viewCollapse view
xSlideShowController.gotoFirstSlide();
   XDrawPage slidePreview = xSlideShowController.getSlideByIndex(xSlideShowController.getCurrentSlideIndex()+1);

   if(slidePreview==null)System.out.println("slidePreview null");
   String filePath = "home/bastien/Documents/slideshowtest.jpg";
       PropertyValue[] aStoreProperties = new PropertyValue[2];
       aStoreProperties[0] = new PropertyValue();
       aStoreProperties[1] = new PropertyValue();
       aStoreProperties[0].Name = "Override";
       aStoreProperties[0].Value = true;
       aStoreProperties[1].Name = "FilterName";
       aStoreProperties[1].Value = "slideshowtest";
       XComponent previewComponent =UnoRuntime.queryInterface(
                       XComponent.class, slidePreview);
       if(previewComponent==null)System.out.println("previewComponent null");
       XStorable xStorable = (XStorable) UnoRuntime.queryInterface(
                       XStorable.class, previewComponent);
       if(xStorable==null)System.out.println("xStorable null"); ==> Null
       xStorable.storeAsURL(filePath, aStoreProperties);


I tried this but XStorable is null too.

Code: Select all   Expand viewCollapse view
XStorable xStorable = (XStorable)     
UnoRuntime.queryInterface(XStorable.class, slidePreview);


Thanks
LibreOffice 5.0.1 on Ubuntu 14.04
Bpinaquy
 
Posts: 2
Joined: Mon Sep 21, 2015 4:26 pm

Re: [Java, SImpress] Save XDrawPage, Get Fullscreen presenta

Postby Bpinaquy » Tue Sep 22, 2015 2:20 pm

Ok, I found how to save the next slide as a picture :
Code: Select all   Expand viewCollapse view
public static boolean save(String fileName) throws IndexOutOfBoundsException, IOException, com.sun.star.uno.Exception {
    if(xSlideShowController.getCurrentSlideIndex() + 1>xSlideShowController.getSlideCount())return false;
    XDrawPage slidePreview = xSlideShowController.getSlideByIndex(xSlideShowController.getCurrentSlideIndex() + 1);
    java.io.File sourceFile = new java.io.File(fileName);
    if(sourceFile.createNewFile())return false;
    StringBuffer sTemplateFileUrl = new StringBuffer("file:///");
    sTemplateFileUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
    PropertyValue aFilterData_thumb[] = new PropertyValue[2];
    aFilterData_thumb[0] = new PropertyValue();
    aFilterData_thumb[0].Name = "PixelWidth";
    aFilterData_thumb[0].Value = 1241;

    aFilterData_thumb[1] = new PropertyValue();
    aFilterData_thumb[1].Name = "PixelHeight";
    aFilterData_thumb[1].Value = 1753;

    PropertyValue aProps_thumb[] = new PropertyValue[3];
    aProps_thumb[0] = new PropertyValue();
    aProps_thumb[0].Name = "MediaType";
    aProps_thumb[0].Value = "image/jpeg";

    aProps_thumb[1] = new PropertyValue();
    aProps_thumb[1].Name = "URL";
    aProps_thumb[1].Value = sTemplateFileUrl.toString();

    aProps_thumb[2] = new PropertyValue();
    aProps_thumb[2].Name = "FilterData";
    aProps_thumb[2].Value = aFilterData_thumb;

    XComponent xComp = UnoRuntime.queryInterface(XComponent.class, slidePreview);
    XMultiComponentFactory xMCF
            = xContext.getServiceManager();
    Object exportFilter = xMCF.createInstanceWithContext("com.sun.star.drawing.GraphicExportFilter", xContext);
    XExporter xExporter = UnoRuntime.queryInterface(XExporter.class, exportFilter);
    xExporter.setSourceDocument(xComp);
    XFilter xFilter = UnoRuntime.queryInterface(XFilter.class, xExporter);
    xFilter.filter(aProps_thumb);
    return true;

}


Still blocked with the fullscreen
LibreOffice 5.0.1 on Ubuntu 14.04
Bpinaquy
 
Posts: 2
Joined: Mon Sep 21, 2015 4:26 pm


Return to Impress

Who is online

Users browsing this forum: No registered users and 3 guests