Package com.CompPad

Source Code of com.CompPad.AddOnAdapter

/* Copyright 2011 Toby D. Rule

  This file is part of CompPad, an OpenOffice extension to provide live
  mathematical and engineering calculations within a Writer document.

    CompPad is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    CompPad is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with CompPad.  If not, see <http://www.gnu.org/licenses/>.
*/

package com.CompPad;
import com.CompPad.AddOn.AddonListener;
import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.ControlEvent;
import com.sun.star.frame.DispatchDescriptor;
import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XFrame;
import com.sun.star.frame.XStatusListener;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.util.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author trule
*/
public final class AddOnAdapter extends WeakBase
   implements com.sun.star.lang.XServiceInfo,
              com.sun.star.frame.XDispatchProvider,
              com.sun.star.lang.XInitialization,
              com.sun.star.frame.XDispatch,
              com.sun.star.frame.XControlNotificationListener
{
    private AddOn myAddOn;
    private XComponentContext m_xContext;

    public AddOnAdapter( XComponentContext context ){
        // context is only used to get multiservice factory, not to identify
        // current frame.
        m_xContext = context;
        System.out.println("  Constructor: AddOnAdapter");
    }
    public String getImplementationName() {
        System.out.println("getImplementationName");
        return "com.CompPad.AddOn";
    }

    public boolean supportsService(String arg0) {
        System.out.println("supportedService");
        return myAddOn.supportsService(arg0);
    }

    public String[] getSupportedServiceNames() {
        System.out.println("getSupportedServiceNames");
        return myAddOn.getSupportedServiceNames();
    }

    public XDispatch queryDispatch(URL arg0, String arg1, int arg2) {
        System.out.println("queryDispatch");
        return myAddOn.queryDispatch(arg0, arg1, arg2);
    }

    public XDispatch[] queryDispatches(DispatchDescriptor[] arg0) {
        System.out.println("aueryDispatches");
        return myAddOn.queryDispatches(arg0);
    }

    public void initialize(Object[] object) throws Exception {
        /* Use createInstanceWithArgumentsAndContext to  create the new class */
        System.out.println("initialize");

        if ( object.length > 0 ){
            try{
                XSingleComponentFactory scf = AddOn.__getComponentFactory("com.CompPad.AddOn");
                myAddOn = (AddOn) scf.createInstanceWithArgumentsAndContext(object, m_xContext);
            }
            catch (java.lang.Exception ex){
                Logger.getLogger(AddOnAdapter.class.getName()).log(Level.SEVERE, null, ex);
                System.out.println("**** ERROR INITIALIZING ADDON");
            }
        }

    }

    public void dispatch(URL arg0, PropertyValue[] arg1) {
        System.out.println("dispatch");
        myAddOn.dispatch(arg0, arg1);
    }

    public void addStatusListener(XStatusListener arg0, URL arg1) {
        System.out.println("addStatusListener");
        myAddOn.addStatusListener(arg0, arg1);
    }

    public void removeStatusListener(XStatusListener arg0, URL arg1) {
        System.out.println("removeStatusListener");
        myAddOn.removeStatusListener(arg0, arg1);
    }

    public void controlEvent(ControlEvent arg0) {
        System.out.println("controlEvent");
        myAddOn.controlEvent(arg0);
    }
}
TOP

Related Classes of com.CompPad.AddOnAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.