Description of the input parameter (structure type) of the function in the XCU file

21 Views Asked by At

I have the following idl file describing my functions, which describes the GetCustomerToStr function:

module vnd {
  module datalink {
   module formulas {
     struct Customer{
       long id;
       string name;
     };
     interface XDataLinkFormulas {
       interface ::com::sun::star::uno::XInterface;
       string GetCustomerToStr([in] Customer customer);
    };
  };
 };
};

I was able to compile the idl file and create the rdb file successfully. enter image description here

Python code from my function is as follows:

import unohelper
import modules.services.datalinkFormulas as formulas
from vnd.datalink.formulas import XDataLinkFormulas, Customer

class DataLinkFormulas (unohelper.Base, XDataLinkFormulas):

   def __init__(self, context):
      self.__context = context
  
   def GetCustomerToStr(self, customer: Customer) -> str:
      return f"Id: {customer.id} Name: {customer.name}"

 g_ImplementationHelper = unohelper.ImplementationHelper()

 g_ImplementationHelper.addImplementation(ctor = DataLinkFormulas, implementationName = "vnd.datalink.formulas", serviceNames = ("com.sun.star.sheet.AddIn",),)

Q: How do I describe my function in an XCU file given that the input parameter is a structure?

P.S: Here are my developments on the XCU file.

<?xml version='1.0' encoding='UTF-8'?>
<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="CalcAddIns" oor:package="org.openoffice.Office">
  <node oor:name="AddInInfo">
    <node oor:name="vnd.datalink.formulas" oor:op="replace">
        <node oor:name="AddInFunctions">
            
            <node oor:name="GetCustomerToStr" oor:op="replace">
                <prop oor:name="DisplayName"><value xml:lang="en">GetCustomerToStr</value></prop>
                <prop oor:name="Description"><value xml:lang="en">Gets the string representation of the owner.</value></prop>
                <prop oor:name="Category"><value>Add-In</value></prop>
                <prop oor:name="CompatibilityName"><value/></prop>
                <node oor:name="Parameters">
                <!--  The next block is incorrect, I don't know how to determine it.--/>
                    <prop oor:name="customer" oor:type="xs:string">
                        <value>
                            <struct>
                                <field oor:name="id" oor:type="xs:id">value1</field>
                                <field oor:name="name" oor:type="xs:string">123</field>
                            </struct>
                        </value>
                    </prop>
                </node>
            </node> 
        </node>
     </node>
 </node>
</oor:component-data>
0

There are 0 best solutions below