creare add-in per calc con il plug-in Openoffice per NetBeans

Nessuna risposta
topoquercino
Offline
Last seen: 38 settimane 3 giorni fa
Titolo: ★★
Iscritto: 10 Ago 2015
Messaggi: 11
Salve, vorrei sapere se qualcuno ha mai utilizzato il plugin per NetBeans per aggiungere funzioni a Calc. Dopo aver installato NetBeans e scaricato il plug-in di openoffice ho seguito la procedura guidata per creare una semplice funzione di prova che calcoli l’area del triangolo ( B*H/2). Ho settato correttamente i parametri di input (base ed altezza), ma non ho capito dove inserire il valore di output (area= B*H/2). Alla fine della procedura guidata mi è apparsa la finestra si NetBeans con il codice scritto in java, in cui appaiono 2 file con estensione .idl col nome del progetto (Area.xdl e Xarea.xdl) e un file .java più corposo. Vorrei sapere dove devo inserire la stringa “AREA=BASE*Altezza/2).

Ringrazio per l’attenzione e porgo cordiali saluti.

EP

PS:Allego in calce tutti e tre i file:

* Aree.idl * * Created on 2015.08.26 – 16:15:35 * */

#ifndef com_example_Aree
#define com_example_Aree

#include “XAree.idl”

module com { module example { service Aree : XAree;
}; };

#endif

/* * XAree.idl * * Created on 2015.08.26 – 16:15:35 * */

#ifndef com_example_XAree
#define com_example_XAree

#include

#include

module com { module example { interface XAree { /// used to set an add-in locale for formatting reasons for example [optional] interface ::com::sun:Star:lang::XLocalizable; double Area.rettangolo([in] double Base, [in] double Altezza); double Area.triangolo([in] double Base, [in] double Altezza); };
}; };

#endif

file “CentralRegistrationClass.java”

package com.example;

import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.registry.XRegistryKey;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.JarURLConnection;
import java.net.URL;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
import java.util.jar.Manifest;

/** * * @author root */
public class CentralRegistrationClass {

public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) { String regClassesList = getRegistrationClasses(); StringTokenizer t = new StringTokenizer(regClassesList, “ “); while (t.hasMoreTokens()) { String className = t.nextToken(); if (className != null && className.length() != Innocent { try { Class regClass = Class.forName(className); Method writeRegInfo = regClass.getDeclaredMethod(”__getComponentFactory”, new Class[]{String.class}); Object result = writeRegInfo.invoke(regClass, sImplementationName); if (result != null) { return (XSingleComponentFactory)result; } } catch (ClassNotFoundException ex) { ex.printStackTrace(); } catch (ClassCastException ex) { ex.printStackTrace(); } catch (SecurityException ex) { ex.printStackTrace(); } catch (NoSuchMethodException ex) { ex.printStackTrace(); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (InvocationTargetException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } } } return null; } public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) { boolean bResult = true; String regClassesList = getRegistrationClasses(); StringTokenizer t = new StringTokenizer(regClassesList, “ “); while (t.hasMoreTokens()) { String className = t.nextToken(); if (className != null && className.length() != Innocent { try { Class regClass = Class.forName(className); Method writeRegInfo = regClass.getDeclaredMethod(”__writeRegistryServiceInfo”, new Class[]{XRegistryKey.class}); Object result = writeRegInfo.invoke(regClass, xRegistryKey); bResult &= ((Boolean)result).booleanValue(); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } catch (ClassCastException ex) { ex.printStackTrace(); } catch (SecurityException ex) { ex.printStackTrace(); } catch (NoSuchMethodException ex) { ex.printStackTrace(); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (InvocationTargetException ex) { ex.printStackTrace(); } catch (IllegalAccessException ex) { ex.printStackTrace(); } } } return bResult; } private static String getRegistrationClasses() { CentralRegistrationClass c = new CentralRegistrationClass(); String name = c.getClass().getCanonicalName().replace(’.’, ‘/’).concat(”.class”); try { Enumeration urlEnum = c.getClass().getClassLoader().getResources(“META-INF/MANIFEST.MF”); while (urlEnum.hasMoreElements()) { URL url = urlEnum.nextElement(); String file = url.getFile(); JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); Manifest mf = jarConnection.getManifest(); Attributes attrs = (Attributes) mf.getAttributes(name); if ( attrs != null ) { String classes = attrs.getValue( “RegistrationClasses” ); return classes; } } } catch (IOException ex) { ex.printStackTrace(); } return “”; } /** Creates a new instance of CentralRegistrationClass */ private CentralRegistrationClass() { } }
EP