Bug 92511 - Incorrect work of GetByName method
Summary: Incorrect work of GetByName method
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.3 Daily
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-02 23:30 UTC by vlad
Modified: 2015-07-14 07:17 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Just open the Form TryMe ,then push the Push Me button. (17.08 KB, application/vnd.sun.xml.base)
2015-07-02 23:30 UTC, vlad
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vlad 2015-07-02 23:30:14 UTC
Created attachment 117013 [details]
Just open the Form TryMe ,then push the Push Me button.

When I try to get one of four Forms,using GetByName method,it  always returns the first Form(see the macro for details).
Comment 1 Cor Nouws 2015-07-13 18:21:28 UTC
Hi vlad,

Thanks for your post, but I think the macro is not correct. Please try the following:

Sub Main
Dim oForm As Object
Dim n%
'Globalscope.BasicLibraries.LoadLibrary("XrayTool")
'xray ThisComponent.DrawPage.Forms

  For n = 0 to ThisComponent.DrawPage.Forms.Count -1
    oForm=ThisComponent.DrawPage.Forms.getByIndex(n) '(oFormName)
	
    MsgBox "The value of oFormName const is - " & oFormName & Chr(13) &_
    "The name of getting form is -" & oForm.Name
  Next
End Sub


I set this as worksForMe.
Regards,
Cor
Comment 2 Cor Nouws 2015-07-13 22:18:50 UTC
Hi vlad,

We only set to Fixed if we know what commit fixed it...
So unless you know, we must set as WorksForMe.

Thanks for replying.
Cor
Comment 3 vlad 2015-07-14 00:22:05 UTC
Ok,very well.The problem is not the method GetByName(it works nice),but ..mmm..to get by name from a collection.If we have something like:
ThisComponent.Sheets.GetByName("MySheetName") 
it returns the sheet "MySheetName",ok?
It is possible to take this sheet using the collections form,like
ThisComponent.Sheets("MySheetName"),because Sheets() is a collection of these values,you can access  a value using the index,like your example,or using the name,like main.
So,in my example I have used the name-call method,and it not works,because returned always the same Form,the first one.
The method GetByName works fine:
ThisComponent.DrawPage.Forms.GetByName("NameOfForm") 
not work(for me ) the name-call method of collection:
ThisComponent.DrawPage.Forms("NameOfForm")
--------------------------------------------------------
I am not good in explanation and I do not know how to make a correct bug name.
Comment 4 Cor Nouws 2015-07-14 07:17:55 UTC
Hi Vlad,

I seldom work with those forms, so should study it a bit to get a possible problem.
Better is to ask it a ask.libreoffice.org or the users list, where there will be people that work in this area a lot.
Anyway glad that you have a working solution now :)
Cheers