| View previous topic :: View next topic |
| Author |
Message |
Reth Newbie

Joined: 09 Jun 2012 Posts: 2
|
Posted: Sun Jun 10, 2012 7:49 am Post subject: OO 3.4 Impress: Forms on slide not accessible within macro |
|
|
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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Sun Jun 10, 2012 3:34 pm Post subject: |
|
|
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 http://forum.openoffice.org |
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Sun Jun 10, 2012 11:54 pm Post subject: |
|
|
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 / OpenOffice.org 3.4.1 en-US + langpacks, MS-Windows XP Home SP3
This forum is unusable, use instead Apache OpenOffice forums |
|
| Back to top |
|
 |
Reth Newbie

Joined: 09 Jun 2012 Posts: 2
|
Posted: Mon Jun 11, 2012 11:21 am Post subject: |
|
|
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 |
|
 |
|
|
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
|