Difference between revisions of "Calc/Add-In/CompleteAddIn"
From Apache OpenOffice Wiki
SergeMoutou (Talk | contribs) (→The code) |
SergeMoutou (Talk | contribs) (→The C++ Code) |
||
Line 35: | Line 35: | ||
==The C++ Code== | ==The C++ Code== | ||
− | We first give the C++ code of the four method presented in IDL file : | + | We first give the C++ code of the four method presented in IDL file. |
+ | |||
+ | ===The two first Methods=== | ||
+ | The two first methods are similar : | ||
<pre><nowiki> | <pre><nowiki> | ||
OUString MyService2Impl::methodOne( OUString const & str ) | OUString MyService2Impl::methodOne( OUString const & str ) | ||
throw (RuntimeException) | throw (RuntimeException) | ||
{ | { | ||
− | return OUString( RTL_CONSTASCII_USTRINGPARAM( | + | return OUString( RTL_CONSTASCII_USTRINGPARAM( |
− | "called methodOne() of MyService2 implementation: ") ) + m_arg + str; | + | "called methodOne() of MyService2 implementation: ") ) + m_arg + str; |
} | } | ||
− | OUString MyService2Impl::methodTwo( OUString const & str ) | + | |
− | throw (RuntimeException) | + | OUString MyService2Impl::methodTwo( OUString const & str )throw (RuntimeException) |
{ | { | ||
− | return OUString( RTL_CONSTASCII_USTRINGPARAM( | + | return OUString( RTL_CONSTASCII_USTRINGPARAM( |
− | "called methodTwo() of MyService2 implementation: ") ) + m_arg + str; | + | "called methodTwo() of MyService2 implementation: ") ) + m_arg + str; |
} | } | ||
+ | </nowiki></pre> | ||
+ | ===The third Method | ||
+ | <pre><nowiki> | ||
sal_Int32 MyService2Impl::methodThree(const Sequence< Sequence< sal_Int32 > > &aValList ) | sal_Int32 MyService2Impl::methodThree(const Sequence< Sequence< sal_Int32 > > &aValList ) | ||
throw (RuntimeException) | throw (RuntimeException) | ||
Line 68: | Line 74: | ||
return temp; | return temp; | ||
} | } | ||
+ | </nowiki></pre> | ||
+ | ===The fourth method=== | ||
+ | |||
+ | <pre><nowiki> | ||
//It's a matrix operation should be called like : {=METHODFOUR(A1:B4)} | //It's a matrix operation should be called like : {=METHODFOUR(A1:B4)} | ||
Sequence< Sequence< sal_Int32 > > MyService2Impl::methodFour(const Sequence< Sequence< sal_Int32 > > &aValList )throw (RuntimeException) | Sequence< Sequence< sal_Int32 > > MyService2Impl::methodFour(const Sequence< Sequence< sal_Int32 > > &aValList )throw (RuntimeException) |
Revision as of 15:58, 17 April 2006
We start from an example of SDK slightly modified :
<OpenOffice.org1.1_SDK>/examples/DevelopersGuide/Components/CppComponent
This example contains two files but I only use one file (and one service).
IDL File
Here is the corresponding IDL file :
// IDL #include <com/sun/star/uno/XInterface.idl> #include <com/sun/star/lang/XInitialization.idl> #include <com/sun/star/lang/XServiceName.idl> #include <com/sun/star/lang/XLocalizable.idl> #include <com/sun/star/sheet/XAddIn.idl> module my_module { interface XSomething : com::sun::star::uno::XInterface { string methodOne( [in] string val ); string methodTwo( [in] string val ); long methodThree( [in] sequence< sequence< long > > aValList ); sequence< sequence< long > > methodFour( [in] sequence< sequence< long > > aValList ); }; service MyService2 { interface XSomething; interface com::sun::star::lang::XInitialization; interface com::sun::star::lang::XServiceName; interface com::sun::star::sheet::XAddIn; }; };
The C++ Code
We first give the C++ code of the four method presented in IDL file.
The two first Methods
The two first methods are similar :
OUString MyService2Impl::methodOne( OUString const & str ) throw (RuntimeException) { return OUString( RTL_CONSTASCII_USTRINGPARAM( "called methodOne() of MyService2 implementation: ") ) + m_arg + str; } OUString MyService2Impl::methodTwo( OUString const & str )throw (RuntimeException) { return OUString( RTL_CONSTASCII_USTRINGPARAM( "called methodTwo() of MyService2 implementation: ") ) + m_arg + str; }
===The third Method
sal_Int32 MyService2Impl::methodThree(const Sequence< Sequence< sal_Int32 > > &aValList ) throw (RuntimeException) { sal_Int32 n1, n2; sal_Int32 nE1 = aValList.getLength(); sal_Int32 nE2; sal_Int32 temp=0; for( n1 = 0 ; n1 < nE1 ; n1++ ) { const Sequence< sal_Int32 > rList = aValList[ n1 ]; nE2 = rList.getLength(); const sal_Int32* pList = rList.getConstArray(); for( n2 = 0 ; n2 < nE2 ; n2++ ) { temp += pList[ n2 ]; } } return temp; }
The fourth method
//It's a matrix operation should be called like : {=METHODFOUR(A1:B4)} Sequence< Sequence< sal_Int32 > > MyService2Impl::methodFour(const Sequence< Sequence< sal_Int32 > > &aValList )throw (RuntimeException) { sal_Int32 n1, n2; sal_Int32 nE1 = aValList.getLength(); sal_Int32 nE2; Sequence< Sequence< sal_Int32 > > temp = aValList; for( n1 = 0 ; n1 < nE1 ; n1++ ) { Sequence< sal_Int32 > rList = temp[ n1 ]; nE2 = rList.getLength(); for( n2 = 0 ; n2 < nE2 ; n2++ ) { rList[ n2 ] += 4; } temp[n1]=rList; } return temp; }