[Solved] Editing Complete Cpp Add-In

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

[Solved] Editing Complete Cpp Add-In

Post 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
Last edited by saleem145 on Sun Jul 15, 2012 1:54 pm, edited 1 time in total.
OpenOffice 3.4.0
Mac OS X 10.5.8
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Editing Complete Cpp Add-In

Post 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.
Apache OpenOffice 4.1.1
Windows XP
Post Reply