Bug 36132

Summary: Extension: Calc-sheetAddin-function written in python don't return cell*ranges*
Product: LibreOffice Reporter: karolus <karlooforum>
Component: contribAssignee: Not Assigned <libreoffice-bugs>
Status: RESOLVED INVALID    
Severity: enhancement    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:
Attachments: Extensionfile ocapy.oxt with Calc-addin-function "Testrange"

Description karolus 2011-04-11 05:18:44 UTC
Created attachment 45474 [details]
Extensionfile ocapy.oxt with Calc-addin-function "Testrange"

Building a Calcaddin-extension I want to return a Cellrange, similar to return of a Calcformula, for Example '=A1:C5' as Arrayformula.

I try it with following:

Xexample.idl
########################
#include  /opt/libreoffice/basis3.3/sdk/idl/com/sun/star/uno/XInterface.idl

// Xexample.idl
module com { module sheetfunctions {
    interface ocapy
    {
        any testrange( [in] any cellrange );
    };
}; };
##########################
*Test with Type "any [ ][ ] testrange.." leads to Compiler-errors from idlc

Pythonscript:
#################################
import uno
import unohelper
from com.sheetfunctions import Xexample


wrapper = uno.createUnoStruct('com.sun.star.script.ArrayWrapper')
wrapper.IsZeroIndex = False

class functions( unohelper.Base, Xocapy ):
    def __init__(self, ctx):
        self.ctx = ctx

    def testrange( self, cellrange ):
        if isinstance(cellrange, tuple):
            return  cellrange 
            #involving wrapper to return a range works only thru basic-bridge:
            #wrapper.Array = cellrange
            #return wrapper
             
        else:
            return cellrange

    
def createInstance( ctx ):
	return functions( ctx )

g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation( \
	createInstance,"com.sheetfunctions.ocapy.functions",
		("com.sun.star.sheet.AddIn",),)
#################################################

Inside python I can work with Input "cellrange" as nestet tuple, but calling from Calc for Example "=TESTRANGE(A1:B3)" as Arrayfomula or not returns: '#Value'.
Calling the Function with a single Celladdress returns the Content from Celladdress.

Is it a bug - is it a missing feature - or do I something wrong ?
Comment 1 Jan Holesovsky 2011-04-14 14:51:05 UTC
This will be best answered on the libreoffice@lists.freedesktop.org mailing list ;-)  Please bring this there, bugzilla is not the best medium for this.