https://bugs.documentfoundation.org/show_bug.cgi?id=159973
Bug ID: 159973 Summary: queryPrecedents returns cells as if in same sheet Product: LibreOffice Version: 7.6.4.1 release Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: medium Component: BASIC Assignee: libreoffice-bugs@lists.freedesktop.org Reporter: patrick.tra...@t-online.de When I use queryPrecedents to get the precedents of a formula, the ScCellRangesObj returned behaves as though all precedents were in the same sheet as the cell itself. It also seems to me that enumerating the precedent cells only returns the first one, but I am not 100% sure that I am doing that right; that would probably be different bug anyway. (I tried enumerating them to see if that functionality was any better, but inspecting the object in the debugger suggests that it would not.) I apologise if this has already been reported; searching for "queryPrecedents" seemed to cause the site to hang! I am running this version: Version: 7.6.4.1 (X86_64) / LibreOffice Community Build ID: e19e193f88cd6c0525a17fb7a176ed8e6a3e2aa1 CPU threads: 8; OS: Linux 5.3; UI render: default; VCL: kf5 (cairo+xcb) Locale: en-GB (en_GB.UTF-8); UI: en-GB Calc: threaded The following code displays the message: Formula: =A2+A6+Bug_Prec_Loc_2.A1+A4 Precedents: AbsoluteName = $Bug_Prec_Loc_1.$A$1:$A$2,$Bug_Prec_Loc_1.$A$4,$Bug_Prec_Loc_1.$A$6 Precedent cell names: $Bug_Prec_Loc_1.$A$1 Enumerated: $Bug_Prec_Loc_1.$A$1 I think it should display something like: Formula: =A2+A6+Bug_Prec_Loc_2.A1+A4 Precedents: AbsoluteName = $Bug_Prec_Loc_1.$A$1,$Bug_Prec_Loc_1.$A$4,$Bug_Prec_Loc_1.$A$6,$Bug_Prec_Loc_2.$A$2 Precedent cell names: $Bug_Prec_Loc_1.$A$1 $Bug_Prec_Loc_1.$A$4 $Bug_Prec_Loc_1.$A$6 $Bug_Prec_Loc_2.$A$2 Enumerated: $Bug_Prec_Loc_1.$A$1 $Bug_Prec_Loc_1.$A$4 $Bug_Prec_Loc_1.$A$6 $Bug_Prec_Loc_2.$A$2 Option Explicit ' Require variables to be defined Option Compatible ' So ParamArray is supported ' Demonstrate a bug in obtaining precedents of a formula ' It appears that the precedents for a formula obtained with queryPrecedents projected into the sheet of the cell containing the formula Sub Bug_Precedents_Local () Dim LF as String : LF = Chr (10) Dim z_1_S as String : z_1_S = "Bug_Prec_Loc_1" Dim z_2_S as String : z_2_S = "Bug_Prec_Loc_2" On Local Error Resume Next ThisComponent.Sheets.insertNewByName (z_1_S, 0) ThisComponent.Sheets.insertNewByName (z_2_S, 1) On Local Error Go To 0 Dim z_1 as Object : z_1 = ThisComponent.Sheets.getByName (z_1_S) Dim z_2 as Object : z_2 = ThisComponent.Sheets.getByName (z_2_S) Dim z_1_A1 as Object : z_1_A1 = z_1.getCellByPosition (0, 0) z_1_A1.setFormula ("=A2+A6+'" + z_2.Name + "'.A1+A4") Dim z_Precedents as Object : z_Precedents = z_1_A1.queryPrecedents (False) Dim z_Cells as Object : z_Cells = z_Precedents.getCells () Dim z_Names as String : z_Names = "" Dim z_Cell as Object : For Each z_Cell in z_Cells z_Names = z_Names + " " + z_Cell.AbsoluteName Next z_Names = z_Names + LF + "Enumerated: " Dim z_Enumeration as Object : z_Enumeration = z_Cells.createEnumeration () While z_Enumeration.hasMoreElements () z_Cell = z_Enumeration.nextElement () z_Names = z_Names + " " + z_Cell.AbsoluteName Wend MsgBox ("Formula: " + z_1_A1.Formula + LF + "Precedents: AbsoluteName = " + z_Precedents.AbsoluteName + LF + "Precedent cell names: " + z_Names) End Sub -- You are receiving this mail because: You are the assignee for the bug.