OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

OO 3.4 Impress: Forms on slide not accessible within macro

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Reth
Newbie
Newbie


Joined: 09 Jun 2012
Posts: 2

PostPosted: Sun Jun 10, 2012 7:49 am    Post subject: OO 3.4 Impress: Forms on slide not accessible within macro Reply with quote

Hi everybody,

since I'm a little bit used to MS VBA I just try to achieve things via macros within OO 3.4 Impress which are not available otherwise.

Currently I'm trying to create some kind of quiz which will show each already selected question in a different manner. Due to the fact that I did not yet find any suitable solution using normal functionalities like user defined animations etc. I'm now trying to create some appropriate macros.

I've got a slide with a table and two rectangular graphic objects on it. One of the rectangles I named "Frage1" (question1 in german). The navigator of impress shows my slide and below 3 forms (when showing also forms without names is ticked): Form1, Form2 and Frage1.

Within my macro I make this slide as current slide:
Code:

        oDoc = ThisComponent
   oController = oDoc.GetCurrentController()
   oController.CurrentPage = oDoc.getDrawPages().getByIndex(0)

afterwards I try to to access the forms on the slide but when debugging and looking into the CurrentPage the forms count always is 0! How can this happen? The following section always raises an IndexOutOfBoundsException:
Code:
oDoc.getdrawpages().getbyindex(0).getforms().getbyindex(0)

The only way to access the rectangular is by going over all elements of CurrentPage (just try and error) and printing out the text strings (the rectangular named Frage1 has Index2):
Code:

   print oController.CurrentPage.getByIndex(1).getText().getString()
   print oController.CurrentPage.getByIndex(2).getText().getString()

But this for my purposes is too less flexible and not "bullet proof" enough! I'd like to access my elements by their names! Is there no chance for me in order to do so?

Could please somebody shed some light on this and may help and telling me how I can access my elements by their names? And maybe also telling me why my forms count always is 0 when introspecting CurrentPage?

And BTW: Is there some kind of API doc and auto completion with listing of available possibilites when coding in OO Basic (like within the VBA environment)?

Many thanks in advance!

Bye
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sun Jun 10, 2012 3:34 pm    Post subject: Reply with quote

Code recorded by the MRI extension:
Code:
Sub Snippet(Optional oInitialTarget As Object)
  Dim oDrawPages As Object
  Dim oObj_1 As Object
  Dim oForms As Object
  Dim oObj_2 As Object
  Dim oObj_3 As Object

  oDrawPages = oInitialTarget.DrawPages
  oObj_1 = oDrawPages.getByIndex(0)
  oForms = oObj_1.getForms()
 
  oObj_2 = oForms.getByIndex(0)
  oObj_3 = oObj_2.getByIndex(0)
End Sub

_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Sun Jun 10, 2012 11:54 pm    Post subject: Reply with quote

Hi,

First there is a misunderstanding in vocabulary.
Rectangular or circular graphic objects are called in OpenOffice english : Shapes.

A Form is used for something different, see http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Forms/Forms
Quote:
Forms offer a method of control-based data input. A form or form document consists of a set of controls, where each one enters a single piece of data. In a simple case, this could be a plain text field allowing you to insert some text without any word breaks.

In other words, a user fills data into a form (german : ein Formular ausfüllen).
So, getForms() returns you an object containing forms, and in your case there are none.

Second, what you are trying to achieve is probably not possible : during a slideshow it is no longer possible to alter by macro the displayed view (other than with effects). See the old Issue 48395.

Anyway, how to retrieve a particular shape in a slide ?
After you have manually put a shape on the Draw/Impress slide, right-click and choose : Name... Give a specific name.
The only way to retrieve a specific shape on a slide is to scan all the shapes of the slide and check their name.
Code:
Dim aSlide As Object, myShape As Object, x As Long

aSlide = oDoc.Drawpages.getByName("NameOfYourSlide")
for x = 0 to aSlide.Count -1
  myShape = aSlide(x)
  if myShape.Name = "blabla"  then
    ' do something
  end if
next

And also set a specific name to each of your slides. Do not rely on the index.

Complex ? Yes, it is. You have to read docs and understand them.
_________________
Bernard

OpenOffice.org 1.1.5 fr / Apache OpenOffice 4.0.1 / LibreOffice 4.1.0
MS-Windows 7 Home SP1
This forum is spammed, use instead Apache OpenOffice forums
Back to top
View user's profile Send private message Visit poster's website
Reth
Newbie
Newbie


Joined: 09 Jun 2012
Posts: 2

PostPosted: Mon Jun 11, 2012 11:21 am    Post subject: Reply with quote

Thanks for your answers.

B Marcelly wrote:
Hi,
First there is a misunderstanding in vocabulary.
Rectangular or circular graphic objects are called in OpenOffice english : Shapes.

Sorry, you are right. This was the term I've been looking for!
B Marcelly wrote:

In other words, a user fills data into a form (german : ein Formular ausfüllen).
So, getForms() returns you an object containing forms, and in your case there are none.

I know the difference and I also know about the form aspect (Formular ausfüllen). But I do not know OO and its internals. Since I read several posts/articles where it was stated that in OO (also in Impress) everything is put inside a form, regardles your are using a "Formular" or not I took it for granted that there is a form present even if I did not choose one. Even more as navigator shows me 3 form objects below my slide!
B Marcelly wrote:

Second, what you are trying to achieve is probably not possible : during a slideshow it is no longer possible to alter by macro the displayed view (other than with effects). See the old Issue 48395.

Wow, that is a real shame. At least the answer that has been given to you as response! I do not know how the authors think about their idea to use the extended slideshow effects!
Maybe they can explain me how I might achieve the wanted behaviour having a slide where the state of each of the already selected shapes is presented regardless in which order these shapes are chosen by the user?! As far as I understood the response you've been given macros do not make sense within Impress at all (at least not within presentations). Or did I miss the point?
Anyway accessing a shape somehow directly via its name when it is not presented within a form seems not to be possible too. Seems I'll have to try with Powerpoint!
B Marcelly wrote:

Complex ? Yes, it is. You have to read docs and understand them.

No it is not complex (I discovered this possibility already - see first post) but it is less than only inconvenient! Regarding the docs: Which one are you referring to? I'm missing integrated API help and automated suggestions. Where is this kind of stuff documented in?

Bye
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group