Issue 55913 - OLE Automation Bridge doesn't convert properly a com.sun.star.lang.PropertyValue array
Summary: OLE Automation Bridge doesn't convert properly a com.sun.star.lang.PropertyVa...
Status: CLOSED WONT_FIX
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: joachim.lingner
QA Contact: issues@api
URL:
Keywords: oooqa
Depends on:
Blocks:
 
Reported: 2005-10-13 12:37 UTC by jsanchezlara
Modified: 2013-02-24 21:06 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description jsanchezlara 2005-10-13 12:37:04 UTC
I found this misfunctionality accessing to the OOo through OLE Automation Bridge
for manipulating the toolbars. According to the API defined for a
XIndexContainer implementation object, this method expects for 2 parameters: Any
Object and the index where the first one must be inserted (in the underlaying
data structure). The problem appears when for adding a item to a toolbar is
needed to use this method, passing it a com.sun.star.lang.PropertyValue array as
parameter (where it is defined the properties of a new toolbar item). Despite of
following the instructions described on the Developers Guide about how to
construct OOo specific objects and arrays for being used thrugh OLE Automation
Bridge, the problem appears when this method was called.
-ERROR REPRODUCTION-
Environment: Windows XP (SP1), OOo Beta 2, a minimal VB.NET application(*)
(*)
Private Sub createToolbarB_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles createToolbarB.Click
       Dim objSM As Object = CreateObject("com.sun.star.ServiceManager")
       Dim CoreRef As Object =
objSM.CreateInstance("com.sun.star.reflection.CoreReflection")
       Dim classPV As Object = CoreRef.forName("com.sun.star.beans.PropertyValue")
       Dim aToolbarItemProp1 As Object
       classPV.CreateObject(aToolbarItemProp1)
       Dim aToolbarItemProp2 As Object
       classPV.CreateObject(aToolbarItemProp2)
       Dim aToolbarItemProp3 As Object
       classPV.CreateObject(aToolbarItemProp3)
       Dim properties As System.Array
       properties = System.Array.CreateInstance(aToolbarItemProp1.GetType, 3)


       aToolbarItemProp1.Name = "CommandURL"
       aToolbarItemProp1.Value = "macro:///standard.module1.TestIt"
       aToolbarItemProp2.Name = "Label"
       aToolbarItemProp2.Value = "Test"
       aToolbarItemProp3.Name = "Type"
       aToolbarItemProp3.Value = 0

       properties(0) = aToolbarItemProp1
       properties(1) = aToolbarItemProp2
       properties(2) = aToolbarItemProp3

       Dim Doc As Object
       Dim dummy As System.Array
       Dim objDummy As Object = New Object()
       dummy = System.Array.CreateInstance(objDummy.GetType, 0)
       Doc =
objSM.createInstance("com.sun.star.frame.Desktop").loadComponentFromURL("private:factory/swriter",
"_blank", 2, dummy)
       Dim LayoutManager As Object = Doc.currentController.Frame.LayoutManager
       LayoutManager.createElement("private:resource/toolbar/user_toolbar1")
       LayoutManager.showElement("private:resource/toolbar/user_toolbar1")
       Dim ToolBar As Object =
LayoutManager.getElement("private:resource/toolbar/user_toolbar1")
       Dim settings As Object = ToolBar.getSettings(True)
       settings.insertByIndex(0, properties) '<== ERROR IS THROWN IN THIS LINE
       ToolBar.setSettings(settings)
   End Sub

The message error shown by application is following:
"com.sun.star.lang.IllegalArgumentException: Type must be
com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >"
Comment 1 stephan.wunderlich 2005-10-14 10:45:05 UTC
You have to tell the bridge what it should do with the array you send.
Not completely sure about the VB-syntax, but something like the following should
solve the problem

	Set aInfo = objServiceManager.Bridge_GetValueObject
	aInfo.Set("[]com.sun.star.beans.PropertyValue", properties)
        settings.insertByIndex(0, aInfo)
Comment 2 joachim.lingner 2005-10-14 11:51:24 UTC
JL->SW: I think I could enhance the bridge, so that the workaround with the
value object is not necessary. Therefore I'll overtake this issue if you don't
mind. 
Comment 3 joachim.lingner 2005-10-14 11:51:54 UTC
.
Comment 4 joachim.lingner 2005-10-14 11:52:48 UTC
.
Comment 5 kai.sommerfeld 2006-02-13 09:55:33 UTC
.
Comment 6 joachim.lingner 2006-03-14 13:51:24 UTC
The problem with UNO functions which take any arguments is that the bridge has
no clue as to what the implementation expects the any to contain. In case of a
SAFEARRAY which is passed for example by VB, the bridge creates a Sequence of
anys. This is done for SAFEARRAYs with VARIANT as element type or any other
element type. Now one could argue that in the latter case, one should create a
sequence of the exact type. However, this may break existing applications.
Therefore I will not fix this. Using the ValueObject it is always possible to
determine what the target type should be. This is also described in the
developer's guide.
Comment 7 ace_dent 2008-05-17 20:56:53 UTC
The Issue you raised has been marked as 'Resolved' and not updated within the
last 1 year+. I am therefore setting this issue to 'Verified' as the first step
towards Closing it. If you feel this is incorrect, please re-open the issue and
add any comments.

Many thanks,
Andrew
 
Cleaning-up and Closing old Issues
~ The Grand Bug Squash, pre v3 ~
http://marketing.openoffice.org/3.0/announcementbeta.html
Comment 8 ace_dent 2008-05-17 22:57:40 UTC
As per previous posting: Verified -> Closed.
A Closed Issue is a Happy Issue (TM).

Regards,
Andrew