Package OLE

Source Code of OLE.CUnknown

/*
Copyright (c) 2003-2008 ITerative Consulting Pty Ltd. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:

o Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
 
o Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
   
o This jcTOOL Helper Class software, whether in binary or source form may not be used within,
or to derive, any other product without the specific prior written permission of the copyright holder

 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
package OLE;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import Framework.TextData;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;

/**
* The CUnknown class represents the OLE IUnknown interface that is required for
* each OLE Automation object and interface. The CUnknown class is an abstract
* class. Use the CDispatch class to interact with OLE Automation objects and
* interfaces.
*
*/
public class CUnknown extends Dispatch {

  private static int NOT_ATTACHED = 0;

  protected Dispatch theDisp;
    protected OLEResourceItem _ResourceItem;
    public CUnknown() {
        super();
    }

    public CUnknown(Dispatch dispatchToBeDisplaced) {
        super(dispatchToBeDisplaced);
    }

    public CUnknown(int pDisp) {
        super(pDisp);
    }

    public CUnknown(String requestedProgramId) {
        super(requestedProgramId);
    }

    public PropertyChangeSupport qq_Listeners = new PropertyChangeSupport(this);

    public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
        qq_Listeners.addPropertyChangeListener(property, listener);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        qq_Listeners.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
        qq_Listeners.removePropertyChangeListener(property, listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        qq_Listeners.removePropertyChangeListener(listener);
    }

    /**
   * The CreateUsingCLSID method sets the ObjectReference pointer to the
   * dispatch interface for the application associated with the OLE object
   * identified by the CLSID.
   *
   * @param classID
   *            The ClassID parameter passes the class identifier (CLSID) for
   *            an OLE object.
   */
    public void createUsingCLSID(TextData classID) {
        createUsingCLSID(classID.toString());
    }

    /**
   * The CreateUsingCLSID method sets the ObjectReference pointer to the
   * dispatch interface for the application associated with the OLE object
   * identified by the CLSID.
   *
   * @param classID
   *            The ClassID parameter passes the class identifier (CLSID) for
   *            an OLE object.
   */
    public void createUsingCLSID(String classID) {
        theDisp = new ActiveXComponent(classID);
    }

    /**
   * The CreateUsingProgID method sets the ObjectReference pointer to the
   * dispatch interface for the application identified by the programmatic ID
   * (ProgID) for the application
   *
   * @param progID
   *            The progID parameter is the programmatic ID (ProgID) for the
   *            OLE automation server.
   */
    public void createUsingProgID(TextData progID) {
        createUsingProgID(progID.toString());
    }

    /**
   * The CreateUsingProgID method sets the ObjectReference pointer to the
   * dispatch interface for the application identified by the programmatic ID
   * (ProgID) for the application
   *
   * @param progID
   *            The progID parameter is the programmatic ID (ProgID) for the
   *            OLE automation server.
   */
   public void createUsingProgID(String progID) {
        theDisp = new ActiveXComponent(progID);
    }

    /**
     * Retrieves a reference to the dispatch interface for the application.
     * @return
     */
    public Dispatch getDispatch() {
        return this.theDisp;
    }
    /**
     * This method is not implemented
     * @return
     */
    public OLEResourceItem get_ResourceItem() {
        throw new RuntimeException(
            "CUnknown.get_ResourceItem() is not implemented");
    }
    /**
     * This method is not implemented
     * @param resourceItem
     */
    public void set_ResourceItem(OLEResourceItem resourceItem) {
        throw new RuntimeException(
        "CUnknown.set_ResourceItem() is not implemented");
    }
   
    /**
   * Check if there is an associated OLE object attached
   *
   * @return true if there is an associated OLE object
   */
    public boolean getObjectReferenceSet() {
      // AD:12/06/2008 Check the associated Dispatch to see if it is attached
      if (this.isAttached()) {
      return true;
    } else if (this.theDisp != null) {
      if (this.theDisp.m_pDispatch == NOT_ATTACHED) {
        return false;
      } else {
        return true;
      }
    } else {
      return false;
    }
  }

}
TOP

Related Classes of OLE.CUnknown

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.