Issue 58527 - problem with templates and macros in post-2.0 versions
Summary: problem with templates and macros in post-2.0 versions
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: OOo 2.0.1
Hardware: PC All
: P3 Trivial (vote)
Target Milestone: OOo 2.0.2
Assignee: joerg.skottke
QA Contact: issues@framework
URL:
Keywords: oooqa, regression
: 59047 59665 60015 60465 (view as issue list)
Depends on:
Blocks:
 
Reported: 2005-11-27 21:36 UTC by gaborf
Modified: 2006-02-18 15:15 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
doc containing self-made macros (18.30 KB, application/vnd.oasis.opendocument.text)
2005-12-03 23:37 UTC, gaborf
no flags Details
document blank (6.24 KB, application/vnd.sun.xml.writer)
2005-12-04 18:26 UTC, gaborf
no flags Details
template blank (6.25 KB, application/vnd.sun.xml.writer)
2005-12-04 18:27 UTC, gaborf
no flags Details
patch file for fix (2.47 KB, patch)
2006-01-25 17:40 UTC, noel.power
no flags Details | Diff
new patch version (2.50 KB, patch)
2006-01-25 23:39 UTC, noel.power
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description gaborf 2005-11-27 21:36:47 UTC
I have a lot of macros besides those included (collected them from well-trained
people). Some of them are simple, some more elaborate and have more subroutines.
My procedure is that I insert a piece of text into a blank writer doc and start
to perform tasks by the macros. All these work fine in OOo1 and OOo2. Most of
them have toolbar icons and keyboard shortcuts assigned to and the problem
decribed below is independent of how they are launched.
In all versions after 2.0 (even in 2.0.1rc1) I can successfully launch just one
macro (sometimes this, sometimes that, no matter which one but it may be a long
and complicated one as well) or at most two, one after the other, and after that
I always get a yellow triangle with an exclamation mark and the following text:

"com.sun.star.uno.RuntimeExceptionScriptProtocolHandler::createScriptProvider(),"

The text is always the same. From then on all my own macros fail.
The built in macros work, but my own ones do not. None of them.
If I close the document and open a new one, not even the first-launched macro
executes. If I exit OOo (quickstarter and all) the first macro will execute again.
If I uninstall the newer version and put back the older (2.0) it works fine again.
Thank you.
Comment 1 gaborf 2005-11-28 10:23:48 UTC
Based on the questions I received in OOo-forum I think it reasonable to add the
following clarification to my original post.
- Where are your macros ? In "My Macros" or in a document, or both ?
All my macros are in C:\Documents and
Settings\MyUsername\ApplicationData\OpenOffice.org2\user\basic\standard  (Win XP).
- do you get the same problem when you [b]create[/b] this very simple macro? [code]
Sub myMacro
MsgBox("It works")
End Sub[/code]
Yes. It executes on the first document but when I launch it on the second I get
the usual
com.sun.star.uno.RuntimeExceptionScriptProtocolHandler::createScriptProvider(),
message
- Did you install 2.0RC1 over 2.0 or did you delete all 2.0 and install a fresh
new 2.0RC1 ?
Always do a clean install, i.e. I uninstall first but do not delete the user
folder in Application Data.
- how did you move your old macros to the new installation?
I do not move them, they remain in place since 2.0rc1 installs over 2.0 so it
uses the same folder in application Data for user settings. Otherwise I copy the
user folder to the newly created folder in Application Data.
Comment 2 gaborf 2005-12-03 14:15:13 UTC
The same with 2.0.1rc2. 
Comment 3 lars 2005-12-03 20:50:06 UTC
Hi, could you attach a file with some of your macros which don't work?
Comment 4 gaborf 2005-12-03 23:37:06 UTC
Created attachment 32010 [details]
doc containing self-made macros
Comment 5 gaborf 2005-12-03 23:37:49 UTC
Thanks for your answer.
I do attach a doc with lots of macros but it will probably show nothing for you.
Why? Because if I put my user folder aside, make an absolutely clean install
with a newly created user folder and import my macros they all work on the
second etc. documents.
However, there is no possibility in OOo2 to import my numerous self-made
toolbars and my several self-made menus. (Only the keyboard settings.) So I do
have to stick to my original user folder. And I emphasize: everything in it
works fine if I uninstall OOo2 and reinstall it. If I uninstall OOo2 and install
any OOo2+ version (letting it use the existing user folder)I get the defect
described.
Therefore I think that some change must have happened in OOo along the route
where self-made macros in the Modules of Standard in Basic are implemented.
Otherwise there should be a problem with the contents of my user folder even if
I uninstall OOo2 and reinstall it.
Do macros do not execute on the second document. There is a difference in the
message I get depending on how I run them. If from the toolbar icons I assigned
to them, the message is what I already stated. If from the menu
(Tools>Marcos>Run Macro...) the Message is shorter:
com.sun.star.uno.RuntimeException.
Comment 6 lars 2005-12-04 10:09:56 UTC
the macros I tried run fine in OOo 2.0.1 RC2, no errors or such; so defect not 
reproducable on Windows XP Pro SP2
Comment 7 gaborf 2005-12-04 18:25:25 UTC
Thanks for your test. It seems to turn out that the problem is with
non-built-in-templates.
I made a new install, involving nothing from the previous ones. If I create a
brand new blank template with 2.0.1r2 and a brand new blank witer doc, the doc
will open without any fuss either by double clicking or from the quickstarter's
document open option. The template, however, always brings up the long message
(and does not allow the macros to execute) either way opened.
If I ask for a new file from the built-in default template, no problem. Please
try if it holds true there. I will attach a doc and a template, both blank.
Comment 8 gaborf 2005-12-04 18:26:37 UTC
Created attachment 32030 [details]
document blank
Comment 9 gaborf 2005-12-04 18:27:33 UTC
Created attachment 32031 [details]
template blank
Comment 10 lars 2005-12-04 18:50:47 UTC
I can confirm that macros in the attached template won't execute, but what do 
you mean by the "built-in default template". And what's with your macros. Do 
they run after the clean install?
Comment 11 gaborf 2005-12-04 21:53:50 UTC
By "built-in default template" I mean that if I do not set a template of my own
as default, just ask for a new writer file then the file which opens is always
the same since it is be based on internal sources of the program suite. I can
define another default template for myself but I cannot change this one.
If I want my macros execute on a text which I placed into a newly opened file
(opened by clicking on New or holding down Ctrl+N WITHOUT a personal template
set as my personal default) then the macros will execute fine. Again so if I
open a formerly created and saved document. 
But if I open a template (set by myself), put some text in it and run the macros
they don't work. Even if I set a blank , newly opened file as my personal
default template without any modification. The one I sent you was like that. My
macros are never embedded in the files, all of them are in Standard.
Thank you for you interest in the matter.
Comment 12 michael.ruess 2005-12-06 12:14:07 UTC
Reassigned to JSK.
Comment 13 gaborf 2005-12-10 00:33:50 UTC
Please try to duplicate this.
Make a clean install of OOo2 RC4 (or any version after OOo2.0 release), 
choosing custom, allowing all extras, except mobile. [I even cleared the 
registry of any remnants of former OOo2 installations.)

Open a new writer file from the built-in default template. (By "built-in 
default template" I mean that if I do not set a template of my own as default, 
just ask for a new writer file then the file which opens is always the same 
since it is based on internal sources of the program suite. I can define 
another default template for myself but I cannot change this one.)

Open "Tools>>Organize macros" and in Standard>Module 1 (which is now obviously 
empty) write or copy this macro:

Sub myMacro
MsgBox("It works")
End Sub

Save it.

Open again a new file from the built-in default template.
Run the macro from Tools>>Run macro.
It will execute.

Now open again a brand new file from the built-in default template.
Save it under any name [e.g.MyOwn] to Application 
Data>OpenOffice.org2>user>template.

From Quickstart>From Template open a new file from MyOwn.
Run the macro from Tools>>Run macro.
It will not execute. It will give this 
message: "com.sun.star.uno.RuntimeException"

***
First I supposed that it was a problem with my installations. As I have already 
written: it turned out that the problem is not with macros but with templates. 
Something seriously bad happened to a part of the program suite connected with 
templates, and it happened after OOo2.0 was issued. It works fine. No version 
after that allows macros to execute on a document which was opened from a user-
made template

Comment 14 lars 2005-12-10 12:06:14 UTC
confirmed on Windows XP Pro SP2 with OOo 2.0.1 RC2; follow the steps from 
reporters last comment
Comment 15 andreschnabel 2005-12-11 10:32:23 UTC
setting regression keyword, as it works with 2.0.0 but not with 2.0.1, following
reporters last description
Comment 16 joerg.skottke 2005-12-20 08:32:18 UTC
Hi Gaborf,

thank you for this thorough analysis of the problem, it's one of the finest
bugreports i've seen for quite some time :-)

I could easily reproduce the issue, even on Linux. 

Change Target, OS, Component, Owner
Comment 17 eberlein 2005-12-20 09:12:53 UTC
I can confirm the error message
"com.sun.star.uno.RuntimeExceptionScriptProtocolHandler::createScriptProvider()"
which occurs, when a specific template fires the event "OnNew" (the second time
after starting the office).
The macro resides in the shared folder and runs fine with 2.0.
2.0 was deinstalled completly.
It is one of our most used templates.
With 2.0 we are frustrated because of the buggy outline numbering, and now we
have to wait until 2.0.3?

@jsk, abi: Sorry, but please consider the target milestone. It is not acceptable
for this serious regression.

Regards

Peter
Comment 18 joerg.skottke 2005-12-22 07:49:32 UTC
Hi Peter,

i'm not 100% sure this is the same issue as your macro is triggered by an event
and here the macro is run manually. I leave it to the developer to determine.

However, you are absolutely correct that this a regression, i will file another
task for this with target 2.0.2.
Comment 19 joerg.skottke 2005-12-22 08:02:55 UTC
created automated test: framework\basic\f_basic_usertemplate.bas::tMacroUserTemplate

submitted issue #59665# based on last comment by Peter with target 2.0.2.
Comment 20 joerg.skottke 2005-12-22 14:43:15 UTC
OK in OOo 2.0 / StarOffice 8
Comment 21 joerg.skottke 2005-12-22 14:45:24 UTC
Retarget to 2.0.2
Comment 22 joerg.skottke 2005-12-22 14:48:12 UTC
.
Comment 23 ab 2005-12-22 15:00:25 UTC
Accepted
Comment 24 ab 2006-01-11 13:35:22 UTC
*** Issue 59047 has been marked as a duplicate of this issue. ***
Comment 25 ab 2006-01-20 14:33:07 UTC
*** Issue 59665 has been marked as a duplicate of this issue. ***
Comment 26 ab 2006-01-20 14:38:45 UTC
*** Issue 60015 has been marked as a duplicate of this issue. ***
Comment 27 noel.power 2006-01-25 17:35:04 UTC
kai, think this is for you and not Andreas ( who will no doubt be glad ;-) )
I will attach a patch which at least seems to fix it. Problem stems from fact
that templates do some foo with storage ( uses temporary storage ) but you only
know about that after you get a OnNew event ( or so it seemed to me after
debugging it
Comment 28 noel.power 2006-01-25 17:40:19 UTC
Created attachment 33553 [details]
patch file for fix
Comment 29 noel.power 2006-01-25 17:41:38 UTC
type -> patch
any chance of turning this around and getting fix upstream quickly
Comment 30 noel.power 2006-01-25 23:38:37 UTC
mmmm, it just occurs to me that maybe OnNew is not the best event to use, I
guess there is a chance of a race condition between a macro firing on "OnNew"
and the storage getting reset on the same event, what do you think?

It seems that "OnViewCreated" created works equally well and appears like that
will always happen before a OnNew event, attaching patch "...-#2.diff" with that
option
Comment 31 noel.power 2006-01-25 23:39:45 UTC
Created attachment 33562 [details]
new patch version
Comment 32 kai.sommerfeld 2006-01-26 08:15:13 UTC
Noel, thanks for the patch. Meanwhile, Andreas together with the framework guys
found another, more straight solution, which we prefer over your patch. But
thanks again for taking care. Setting task back to Andreas.
Comment 33 noel.power 2006-01-26 09:23:11 UTC
->ab any chance of you identifying the cws that this will appear in?
Comment 34 ab 2006-01-26 13:49:34 UTC
ab->npower: This task has already be assigned to cws ab23pp2 for a long
time. But it wasn't clear to me that you cannot see this in an easy way,
because SO internally the bug handling framework automatically provides
this information for every task. So in the future I will always also write ma-
nually into the task which cws I assign it to.
Comment 35 ab 2006-01-26 14:16:47 UTC
Fixed
Comment 36 lars 2006-01-26 17:01:08 UTC
*** Issue 60465 has been marked as a duplicate of this issue. ***
Comment 37 noel.power 2006-01-27 09:07:29 UTC
Andreas,
>This task has already be assigned to cws ab23pp2 for a long
>time.
:-)
> But it wasn't clear to me that you cannot see this in an easy way,
>because SO internally the bug handling framework automatically provides
>this information for every task.
Yes, I searched unsuccessfully in EIS. There is some option in there to allow
your cws to be viewed externally or not ( most likely defaulted to no when using
internal EIS ) 
>So in the future I will always also write ma-
>nually into the task which cws I assign it to.
That would be great :-) thanks again.
Comment 38 ab 2006-01-30 12:03:38 UTC
ab->jsk: I've tested the fix according to the description from
gaborf Fri Dec 9 16:33:50 -0800 2005


re-open issue and reassign to jsk@openoffice.org
Comment 39 ab 2006-01-30 12:03:49 UTC
reassign to jsk@openoffice.org
Comment 40 ab 2006-01-30 12:03:56 UTC
reset resolution to FIXED
Comment 41 joerg.skottke 2006-01-31 11:10:59 UTC
Verified by autotest, f_basic_usertemplate.inc has been updated.
Comment 42 lars 2006-01-31 20:56:37 UTC
it's not fixed in m154
Comment 43 andreschnabel 2006-01-31 21:06:22 UTC
andreschnabel->lars:
as mentioned by ab, this is fixed in cws ab23pp2, which is not integrated yet.

you may search for cws information in EIS:
http://eis.services.openoffice.org/EIS2/servlet/GuestLogon
Comment 44 andreschnabel 2006-02-18 15:15:56 UTC
ok with 2.0.2RC1 -> close