getName issue

The Application Programming Interface and the OASIS Open Document Format

getName issue

Postby lardly » Fri Aug 07, 2009 3:02 pm

This might have to do with my poor comprehension of the model/view/controller model, but I can't seem to get getName to work. I can find a Name property to the form, which I can set. Otherwise, this code fails on getName with the error "Improper use of an object." Similarly it fails if rewritten with getPropertyValue("Name"). Debian 5.0.1 Lenny OO 2.4.1. Thanks.

forms = thisComponent.Drawpage.Forms
controller = thisComponent.getCurrentController

form_found = 0
for index = 0 to forms.Count - 1
form = forms.GetbyIndex(index)
formName = form.GetName()
next index
openOffice 2.4 on Debian 5.0.1 stable Lenny
lardly
 
Posts: 2
Joined: Fri Aug 07, 2009 2:14 pm

Re: getName issue

Postby FJCC » Fri Aug 07, 2009 4:41 pm

I copied your code into a macro attached to a writer document and it ran without error. I then added a print statement like this
Code: Select all   Expand viewCollapse view
forms = thisComponent.Drawpage.Forms
controller = thisComponent.getCurrentController

form_found = 0
for index = 0 to forms.Count - 1
form = forms.GetbyIndex(index)
formName = form.GetName()
print formName
next index


and formName indeed contains the correct form name. I can't at the moment think what could be wrong on your end. Could you give some more details of what you are doing? What kind of document is ThisComponent when you run the macro? If you get the object inspection tool xray or MRI you can look at what kind of object your "form" variable is and that might explain what is going on.
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7481
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: getName issue

Postby B Marcelly » Sat Oct 31, 2009 3:21 pm

Hi,
lardly wrote: I can find a Name property to the form, which I can set. Otherwise, this code fails on getName with the error "Improper use of an object." Similarly it fails if rewritten with getPropertyValue("Name").

Difficult to diagnose without a complete code or the document itself.
You will get the error "Improper use of an object" if you declare the variable formName as an object:
Code: Select all   Expand viewCollapse view
Dim formName As Object
' ...
formName = form.GetName()

Method getName returns a String, not an Object. The same error will appear with form.Name or form.getPropertyValue("Name").
Correct declaration:
Code: Select all   Expand viewCollapse view
Dim formName As String
' ...
formName = form.getName()

______
Bernard
B Marcelly
Volunteer
 
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: getName issue

Postby skidmog » Fri Jul 15, 2011 6:18 pm

I'm looking to get the form controller name and haven't got it yet.
the GetName gives me the form within the controller
I want the form name as I am using some context sensitive help buttons to access help based on formname or tag-value.
skidmog - Application Development
( OpenOffice 3.3 on Windows 7 )
skidmog
 
Posts: 6
Joined: Fri Jul 15, 2011 6:14 pm

Re: getName issue

Postby B Marcelly » Fri Jul 15, 2011 9:38 pm

Hi skidmog,
Your question is different from this thread. Create your own thread.
And show the instructions you use.
Tag value should be enough to access a help. Or I don't understand what you mean.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
B Marcelly
Volunteer
 
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest