List Info

Thread: Error on closing eventlistner 'Cannot coerce argument type during corereflection'




Error on closing eventlistner 'Cannot coerce argument type during corereflection'
user name
2006-09-27 21:56:53
Hi all,

I've added a listner to a Calc cell.
Assigned Sub Main to Document Open.
Assigned Sub RemoveListener (see below) to Document Close.
However, this one causes an error. See comment marked with
>> in line.

Couldn't find a solution easily (and didn't find courage to
study the 
whole chapter about events and such ...)
Any idea what's wrong and how I can solve this?

Thanks,
Cor

global oListner0 as object
'also oListner1 and oListner2

Sub Main
   AddListners
End Sub

Sub AddListners
   Dim oCell
   Const sCellName as String  = "A1"

   oCell =
ThisComponent.Sheets.getByIndex(0).getCellRangeByName(sCellN
ame)
   oListner0 = CreateUnoListener( "A10_", 
"com.sun.star.chart.XChartDataChangeEventListener"
)
   oCell.addChartDataChangeEventListener(oListner0)

  ' do the same for sheet(1) and (2)
End Sub

Sub RemoveListener
   Dim oCell
   ' removes the listener
   oCell =
ThisComponent.Sheets.getByIndex(0).getCellByPosition(0, 0)
   oCell.removeModifyListener(oListner0)
*>>*
   ' Gives "Cannot coerce argument type during
corereflection call"

   ' do the same for other listners
End Sub

Sub A10_chartDataChanged(oEvent)
  'do something
end sub


-- 

Cor Nouws
Arnhem - Netherlands
www.nouenoff.nl

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

Error on closing eventlistner 'Cannot coerce argument type during corereflection'
user name
2006-09-27 22:23:44
Am Mittwoch, den 27.09.2006, 23:56 +0200 schrieb Cor Nouws:
> Sub AddListners
>    Dim oCell
>    Const sCellName as String  = "A1"
> 
>    oCell =
ThisComponent.Sheets.getByIndex(0).getCellRangeByName(sCellN
ame)
>    oListner0 = CreateUnoListener( "A10_", 
>
"com.sun.star.chart.XChartDataChangeEventListener"
)
>    oCell.addChartDataChangeEventListener(oListner0)
> 
>   ' do the same for sheet(1) and (2)
> End Sub
> 
> Sub RemoveListener
>    Dim oCell
>    ' removes the listener
>    oCell =
ThisComponent.Sheets.getByIndex(0).getCellByPosition(0, 0)
>    oCell.removeModifyListener(oListner0)
> *>>*
>    ' Gives "Cannot coerce argument type during
corereflection call"

>From my experience this error message generally wants to
tell you that
typecasting is impossible in this situation.

Since you added a "ChartDataChangeEventListener" I
think removing must
be done with exactly the same type:

	oCell.removeChartDataChangeEventListener(oListner0)

should do.

>    ' do the same for other listners
> End Sub

HTH,
Marc


------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

Error on closing eventlistner 'Cannot coerce argument type during corereflection'
user name
2006-09-27 23:01:23
Thanks Marc,

That did it.

Cor

Marc Santhoff wrote:

>>   ' Gives "Cannot coerce argument type during
corereflection call"
> 
> 
>>From my experience this error message generally
wants to tell you that
> typecasting is impossible in this situation.
> 
> Since you added a
"ChartDataChangeEventListener" I think removing
must
> be done with exactly the same type:
> 
> 	oCell.removeChartDataChangeEventListener(oListner0)
> 
> should do.
> 
> 
>>   ' do the same for other listners
>>End Sub
> 
> 
> HTH,
> Marc
> 
> 
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
> For additional commands, e-mail: dev-helpapi.openoffice.org
> 
> 
> 
> 


-- 

Cor Nouws
Arnhem - Netherlands
www.nouenoff.nl

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )