Adjusting an Array Range in Calc

Lars Callenbach lars.callenbach at gmx.de
Fri Sep 21 14:10:22 PDT 2012


Hi Jan,

I have a plugin with an C++ addin code of the following form
************************
....
static Reference< XInterface > 
SAL_CALL create_CalcAddins_impl(Reference<XComponentContext> const & xContext) 
    SAL_THROW( () ) {
    return static_cast< ::cppu::OWeakObject * > ( new CalcAddins_impl );
}

static struct ::cppu::ImplementationEntry s_component_entries[] = {
    { create_CalcAddins_impl, getImplementationName_CalcAddins_impl,
      getSupportedServiceNames_CalcAddins_impl, 
      ::cppu::createSingleComponentFactory, 0, 0 },
    { 0, 0, 0, 0, 0, 0 }
};


extern "C" {
	SAL_DLLPUBLIC_EXPORT  void SAL_CALL component_getImplementationEnvironment(
                                            sal_Char const ** ppEnvTypeName, 
                                            uno_Environment ** ppEnv) {
		*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
	}

	SAL_DLLPUBLIC_EXPORT  sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * xMgr, 
                                          registry::XRegistryKey * xRegistry) { 
		return ::cppu::component_writeInfoHelper( xMgr, xRegistry, 
                                                  s_component_entries );
	}

	SAL_DLLPUBLIC_EXPORT  void * SAL_CALL component_getFactory( sal_Char const * implName,
		lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry) {
		return ::cppu::component_getFactoryHelper(implName, xMgr, xRegistry, 
                                                  s_component_entries );
	}
}
************************

The following function is an example:
************************
...
SEQSEQ(ANY) SAL_CALL CalcAddins_impl::qlInterpolationInterpolate(
        const STRING &ObjectId,
        const SEQSEQ(ANY) &XValues,
        const ANY &AllowExtrapolation,
        const ANY &Trigger) throw(RuntimeException) {
    try {
....
        SEQSEQ(ANY) returnValue;

        QuantLibAddin::qlInterpolationInterpolateBind bindObject = 
            boost::bind((QuantLibAddin::qlInterpolationInterpolateSignature)
                    &QuantLibAddin::Interpolation::operator(), ObjectIdObjPtr, 
                _1,
                AllowExtrapolationCpp);
                    
        {
            returnValue.realloc(XValuesLib.size());
            for (unsigned int i=0; i<XValuesLib.size(); ++i) {
                SEQ(ANY) s(1);
                scalarToCalc(s[0], bindObject( XValuesLib[i] ) );
                returnValue[i] = s;
            }
        }



        return returnValue;
    } catch (const std::exception &e) {
        OH_LOG_MESSAGE("ERROR: qlInterpolationInterpolate: " << e.what());
        THROW_RTE;
    }
}
************************

The code for this function works fine if I use Cntr-F2 to define the 
function as a Matrix function the first time - but only the first time. 
The first time the function name appears in capital letters and the return 
values are valid. 

Whenever I try to change the Matrix result array in Calc (e.g. change return
values from A1:A4 to A1:A5) an error occurs - the name of the addin function
changes from capital to small letters (indication that the addin function is 
not known) and #value errors appear. If I delete the Matrix result and use
Cntr-F2 to define a new Matrix function for A1:A5 everything works fine again
(but only for the first time). 

This error occurs not only for this addin function but also for others with
vector return types. It seems to be not possible to change an Matrix result 
after an initial definition using the defined C++ addins. 

Are there other C++ functions that need to be included in the defintion of the
addin? Something seems to be missing ...


Regards,
   Lars






-------- Original-Nachricht --------
> Datum: Mon, 10 Sep 2012 09:45:01 +0200
> Von: Jan Holesovsky <kendy at suse.cz>
> An: Lars Callenbach <lars.callenbach at gmx.de>
> CC: libreoffice at lists.freedesktop.org
> Betreff: Re: Adjusting an Array Range in Calc

> Hi Lars,
> 
> Lars Callenbach píše v Ne 02. 09. 2012 v 11:15 +0200:
> 
> > I have a working plugin for Quantlib. Scalar results of the library
> (single numbers) are working fine. 
> > If I have a Matrix result (array range formula) than it is not possible
> to change the size of the array. 
> > What happens if I try to change the array range: the name of the formula
> changes from upper-case to lower-case (this is simply an indication that
> the function is not known) and an error message appears (error 508).
> > 
> > Help appreciated.
> 
> I am sorry, but it seems that the information you've provided is too
> terse :-(  Can you please write more?  Ideally small snippets of code
> you have now, and exactly what are you trying to achieve with it?
> 
> Thank you,
> Kendy
> 


More information about the LibreOffice mailing list