[Gelöst] Parameter-Übergabe Calc <===> JavaScript
Verfasst: Sa, 23.01.2010 17:50
Hallo zusammen
Ich konnte das Problem selber lösen. Falls ich sehe, dass Interesse an diesem Thema besteht, werde ich bis anfangs Februar (sobald ich Zeit finde) ein Calc mit 2 verschiedenen lauffähigen Lösungen und Kommentar ins Forum stellen. Hans Louis
Ursprünglicher Text: Hallo Könner
Ich habe Code geschrieben, um z.B. von Calc-Code aus ein JavaScript aufzufufen. In Calc lautet bei mir der Aufrufe
bsc = createUnoService("com.sun.star.configuration.bootstrap.BootstrapContext")
tmspf = bsc.getValueByName("/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory")
sp = mspf.createScriptProvider("")
script = sp.getScript("vnd.sun.star.script:Library1.Macro_01.js?language=JavaScript&location=user")
script.invoke(array(), array(), array())
Das funktioniert.
Ich möchte aber auch Parameter (z.B. ein simpler String) übergeben. Das kriege ich einfach nicht hin.
Als Information dazu habe ich gefunden
***********************************************
http://wiki.services.openoffice.org/wik ... ing_Macros
....... Handling arguments passed to macros
In certain cases arguments may be passed to macros, for example, when a macro is assigned to a button in a document. In this case the arguments are passed to the macro as follows:
JavaScript: In the global Object[] variable ARGUMENTS
event = ARGUMENTS[0];
Each of the arguments in the Object[] are of the UNO type Any. For more Information on how the Any type is used in Java see Type Mappings. The ButtonPressHandler macros in the Highlight library of a OpenOffice.org installation show how a macro can handle arguments.
==> C:\Programme\OpenOffice.org \Basis\share\Scripts\javascript\Highlight\ButtonPressHandler.js
*********************************************************************************************************************
Es ist mir nicht gelungen, dies in Code umzusetzen. Was muss in "invoke" stehen und was im JavaScript? Kann mir jemand helfen und mir den konkrete Lösung mitteilen. Besten Dank. Hans Louis
Ich konnte das Problem selber lösen. Falls ich sehe, dass Interesse an diesem Thema besteht, werde ich bis anfangs Februar (sobald ich Zeit finde) ein Calc mit 2 verschiedenen lauffähigen Lösungen und Kommentar ins Forum stellen. Hans Louis
Ursprünglicher Text: Hallo Könner
Ich habe Code geschrieben, um z.B. von Calc-Code aus ein JavaScript aufzufufen. In Calc lautet bei mir der Aufrufe
bsc = createUnoService("com.sun.star.configuration.bootstrap.BootstrapContext")
tmspf = bsc.getValueByName("/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory")
sp = mspf.createScriptProvider("")
script = sp.getScript("vnd.sun.star.script:Library1.Macro_01.js?language=JavaScript&location=user")
script.invoke(array(), array(), array())
Das funktioniert.
Ich möchte aber auch Parameter (z.B. ein simpler String) übergeben. Das kriege ich einfach nicht hin.
Als Information dazu habe ich gefunden
***********************************************
http://wiki.services.openoffice.org/wik ... ing_Macros
....... Handling arguments passed to macros
In certain cases arguments may be passed to macros, for example, when a macro is assigned to a button in a document. In this case the arguments are passed to the macro as follows:
JavaScript: In the global Object[] variable ARGUMENTS
event = ARGUMENTS[0];
Each of the arguments in the Object[] are of the UNO type Any. For more Information on how the Any type is used in Java see Type Mappings. The ButtonPressHandler macros in the Highlight library of a OpenOffice.org installation show how a macro can handle arguments.
==> C:\Programme\OpenOffice.org \Basis\share\Scripts\javascript\Highlight\ButtonPressHandler.js
*********************************************************************************************************************
Es ist mir nicht gelungen, dies in Code umzusetzen. Was muss in "invoke" stehen und was im JavaScript? Kann mir jemand helfen und mir den konkrete Lösung mitteilen. Besten Dank. Hans Louis