Impress: assign Custom animation effect to selected (repost)

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

I'm reposting this (clarified) question that I originally posted to the Impress subforum
( http://user.services.openoffice.org/en/ ... 10&t=10387 )

Background: On each Impress slide I put several text elements and then assign the Custom Animation effect "Appear" to each. So for each slide I first get textblock1 displayed and after next click textblock2, after next textblock 3, and so on until all textblocks in that slide are displayed. Then that is repeated on the next slide. This means that I need to assign "Appear" a lot of times. Then it becomes tedious to do these steps each time: (1) select Custom Animations under tasks, (2) click "Add", (3) click "ok". It would be much quicker with a one-step solution (i.e. a hotkey or a toolbar button). I can't find any such default option.

Question: How do I make a macro that when run assigns the Custom Animation effect "Appear" to the currently selected object?

I think these resources are relevant:
http://api.openoffice.org/docs/common/r ... ffect.html
http://wiki.services.openoffice.org/wik ... teractions

I made this (non-working) attempt at a macro:

Code: Select all

Sub test
rem add custom animation: Appear to selected object
dim selection as object
selection = ThisComponent.CurrentController
selection.setPropertyValue("Effect", com.sun.star.presentation.AnimationEffect.APPEAR );
End Sub
Can anyone see what is wrong here? (probably several things).
OOo 3.0.X on Ms Windows XP
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

So, just to clarify even more, what I need to do is:
1. create a variable and somehow assign the currently selected object to it
2. operate on the variable so that a property of the selected object gets changed
Any help on getting either of these steps right is appreciated.
OOo 3.0.X on Ms Windows XP
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

Hm, no replies. I've also tried the IRC channel #Openoffice.org
( http://wiki.services.openoffice.org/wik ... munication ) several times without finding anyone that can assist with this. Weird since it doesn't seem so hard to solve (though hard enough for me to not grasp it on my own :lol: ). It seems much easier than many of the other script related issues here. Maybe it is because it is for Impress because most of the other topics seem to concern scripts for Writer and Calc? Anyway, I really hope the lack of response is not because folks feel that it is too easy and that I should figure it out myself, because I really have tried to do that. I've spent over two hours reading various documents and in the API but, having no experience with this macro business, it is over my head ATM.

One more thing: does anyone know of another good forum/place/way to ask for support with my macro problem? Is there even some support service that costs money available somewhere?
OOo 3.0.X on Ms Windows XP
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

Ok, I gave this another hour just now. Without success. I still can't write a macro that works with the desired functionality. I also searched extensively for some more crude workaround, like making an external script and controlling the OpenOffice interface from it. That ran into problems because the lack of a reliable way to use keyboard actions in Impress. In the Custom Animation pane the different buttons do have one underlined character in their names. So pressing alt + that character should cause the same actions as when clicking the button. But in OpenOffice that works ONLY if the pane has previously been given focus, by clicking in it. I'm unsure why but that is the way it is. And I haven't found any reliable way to give that pane focus through an external script.
OOo 3.0.X on Ms Windows XP
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

Stubbornness is a gift... I have a crude workaround in the form of an external script. I'll post it in case anyone else is interested.

I'm however still very interested in help with a proper internal macro to do this basic action, as previously requested here.

To use the script you must:
1. install http://www.autohotkey.com/ (you can remove it later if you opt for 4a below)
2. save the code below to a textfile and name it "oo_appear.ahk"
3. save the two attached small images to the same folder as "oo_appear.ahk"
4a. either use autohotkey to compile the .ahk into a .exe and then run that or
4b. run the .ahk (works as long as you have autohotkey installed)

Code: Select all

; AUTOHOTKEY SCRIPT FOR ONE-STEP ASSIGNING EFFECT "APPEAR" IN OPENOFFICE 3
; REQUIRES FILES oo.png & oo2.png IN SCRIPT FOLDER

F3::

SetMouseDelay, 0
SetKeyDelay, 0

;-- CoordMode, Mouse, Relative
WinGetActiveTitle, OutputVar
if OutputVar contains OpenOffice.org Impress 
{
WinGetPos,,, Width, Height, A
X1 := Width - 110
Y1 = 70
X2 := Width
Y2 = 175
;msgbox, %X1%|%X2%|%Y1%|%Y2%
ImageSearch, out1x, out1y, X1, Y1, X2, Y2, oo.png
if ErrorLevel = 1
{
ToolTip,sidebar not found,,,
sleep 1000
ToolTip
}
 else 
 {
 ;msgbox, %out1x%, %out1y%
 X1 := out1x - 140
 Y1 := out1y + 110
 X2 := Width - 50
 Y2 := out1y + 180
 ImageSearch, out2x,out2y, X1, Y1, X2, Y2, oo2.png
if ErrorLevel = 1
{
ToolTip,active Add button not found,,,
sleep 1000
ToolTip
}
else
{
CoordMode, Mouse, Screen
 MouseGetPos, xx, yy
CoordMode, Mouse, Relative
 X1 := out2x + 10
Y1 := out2y + 25
click %X1% %Y1%
WinWait, Custom Animation,, 4,
if ErrorLevel = 1
 return
WinActivate, Custom Animation
 SendInput  {Tab}{Tab}{Enter}
CoordMode, Mouse, Screen
 MouseMove, %xx%, %yy%, 0
 CoordMode, Mouse, Relative
 }
 }
}
return
Since the script matches the images against what it sees in the OO window, the height and number of toolbars and the width of the sidebar must be within certain bounds. If you stick roughly to these formats then the script should work:
Image

I today 11/2 2010 added an updated oo.png that works with OO 3.2
Attachments
new file, use this oo.png for OO 3.2
new file, use this oo.png for OO 3.2
oo.png (227 Bytes) Viewed 13728 times
oo2.png
oo2.png (434 Bytes) Viewed 14579 times
oo.png
oo.png (231 Bytes) Viewed 14578 times
Last edited by rowzain on Thu Feb 11, 2010 10:02 pm, edited 1 time in total.
OOo 3.0.X on Ms Windows XP
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

Ok, I officially renew my request for help with making this into a native extension. I did some more searching for a solution right now but without success.

This really puzzles me since OpenOffice is such a popular Office suite. I had thought that this kind of question would be answered in no time. (Or actually I first thought that the question would have been posed and answered by someone else in the forum already.) But I'm still hoping that some scripting-knowledgeable person will jump in and save the day :P
OOo 3.0.X on Ms Windows XP
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

...two and half months later, I still miss this type of feature as a macro. Here's hope someone with an answer has shown up in these forums since last time!
OOo 3.0.X on Ms Windows XP
schroedl
Posts: 1
Joined: Thu Feb 05, 2009 6:59 am

Re: Impress: assign Custom animation effect to selected (repost)

Post by schroedl »

I agree that having a macro written for this function would be very useful...just for productivity reasons. I thank you for your hard work at pursuing information on this. I've been searching the internet for the same macro and all I find is these requests with no responses. :( I wish I could do this, I have a huge project that it would really cut the time down for.
OOo 3.0.X on Ubuntu 8.x + Windows Vista
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

I'm back, 8 long months after the start of this thread. I still want to get this working. I still hope that someone who knows basic OO scripting lends a hend to get it working.

Any other comments are also welcome. Like how hard you assess the scripting task at hand to be. It does not seem hard in principle. But the macro system is almost impossible to learn for a beginner like me, so I don't know.
OOo 3.0.X on Ms Windows XP
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (repost)

Post by rowzain »

I'm back! 1 year and 3 months after the first post. The problem remains. It seems to me that Impress might as well be labeled abandonware. Since it seems to be going nowhere, from a users point of view when judging the last few updates to Open Office. Anyway, not meaning to (only) nag - if someone does know a way do solve the problem I've described then do post the solution please.
OOo 3.0.X on Ms Windows XP
CLBjr
Posts: 1
Joined: Sat Apr 17, 2010 7:40 am

Re: Impress: assign Custom animation effect to selected (rep

Post by CLBjr »

I am an amateur at programming, but it seems to me that in your original code the object you have given the name "selection" has been set to the CurrentController, which as a DrawPage and not an item on that page. You really want to get at an item in the current selection set.

It is so easy grab the wrong object. I have found that putting a watch on variables to be extremely helpful in knowing what object I have grabbed and what the properties and methods of that object are.

I have started working on a similar issue. This is what my code looks like to grab the first currently selected item and set the effect:

dim Doc as object
dim controllerCurrent as object
dim selectionCollection as object
dim selectedItem as object

doc = ThisComponent
controllerCurrent = doc.CurrentController

selectionCollection = controllerCurrent.Selection()
selectedItem = selectionCollection(0)
selectedItem.Effect = com.sun.star.presentation.AnimationEffect.APPEAR

Hope this helps. I would be interested in learning about anything you get working.
OpenOffice 3.2
Windows XP
ktechman
Posts: 5
Joined: Sat May 24, 2008 7:58 am

Re: Impress: assign Custom animation effect to selected (rep

Post by ktechman »

Here is what I did I opened a new presentation and created a blank slide without any text but with the "click here to add text" routine present added the various "Custom Animation" effects and then copied and pasted that blank slide as many times as I would need different slides and now there is no need to reassign the custom animation for each slide.
rowzain
Posts: 23
Joined: Sun Oct 05, 2008 2:57 pm

Re: Impress: assign Custom animation effect to selected (rep

Post by rowzain »

CLBjr, you are my hero! :o :) :D :bravo:
I have been hoping for a native solution for 1½ years and then your code comes along. It works perfect for single items. Thank you! I can't so far get it to add the custom animation APPEAR to multiple selected items, like when you have selected three textboxes and want them to appear at the same time. Any ideas on how to do that? But now that we have a working example I'm sure it will be easier to expand this.

ktechman: that works only if you want a single animation effect per slide. But what this thread is about is useful when having many such effects on each slide.
OOo 3.0.X on Ms Windows XP
James1293
Posts: 1
Joined: Sat Jul 16, 2011 8:44 pm

Re: Impress: assign Custom animation effect to selected (rep

Post by James1293 »

For anyone else that is wondering, here is how to use this macro:
  • * Go to Tools > Macros > Organize Macros > Openoffice.org BASIC
    * Click Edit button
    * At the bottom of the window that appears, type Sub Assignappear
    * Paste the code
    * Type End Sub
Did anyone find a solution for multiple objects?

Yes, I realize that I am a year late :D . CLBjr, Thank you very much for making this!
And rowzain, thanks for asking this question! And thanks for making the auto hot key script, which is something I've been searching for for other purposes :)
OOo 3.2.* on Ubuntu 10.04; OOo 3.2.* on Windows XP; Libre 3.3.* on Ubuntu 11.04
FJCC
Moderator
Posts: 9626
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Impress: assign Custom animation effect to selected (rep

Post by FJCC »

OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
bozeman
Posts: 1
Joined: Thu Sep 01, 2011 12:10 am

Re: Impress: assign Custom animation effect to selected (rep

Post by bozeman »

I was frustrated by the same issue. In 3.3.0, I found that if you use the pulldown box "Slide" and then the command button "duplicate slide" it copies everything including text appearance / transition effects. Then just edit the text to whatever the new slide is supposed to be.

Thank goodness, I was about to scream over this. :crazy:
OpenOffice 3.3.0 on Windows XP
Post Reply