Page 1 of 1

[Solved] Editing Complete Cpp Add-In

Posted: Wed Jul 04, 2012 10:55 pm
by saleem145
Hello,

I am trying to modify the complete cpp add-in.

/Applications/OpenOffice.org_SDK/examples/DevelopersGuide/Components/CppComponent

I want to change method 2 to return a double and add method 5 which also returns a double

My idl now is


#include <com/sun/star/uno/XInterface.idl>
#include <com/sun/star/lang/IllegalArgumentException.idl>

Code: Select all

module my_module
{

    interface XSomething
    {
        string methodOne( [in] string val );
        double methodTwo();
        double methodFive();
    };

    service MyService1 : XSomething;

    service MyService2 : XSomething 
    {
        create([in]string sArgument)
            raises (::com::sun::star::lang::IllegalArgumentException);
    };
};
The following changes were made to service1_impl.cxx

Code: Select all

class MyService1Impl
    : public ::my_module::XSomething
    , public lang::XServiceInfo
    , public lang::XTypeProvider
{


   virtual OUString SAL_CALL methodOne( OUString const & str )
        throw (RuntimeException);
    virtual double SAL_CALL methodTwo( )
        throw (RuntimeException);
    virtual double SAL_CALL methodFive( )

}
/

Code: Select all

/ XSomething implementation                                                                                                                                                                   
OUString MyService1Impl::methodOne( OUString const & str )
    throw (RuntimeException)
{
    m_sData = str;
    return OUString( RTL_CONSTASCII_USTRINGPARAM(
        "called methodOne() of MyService1 implementation: ") ) + m_sData;
}

double MyService1Impl::methodTwo( )
    throw (RuntimeException)
{
    return 3;
}

double MyService1Impl::methodFive( )
    throw (RuntimeException)
{
    return 2;
}

The following changes were made to service2_impl.cxx

Code: Select all

class MyService2Impl : public ::cppu::WeakImplHelper3<
      ::my_module::XSomething, lang::XServiceInfo, lang::XInitialization >
{



    virtual OUString SAL_CALL methodOne( OUString const & str )
        throw (RuntimeException);
    virtual double SAL_CALL methodTwo( )
        throw (RuntimeException);
    virtual double SAL_CALL methodFive( )
        throw (RuntimeException);


}

Code: Select all

// XSomething implementation                                                                                                                                                                   
OUString MyService2Impl::methodOne( OUString const & str )
    throw (RuntimeException)
{
    m_sData = str;
    return OUString( RTL_CONSTASCII_USTRINGPARAM(
        "called methodOne() of MyService2 implementation: ") ) + m_sData;
}

double MyService2Impl::methodTwo( )
    throw (RuntimeException)
{
    return 5;
}

double MyService2Impl::methodFive( )
    throw (RuntimeException)
{
    return 3;
}

I changed the XCU file as well and edited TestComponent.cpp. The functions work correctly when I run TestComponent from the shell. I can also call MethodOne from Calc and have it work correctly. But if I call MethodTwo or MethodFive calc crashes....

Any suggestions?? Another question is there a way to convert the rdb file back to idl and make sure I have the correct definitions in there??

Saleem

Re: Editing Complete Cpp Add-In

Posted: Wed Jul 04, 2012 11:42 pm
by Charlie Young
I'm not real clear on why you need a second service, or whether that has anything to do with your problem.

I don't think there is a way to go back from an .rdb to an .idl, but there is a program called regview in the URE\bin folder which is used to read .rdb files, supplying the needed information. It is in URE\bin along with regmerge, which you must have used if you ever got things working at all.