Re: Problem with OO Slideshow

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: Problem with OO Slideshow

by Dustin Breese :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

HI, Thomas,

Here's the code I used.  I hope it comes across formatted, if not, apologies.

What I find odd is that the code will start up OO, but will just hang
there in the sleep loop until I click on the OO blank screen that
shows.  As soon as I click on it manually, it obtains a proper,
non-null reference to the controller and everything works fine.  If
anyone knows what's up, it would be greatly appreciated!

-Dustin

        public void start(String file) {
                try {
                        // get the remote office component context
                        XComponentContext xContext = Bootstrap.bootstrap();
                        XMultiComponentFactory xMCF = xContext.getServiceManager();
                        Object desktop =
xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
xContext);
                        XComponentLoader xComponentLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class,
                                        desktop);

                        PropertyValue[] fileProps = new PropertyValue[1];
                        fileProps[0] = new PropertyValue();
                        fileProps[0].Name = "ReadOnly";
                        fileProps[0].Value = Boolean.TRUE;

                        XComponent xDocument =
xComponentLoader.loadComponentFromURL("file:///Users/dbreese/Documents/"
+ file,
                                        "_default", 0, new PropertyValue[0]);

                        XPresentationSupplier supplier = (XPresentationSupplier)
UnoRuntime.queryInterface(
                                        XPresentationSupplier.class, xDocument);
                        XPresentation pres = supplier.getPresentation();
                        XPresentation2 pres2 = (XPresentation2)
UnoRuntime.queryInterface(XPresentation2.class, pres);

                        PropertyValue[] aPresentationArgs = new PropertyValue[4];

                        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;

                        aPresentationArgs[3] = new PropertyValue();
                        aPresentationArgs[3].Name = "AllowAnimations";
                        aPresentationArgs[3].Value = Boolean.TRUE;

                        pres2.startWithArguments(aPresentationArgs);
                        int maxLoops = 100;
                        while (maxLoops-- > 0) {
                                if (pres2.isRunning()) {
                                        System.err.println("Running now!");
                                        break;
                                }
                                System.err.println("Sleeping...");
                                Thread.sleep(1000);
                        }

                        if (pres2.isRunning()) {
                                XSlideShowController slideController = pres2.getController();
                                System.err.println("slideController = " + slideController);

                                if (slideController != null) {
                                        mSlideControllers.put(file, slideController);
                                }
                        } else {
                                System.err.println("Could not obtain slide controller!");
                        }
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                }
        }


On Thu, Oct 29, 2009 at 4:17 AM, Thomas Pietrzak
<thomas.pietrzak@...> wrote:

> Hi,
>
> I saw your messages about XSlideShowController on the openoffice API
> mailing list, and I have a problem close to the one you talked about.
> However I don't know how to post on the mailing list, and I'm in a rush
> for my project.
>
> I'm currently trying to make a little extensions that logs each slide
> change in a file with a time stamp. The problem  is that I can't find
> out how to access the presentation object. I need something like a
> callback when the presentation starts and when the slide changes.
>
> I think I could get the slide number with getCurrentSlideIndex from
> XSlideShowController. However I can't get an instance (actually THE
> instance) of XSlideShowController. With this code:
>
> XPresentationSupplier xPresentationSupplier =
>   (XPresentationSupplier) UnoRuntime.queryInterface(
>   XPresentationSupplier.class, m_xContext);
>
> xPresentationSupplier is null (m_xContext is not). I tried to add this
> code in the constructor of my extension, on in the buttonclick event. I
> even tried to call this after beginning a slideshow with a robot, but
> the result is the same.
>
> For information, my XComponentContext comes from the constructor, and
> not from the bootstrap. If I try a bootstrap I get an exception.
>
> So where do you put your code? Do you have any idea on how could I get
> what I want?
>
> Can you send me your code so that I can test the exact stuff?
>
> Many Thanks,
>
> Best Regards,
>
> ---
> Tom
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...