Issue 110821 - extensions: automation bridge/ooo-basic doesn't understand com default method
Summary: extensions: automation bridge/ooo-basic doesn't understand com default method
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: DEV300m76
Hardware: PC Windows, all
: P3 Trivial (vote)
Target Milestone: OOo 3.3
Assignee: ab
QA Contact: issues@framework
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-12 18:23 UTC by noel.power
Modified: 2017-05-20 10:22 UTC (History)
2 users (show)

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


Attachments
patch (7.44 KB, patch)
2010-04-12 18:24 UTC, noel.power
no flags Details | Diff
test doc and test data (24.91 KB, application/x-compressed)
2010-04-12 18:25 UTC, noel.power
no flags Details
updated patch (5.46 KB, application/vnd.ms-excel)
2010-06-24 07:59 UTC, noel.power
no flags Details
patch ( with correct mime type ) (5.46 KB, patch)
2010-06-24 08:12 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 noel.power 2010-04-12 18:23:22 UTC
COM objects can have default members, those members can be properties or
methods, already for vba support in basic we have a concept of default members &
default properties ( exposed via XDefaultMethod & XDefaultProperty ) this
loosely maps to the COM concept of default members ( note: we have a default
method to fake use of properties that take parameters which of course is an
alien concept for uno )
The automation bridge though cannot tell basic about these default members, the
(tobe attached) patch exposes the missing information about the default member
to basic. This allow constructs like 

Sheets(1).Cells(L, 1) = rs.Fields("PartNo#")

to work. In the example line above rs is a ADODB.Recordset object ( returned
from the automation bridge )

Fields("PartNo#") calls a default member called 'Item' ( the collection iterator
method ) with the index "PartNo#" this returns a 'Field' object which has a
default 'property' value which is assigned to the Range returned from 
"Sheets(1).Cells(L, 1)" - I will attach a sample document containing the above
example. Naturally when running on windows ( without the patch ) the test
document fails miserably, with the patch you should get a message box telling
you "looped 9 times" and the cells A1:B9 should contain values like those below

A               | B
=========================
20090324 073237	| M0103A
20090324 033719	| M0104A
20090324 033733	| M0104A
20090324 033740	| M0104A
20090324 033757	| M0104A
20090324 033757	| M0104A
20090324 033757	| M0104A
20090324 033803	| M0104A
20090324 033810	| M0104A
Comment 1 noel.power 2010-04-12 18:24:45 UTC
Created attachment 68891 [details]
patch
Comment 2 noel.power 2010-04-12 18:25:39 UTC
Created attachment 68892 [details]
test doc and test data
Comment 3 noel.power 2010-04-13 15:57:38 UTC
.
Comment 4 ab 2010-06-03 12:00:09 UTC
STARTED, 3.x
Comment 5 joachim.lingner 2010-06-22 11:18:14 UTC
The function 
SAL_CALL IUnknownWrapper_Impl::initialize( 

must catch the BridgeRuntimeError which may be thrown, for example when calling
getTypeInfo.
BridgeRuntimeError does not inherit Exception.

If ITypeInfo::GetDocumentation returns a string for the default
property/function and still there is no VARDESC or FUNCDESC available, then this
sound for me that ITypeInfo does not work properly. In this case the functions
getDefaultMethodName and getDefaultPropertyName should throw an exception, so
that OOo can show a message box indicating that the automation object is broken.

Comment 6 joachim.lingner 2010-06-22 11:31:06 UTC
put myself on CC
Comment 7 noel.power 2010-06-23 12:07:03 UTC
@jl
>The function 
>SAL_CALL IUnknownWrapper_Impl::initialize
[...]
>BridgeRuntimeError does not inherit Exception
indeed it does not ( and I didn't notice that ) so I think that is a nice catch,
thanks !!

>In this case the functions getDefaultMethodName and getDefaultPropertyName
>should throw an exception.

I think I have to disagree a little here ( but only in the implementation ) 
I think in the case where you do get a String back ITypeInfo::GetDocumentation (
and no VARDESC or FUNCDESC available ) we should just propagate the error from
the initialize method ( I don't think it is necessary to involve the XDefaultxxx
facet in this at all ) is that ok for you?

if so (please let me know) I will regenerate the patch based on the f/b ( but
give me a day or so as I am a little busy )
Comment 8 joachim.lingner 2010-06-23 12:31:16 UTC
OK.
Comment 9 noel.power 2010-06-24 07:59:07 UTC
Created attachment 70184 [details]
updated patch
Comment 10 noel.power 2010-06-24 08:02:00 UTC
I made the latest patch slightly stricter ( I no longer eat the final Exception
in the initialise method ) I hope this isn't too punitive ( COM objects I think
can be a bit flacky ) 
Also I wasn't able to test the patch :-/ ( but then again only a couple of lines
were changed )
Comment 11 noel.power 2010-06-24 08:12:36 UTC
Created attachment 70185 [details]
patch ( with correct mime type )
Comment 12 ab 2010-07-05 13:05:10 UTC
OOo 3.3, FIXED
Comment 13 michael.brauer 2010-08-02 13:46:46 UTC
Verified in CWS mib17