org.eclipse.swt.win32.win32.x86_3.7.2.v3740f

ation.";
      if (hresult != 0) {
        msg = msg + " result = " + hresult;
      }
      throw new SWTException(code, msg);
    case 1014: 
      String msg = "Action can not be performed.";
      if (hresult != 0) {
        msg = msg + " result = " + hresult;
      }
      throw new SWTException(code, msg);
    case 1007: 
      String msg = "Action can not be performed.";
      if (hresult != 0) {
        msg = msg + " result = " + hresult;
      }
      throw new SWTError(code, msg);
    }
    SWT.error(code);
  }
  
  public static String findProgramID(String extension)
  {
    if (extension == null) {
      SWT.error(4);
    }
    if (extension.length() == 0) {
      return "";
    }
    if (extension.charAt(0) != '.') {
      extension = "." + extension;
    }
    TCHAR extensionKey = new TCHAR(0, extension, true);
    String result = getKeyValue(extensionKey);
    if (result != null)
    {
      TCHAR notInsertableKey = new TCHAR(0, result + "\\NotInsertable", true);
      if (getKeyExists(notInsertableKey)) {
        return "";
      }
      TCHAR insertableKey = new TCHAR(0, result + "\\Insertable", true);
      if (getKeyExists(insertableKey)) {
        return result;
      }
      TCHAR serverKey = new TCHAR(0, result + "\\protocol\\StdFileEditing\\server", true);
      if (getKeyExists(serverKey)) {
        return result;
      }
    }
    return "";
  }
  
  static String getKeyValue(TCHAR key)
  {
    int[] phkResult = new int[1];
    if (OS.RegOpenKeyEx(Integer.MIN_VALUE, key, 0, 131097, phkResult) != 0) {
      return null;
    }
    String result = null;
    int[] lpcbData = new int[1];
    if (OS.RegQueryValueEx(phkResult[0], null, 0, null, null, lpcbData) == 0)
    {
      int length = lpcbData[0] / TCHAR.sizeof;
      if (length == 0)
      {
        result = "";
      }
      else
      {
        TCHAR lpData = new TCHAR(0, length);
        if (OS.RegQueryValueEx(phkResult[0], null, 0, null, lpData, lpcbData) == 0)
        {
          length = Math.max(0, lpData.length() - 1);
          result = lpData.toString(0, length);
        }
      }
    }
    if (phkResult[0] != 0) {
      OS.RegCloseKey(phkResult[0]);
    }
    return result;
  }
  
  private static boolean getKeyExists(TCHAR key)
  {
    int[] phkResult = new int[1];
    if (OS.RegOpenKeyEx(Integer.MIN_VALUE, key, 0, 131097, phkResult) != 0) {
      return false;
    }
    if (phkResult[0] != 0) {
      OS.RegCloseKey(phkResult[0]);
    }
    return true;
  }
  
  public static boolean isOleFile(File file)
  {
    if ((file == null) || (!file.exists()) || (file.isDirectory())) {
      return false;
    }
    return COM.StgIsStorageFile((file.getAbsolutePath() + "\000").toCharArray()) == 0;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.OLE
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.ole.win32;

import org.eclipse.swt.SWTException;
import org.eclipse.swt.internal.ole.win32.COM;
import org.eclipse.swt.internal.ole.win32.DISPPARAMS;
import org.eclipse.swt.internal.ole.win32.EXCEPINFO;
import org.eclipse.swt.internal.ole.win32.FUNCDESC;
import org.eclipse.swt.internal.ole.win32.GUID;
import org.eclipse.swt.internal.ole.win32.IDispatch;
import org.eclipse.swt.internal.ole.win32.ITypeInfo;
import org.eclipse.swt.internal.ole.win32.IUnknown;
import org.eclipse.swt.internal.ole.win32.TYPEATTR;
import org.eclipse.swt.internal.ole.win32.VARDESC;
import org.eclipse.swt.internal.ole.win32.VARIANT;
import org.eclipse.swt.internal.win32.OS;

public final class OleAutomation
{
  private IUnknown objIUnknown;
  private IDispatch objIDispatch;
  private String exceptionDescription;
  private ITypeInfo objITypeInfo;
  
  OleAutomation(IDispatch idispatch)
  {
    if (idispatch == null) {
      OLE.error(1011);
    }
    objIDispatch = idispatch;
    objIDispatch.AddRef();
    
    int[] ppv = new int[1];
    
    int result = objIDispatch.GetTypeInfo(0, 2048, ppv);
    if (result == 0) {
      objITypeInfo = new ITypeInfo(ppv[0]);
    }
  }
  
  public OleAutomation(OleClientSite clientSite)
  {
    if (clientSite == null) {
      OLE.error(1011);
    }
    objIDispatch = clientSite.getAutomationObject();
    
    int[] ppv = new int[1];
    
    int result = objIDispatch.GetTypeInfo(0, 2048, ppv);
    if (result == 0) {
      objITypeInfo = new ITypeInfo(ppv[0]);
    }
  }
  
  public OleAutomation(String progId)
  {
    try
    {
      OS.OleInitialize(0);
      GUID appClsid = getClassID(progId);
      if (appClsid == null)
      {
        OS.OleUninitialize();
        OLE.error(1004);
      }
      int flags = 1;
      if (progId.startsWith("Excel")) {
        flags |= 0x4;
      }
      int[] ppvObject = new int[1];
      int result = COM.CoCreateInstance(appClsid, 0, flags, COM.IIDIUnknown, ppvObject);
      if (result != 0)
      {
        OS.OleUninitialize();
        OLE.error(1001, result);
      }
      objIUnknown = new IUnknown(ppvObject[0]);
      
      ppvObject[0] = 0;
      result = objIUnknown.QueryInterface(COM.IIDIDispatch, ppvObject);
      if (result != 0) {
        OLE.error(1003);
      }
      objIDispatch = new IDispatch(ppvObject[0]);
      
      ppvObject[0] = 0;
      result = objIDispatch.GetTypeInfo(0, 2048, ppvObject);
      if (result == 0) {
        objITypeInfo = new ITypeInfo(ppvObject[0]);
      }
    }
    catch (SWTException e)
    {
      dispose();
      throw e;
    }
  }
  
  public void dispose()
  {
    if (objIDispatch != null) {
      objIDispatch.Release();
    }
    objIDispatch = null;
    if (objITypeInfo != null) {
      objITypeInfo.Release();
    }
    objITypeInfo = null;
    if (objIUnknown != null)
    {
      objIUnknown.Release();
      OS.OleUninitialize();
    }
    objIUnknown = null;
  }
  
  int getAddress()
  {
    return objIDispatch.getAddress();
  }
  
  GUID getClassID(String clientName)
  {
    GUID guid = new GUID();
    
    char[] buffer = (char[])null;
    if (clientName != null)
    {
      int count = clientName.length();
      buffer = new char[count + 1];
      clientName.getChars(0, count, buffer, 0);
    }
    if (COM.CLSIDFromProgID(buffer, guid) != 0)
    {
      int result = COM.CLSIDFromString(buffer, guid);
      if (result != 0) {
        return null;
      }
    }
    return guid;
  }
  
  public String getHelpFile(int dispId)
  {
    if (objITypeInfo == null) {
      return null;
    }
    String[] file = new String[1];
    int rc = objITypeInfo.GetDocumentation(dispId, null, null, null, file);
    if (rc == 0) {
      return file[0];
    }
    return null;
  }
  
  public String getDocumentation(int dispId)
  {
    if (objITypeInfo == null) {
      return null;
    }
    String[] doc = new String[1];
    int rc = objITypeInfo.GetDocumentation(dispId, null, doc, null, null);
    if (rc == 0) {
      return doc[0];
    }
    return null;
  }
  
  public OlePropertyDescription getPropertyDescription(int index)
  {
    if (objITypeInfo == null) {
      return null;
    }
    int[] ppVarDesc = new int[1];
    int rc = objITypeInfo.GetVarDesc(index, ppVarDesc);
    if (rc != 0) {
      return null;
    }
    VARDESC vardesc = new VARDESC();
    COM.MoveMemory(vardesc, ppVarDesc[0], VARDESC.sizeof);
    
    OlePropertyDescription data = new OlePropertyDescription();
    id = memid;
    name = getName(memid);
    type = elemdescVar_tdesc_vt;
    if (type == 26)
    {
      short[] vt = new short[1];
      COM.MoveMemory(vt, elemdescVar_tdesc_union + OS.PTR_SIZEOF, 2);
      type = vt[0];
    }
    flags = wVarFlags;
    kind = varkind;
    description = getDocumentation(memid);
    helpFile = getHelpFile(memid);
    
    objITypeInfo.ReleaseVarDesc(ppVarDesc[0]);
    return data;
  }
  
  public OleFunctionDescription getFunctionDescription(int index)
  {
    if (objITypeInfo == null) {
      return null;
    }
    int[] ppFuncDesc = new int[1];
    int rc = objITypeInfo.GetFuncDesc(index, ppFuncDesc);
    if (rc != 0) {
      return null;
    }
    FUNCDESC funcdesc = new FUNCDESC();
    COM.MoveMemory(funcdesc, ppFuncDesc[0], FUNCDESC.sizeof);
    
    OleFunctionDescription data = new OleFunctionDescription();
    
    id = memid;
    optionalArgCount = cParamsOpt;
    invokeKind = invkind;
    funcKind = funckind;
    flags = wFuncFlags;
    callingConvention = callconv;
    documentation = getDocumentation(memid);
    helpFile = getHelpFile(memid);
    
    String[] names = getNames(memid, cParams + 1);
    if (names.length > 0) {
      name = names[0];
    }
    args = new OleParameterDescription[cParams];
    for (int i = 0; i < args.length; i++)
    {
      args[i] = new OleParameterDescription();
      if (names.length > i + 1) {
        args[i].name = names[(i + 1)];
      }
      short[] vt = new short[1];
      COM.MoveMemory(vt, lprgelemdescParam + i * COM.ELEMDESC_sizeof() + OS.PTR_SIZEOF, 2);
      if (vt[0] == 26)
      {
        int[] pTypedesc = new int[1];
        COM.MoveMemory(pTypedesc, lprgelemdescParam + i * COM.ELEMDESC_sizeof(), OS.PTR_SIZEOF);
        short[] vt2 = new short[1];
        COM.MoveMemory(vt2, pTypedesc[0] + OS.PTR_SIZEOF, 2);
        vt[0] = ((short)(vt2[0] | 0x4000));
      }
      args[i].type = vt[0];
      short[] wParamFlags = new short[1];
      COM.MoveMemory(wParamFlags, lprgelemdescParam + i * COM.ELEMDESC_sizeof() + COM.TYPEDESC_sizeof() + OS.PTR_SIZEOF, 2);
      args[i].flags = wParamFlags[0];
    }
    returnType = elemdescFunc_tdesc_vt;
    if (returnType == 26)
    {
      short[] vt = new short[1];
      COM.MoveMemory(vt, elemdescFunc_tdesc_union + OS.PTR_SIZEOF, 2);
      returnType = vt[0];
    }
    objITypeInfo.ReleaseFuncDesc(ppFuncDesc[0]);
    return data;
  }
  
  public TYPEATTR getTypeInfoAttributes()
  {
    if (objITypeInfo == null) {
      return null;
    }
    int[] ppTypeAttr = new int[1];
    int rc = objITypeInfo.GetTypeAttr(ppTypeAttr);
    if (rc != 0) {
      return null;
    }
    TYPEATTR typeattr = new TYPEATTR();
    COM.MoveMemory(typeattr, ppTypeAttr[0], TYPEATTR.sizeof);
    objITypeInfo.ReleaseTypeAttr(ppTypeAttr[0]);
    return typeattr;
  }
  
  public String getName(int dispId)
  {
    if (objITypeInfo == null) {
      return null;
    }
    String[] name = new String[1];
    int rc = objITypeInfo.GetDocumentation(dispId, name, null, null, null);
    if (rc == 0) {
      return name[0];
    }
    return null;
  }
  
  public String[] getNames(int dispId, int maxSize)
  {
    if (objITypeInfo == null) {
      return new String[0];
    }
    String[] names = new String[maxSize];
    int[] count = new int[1];
    int rc = objITypeInfo.GetNames(dispId, names, maxSize, count);
    if (rc == 0)
    {
      String[] newNames = new String[count[0]];
      System.arraycopy(names, 0, newNames, 0, count[0]);
      return newNames;
    }
    return new String[0];
  }
  
  public int[] getIDsOfNames(String[] names)
  {
    int[] rgdispid = new int[names.length];
    int result = objIDispatch.GetIDsOfNames(new GUID(), names, names.length, 2048, rgdispid);
    if (result != 0) {
      return null;
    }
    return rgdispid;
  }
  
  public String getLastError()
  {
    return exceptionDescription;
  }
  
  public Variant getProperty(int dispIdMember)
  {
    Variant pVarResult = new Variant();
    int result = invoke(dispIdMember, 2, null, null, pVarResult);
    return result == 0 ? pVarResult : null;
  }
  
  public Variant getProperty(int dispIdMember, Variant[] rgvarg)
  {
    Variant pVarResult = new Variant();
    int result = invoke(dispIdMember, 2, rgvarg, null, pVarResult);
    return result == 0 ? pVarResult : null;
  }
  
  public Variant getProperty(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)
  {
    Variant pVarResult = new Variant();
    int result = invoke(dispIdMember, 2, rgvarg, rgdispidNamedArgs, pVarResult);
    return result == 0 ? pVarResult : null;
  }
  
  public boolean equals(Object object)
  {
    if (object == this) {
      return true;
    }
    if ((object instanceof OleAutomation))
    {
      if (objIDispatch == null) {
        return false;
      }
      OleAutomation oleAutomation = (OleAutomation)object;
      if (objIDispatch == null) {
        return false;
      }
      int address1 = objIDispatch.getAddress();
      int address2 = objIDispatch.getAddress();
      return address1 == address2;
    }
    return false;
  }
  
  public Variant invoke(int dispIdMember)
  {
    Variant pVarResult = new Variant();
    int result = invoke(dispIdMember, 1, null, null, pVarResult);
    return result == 0 ? pVarResult : null;
  }
  
  public Variant invoke(int dispIdMember, Variant[] rgvarg)
  {
    Variant pVarResult = new Variant();
    int result = invoke(dispIdMember, 1, rgvarg, null, pVarResult);
    return result == 0 ? pVarResult : null;
  }
  
  public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)
  {
    Variant pVarResult = new Variant();
    int result = invoke(dispIdMember, 1, rgvarg, rgdispidNamedArgs, pVarResult);
    return result == 0 ? pVarResult : null;
  }
  
  private int invoke(int dispIdMember, int wFlags, Variant[] rgvarg, int[] rgdispidNamedArgs, Variant pVarResult)
  {
    if (objIDispatch == null) {
      return -2147467259;
    }
    DISPPARAMS pDispParams = new DISPPARAMS();
    if ((rgvarg != null) && (rgvarg.length > 0))
    {
      cArgs = rgvarg.length;
      rgvarg = OS.GlobalAlloc(64, VARIANT.sizeof * rgvarg.length);
      int offset = 0;
      for (int i = rgvarg.length - 1; i >= 0; i--)
      {
        rgvarg[i].getData(rgvarg + offset);
        offset += VARIANT.sizeof;
      }
    }
    if ((rgdispidNamedArgs != null) && (rgdispidNamedArgs.length > 0))
    {
      cNamedArgs = rgdispidNamedArgs.length;
      rgdispidNamedArgs = OS.GlobalAlloc(64, 4 * rgdispidNamedArgs.length);
      int offset = 0;
      for (int i = rgdispidNamedArgs.length; i > 0; i--)
      {
        COM.MoveMemory(rgdispidNamedArgs + offset, new int[] { rgdispidNamedArgs[(i - 1)] }, 4);
        offset += 4;
      }
    }
    EXCEPINFO excepInfo = new EXCEPINFO();
    int[] pArgErr = new int[1];
    int pVarResultAddress = 0;
    if (pVarResult != null) {
      pVarResultAddress = OS.GlobalAlloc(64, VARIANT.sizeof);
    }
    int result = objIDispatch.Invoke(dispIdMember, new GUID(), 2048, wFlags, pDispParams, pVarResultAddress, excepInfo, pArgErr);
    if (pVarResultAddress != 0)
    {
      pVarResult.setData(pVarResultAddress);
      COM.VariantClear(pVarResultAddress);
      OS.GlobalFree(pVarResultAddress);
    }
    if (rgdispidNamedArgs != 0) {
      OS.GlobalFree(rgdispidNamedArgs);
    }
    if (rgvarg != 0)
    {
      int offset = 0;
      int i = 0;
      for (int length = rgvarg.length; i < length; i++)
      {
        COM.VariantClear(rgvarg + offset);
        offset += VARIANT.sizeof;
      }
      OS.GlobalFree(rgvarg);
    }
    manageExcepinfo(result, excepInfo);
    
    return result;
  }
  
  public void invokeNoReply(int dispIdMember)
  {
    int result = invoke(dispIdMember, 1, null, null, null);
    if (result != 0) {
      OLE.error(1014, result);
    }
  }
  
  public void invokeNoReply(int dispIdMember, Variant[] rgvarg)
  {
    int result = invoke(dispIdMember, 1, rgvarg, null, null);
    if (result != 0) {
      OLE.error(1014, result);
    }
  }
  
  public void invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)
  {
    int result = invoke(dispIdMember, 1, rgvarg, rgdispidNamedArgs, null);
    if (result != 0) {
      OLE.error(1014, result);
    }
  }
  
  private void manageExcepinfo(int hResult, EXCEPINFO excepInfo)
  {
    if (hResult == 0)
    {
      exceptionDescription = "No Error";
      return;
    }
    if (hResult == -2147352567)
    {
      if (bstrDescription != 0)
      {
        int size = COM.SysStringByteLen(bstrDescription);
        char[] buffer = new char[(size + 1) / 2];
        COM.MoveMemory(buffer, bstrDescription, size);
        exceptionDescription = new String(buffer);
      }
      else
      {
        exceptionDescription = "OLE Automation Error Exception ";
        if (wCode != 0) {
          exceptionDescription = (exceptionDescription + "code = " + wCode);
        } else if (scode != 0) {
          exceptionDescription = (exceptionDescription + "code = " + scode);
        }
      }
    }
    else {
      exceptionDescription = ("OLE Automation Error HResult : " + hResult);
    }
    if (bstrDescription != 0) {
      COM.SysFreeString(bstrDescription);
    }
    if (bstrHelpFile != 0) {
      COM.SysFreeString(bstrHelpFile);
    }
    if (bstrSource != 0) {
      COM.SysFreeString(bstrSource);
    }
  }
  
  public boolean setProperty(int dispIdMember, Variant rgvarg)
  {
    Variant[] rgvarg2 = { rgvarg };
    int[] rgdispidNamedArgs = { -3 };
    int dwFlags = 4;
    if ((rgvarg.getType() & 0x4000) == 16384) {
      dwFlags = 8;
    }
    Variant pVarResult = new Variant();
    int result = invoke(dispIdMember, dwFlags, rgvarg2, rgdispidNamedArgs, pVarResult);
    return result == 0;
  }
  
  public boolean setProperty(int dispIdMember, Variant[] rgvarg)
  {
    int[] rgdispidNamedArgs = { -3 };
    int dwFlags = 4;
    for (int i = 0; i < rgvarg.length; i++) {
      if ((rgvarg[i].getType() & 0x4000) == 16384) {
        dwFlags = 8;
      }
    }
    Variant pVarResult = new Variant();
    int result = invoke(dispIdMember, dwFlags, rgvarg, rgdispidNamedArgs, pVarResult);
    return result == 0;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.OleAutomation
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.ole.win32;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class OleClientSite$1
  implements Listener
{
  final OleClientSite this$0;
  
  OleClientSite$1(OleClientSite paramOleClientSite)
  {
    this$0 = paramOleClientSite;
  }
  
  public void handleEvent(Event e)
  {
    switch (type)
    {
    case 10: 
    case 11: 
      OleClientSite.access$0(this$0, e); break;
    case 12: 
      OleClientSite.access$1(this$0, e); break;
    case 15: 
      this$0.onFocusIn(e); break;
    case 16: 
      this$0.onFocusOut(e); break;
    case 9: 
      OleClientSite.access$2(this$0, e); break;
    case 31: 
      OleClientSite.access$3(this$0, e); break;
    case 1: 
      break;
    case 26: 
      this$0.isActivated = true; break;
    case 27: 
      this$0.isActivated = false; break;
    default: 
      OLE.error(20);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.OleClientSite.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.ole.win32;

import org.eclipse.swt.internal.ole.win32.COMObject;

class OleClientSite$2
  extends COMObject
{
  final OleClientSite this$0;
  
  OleClientSite$2(OleClientSite paramOleClientSite, int[] $anonymous0)
  {
    super($anonymous0);this$0 = paramOleClientSite;
  }
  
  public int method0(int[] args)
  {
    return this$0.QueryInterface(args[0], args[1]);
  }
  
  public int method1(int[] args)
  {
    return this$0.AddRef();
  }
  
  public int method2(int[] args)
  {
    return this$0.Release();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.OleClientSite.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.ole.win32;

import org.eclipse.swt.internal.ole.win32.COMObject;

class OleClientSite$3
  extends COMObject
{
  final OleClientSite this$0;
  
  OleClientSite$3(OleClientSite paramOleClientSite, int[] $anonymous0)
  {
    super($anonymous0);this$0 = paramOleClientSite;
  }
  
  public int method0(int[] args)
  {
    return this$0.QueryInterface(args[0], args[1]);
  }
  
  public int method1(int[] args)
  {
    return this$0.AddRef();
  }
  
  public int method2(int[] args)
  {
    return this$0.Release();
  }
  
  public int method3(int[] args)
  {
    return OleClientSite.access$4(this$0);
  }
  
  public int method5(int[] args)
  {
    return OleClientSite.access$5(this$0, args[0]);
  }
  
  public int method6(int[] args)
  {
    return OleClientSite.access$6(this$0);
  }
  
  public int method7(int[] args)
  {
    return OleClientSite.access$7(this$0, args[0]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.OleClientSite.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.ole.win32;

import org.eclipse.swt.internal.ole.win32.COMObject;

class OleClientSite$4
  extends COMObject
{
  final OleClientSite this$0;
  
  OleClientSite$4(OleClientSite paramOleClientSite, int[] $anonymous0)
  {
    super($anonymous0);this$0 = paramOleClientSite;
  }
  
  public int method0(int[] args)
  {
    return this$0.QueryInterface(args[0], args[1]);
  }
  
  public int method1(int[] args)
  {
    return this$0.AddRef();
  }
  
  public int method2(int[] args)
  {
    return this$0.Release();
  }
  
  public int method3(int[] args)
  {
    return OleClientSite.access$8(this$0, args[0], args[1]);
  }
  
  public int method4(int[] args)
  {
    return OleClientSite.access$9(this$0, args[0], args[1]);
  }
  
  public int method6(int[] args)
  {
    OleClientSite.access$10(this$0);return 0;
  }
  
  public int method7(int[] args)
  {
    return OleClientSite.access$11(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.OleClientSite.4
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.ole.win32;

import org.eclipse.swt.internal.ole.win32.COMObject;

class OleClientSite$5
  extends COMObject
{
  final OleClientSite this$0;
  
  OleClientSite$5(OleClientSite paramOleClientSite, int[] $anonymous0)
  {
    super($anonymous0);this$0 = paramOleClientSite;
  }
  
  public int method0(int[] args)
  {
    return this$0.QueryInterface(args[0], args[1]);
  }
  
  public int method1(int[] args)
  {
    return this$0.AddRef();
  }
  
  public int method2(int[] args)
  {
    return this$0.Release();
  }
  
  public int method3(int[] args)
  {
    return this$0.GetWindow(args[0]);
  }
  
  public int method4(int[] args)
  {
    return OleClientSite.access$12(this$0, args[0]);
  }
  
  public int method5(int[] args)
  {
    return OleClientSite.access$13(this$0);
  }
  
  public int method6(int[] args)
  {
    return OleClientSite.access$14(this$0);
  }
  
  public int method7(int[] args)
  {
    return OleClientSite.access$15(this$0);
  }
  
  public int method8(int[] args)
  {
    return OleClientSite.access$16(this$0, args[0], args[1], args[2], args[3], args[4]);
  }
  
  public int method9(int[] args)
  {
    if (args.length == 2) {
      return OleClientSite.access$17(this$0, args[0], args[1]);
    }
    return OleClientSite.access$18(this$0, args[0]);
  }
  
  public int method10(int[] args)
  {
    return this$0.OnUIDeactivate(args[0]);
  }
  
  public int method11(int[] args)
  {
    return OleClientSite.access$19(this$0);
  }
  
  public int method14(int[] args)
  {
    return OleClientSite.access$20(this$0, args[0]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.OleClientSite.5
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.ole.win32;

import org.eclipse.swt.internal.ole.win32.COMObject;

class OleClientSite$6
  extends COMObject
{
  final OleClientSite this$0;
  
  OleClientSite$6(OleClientSite paramOleClientSite, int[] $anonymous0)
  {
    super($anonymous0);this$0 = paramOleClientSite;
  }
  
  public int method0(int[] args)
  {
    return this$0.QueryInterface(args[0], args[1]);
  }
  
  public int method1(int[] args)
  {
    return this$0.AddRef();
  }
  
  public int method2(int[] args)
  {
    return this$0.Release();
  }
  
  public int method3(int[] args)
  {
    return this$0.ActivateMe(args[0]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.swt.ole.win32.OleClientSite.6
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.swt.ole.win32;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.C;
import org.eclipse.swt.internal.Compatibility;
import org.eclipse.swt.internal.ole.win32.CAUUID;
import org.eclipse.swt.internal.ole.win32.COM;
import org.eclipse.swt.internal.ole.win32.COMObject;
import org.eclipse.swt.internal.ole.win32.GUID;
import org.eclipse.swt.internal.ole.win32.IDispatch;
import org.eclipse.swt.internal.ole.win32.IMoniker;
import org.eclipse.swt.internal.ole.win32.IOleCommandTarget;
import org.eclipse.swt.internal.ole.win32.IOleDocument;
import org.eclipse.swt.internal.ole.win32.IOleDocumentView;
import org.eclipse.swt.internal.ole.win32.IOleInPlaceObject;
import org.eclipse.swt.internal.ole.win32.IOleLink;
import org.eclipse.swt.internal.ole.win32.IOleObject;
import org.eclipse.swt.internal.ole.win32.IPersist;
import org.eclipse.swt.internal.ole.win32.IPersistFile;
import org.eclipse.swt.internal.ole.win32.IPersistStorage;
import org.eclipse.swt.internal.ole.win32.ISpecifyPropertyPages;
import org.eclipse.swt.internal.ole.win32.IStorage;
import org.eclipse.swt.internal.ole.win32.IStream;
import org.eclipse.swt.internal.ole.win32.IUnknown;
import org.eclipse.swt.internal.ole.win32.IViewObject2;
import org.eclipse.swt.internal.ole.win32.OLECMD;
import org.eclipse.swt.internal.ole.win32.OLEINPLACEFRAMEINFO;
import org.eclipse.swt.internal.ole.win32.VARIANT;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.RECT;
import org.eclipse.swt.internal.win32.SIZE;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;

public class OleClientSite
  extends Composite
{
  private COMObject iUnknown;
  COMObject iOleClientSite;
  private COMObject iAdviseSink;
  private COMObject iOleInPlaceSite;
  private COMObject iOleDocumentSite;
  protected GUID appClsid;
  private GUID objClsid;
  private int refCount;
  protected OleFrame frame;
  protected IUnknown objIUnknown;
  protected IOleObject objIOleObject;
  protected IViewObject2 objIViewObject2;
  protected IOleInPlaceObject objIOleInPlaceObject;
  protected IOleCommandTarget objIOleCommandTarget;
  protected IOleDocumentView objDocumentView;
  protected IStorage tempStorage;
  private int aspect;
  private int type;
  private boolean isStatic;
  boolean isActivated;
  private RECT borderWidths = new RECT();
  private RECT indent = new RECT();
  private boolean inUpdate = false;
  private boolean inInit = true;
  private boolean inDispose = false;
  private static final String WORDPROGID = "Word.Document";
  private Listener listener;
  static final int STATE_NONE = 0;
  static final int STATE_RUNNING = 1;
  static final int STATE_INPLACEACTIVE = 2;
  static final int STATE_UIACTIVE = 3;
  static final int STATE_ACTIVE = 4;
  int state = 0;
  
  protected OleClientSite(Composite parent, int style)
  {
    super(parent, style);
    
    createCOMInterfaces();
    while (parent != null)
    {
      if ((parent instanceof OleFrame))
      {
        frame = ((OleFrame)parent);
        break;
      }
      parent = parent.getParent();
    }
    if (frame == null) {
      OLE.error(5);
    }
    frame.AddRef();
    
    aspect = 1;
    type = 1;
    isStatic = false;
    
    listener = new Listener()
    {
      public void handleEvent(Event e)
      {
        switch (type)
        {
        case 10: 
        case 11: 
          OleClientSite.this.onResize(e); break;
        case 12: 
          OleClientSite.this.onDispose(e); break;
        case 15: 
          onFocusIn(e); break;
        case 16: 
          onFocusOut(e); break;
        case 9: 
          OleClientSite.this.onPaint(e); break;
        case 31: 
          OleClientSite.this.onTraverse(e); break;
        case 1: 
          break;
        case 26: 
          isActivated = true; break;
        case 27: 
          isActivated = false; break;
        default: 
          OLE.error(20);
        }
      }
    };
    frame.addListener(11, listener);
    frame.addListener(10, listener);
    addListener(12, listener);
    addListener(15, listener);
    addListener(16, listener);
    addListener(9, listener);
    addListener(31, listener);
    addListener(1, listener);
    addListener(26, listener);
    addListener(27, listener);
  }
  
  public OleClientSite(Composite parent, int style, File file)
  {
    this(parent, style);
    try
    {
      if ((file == null) || (file.isDirectory()) || (!file.exists())) {
        OLE.error(5);
      }
      GUID fileClsid = new GUID();
      char[] fileName = (file.getAbsolutePath() + "\000").toCharArray();
      int result = COM.GetClassFile(fileName, fileClsid);
      if (result != 0) {
        OLE.error(1004, result);
      }
      String progID = getProgID(fileClsid);
      if (progID == null) {
        OLE.error(1004, result);
      }
      appClsid = fileClsid;
      OleCreate(appClsid, fileClsid, fileName, file);
    }
    catch (SWTException e)
    {
      dispose();
      disposeCOMInterfaces();
      throw e;
    }
  }
  
  public OleClientSite(Composite parent, int style, String progId)
  {
    this(parent, style);
    try
    {
      appClsid = getClassID(progId);
      if (appClsid == null) {
        OLE.error(1004);
      }
      tempStorage = createTempStorage();
      
      int[] address = new int[1];
      
      int clientSite = isICAClient() ? 0 : iOleClientSite.getAddress();
      int result = COM.OleCreate(appClsid, COM.IIDIUnknown, 1, null, clientSite, tempStorage.getAddress(), address);
      if (result != 0) {
        OLE.error(1001, result);
      }
      objIUnknown = new IUnknown(address[0]);
      
      addObjectReferences();
      if (COM.OleRun(objIUnknown.getAddress()) == 0) {
        state = 1;
      }
    }
    catch (SWTException e)
    {
      dispose();
      disposeCOMInterfaces();
      throw e;
    }
  }
  
  public OleClientSite(Composite parent, int style, String progId, File file)
  {
    this(parent, style);
    try
    {
      if ((file == null) || (file.isDirectory()) || (!file.exists())) {
        OLE.error(5);
      }
      appClsid = getClassID(progId);
      if (appClsid == null) {
        OLE.error(1004);
      }
      char[] fileName = (file.getAbsolutePath() + "\000").toCharArray();
      GUID fileClsid = new GUID();
      COM.GetClassFile(fileName, fileClsid);
      
      OleCreate(appClsid, fileClsid, fileName, file);
    }
    catch (SWTException e)
    {
      dispose();
      disposeCOMInterfaces();
      throw e;
    }
  }
  
  void OleCreate(GUID appClsid, GUID fileClsid, char[] fileName, File file)
  {
    boolean isOffice2007 = isOffice2007(true);
    if ((!isOffice2007) && (COM.IsEqualGUID(appClsid, fileClsid)))
    {
      tempStorage = createTempStorage();
      
      int[] address = new int[1];
      int result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, 1, null, iOleClientSite.getAddress(), tempStorage.getAddress(), address);
      if (result != 0) {
        OLE.error(1001, result);
      }
      objIUnknown = new IUnknown(address[0]);
    }
    else
    {
      IStorage storage = null;
      if (COM.StgIsStorageFile(fileName) == 0)
      {
        int[] address = new int[1];
        int mode = 65552;
        int result = COM.StgOpenStorage(fileName, 0, mode, 0, 0, address);
        if (result != 0) {
          OLE.error(1002, result);
        }
        storage = new IStorage(address[0]);
      }
      else
      {
        int[] address = new int[1];
        int mode = 4114;
        int result = COM.StgCreateDocfile(null, mode | 0x4000000, 0, address);
        if (result != 0) {
          OLE.error(1002, result);
        }
        storage = new IStorage(address[0]);
        
        String streamName = "CONTENTS";
        GUID wordGUID = getClassID("Word.Document");
        if ((wordGUID != null) && (COM.IsEqualGUID(appClsid, wordGUID))) {
          streamName = "WordDocument";
        }
        if (isOffice2007) {
          streamName = "Package";
        }
        address = new int[1];
        result = storage.CreateStream(streamName, mode, 0, 0, address);
        if (result != 0)
        {
          storage.Release();
          OLE.error(1002, result);
        }
        IStream stream = new IStream(address[0]);
        try
        {
          FileInputStream fileInput = new FileInputStream(file);
          int increment = 4096;
          byte[] buffer = new byte[increment];
          int count = 0;
          while ((count = fileInput.read(buffer)) > 0)
          {
            int pv = COM.CoTaskMemAlloc(count);
            OS.MoveMemory(pv, buffer, count);
            result = stream.Write(pv, count, null);
            COM.CoTaskMemFree(pv);
            if (result != 0)
            {
              fileInput.close();
              stream.Release();
              storage.Release();
              OLE.error(1002, result);
            }
          }
          fileInput.close();
          stream.Commit(0);
          stream.Release();
        }
        catch (IOException localIOException)
        {
          stream.Release();
          storage.Release();
          OLE.error(1002);
        }
      }
      tempStorage = createTempStorage();
      
      int result = storage.CopyTo(0, null, null, tempStorage.getAddress());
      storage.Release();
      if (result != 0) {
        OLE.error(1002, result);
      }
      int[] ppv = new int[1];
      result = COM.CoCreateInstance(appClsid, 0, 3, COM.IIDIUnknown, ppv);
      if (result != 0) {
        OLE.error(1001, result);
      }
      objIUnknown = new IUnknown(ppv[0]);
      
      ppv = new int[1];
      result = objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv);
      if (result != 0) {
        OLE.error(1001, result);
      }
      IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]);
      
      result = iPersistStorage.Load(tempStorage.getAddress());
      iPersistStorage.Release();
      if (result != 0) {
        OLE.error(1001, result);
      }
    }
    addObjectReferences();
    if (COM.OleRun(objIUnknown.getAddress()) == 0) {
      state = 1;
    }
  }
  
  protected void addObjectReferences()
  {
    int[] ppvObject = new int[1];
    if (objIUnknown.QueryInterface(COM.IIDIPersist, ppvObject) == 0)
    {
      IPersist objIPersist = new IPersist(ppvObject[0]);
      GUID tempid = new GUID();
      if (objIPersist.GetClassID(tempid) == 0) {
        objClsid = tempid;
      }
      objIPersist.Release();
    }
    ppvObject = new int[1];
    int result = objIUnknown.QueryInterface(COM.IIDIViewObject2, ppvObject);
    if (result != 0) {
      OLE.error(1003, result);
    }
    objIViewObject2 = new IViewObject2(ppvObject[0]);
    objIViewObject2.SetAdvise(aspect, 0, iAdviseSink.getAddress());
    
    ppvObject = new int[1];
    result = objIUnknown.QueryInterface(COM.IIDIOleObject, ppvObject);
    if (result != 0) {
      OLE.error(1003, result);
    }
    objIOleObject = new IOleObject(ppvObject[0]);
    
    int[] ppvClientSite = new int[1];
    result = objIOleObject.GetClientSite(ppvClientSite);
    if (ppvClientSite[0] == 0) {
      objIOleObject.SetClientSite(iOleClientSite.getAddress());
    } else {
      Release();
    }
    int[] pdwConnection = new int[1];
    objIOleObject.Advise(iAdviseSink.getAddress(), pdwConnection);
    objIOleObject.SetHostNames("main", "main");
    
    COM.OleSetContainedObject(objIUnknown.getAddress(), true);
    
    ppvObject = new int[1];
    if (objIUnknown.QueryInterface(COM.IIDIOleLink, ppvObject) == 0)
    {
      IOleLink objIOleLink = new IOleLink(ppvObject[0]);
      int[] ppmk = new int[1];
      if (objIOleLink.GetSourceMoniker(ppmk) == 0)
      {
        IMoniker objIMoniker = new IMoniker(ppmk[0]);
        objIMoniker.Release();
        type = 0;
        objIOleLink.BindIfRunning();
      }
      else
      {
        isStatic = true;
      }
      objIOleLink.Release();
    }
  }
  
  protected int AddRef()
  {
    refCount += 1;
    return refCount;
  }
  
  private int CanInPlaceActivate()
  {
    if ((aspect == 1) && (type == 1)) {
      return 0;
    }
    return 1;
  }
  
  private int ContextSensitiveHelp(int fEnterMode)
  {
    return 0;
  }
  
  protected void createCOMInterfaces()
  {
    iUnknown = new COMObject(new int[] { 2 })
    {
      public int method0(int[] args)
      {
        return QueryInterface(args[0], args[1]);
      }
      
      public int method1(int[] args)
      {
        return AddRef();
      }
      
      public int method2(int[] args)
      {
        return Release();
      }
    };
    iOleClientSite = new COMObject(new int[] { 2, 0, 0, 0, 3, 1, 0, 1 })
    {
      public int method0(int[] args)
      {
        return QueryInterface(args[0], args[1]);
      }
      
      public int method1(int[] args)
      {
        return AddRef();
      }
      
      public int method2(int[] args)
      {
        return Release();
      }
      
      public int method3(int[] args)
      {
        return OleClientSite.this.SaveObject();
      }
      
      public int method5(int[] args)
      {
        return OleClientSite.this.GetContainer(args[0]);
      }
      
      public int method6(int[] args)
      {
        return OleClientSite.this.ShowObject();
      }
      
      public int method7(int[] args)
      {
        return OleClientSite.this.OnShowWindow(args[0]);
      }
    };
    iAdviseSink = new COMObject(new int[] { 2, 0, 0, 2, 2, 1 })
    {
      public int method0(int[] args)
      {
        return QueryInterface(args[0], args[1]);
      }
      
      public int method1(int[] args)
      {
        return AddRef();
      }
      
      public int method2(int[] args)
      {
        return Release();
      }
      
      public int method3(int[] args)
      {
        return OleClientSite.this.OnDataChange(args[0], args[1]);
      }
      
      public int method4(int[] args)
      {
        return OleClientSite.this.OnViewChange(args[0], args[1]);
      }
      
      public int method6(int[] args)
      {
        OleClientSite.this.OnSave();return 0;
      }
      
      public int method7(int[] args)
      {
        return OleClientSite.this.OnClose();
      }
    };
    iOleInPlaceSite = new COMObject(new int[] { 2, 0, 0, 1, 1, 0, 0, 0, 5, C.PTR_SIZEOF == 4 ? 2 : 1, 1, 0, 0, 0, 1 })
    {
      public int method0(int[] args)
      {
        return QueryInterface(args[0], args[1]);
      }
      
      public int method1(int[] args)
      {
        return AddRef();
      }
      
      public int method2(int[] args)
      {
        return Release();
      }
      
      public int method3(int[] args)
      {
        return GetWindow(args[0]);
      }
      
      public int method4(int[] args)
      {
        return OleClientSite.this.ContextSensitiveHelp(args[0]);
      }
      
      public int method5(int[] args)
      {
        return OleClientSite.this.CanInPlaceActivate();
      }
      
      public int method6(int[] args)
      {
        return OleClientSite.this.OnInPlaceActivate();
      }
      
      public int method7(int[] args)
      {
        return OleClientSite.this.OnUIActivate();
      }
      
      public int method8(int[] args)
      {
        return OleClientSite.this.GetWindowContext(args[0], args[1], args[2], args[3], args[4]);
      }
      
      public int method9(int[] args)
      {
        if (args.length == 2) {
          return OleClientSite.this.Scroll(args[0], args[1]);
        }
        return OleClientSite.this.Scroll_64(args[0]);
      }
      
      public int method10(int[] args)
      {
        return OnUIDeactivate(args[0]);
      }
      
      p
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd