It appears that setting the Begin time (to say 1.0) on just com.sun.star.animations.Event nodes does what I need.

If I change all animation effect on a page to WITH_PREVIOUS, then trace the animation node hierarchy then I observe that there is no longer an com.sun.star.animations.Event node present. This may explain why simply forcing the node-type in user data does not fully work - I also needed to remove / reset the parent com.sun.star.animations.Event. This appears too complex (and more than a little hacky!) so gave up on this approach!

More problems to solve now ...

Regards,

~A


Andy Cordwell wrote:
Thanks for the suggestions, but I'm still struggling to get this working satisfactorily!

My test presentation is a simple 3 page affair created and saved in the native OpenOffice format. First page is 3 text items, with 2nd item start set to ON CLICK and third item set to AFTER_PREVIOUS. Page 2 is a graphic, page 3 is two text items (no effects). All items have been added with default settings, and the only changes made were to apply the animation effects. This presentation waits for user input before drawing the 2nd text item on page 1 (as expected!).

I've modified the Java code (see below again!) to iterate over the animation nodes as suggested. This program outputs the animation node type, begin duration, and each of the user settings entries (and a couple of other bits).

Christian suggested setting Begin = 0.0 for all nodes that have Begin == Timing::INDEFINITE. However, both the animated nodes already have the Begin set to 0.0 (see output).

If I blindly set Begin = 0.0 for *all* nodes then it appears to work, but I suspect this will lead to other problems?

I then tried manually replacing the 'node-type' user data entry (for ON_CLICK nodes) to WITH_PREVIOUS (see commented out code). Initially this showed the setting correctly as WITH_PREVIOUS in the UI, but otherwise didn't work. If I then continued and simply opened and accepted the Animation Effect dialog (note no user input made!) then the Presentation would run through without waiting for user input! Great - exactly what I want! I'm a bit lost to explain why this would work - a possible explanation is that some data item is being corrected based on the node type? Does anyone have any ideas whats happening or how to correct it?

OpenOffice 2.0.2 running in Fedora Core 4.

Thanks and regards,

Andy

------------------------------------------
-- OUTPUT TRACE

Page:0
       Processing an animation node:
Begin: Any[Type[void], null] Node Type:1 Duration: Any[Type[void], null] PAR
--class com.sun.star.uno.Any
               Name:node-type Value:5 (TIMING_ROOT)
       Processing an animation node:
Begin: Any[Type[void], null] Node Type:2 Duration: Any[Type[void], null] SEQ
--class com.sun.star.uno.Any
               Name:node-type Value:4 (MAIN_SEQUENCE)
       Processing an animation node:
Begin: [EMAIL PROTECTED] Node Type:1 Duration: Any[Type[void], null] PAR
--class com.sun.star.animations.Event
               No settings
       Processing an animation node:
               Begin: 0.0 Node Type:1 Duration: Any[Type[void], null] PAR
--class java.lang.Double
               No settings
       Processing an animation node:
               Begin: 0.0 Node Type:1 Duration: Any[Type[void], null] PAR
--class java.lang.Double
               Name:preset-property Value:Direction;Accelerate;Decelerate
               Name:node-type Value:1 (ON_CLICK)
               Name:preset-class Value:1
               Name:preset-id Value:ooo-entrance-fly-in
               Name:preset-sub-type Value:from-top-left
       Processing an animation node:
               Begin: 0.0 Node Type:5 Duration: 0.0010 SET
--class java.lang.Double
               No settings
       No more nodes
       Processing an animation node:
Begin: Any[Type[void], null] Node Type:4 Duration: 0.5 ANIMATE
--class com.sun.star.uno.Any
               No settings
       No more nodes
       Processing an animation node:
Begin: Any[Type[void], null] Node Type:4 Duration: 0.5 ANIMATE
--class com.sun.star.uno.Any
               No settings
       No more nodes
       Processing an animation node:
               Begin: 0.5 Node Type:1 Duration: Any[Type[void], null] PAR
--class java.lang.Double
               No settings
       Processing an animation node:
               Begin: 0.0 Node Type:1 Duration: Any[Type[void], null] PAR
--class java.lang.Double
               Name:preset-property Value:Direction;Accelerate;Decelerate
               Name:node-type Value:3 (AFTER_PREVIOUS)
               Name:preset-class Value:1
               Name:preset-id Value:ooo-entrance-fly-in
               Name:preset-sub-type Value:from-top-left
       Processing an animation node:
               Begin: 0.0 Node Type:5 Duration: 0.0010 SET
--class java.lang.Double
               No settings
       No more nodes
       Processing an animation node:
Begin: Any[Type[void], null] Node Type:4 Duration: 0.5 ANIMATE
--class com.sun.star.uno.Any
               No settings
       No more nodes
       Processing an animation node:
Begin: Any[Type[void], null] Node Type:4 Duration: 0.5 ANIMATE
--class com.sun.star.uno.Any
               No settings
       No more nodes
Page:1
       Processing an animation node:
Begin: Any[Type[void], null] Node Type:1 Duration: Any[Type[void], null] PAR
--class com.sun.star.uno.Any
               Name:node-type Value:5 (TIMING_ROOT)
Page:2
       Processing an animation node:
Begin: Any[Type[void], null] Node Type:1 Duration: Any[Type[void], null] PAR
--class com.sun.star.uno.Any
               Name:node-type Value:5 (TIMING_ROOT)


------------------------------------------
-- CODE

import com.sun.star.lang.XComponent;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.lang.XMultiComponentFactory;

import com.sun.star.awt.Point;
import com.sun.star.awt.Size;

import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;

import com.sun.star.container.XNamed;

import com.sun.star.drawing.XDrawPagesSupplier;
import com.sun.star.drawing.XDrawPages;
import com.sun.star.drawing.XDrawPageSupplier;
import com.sun.star.drawing.XDrawPage;
import com.sun.star.drawing.XShapes;
import com.sun.star.drawing.XShape;

import com.sun.star.animations.XAnimationNodeSupplier;
import com.sun.star.animations.XAnimationNode;
import com.sun.star.animations.XTimeContainer;
import com.sun.star.animations.XIterateContainer;
import com.sun.star.animations.Timing;
import com.sun.star.animations.AnimationNodeType;

import com.sun.star.presentation.XPresentation;
import com.sun.star.presentation.XPresentationSupplier;
import com.sun.star.presentation.ClickAction;
import com.sun.star.presentation.AnimationEffect;
import com.sun.star.presentation.AnimationSpeed;
import com.sun.star.presentation.EffectNodeType;

import com.sun.star.uno.XComponentContext;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Any;

import com.sun.star.frame.XComponentLoader;

import com.sun.star.container.XEnumeration;
import com.sun.star.container.XEnumerationAccess;
import com.sun.star.beans.NamedValue;


public class PresentationDemo2
{
   public static void EnumUserData( XAnimationNode animation_node )
   {
       boolean was_found = false;
       int found_index = -1;
             NamedValue [] aSettings = animation_node.getUserData();
             if (aSettings.length == 0)
       {
           System.out.println( "\t\tNo settings");
       }
             for (int i = 0; i < aSettings.length; ++i)
       {
           String name = (String)aSettings[i].Name.toString();
           String value = (String)aSettings[i].Value.toString();
System.out.print( "\t\tName:" + aSettings[i].Name + " Value:" + aSettings[i].Value + " " );

           if ( name.compareTo( "node-type" ) == 0 )
           {
               switch( new Integer( value ).intValue() )
               {
case EffectNodeType.DEFAULT:System.out.println( "(DEFAULT)"); break; case EffectNodeType.ON_CLICK:System.out.println( "(ON_CLICK)");break; case EffectNodeType.WITH_PREVIOUS:System.out.println( "(WITH_PREVIOUS)");break; case EffectNodeType.AFTER_PREVIOUS:System.out.println( "(AFTER_PREVIOUS)");break; case EffectNodeType.MAIN_SEQUENCE:System.out.println( "(MAIN_SEQUENCE)");break; case EffectNodeType.TIMING_ROOT:System.out.println( "(TIMING_ROOT)");break; case EffectNodeType.INTERACTIVE_SEQUENCE:System.out.println( "(INTERACTIVE_SEQUENCE)");break;
               }
                             /*
if ( new Integer( value ).intValue() == EffectNodeType.ON_CLICK )
               {
                   was_found = true;
                   found_index = i;
               }
               */
           }
           else
           {
               System.out.println( "" );
           }
       }
             /*
       // Set this node-type to WITH_PREVIOUS.
       if ( was_found )
       {
aSettings[ found_index ] = new com.sun.star.beans.NamedValue("node-type", new java.lang.Short( EffectNodeType.AFTER_PREVIOUS ));

           animation_node.setUserData( aSettings );

System.out.println( "\t\t***Updating onClick to Name:" + aSettings[found_index].Name + " Value:" + aSettings[found_index].Value + " " );
       }
       */
   }
     public static void ConvertNode( XAnimationNode animation_node )
   {
       System.out.println( "\tProcessing an animation node:" );

System.out.print( "\t\tBegin: " + animation_node.getBegin().toString() + " Node Type:" + animation_node.getType() + " Duration: " + animation_node.getDuration() + " ");
       if( animation_node.getBegin() == Timing.INDEFINITE )
       {
           // This never gets called!
           System.out.println( "*****" );
           //animation_node.setBegin( (double)0.0 );          }
switch( new Integer( animation_node.getType() ).intValue() )
       {
case AnimationNodeType.CUSTOM: System.out.println( "CUSTOM" ); break; case AnimationNodeType.PAR: System.out.println( "PAR" ); break; case AnimationNodeType.SEQ: System.out.println( "SEQ" ); break; case AnimationNodeType.ITERATE: System.out.println( "ITERATE" ); break; case AnimationNodeType.ANIMATE: System.out.println( "ANIMATE" ); break; case AnimationNodeType.SET: System.out.println( "SET" ); break; case AnimationNodeType.ANIMATEMOTION: System.out.println( "ANIMATEMOTION" ); break; case AnimationNodeType.ANIMATECOLOR: System.out.println( "ANIMATECOLOR" ); break; case AnimationNodeType.ANIMATETRANSFORM: System.out.println( "ANIMATETRANSFORM" ); break; case AnimationNodeType.TRANSITIONFILTER: System.out.println( "TRANSITIONFILTER" ); break; case AnimationNodeType.AUDIO: System.out.println( "AUDIO" ); break; case AnimationNodeType.COMMAND: System.out.println( "COMMAND" ); break;
       }

       Object object = animation_node.getBegin();
       System.out.println( "--" + object.getClass() );
             EnumUserData( animation_node );

XEnumerationAccess xEnumAccess = (XEnumerationAccess)UnoRuntime.queryInterface(XEnumerationAccess.class, animation_node);
       if( xEnumAccess != null )
       {
XEnumeration xEnum = (XEnumeration)xEnumAccess.createEnumeration();
           while( xEnum.hasMoreElements() )
           {
               try
               {
                   Object any = xEnum.nextElement();
XAnimationNode node = (XAnimationNode)UnoRuntime.queryInterface(XAnimationNode.class, any );

                   ConvertNode( node );
               }
               catch( Exception ex )
               {
                   System.out.println( "*** Failed:" + ex );
               }
           }
       }
       else
       {
           System.out.println( "\tNo more nodes" );
       }
   }

   public static void main( String args[] )
   {
       try
       {
           // Startup the loader
XComponentContext xOfficeContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); XMultiComponentFactory xServiceManager = xOfficeContext.getServiceManager(); Object oDesktop = xServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xOfficeContext ); XComponentLoader xCompLoader =(XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);

           // Open the document
String file_url = "/home/acordwell/OO_Test2/SimplePresentation.odp"; XComponent xComponent = xCompLoader.loadComponentFromURL( file_url, "_blank", 0, new com.sun.star.beans.PropertyValue[0] );

           int slide_show_duration = 2;
                     // Loop through each page and set the duration
XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier)UnoRuntime.queryInterface( XDrawPagesSupplier.class, xComponent );
           XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
           int i;
           for ( i = 0; i < xDrawPages.getCount(); i++ )
           {                          System.out.println( "Page:" + i );
XDrawPage xDrawPage = (XDrawPage)UnoRuntime.queryInterface( XDrawPage.class, xDrawPages.getByIndex( i )); XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xDrawPage);

               xPropSet.setPropertyValue( "Change", new Integer( 3 ) );
xPropSet.setPropertyValue( "Duration", new Integer( slide_show_duration ) ); XAnimationNodeSupplier animation_node_supplier = (XAnimationNodeSupplier)UnoRuntime.queryInterface(XAnimationNodeSupplier.class, xDrawPage); XAnimationNode animation_node = (XAnimationNode)animation_node_supplier.getAnimationNode();
               ConvertNode( animation_node );
           }

// start an endless presentation which is displayed in full-screen mode and placed on top XPresentationSupplier xPresSupplier = (XPresentationSupplier)UnoRuntime.queryInterface( XPresentationSupplier.class, xComponent );
           XPresentation xPresentation = xPresSupplier.getPresentation();

           // Start Presentation
XPropertySet xPresPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xPresentation ); xPresPropSet.setPropertyValue( "IsEndless", new Boolean( true ) ); xPresPropSet.setPropertyValue( "IsAlwaysOnTop", new Boolean( true ) ); xPresPropSet.setPropertyValue( "AllowAnimations", new Boolean( false ) ); xPresPropSet.setPropertyValue( "IsAutomatic", new Boolean( false ) ); // Automatic slide transition! xPresPropSet.setPropertyValue( "IsMouseVisible", new Boolean( false ) );

           xPresentation.start();
       }          catch( Exception ex )
       {
           System.out.println( ex );
       }
       System.exit( 0 );
   }
}


Andy Cordwell wrote:

I'd like to write a application that opens a PowerPoint presentation and plays it to the end, all without user intervention. I've written a Java program (based on the PresentationDemo sample - see below) that:

Opens the presentation
For each page, sets the Change = 1 and Duration = 5
Sets IsAutomatic = False in the Presentation property set. Together with above displays each page for 5 seconds then moves on.
Starts the presentation.

However, this will stop as soon as the first animated shape is encounter and waits for user input before animating and proceeding (which is unacceptable for my application since there will be no user input). Explicitly disabling the Animations Allowed property (both in the UI and from code) doesn't appear to do anything - the presentation still waits for user click before proceeding. Have I misunderstood what this feature will do?

One possible solution is to set Custom Animation ~ Effect ~ Start = "After Previous" and set the Effect Options ~ Timing ~ Delay = "a few seconds", applying these settings to each relevant animated shape. Unfortunately, I can't find a way of doing this through the API. Is this method supported through the Java / C++ API?
Are there any other suggestions to accomplish hands off playing?

I'm currently using Java for prototyping, and will rewrite in C++ once complete. Running version 2.0.2 under FedoraCore4.

Thanks,

Andy


public class PresentationDemo
{
   public static void main( String args[] )
   {
       try
       {
           // Startup the loader
XComponentContext xOfficeContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); XMultiComponentFactory xServiceManager = xOfficeContext.getServiceManager(); Object oDesktop = xServiceManager.createInstanceWithContext( "com.sun.star.frame.Desktop", xOfficeContext ); XComponentLoader xCompLoader =(XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);

           // Open the document
String file_url = "/home/mine/OO_Test2/SimplePresentation.odp"; XComponent xComponent = xCompLoader.loadComponentFromURL( file_url, "_blank", 0, new com.sun.star.beans.PropertyValue[0] );

           int slide_show_duration = 2;
                      // Loop through each page and set the duration
XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier)UnoRuntime.queryInterface( XDrawPagesSupplier.class, xComponent );
           XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
           int i;
           for ( i = 0; i < xDrawPages.getCount(); i++ )
{ System.out.println( "Page:" + i ); XDrawPage xDrawPage = (XDrawPage)UnoRuntime.queryInterface( XDrawPage.class, xDrawPages.getByIndex( i )); XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xDrawPage);

               xPropSet.setPropertyValue( "Change", new Integer( 1 ) );
xPropSet.setPropertyValue( "Duration", new Integer( slide_show_duration ) ); // Walk the animations object tree and set onClick to after previous
                              // get the shape container for page one
XShapes xShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, xDrawPage );

               int shape_index = 0;
for( shape_index = 0; shape_index < xShapes.getCount(); shape_index++ )
               {
XShape xShape = (XShape)UnoRuntime.queryInterface( XShape.class, xShapes.getByIndex( shape_index ) );

XPropertySet xShapePropSet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xShape ); //String handler = AnyConverter.toString( xShapePropSet.getPropertyValue( "OnClick") ); //Object handler = xShapePropSet.getPropertyValue( "OnClick"); ClickAction action = (ClickAction) xShapePropSet.getPropertyValue( "OnClick" ); String bookmark = (String)xShapePropSet.getPropertyValue( "Bookmark"); AnimationEffect effect = (AnimationEffect)xShapePropSet.getPropertyValue( "Effect" ); // -1 means no order. 0 + (doc state 1 - are they incorrect?) means animated. -1 means none int presentationOrder = ((Integer)xShapePropSet.getPropertyValue( "PresentationOrder" )).intValue(); short delay = ((Short)xShapePropSet.getPropertyValue( "TextAnimationDelay" )).shortValue(); AnimationSpeed speed = (AnimationSpeed)xShapePropSet.getPropertyValue( "Speed" );
                                      System.out.println(
                           "\tShape:" + shape_index +
                           " Action:" + action.getValue() +
                           " Effect:" + effect.getValue() +
                           " POrder:" + presentationOrder +
                           " Delay:" + delay +
                           " Speed:" + speed.getValue()
                           );

               }
           }
// start an endless presentation which is displayed in full-screen mode and placed on top XPresentationSupplier xPresSupplier = (XPresentationSupplier)UnoRuntime.queryInterface( XPresentationSupplier.class, xComponent ); XPresentation xPresentation = xPresSupplier.getPresentation();

           // Start Presentation
XPropertySet xPresPropSet = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xPresentation ); xPresPropSet.setPropertyValue( "IsEndless", new Boolean( true ) ); xPresPropSet.setPropertyValue( "IsAlwaysOnTop", new Boolean( true ) ); //xPresPropSet.setPropertyValue( "AllowAnimations", new Boolean( true ) ); xPresPropSet.setPropertyValue( "AllowAnimations", new Boolean( false ) ); xPresPropSet.setPropertyValue( "IsAutomatic", new Boolean( false ) ); // Automatic slide transition! xPresPropSet.setPropertyValue( "IsMouseVisible", new Boolean( false ) );
                                  xPresentation.start();
       }           catch( Exception ex )
       {
           System.out.println( ex );
       }
       System.exit( 0 );
   }





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to