Files
odfstudio/wizards/source/scriptforge/script.xlb
T
Jean-Pierre Ledure 710433d5a6 ScriptForge (Array Map(), Filter(), Reduce()
New methods in the 'array' service:
- Map(module, method, array, Args) -> outarray
  Executes the method for each item
  in array and accumulates the results
  in outarray.
- Filter(module, method, array, Args) -> outarray
  outarray contains all the items of
  the input array for which the method
  has returned True
- Reduce(module, method, array, initialvalue) -> scalar
  At each iteration, the partial result
  is passed as 1st argument of the next
  iteration.

Module = any Basic module, any Basic class instance,
         any ScriptForge service instance
Method = given as a string
         may be a method or a property
         when module is a SF object

Above mzthods allow the programmer to write
simpler, shorter code, without neccessarily
needing to bother about intricacies
like loops, branching and error handling.

Examples:
 Let's assume:
  ar = CreateScriptService("array")
  fs = CreateScriptService("filesystem")
  st = CreateScriptService("string")
  ui = CreateScriptService("UI")
 Open read-only all Calc docs stored in a folder
  folder = "C:\MyFolder"
  ar.Map(ui, "OpenDocument", fs.Files(folder, filter := "*.ods"), "", True)
 Minimize all active Writer docs
  ar.Map(ui, "Minimize", ar.Filter(st, "EndsWith", _
         ui.Documents(), ".odt"))

Designed for Basic user scripts only.
The user documentation should include those
new functions.

In addition:
- some changes done in Session for more
  flexibility in script provider handling
- identification of SF objects modified
  in SF_Utils

Change-Id: I16f5fe03d31613c9c777905edd5190f56e460df3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202037
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
2026-03-19 10:12:38 +01:00

24 lines
1.2 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ScriptForge" library:readonly="false" library:passwordprotected="false">
<library:element library:name="SF_Services"/>
<library:element library:name="SF_UI"/>
<library:element library:name="SF_Exception"/>
<library:element library:name="SF_Dictionary"/>
<library:element library:name="SF_Session"/>
<library:element library:name="_CodingConventions"/>
<library:element library:name="_ModuleModel"/>
<library:element library:name="SF_String"/>
<library:element library:name="SF_Utils"/>
<library:element library:name="SF_TextStream"/>
<library:element library:name="SF_Array"/>
<library:element library:name="SF_Platform"/>
<library:element library:name="SF_PythonHelper"/>
<library:element library:name="SF_FileSystem"/>
<library:element library:name="SF_Timer"/>
<library:element library:name="SF_Region"/>
<library:element library:name="SF_L10N"/>
<library:element library:name="SF_SharedMemory"/>
<library:element library:name="SF_Root"/>
<library:element library:name="__License"/>
</library:library>