1.9.95 script calling Calc built-in functions
"Jahn, Ray \(R.\)" <[email protected]> Wed, 27 Apr 2005 18:32:47 -0400
| Newsgroups | gmane.comp.openoffice.questions,gmane.comp.openoffice.devel.general,gmane.comp.openoffice.scripting |
|---|---|
| Message-ID | <59A2617D770ED44B842CB39C07C83B2D096E3FB3@na1fcm52.dearborn.ford.com> |
Thanks to the explanation by Andrew Douglas Pitonyak and Mathias Bauer.
Scope: global vs. local vs. any other
Are all objects returned by CreateUnoService() global objects and =
therefore not to be disposed of by users? If the answer is dependent on =
the exact service requested, is there a documentation specifying which =
are global and which are other types? I tried the Developers Guide, =
version 2.0, and a few OO mail lists. Not much luck so far.
FunctionAccess:
Is the FunctionAccess service object returned by CreateUnoService() a =
pointer to a singleton object, that is, the actual singleton =
FunctionAccess service object?
Memory management (leakage):
Is the memory automatically reclaimed (at an unspecified time) when the =
service objects go out of scope?
Is the memory management guideline independent of the script languages =
(Basic, Java-BeanShell, etc.)
There is no concern for memory leakage if all service objects returned =
by CreateUnoService() are mere pointers (handles) to the real (global) =
service objects.
Efficiency:
The overhead of CreateUnoService() becomes noticeable when the =
repetition approaches 100000 - 1000000 (1 million) in Basic on MS =
Windows 2000.
Regards,
' --- example code in OO Basic 1.9.95
option explicit
' simulate repetitive calls from sheet cells to CreateUnoService()
' assume 10 - 20 calls to built-in sheet functions to satisfy one cell =
request
' assume the same number of calls to CreateUnoService() due to the =
partition of algorithm logic=20
Sub test_01()
dim ii as long, cnt as long, err as long
cnt =3D 1000000
for ii =3D 0 to cnt step 1
err =3D call_sheet_functions()
next
msgbox( "call_sheet_functions() repeats " & cnt )
End Sub
function call_sheet_functions() as long
Dim oFunction as variant
oFunction =3D CreateUnoService("com.sun.star.sheet.FunctionAccess")
' data processing section, call sheet built-in functions
call_sheet_functions =3D 0
end function