Bug 123005 - FILEOPEN: Error on creating getCurrentController().getActiveSheet() for basic script from location=document ?
Summary: FILEOPEN: Error on creating getCurrentController().getActiveSheet() for basic...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.4 all versions
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected
: 123275 123764 (view as bug list)
Depends on:
Blocks: Macro
  Show dependency treegraph
 
Reported: 2019-01-28 00:25 UTC by Taka~ TIDA
Modified: 2023-11-29 10:09 UTC (History)
10 users (show)

See Also:
Crash report or crash signature:


Attachments
Document with the macro given in the report (10.75 KB, application/vnd.oasis.opendocument.spreadsheet)
2019-01-30 15:10 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Taka~ TIDA 2019-01-28 00:25:44 UTC
Description:
"ThisComponent.CurrentController.ActiveSheet" does not work when the file loads.

The error message is "CurrentController does not exist".

Before update on 2019/1/26, it worked.


Steps to Reproduce:
1.write "=Vsr( CELL("COL",A5), CELL("ROW",A5) )" into the Cell A5
2.write any value, e.g. 555, into the any Cell below A5
3.save the file
4.load the file

Actual Results:
error
"BASIC ランタイムエラー(BASIC Runtime Error)
次のプロパティまたはメソッドが見つかりません:getCurrentController。
(Can't find the next property or method : getCurrentController.)"

error-no:423

Expected Results:
Cell A5 shows the value, e.g. 555.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
'Macro########
Function Vsr0( ax As Variant,ay As Variant ) As Variant
rem Search NON-NULL Cell and RETURN the Numeric value
rem e.g. =Vsr( CELL("COL",A5), CELL("ROW",A5) )

on error goto error_vsr0

Dim oDoc, oCtrl, oSheet As Object
  oDoc = ThisComponent
  oCtrl = oDoc.getCurrentController()
  oSheet = oCtrl.ActiveSheet
'or'  oSheet = ThisComponent.CurrentController.ActiveSheet

rem addr:1〜 ;  index:0〜'i=ax-1 :  j=ay-1
dim i, j  As Variant
i=ax-1
j=ay     ' look the value below 1 line; 1行下から値を見る

Dim  oCell, t4R As Object
Dim ans, a As Variant
ans=""
a=0

jLmt = iif(jLimit>0, jLimit, 500)
jx =j+jLmt

do
  oCell = oSheet.getCellByPosition(i,j)
  a = oCell.Value
     ans = oCell.String
  j=j+1

  if j>jx then'
    exit do
  end if
  
loop while isNull(ans)  OR ans = ""
goto ok_vsr0

error_vsr0:
  print( "error-line:"& erl & ", err:" & err & chr$(10) & error$ )
stop
ok_vsr0:
Vsr0=a
end Function
'########
Comment 1 Regina Henschel 2019-01-28 14:30:50 UTC
Please copy the information from the Help > About box and add it here.
Comment 2 Regina Henschel 2019-01-28 15:30:20 UTC
Where is your macro located? Inside a document or in "My Macros & Dialogs" library 'Standard' or in a different library or somewhere else?
When is your macro called?
Comment 3 Oliver Brinzing 2019-01-28 18:08:43 UTC
may related to

https://bugs.documentfoundation.org/show_bug.cgi?id=122545
FILEOPEN: Error on creating script provider for Python script from location=document ?
Comment 4 Taka~ TIDA 2019-01-30 14:23:06 UTC
(In reply to Regina Henschel from comment #1)
> Please copy the information from the Help > About box and add it here.

Comment 1 Regina Henschel 2019-01-28 14:30:50 UTC 
Sorry for late.

[Ans[
バージョン: 6.1.4.2
Build ID: 1:6.1.4-0ubuntu0.18.10.1
CPU threads: 4; OS:Linux 4.18; UI render: default; VCL: gtk3_kde5; 
ロケール: ja-JP (ja_JP.UTF-8); Calc: group threaded
]

(Today, I've installed the newest one without the Language-pack ja_JP.

)
[
Version: 6.2.0.2
Build ID: 2ce5217b30a543f7666022df50f0562f82be0cff
CPU threads: 4; OS: Linux 4.18; UI render: default; VCL: kde5; 
Locale: ja-JP (ja_JP.UTF-8); UI-Language: en-US
Calc: threaded

]]
Comment 5 Regina Henschel 2019-01-30 15:10:36 UTC
Created attachment 148758 [details]
Document with the macro given in the report

I have put your macro into a document. That makes it easier to reproduce the error. Open the attached document. The error message pops up. If the document is loaded, the macro works. You need to use a hard recalculate to call it when you change content in column A.
Comment 6 Regina Henschel 2019-01-30 15:13:09 UTC
It is OK in Version: 6.0.7.3 (x64)
Build ID: dc89aa7a9eabfd848af146d5086077aeed2ae4a5
CPU threads: 8; OS: Windows 10.0; UI render: default; 
Locale: de-DE (en_US); Calc: CL

It fails in Version: 6.1.4.2 (x64)
Build ID: 9d0f32d1f0b509096fd65e0d4bec26ddd1938fd3
CPU threads: 8; OS: Windows 10.0; UI render: default; 
Locale: de-DE (en_US); Calc: CL
Comment 7 Oliver Brinzing 2019-01-30 17:05:42 UTC
reproducible with

Version: 6.1.5.1 (x64)
Build-ID: f18954c1ba9116b85c32b6bdbc0188d3e0fd24c7
CPU-Threads: 4; BS: Windows 10.0; UI-Render: Standard; 
Gebietsschema: de-DE (de_DE); Calc: group threaded
Comment 8 raal 2019-01-30 17:19:02 UTC
This seems to have begun at the below commit.
Adding Cc: to Vasily Melenchuk ; Could you possibly take a look at this one?
Thanks
 5d007cfc8733799cf0535eac3e482eb8cae4b908 is the first bad commit
commit 5d007cfc8733799cf0535eac3e482eb8cae4b908
Author: Jenkins Build User <tdf@pollux.tdf>
Date:   Fri Jun 8 00:50:11 2018 +0200

    source 1e55a47e89a9d9d6cf9cb3993484022aaf2c097b

author	Vasily Melenchuk <Vasily.Melenchuk@cib.de>	2018-04-06 20:19:10 +0300
committer	Thorsten Behrens <Thorsten.Behrens@CIB.de>	2018-06-08 00:47:06 +0200
commit 1e55a47e89a9d9d6cf9cb3993484022aaf2c097b (patch)
tree 3a3372525645775c32721e59ce8c205c8f474ffd
parent 2a7f74900fb646235b74d4c9bd4690e44edc3ed4 (diff)
tdf#62268: allow row height recalculation on document load
Comment 9 Taka~ TIDA 2019-01-30 17:33:19 UTC
(In reply to Regina Henschel from comment #2)
> Where is your macro located? Inside a document or in "My Macros & Dialogs"
> library 'Standard' or in a different library or somewhere else?
> When is your macro called?

[[
in "My Macros & Dialogs" library 'Standard';

it's called on loading a file which calls macro.

At Version: 6.1.4.2
err:423
次のプロパティまたはメソッドが見つかりません:getCurrentController。
]]


At 6.2.0.2
[My Macros & Dialogs[
error-line:86, err:423
  Property or method not found: CurrentController.

error-line:34, err:423
  Property or method not found: getCurrentController.
]]


At 6.2.0.2
[file-macro[
error-line:86, err:91
  Object variable not set.
]]


((''source

Dim oDoc, oCtrl, oSheet As Object
  oDoc = ThisComponent
  oCtrl = oDoc.getCurrentController()   REM <==== error line:34
  oSheet = oCtrl.ActiveSheet

''~~~ another Function ~~~~~
Dim oDoc, oCtrl, oSheet As Object

oSheet = ThisComponent.CurrentController.ActiveSheet   REM <==== error line:86
))
Comment 10 Taka~ TIDA 2019-01-30 18:59:54 UTC
(In reply to Oliver Brinzing from comment #3)
> may related to
> 
> https://bugs.documentfoundation.org/show_bug.cgi?id=122545
> FILEOPEN: Error on creating script provider for Python script from
> location=document ?


#----------------------------------

Calcurate 計算式 
 Iterative References
 ■ Iterations 反復
    Steps 100
    Minimum change: 0.001

 General Calculations
 ■ Automatically find column and row labels 行と列のラベルを自動的に検索


Formula 数式

 Detailed Calculation Settings 詳細な計算の設定
XX NG XX● Default settings デフォルト設定
      ○ Custom (conversion of text to numbers and more): ユーザー定義
    ↓
OK      ○ Default settings デフォルト設定
      ● Custom (conversion of text to numbers and more): ユーザー定義

Recalculation on File Load ファイル読み込み時に再計算
Excel 2007 and newer:  Always recalculate 常に再計算する

ODF spreadsheet (not saved by LibreOffice):
                       Always recalculate 常に再計算する
Comment 11 Taka~ TIDA 2019-02-02 01:22:01 UTC
@ LibreOffice
[[

Version: 6.2.0.3
Build ID: 98c6a8a1c6c7b144ce3cc729e34964b47ce25d62
CPU threads: 4; OS: Linux 4.18; UI render: default; VCL: kde5; 
Locale: ja-JP (ja_JP.UTF-8); UI-Language: en-US
Calc: threaded

]]

The error-boxes were not appeared.
But the macro wasn't evaluated.
((Older version of LibreOffice evaluated recursively,
 so it showed correct values.))

A sample spread-sheet for Debug; "_DeBug2_price-sample_dollar.ods"
can be download from HERE↓ vvvvvvvvvvv (This doesn't include the macro but call it.)
>https://drive.google.com/open?id=1sI1eU3FdMCr9CmCr-zVFsyfLsUEyBENp
Comment 12 Oliver Brinzing 2019-02-08 19:55:09 UTC
*** Bug 123275 has been marked as a duplicate of this bug. ***
Comment 13 Oliver Brinzing 2019-02-28 18:03:17 UTC
*** Bug 123764 has been marked as a duplicate of this bug. ***
Comment 14 Jon A. Miller 2019-04-18 14:38:43 UTC
Bug still exists with LO 6.2.3.2 Win10-1809
Comment 15 Oliver Brinzing 2019-05-01 07:40:37 UTC
*** Bug 125042 has been marked as a duplicate of this bug. ***
Comment 16 Xisco Faulí 2020-02-18 09:50:27 UTC
if recalculation on File Load for ODF files is set to Always Recalculate in
Tools/Options.../LibreOffice Calc/Formula the problem can also be reproduced in

Version: 5.2.0.0.alpha1+
Build ID: 5b168b3fa568e48e795234dc5fa454bf24c9805e
CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; 
Locale: ca-ES (ca_ES.UTF-8)

and

Version: 4.3.0.0.alpha1+
Build ID: c15927f20d4727c3b8de68497b6949e72f9e6e9e

thus, this is not a regression per se. 1e55a47e89a9d9d6cf9cb3993484022aaf2c097b just made this problem more visible
Comment 17 QA Administrators 2022-09-20 03:33:21 UTC Comment hidden (obsolete)
Comment 18 Oliver Brinzing 2022-09-20 09:39:57 UTC
repro with:

Version: 7.4.1.2 (x64) / LibreOffice Community
Build ID: 3c58a8f3a960df8bc8fd77b461821e42c061c5f0
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: default
Comment 19 Jon A. Miller 2022-09-20 16:27:12 UTC
-bug still exists on version:

Version: 7.4.1.2 (x64) / LibreOffice Community
Build ID: 3c58a8f3a960df8bc8fd77b461821e42c061c5f0
CPU threads: 16; OS: Windows 10.0 Build 19044; UI render: Skia/Vulkan; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: CL

Edition	Windows 10 Pro
Version	21H2
Installed on	‎2020-‎07-‎12
OS build	19044.2006
Experience	Windows Feature Experience Pack 120.2212.4180.0

-bug is a regression on version 6.1.4.2 released Dec 2018

-Ref: 123275 marked as dupe
Comment 20 Mike Kaganski 2023-11-29 10:09:17 UTC
I would say, that this is not a bug. UDFs (user-defined functions) should not operate on things like controllers, active sheets, etc; they are expected to take data, digest it, and output data. Relying on other data not directly mentioned in the formula is basically breaking the assumptions ... so indeed, there might be no controller when the function is executed (and the load time is just one example; the document may also be opened in headless configurations, etc).