Bug 147257 - The property of an object is found by the getPropertyValue method and is not found in Basic directly.
Summary: The property of an object is found by the getPropertyValue method and is not ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.3.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-07 15:01 UTC by Vladimir Sokolinskiy
Modified: 2024-02-09 17:17 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Sokolinskiy 2022-02-07 15:01:42 UTC
Open (create) any Calc document.
Run macros.

Sub Test1
  Dim oUDR
  oUDR=ThisComponent.getPropertyValue("UnnamedDatabaseRanges")
  Msgbox oUDR.hasByTable(0)
End Sub

Sub Test2
  Dim oUDR
  oUDR=ThisComponent.UnnamedDatabaseRanges
  Msgbox oUDR.hasByTable(0)
End Sub

Test1 shows "False". 

Result of Test2:

BASIC runtime error.
Property or method not found: UnnamedDatabaseRanges.
Comment 1 Mike Kaganski 2022-02-07 15:56:33 UTC
See https://git.libreoffice.org/core/+/75c3b913d8c78a980294f4e7085aec8cf507bd43 that had introduced the property.

It didn't extend SpreadsheetDocument service public attributes, nor made that through XPropertySet -> hence no introspection-based access.

Given the implementation, extending SpreadsheetDocument service looks proper in this case.
Comment 2 Vladimir Sokolinskiy 2022-02-07 16:31:53 UTC
Mike, thank you very much!
Comment 3 Mike Kaganski 2022-02-08 06:11:31 UTC
This could be an easyhack requiring to modify offapi/com/sun/star/sheet/SpreadsheetDocument.idl and lcl_GetDocOptPropertyMap in sc/source/ui/unoobj/docuno.cxx. However, the question is: do we also publish XUnnamedDatabaseRanges interface, or do we expose the property as 'any'? Or maybe there is a reason to not publish the property at all? Eike, could you please help?
Comment 4 QA Administrators 2024-02-09 03:13:37 UTC Comment hidden (obsolete)
Comment 5 Eike Rathke 2024-02-09 15:32:34 UTC
Got this on sight again due to the new ping..

(In reply to Mike Kaganski from comment #3)
> However, the
> question is: do we also publish XUnnamedDatabaseRanges interface, or do we
> expose the property as 'any'? Or maybe there is a reason to not publish the
> property at all? Eike, could you please help?
XUnnamedDatabaseRanges probably wasn't marked as published because we refrain from publishing internal interfaces (and those unnamed ranges are internal features) as that would freeze the interface to not be modifiable.

Comment 0 Test1 using the property UnnamedDatabaseRanges is working (and displays True if there actually is such range). Adding it as an optional read-only property to the service might do, though I don't see much benefit. What is actually expected here?
Comment 6 Vladimir Sokolinskiy 2024-02-09 17:17:22 UTC
Hello Eike!
We often use the following function to determine the range of cells included in a worksheet's autofilter. We would like to legitimize it. :)

' Returns the DataBaseRange for the worksheet autofilter or Nothing.
' - oDoc document Calc.
' - oSheet document sheet.
Function GetSheetFilterDBRange(oDoc, oSheet) as Object
  Dim i as Long
  GetSheetFilterDBRange=Nothing
  i=oSheet.RangeAddress.Sheet
  With oDoc.getPropertyValue("UnnamedDatabaseRanges")
    If .hasByTable(i) Then GetSheetFilterDBRange=.getByTable(i)
  End With
End Function