I managed to fix the problem, in my supported services. My fix was:
static Sequence< OUString > getSupportedServiceNames_XenonAddin()
throw (RuntimeException)
{
- Sequence< OUString > name(1);
+ Sequence< OUString > name(2);
name[0] = OUString(_serviceName, sizeof(_serviceName_)-1,
RTL_TEXTENCODING_ASCII_US);
+ name[1] =
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.AddIn"));
return name;
}
A big thankyou to the C++ addin guides on the wiki they have helped a lot
with creating this addin :-)
Paul
On Sat, Dec 6, 2008 at 2:04 PM, Paul Wheeler <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am new to openoffice development and am trying to write my own calc
> addin. I have followed the guidlines on the wiki (both the simple and
> complete versions). I have managed to build an addin and a oxt extension. I
> can load the extension and run the function using the basic macro:
>
> Sub Main
> mgr = getProcessServiceManager()
> o = mgr.createInstance("Xenon.Xenon")
>
> MsgBox o.expo(10)
> End Sub
>
> So far so good :-)
>
> However I can not see my functions in the function list. My idl file looks
> like this:
>
> module Xenon {
> interface XXenon : com::sun::star::uno::XInterface
> {
> double expo( [in] double m );
> };
>
> service Xenon {
> interface XXenon;
> interface com::sun::star::lang::XInitialization;
> interface com::sun::star::lang::XServiceName;
> interface com::sun::star::sheet::XAddIn;
> };
> };
>
> and the XAddin part of my cxx file like this:
>
> #define _serviceName_ "Xenon.Xenon"
>
> static const sal_Char *_serviceName = _serviceName_;
> static const sal_Char *_functionDisplayName = "EXPO";
> static const sal_Char *_functionName = "expo";
> static const sal_Char *_functionDescription = "Returns a random #
> from an Exponential(m) distribution";
>
> //XAddIn
> OUString XenonAddin::getProgrammaticFuntionName( const OUString&
> aDisplayName ) throw (RuntimeException)
>
> {
>
>
> if(aDisplayName.equalsAscii(_functionDisplayName))
>
>
> {
>
> OString
> os(_functionName);
>
> return OStringToOUString(os,
> RTL_TEXTENCODING_ASCII_US);
>
> }
>
> return
> OUString(RTL_CONSTASCII_USTRINGPARAM(""));
>
>
> }
>
>
> OUString XenonAddin::getDisplayFunctionName( const OUString&
> aProgrammaticName ) throw (RuntimeException)
>
> {
>
>
> if(aProgrammaticName.equalsAscii(_functionName))
>
>
> {
>
> OString
> os(_functionDisplayName);
>
> return OStringToOUString(os,
> RTL_TEXTENCODING_ASCII_US);
>
> }
>
> return
> OUString(RTL_CONSTASCII_USTRINGPARAM(""));
>
>
> }
>
>
> OUString XenonAddin::getFunctionDescription( const OUString&
> aProgrammaticName ) throw (RuntimeException)
>
> {
>
>
> if(aProgrammaticName.equalsAscii(_functionName))
>
>
> {
>
> OString
> os(_functionDescription);
>
> return OStringToOUString(os,
> RTL_TEXTENCODING_ASCII_US);
>
> }
>
> return
> OUString(RTL_CONSTASCII_USTRINGPARAM(""));
>
>
> }
>
>
> OUString XenonAddin::getDisplayArgumentName( const OUString&
> aProgrammaticName, ::sal_Int32 nArgument ) throw (RuntimeException)
>
> {
>
> if(aProgrammaticName.equalsAscii(_functionName) &&
> nArgument==0) return OUString(RTL_CONSTASCII_USTRINGPARAM("m"));
> return
> OUString(RTL_CONSTASCII_USTRINGPARAM(""));
>
>
> }
>
>
> OUString XenonAddin::getArgumentDescription( const OUString&
> aProgrammaticName, ::sal_Int32 nArgument ) throw (RuntimeException)
>
> {
>
> if(aProgrammaticName.equalsAscii(_functionName) &&
> nArgument==0) return OUString(RTL_CONSTASCII_USTRINGPARAM("mean"));
> return
> OUString(RTL_CONSTASCII_USTRINGPARAM(""));
>
>
> }
>
>
> OUString XenonAddin::getProgrammaticCategoryName( const OUString&
> aProgrammaticName ) throw (RuntimeException)
>
> {
>
> return
> OUString(RTL_CONSTASCII_USTRINGPARAM("Xenon"));
>
>
> }
>
>
> OUString XenonAddin::getDisplayCategoryName( const OUString&
> aProgrammaticName ) throw (RuntimeException)
>
> {
>
> return
> OUString(RTL_CONSTASCII_USTRINGPARAM("Xenon"));
>
>
> }
>
>
>
> I understand their are some limitations as to the categroy names so I tried
> adding them to the existing "Financial" category instead but still no luck.
> Any help on this would be much appreciated.
>
> I am developing on Gentoo Linux with OOo 3 using the binary openoffice
> package. My gcc is v4.3.2 and compile using the simple build script provided
> in the simple add in (slightly modified for my environment).
>
> idlc -C -I$OOoSDK/idl $SRC_DIR/Xenon.idl
>
> regmerge $SRC_DIR/Xenon.rdb /UCR $SRC_DIR/Xenon.urd
>
> cppumaker -BUCR -TXenon.XXenon \
> -Tcom.sun.star.sheet.XAddIn \
> -Tcom.sun.star.lang.XServiceName \
> -Tcom.sun.star.lang.XServiceInfo \
> -Tcom.sun.star.lang.XInitialization \
> -Tcom.sun.star.lang.IllegalArgumentException \
> -Tcom.sun.star.lang.XTypeProvider \
> -Tcom.sun.star.uno.XWeak \
> -Tcom.sun.star.uno.XAggregation \
> -Tcom.sun.star.lang.XMultiServiceFactory \
> -Tcom.sun.star.uno.XComponentContext \
> -Tcom.sun.star.lang.XSingleComponentFactory \
> -Tcom.sun.star.lang.XSingleServiceFactory \
> -Tcom.sun.star.registry.XRegistryKey \
> $SRC_DIR/Xenon.rdb \
> $OOo/share/misc/*.rdb $OOo/../basis3.0/program/*.rdb
>
> g++ -O2 -fomit-frame-pointer -c -o $SRC_DIR/XenonAddin.o -DUNX \
> -DGCC -DLINUX -DCPPU_ENV=gcc3 -I. -I$OOoSDK/include $SRC_DIR/XenonAddin.cxx
>
> ld -o $SRC_DIR/libXenonAddin.so -shared -L$OOo/lib --retain-symbols-file \
> $SRC_DIR/symbols.txt $SRC_DIR/XenonAddin.o
>
> rm -rf com Xenon $SRC_DIR/*.urd $SRC_DIR/XenonAddin.o
>
> regcomp -register -r $SRC_DIR/*.rdb -c $SRC_DIR/*.so
>
> mv $SRC_DIR/*.rdb $SRC_DIR/*.so $BIN_DIR
>
> cp $SRC_DIR/oxt/* $BIN_DIR
>
> mkdir $BIN_DIR/META-INF
>
> cp $SRC_DIR/oxt/META-INF/* $BIN_DIR/META-INF
>
> cd $BIN_DIR
>
> zip Xenon.oxt * -r
>
>
> Paul
>