Issue 99858

Summary: Java-like scripts of an extension cannot be run
Product: General Reporter: bmarcelly <marcelly.bernard>
Component: codeAssignee: ab
Status: CLOSED FIXED QA Contact:
Severity: Trivial    
Priority: P3 CC: issues, marcelly.bernard
Version: OOO300m2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Issue Depends on: 98990    
Issue Blocks:    
Attachments:
Description Flags
Test extension with Basic, JavaScript, BeanShell, Java, Python scripts.
none
Error message when trying to run a JavaScript script.
none
script extension in javascript
none
installation command line script for Windows OS none

Description bmarcelly 2009-03-04 11:16:25 UTC
I found this problem on OOO310m2, and also on 2.4.2. It is not systematic but very 
disturbing for the user.

On an OpenOffice freshly started (QuickStarter not used), install an extension 
containing a script in JavaScript or BeanShell or Java.
After installation, try to run the script from a toolbar or a menu.
Error : 
A Scripting Error has occurred while running the JavaScript script xxxx.js
Message : Cannot resolve script location for script = xxxx.js

Try menu Tools > Macros > Run macros : you cannot see the script name in "My Macros".
The problem persists even after closing / restarting OpenOffice.

Work-around :
Open Tools > Extension Manager
Select the extension, click Disable, then click Enable. Close the Extension Manager.
Now the script runs ! It is visible in "My Macros".
The problem has disappeared, even if OpenOffice is restarted.

Next attachment is a small test extension containing HelloWorld scripts in Basic, 
JavaScript, BeanShell, Java, Python.
Use an OpenOffice which does not have Java-like scripts. Install this extension.
Open a new Writer document and open menu Tools > Add-Ons > Test1. Run the different 
scripts from there.
Comment 1 bmarcelly 2009-03-04 11:17:07 UTC
Created attachment 60676 [details]
Test extension with Basic, JavaScript, BeanShell, Java, Python scripts.
Comment 2 bmarcelly 2009-03-04 11:17:47 UTC
Created attachment 60677 [details]
Error message when trying to run a JavaScript script.
Comment 3 Olaf Felka 2009-03-04 11:36:00 UTC
Looks like issue 98990
Comment 4 joachim.lingner 2009-03-06 08:37:12 UTC
The scripts are actually not registered, that is, insertByName is not called.
The reason is, that before the function is called at the master script provider,
it is asked if the script is already registered. This function returns true
which is wrong. The master script provider calls in turn all script providers,
of which the python provider returns true. This should be fixed in issue 98990.

However, the error message is still displayed which suggest a bug in the
scripting providers.
BTW, this feature seems long broken. It didn't even work with OOo 2.3 (with python).
Comment 5 joachim.lingner 2009-03-06 08:40:52 UTC
To test without python, one need to deselect python in the setup and also to
remove the entry in the manifest.xml of the test1.oxt which refers to the python
code.
Comment 6 questpc 2009-03-17 08:31:06 UTC
Created attachment 60964 [details]
script extension in javascript
Comment 7 questpc 2009-03-17 08:31:45 UTC
Created attachment 60965 [details]
installation command line script for Windows OS
Comment 8 questpc 2009-03-17 08:32:23 UTC
I've developed a script extension in Javascript using the Extension Compiler. It
used to work just fine in Russian (so-called "Infra") OpenOffice.org 3.0.0. I
install the extensions from GUI (I didn't knew unopkg was available on Windows,
too).

However, during the development of extension, OOo 3.0.1 was released and
extension installation broke up again. Installation process went without errors,
the toolbar button in Writer was added successfully. But, the script itself
seems not to be copied/registered to the library, so pressing the button
produces the following error message:
"Cannot resolve script location for script = FreshEye.js"

The "branch" OOodev- Macros has a node "FreshEye_1.0.oxt" but the node is empty
- it doesn't expand, it has no macros ("Macro name" field is empty).

Then, I've used latest update of Extension Compiler with latest OOo310m5 build
for Windows. No luck, the same message - so I don't think the issue is solved in
3.1 branch, yet :-( Then I've tried to install with unopkg and this time it
worked fine with OOO310m5.

Reinstalled back Russian OOo 3.0.1. unopkg works, yet the same "Cannot resolve
script location for script = FreshEye.js" error is produced with toolbar button
was pressed! It worked only when installed with unopkg and then disable-enable
workaround in GUI extension manager (thanks to bmarcelly) for the workaround.

But, such long way of installation is cumbersome to end users.
Comment 9 questpc 2009-05-15 11:12:49 UTC
I've downloaded ooo 3.1.0rc2 and the problem is still unresolved. The extension
works only after installing from command line with unopkg AND pressing
"disable"/"enable" button twice in extension manager.

I don't want to put another comment, but the general javascript execution speed
is not very fast, too. Especially comparing to Firefox 3.5 with TraceMonkey
enabled. It would be a good idea to adapt such fast Javascript engine to the
OpenOffice.
Comment 10 ab 2009-06-17 11:54:31 UTC
Needs evaluation, STARTED, 3.x for now
Comment 11 bmarcelly 2014-02-25 08:18:50 UTC
Can't reproduce anymore on Apache OpenOffice 4.0.1.
All Java-like scripts work after extension installation.

I close as RESOLVED.