Create a new Calc document and save, for example, as C:\Temp\test.ods (Windows). Call macro: Sub TestIndirect Dim oFA, v oFA=createUnoService("com.sun.star.sheet.FunctionAccess") v=oFA.callFunction("Indirect", Array("'file:///C:/Temp/test.ods'#$Sheet1.A1")) End Sub Result: Error Expected: The value of the corresponding cell.
Repro. The problem is in ScExternalRefManager::getSingleRefToken, which fails because isLinkUpdateAllowedInDoc returns false for the temporary document used in ScFunctionAccess. There seems to be no property to change that among properties defined for SpreadsheetDocumentSettings service [1] (IsExecuteLinkEnabled feels close, but it is absent in ScFunctionAccess; and isLinkUpdateAllowedInDoc needs the document to have SfxObjectShell, which is not true). Eike: is it reasonable to introduce such property for SpreadsheetDocumentSettings? Or are there some concerns that would make that unwanted? [1] https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sheet_1_1SpreadsheetDocumentSettings.html
(In reply to Mike Kaganski from comment #1) > is it reasonable to introduce such property for SpreadsheetDocumentSettings? > Or are there some concerns that would make that unwanted? Alternatively, isLinkUpdateAllowedInDoc could check rDoc.IsFunctionAccess() and return true (that's easier, and likely makes sense, since enabling that explicitly for function access looks overkill to me).
Checking rDoc.IsFunctionAccess() in isLinkUpdateAllowedInDoc() if there is no SfxObjectShell looks viable, apparently it could also work without the non-present sfx2::LinkManager in this case, needs to be checked. However, careful with still obeying the "update links when opening" setting, I think if that is set to Never also the function access shouldn't be allowed to do so. Unfortunately there is no caller parent document here that could be asked to determine the on request and always cases. Probably the interim document should have EnableExecuteLink() set accordingly in ScTempDocSource::CreateDocument(). So then in isLinkUpdateAllowedInDoc() it would be checking rDoc.IsFunctionAccess() && rDoc.IsExecuteLinkEnabled()
On the other hand, it's extension or macro/script code that could do anything anyhow..
Mike Kaganski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/7f58df88771767962fc4e98f2b6bed445ab18994 tdf#148040: allow external link update for css.sheet.FunctionAccess It will be available in 7.4.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Mike, thank you very much!