Page 1 of 1
Calling a C++ function from Python
Posted: Mon Aug 06, 2012 1:20 am
by saleem145
Hello,
I am trying the following code --
Code: Select all
startDate = spreadsheet.NamedRanges.getByName("START_DATE").getReferredCells().getValue()
endDate = spreadsheet.NamedRanges.getByName("END_DATE").getReferredCells().getValue()
fields = spreadsheet.NamedRanges.getByName("FIELDS").getReferredCells().getDataArray()
service = CreateUnoService("my_module.MyService1")
service.initializeDataset(start_date, end_date, fields)
The last line is failing. Any suggestions. I have the code working from basic.
Thanks,
Saleem
Re: Calling a C++ function from Python
Posted: Mon Aug 06, 2012 10:10 am
by Charlie Young
saleem145 wrote:Hello,
I am trying the following code --
Code: Select all
startDate = spreadsheet.NamedRanges.getByName("START_DATE").getReferredCells().getValue()
endDate = spreadsheet.NamedRanges.getByName("END_DATE").getReferredCells().getValue()
fields = spreadsheet.NamedRanges.getByName("FIELDS").getReferredCells().getDataArray()
service = CreateUnoService("my_module.MyService1")
service.initializeDataset(start_date, end_date, fields)
The last line is failing. Any suggestions. I have the code working from basic.
Thanks,
Saleem
createUnoService is a Basic function, not Python. It is equivalent to the ServiceManager's createInstance() method.
Try
Code: Select all
ctx = XSCRIPTCONTEXT.getComponentContext()
oMSF = ctx.getServiceManager()
oMSF.createInstance("some service")
Re: Calling a C++ function from Python
Posted: Mon Aug 06, 2012 2:40 pm
by saleem145
Hi Charlie,
That's not the issue. I have my own CreateUnoService implemented.
Code: Select all
def CreateUnoService(serviceName):
sm = uno.getComponentContext().ServiceManager
return sm.createInstanceWithContext(serviceName, uno.getComponentContext())
BTW: I got the plotting add-on to work.
Thanks,
Saleem
Re: Calling a C++ function from Python
Posted: Mon Aug 06, 2012 4:07 pm
by Villeroy
Why don't you use an object inspector?
Why don't you split up the long lines?
Code: Select all
onames = spreadsheet.NamedRanges
onamed = onames.getByName("START_DATE")
# this fails if the named has relative parts:
orange = onamed.getReferredCells()
# this fails because a range object has no value:
nval = orange.getValue()
ocell = orange.getCellByPosition(0,0)
nval = ocell.getValue()
Re: Calling a C++ function from Python
Posted: Mon Aug 06, 2012 5:57 pm
by hanya
If you ask about your custom or own service, interface, structs or other API implementation, please write its IDL definitions. No one can understand or make answer without it.