Bug 118824 - CurrentValue Returns Wrong Value in Base - Different from OOo
Summary: CurrentValue Returns Wrong Value in Base - Different from OOo
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
6.0.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-18 14:27 UTC by Joel Madero
Modified: 2018-07-27 12:05 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
MyLibrary Database (1.25 MB, application/vnd.oasis.opendocument.database)
2018-07-18 14:28 UTC, Joel Madero
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joel Madero 2018-07-18 14:27:43 UTC
Description:
The attached database is a database I'm building pertaining to my book library. If you open "MyLibrary" and click on the Google looking button next to the second line dropdown (reads "Orson Scott Card") Google will search for the AuthorID (12) instead of the actual value in the drop down ("Orson Scott Card"). OOo works as expected and searches for the actual value in the dropdown (i.e., the author's name).

Here is the code used in my macro:

Sub GoogleAuthor
   Dim launcher As Object
   Dim aWebPage As String   

      myLibraryForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
      book_author = myLibraryForm.getByName("Author").CurrentValue
      launcher = CreateUnoService("com.sun.star.system.SystemShellExecute")
      aWebPage = "https://www.google.com/search?source=hp&ei=NUpNW6KJAoritQXXqozYCw&q=Author: " & book_author
      launcher.execute(aWebPage, "", 0)

End Sub

Steps to Reproduce:
1. Open attached database
2. Open Form Document named "MyLibrary"
3. Click on the Google looking button next to "Orson Scott Card"

Actual Results:
Browser opens and Google searches for "Author: 12".

Expected Results:
Browser should open and search for the actual value in the dropdown which would be "Author: Orson Scott Card"


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Not an issue in OOo 4.1.5.
Comment 1 Joel Madero 2018-07-18 14:28:30 UTC
Created attachment 143618 [details]
MyLibrary Database

This is the database.
Comment 2 Drew Jensen 2018-07-20 01:19:21 UTC
You are correct currentvalue does return a different result between AOO and LibO, and appears to have done so since LibO 4.1. 

I find this mentioned in a comment, from 2015, on an issue https://bugs.documentfoundation.org/show_bug.cgi?id=91828#c10
"Since LO 4.1 CurrentValue of a listbox changed to the value, which should be saved in the database. Older versions will show the text, which could be seen on the screen."

That sounds a bit like it might of been intentional, but I read over the release notes for 4.0, 4.1 and 4.2 in which there is mention of changes to checkbox form controls, but none about listbox and a change in currentvalue. Nor could I see any  mentioned in the API changes listed there.

For a workaround you just need to treat the control as if multi-select is turned on and use the SelectedItems and ListItems to retrieve the string.
Comment 3 Robert Großkopf 2018-07-27 09:11:22 UTC
This is a feature, not a bug. There are differences between LO and AOO. Special:
Since LO 4.1 the current value in listboxes gives the value, which is submitted to the database.
Since LO 4.1.2 datafields must be read by oField.currentValue.Year ...Month ...Day

You could get the value, which is shown in the listbox, with
--------
SUB Listenfeldanzeige
DIM oDoc AS OBJECT
DIM oForm AS OBJECT
DIM oListbox AS OBJECT
DIM oController AS OBJECT
DIM oView AS OBJECT
oDoc = thisComponent
oForm = oDoc.Drawpage.Forms(0)
oListbox = oForm.getByName("Listenfeld")
oController = oDoc.getCurrentController()
oView = oController.getControl(oListbox)
print "Angezeigter Inhalt: " & oView.SelectedItem
END SUB
--------
Works with LO and AOO.
Comment 4 Drew Jensen 2018-07-27 12:05:05 UTC
(In reply to robert from comment #3)
> This is a feature, not a bug. There are differences between LO and AOO.
> Special:
> Since LO 4.1 the current value in listboxes gives the value, which is
> submitted to the database.
> Since LO 4.1.2 datafields must be read by oField.currentValue.Year ...Month
> ...Day
> 

Well, then the issue needs to be set to, notabug.