Package org.eclipse.swt.ole.win32

Examples of org.eclipse.swt.ole.win32.OleAutomation


  private static class CMN_getOleProperty extends ControlCommandMessage {
    @Override
    public Object run(Object[] args) {
      String[] propertyPath = (String[])args[0];
      OleAutomation automation = new OleAutomation(getSite((OleFrame)getControl()));
      int[] ids;
      for(int i=0; i<propertyPath.length; i++) {
        ids = automation.getIDsOfNames(new String[] {propertyPath[i]});
        if(ids == null) {
          automation.dispose();
          return null;
        }
        if(i == propertyPath.length - 1) {
          Object[] vargs = (Object[])args[1];
          Variant[] params = new Variant[vargs.length];
          for(int j=0; j<vargs.length; j++) {
            params[j] = createVariant(vargs[j]);
          }
          Variant propertyVariant = automation.getProperty(ids[0], params);
          for(Variant param: params) {
            dispose(param);
          }
          Object result = getVariantValue(propertyVariant);
          dispose(propertyVariant);
          automation.dispose();
          return result;
        }
        Variant variantProperty = automation.getProperty(ids[0]);
        OleAutomation newAutomation = variantProperty.getAutomation();
        variantProperty.dispose();
        automation.dispose();
        automation = newAutomation;
      }
      automation.dispose();
View Full Code Here


          sb.append("  ");
        }
        sb.append(propertyName).append(Utils.LINE_SEPARATOR);
        Variant variantProperty = automation.getProperty(automation.getIDsOfNames(new String[] {propertyName})[0]);
        if(variantProperty != null && variantProperty.getType() == OLE.VT_DISPATCH) {
          OleAutomation newAutomation = variantProperty.getAutomation();
          dumpOleInterfaceDefinitions(sb, newAutomation, index + 1);
          newAutomation.dispose();
        }
        dispose(variantProperty);
      }
    }
View Full Code Here

        if(value != null) {
          String fieldDescription = fieldName.substring("VT_".length()).toLowerCase(Locale.ENGLISH);
          oleTypeToDescriptionMap.put(value, fieldDescription);
        }
      }
      OleAutomation automation = new OleAutomation(getSite((OleFrame)getControl()));
      StringBuilder sb = new StringBuilder();
      dumpOleInterfaceDefinitions(sb, automation, 0);
      automation.dispose();
      System.out.print(sb.toString());
      return null;
    }
View Full Code Here

    OleControlSite site;
    try {
      site = new OleControlSite(frame, SWT.NONE, "Shell.Explorer");
      configureOleFrame(site, frame);
      // Add a listener
      OleAutomation shellExplorer = new OleAutomation(site);
      int[] dispIDs = shellExplorer.getIDsOfNames(new String[] {"Application"});
      Variant pVarResult = shellExplorer.getProperty(dispIDs[0]);
      final OleAutomation application = pVarResult.getAutomation();
      frame.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
          application.dispose();
        }
      });
      pVarResult.dispose();
      shellExplorer.dispose();
      OleListener listener = new OleListener() {
View Full Code Here

          webBrowserField.setAccessible(true);
          Object swtWebBrowser = webBrowserField.get(browser);
          if(ieClass.isInstance(swtWebBrowser)) {
            Field autoField = ieClass.getDeclaredField("auto");
            autoField.setAccessible(true);
            OleAutomation swtBrowserAutomation = (org.eclipse.swt.ole.win32.OleAutomation)autoField.get(swtWebBrowser);
            int[] rgdispid = swtBrowserAutomation.getIDsOfNames(new String[] { "ExecWB", "cmdID", "cmdexecopt" });
            Variant[] rgvarg = new Variant[] {
                new Variant(OLE.OLECMDID_PRINT),
                new Variant(isShowingDialog? OLE.OLECMDEXECOPT_PROMPTUSER : OLE.OLECMDEXECOPT_DONTPROMPTUSER),
            };
            int[] rgdispidNamedArgs = new int[] {
                rgdispid[1],
                rgdispid[2],
            };
            /*Variant pVarResult =*/ swtBrowserAutomation.invoke(rgdispid[0], rgvarg, rgdispidNamedArgs);
            // isn't there any possible error handling?
            return true;
          }
        } catch (Throwable t) {
        }
View Full Code Here

    }
    System.out.println();

    System.out.println("Methods:");

    OleFunctionDescription funcDesc;
    for (int i = 0; (funcDesc = oleAutomation.getFunctionDescription(i)) != null; i++) {
      System.out.print(funcDesc.name);
      System.out.print("(");
      for (int j = 0; j < funcDesc.args.length; j++) {
        OleParameterDescription parmDesc = funcDesc.args[j];
View Full Code Here

    OleFunctionDescription funcDesc;
    for (int i = 0; (funcDesc = oleAutomation.getFunctionDescription(i)) != null; i++) {
      System.out.print(funcDesc.name);
      System.out.print("(");
      for (int j = 0; j < funcDesc.args.length; j++) {
        OleParameterDescription parmDesc = funcDesc.args[j];
        System.out.print(parmDesc.name);
        System.out.print(", ");
      }
      System.out.println(")");
    }
View Full Code Here

    return setIntegerProperty("Height", value);
  }

  public void dump() {
    System.out.println("Properties:");
    OlePropertyDescription propDesc;
    for (int i = 0; (propDesc = oleAutomation.getPropertyDescription(i)) != null; i++) {
      System.out.println(propDesc.name);
    }
    System.out.println();
View Full Code Here

      int pVarResult,
      int pExcepInfo,
      int pArgErr) {
    HResultException ex = null;
    Variant[] vArgs = null;
    Variant result = null;
    try {
      vArgs = extractVariantArrayFromDispParamsPtr(pDispParams);
      result = invoke(dispIdMember, dwFlags, vArgs);
      if (pVarResult != 0) {
        Utils.win32_copy(pVarResult, result);
      }
    } catch (HResultException e) {
      // Log to the console for detailed examination.
      //
      e.printStackTrace();
      ex = e;
    } catch (InvocationTargetException e) {
      // If we get here, it means an exception is being thrown from
      // Java back into JavaScript
      Throwable t = e.getTargetException();
      ex = new HResultException(t);
      ModuleSpace.setThrownJavaException(t);
    } catch (Exception e) {
      // Log to the console for detailed examination.
      //
      e.printStackTrace();
      ex = new HResultException(e);
    } finally {
      // We allocated variants for all arguments, so we must dispose them all.
      //
      for (int i = 0; i < vArgs.length; ++i) {
        if (vArgs[i] != null) {
          vArgs[i].dispose();
        }
      }
      if (result != null) {
        result.dispose();
      }
    }
    if (ex != null) {
      // Set up an exception for IE to throw.
      //
View Full Code Here

      throw new RuntimeException("Invalid dispatch oracle.");
    }
    try {
      // GWT 2: called static scope with dispId as parameter
      if (dispId == 0 && (flags & COM.DISPATCH_METHOD) != 0 && params.length >= 2) {
        Variant dispIdVar = params[0]; // zero is dispId, next should be null (as 'this') for static context
        dispId = dispIdVar.getInt();
        if (javaDispatch.isMethod(dispId)) {
          MethodAdaptor method = javaDispatch.getMethod(dispId);
          Object target = getTarget();
          Object jthis =
              method.needsThis() ? JsValueGlue.get(
                new JsValueIE6(params[1]),
                classLoader,
                method.getDeclaringClass(),
                "this") : null;
          Variant[] otherParams = new Variant[params.length - 2];
          System.arraycopy(params, 2, otherParams, 0, otherParams.length);
          return callMethod(classLoader, dispIdOracle, jthis, otherParams, method);
        }
      }
      // Whatever the caller asks for, try to find it via reflection.
      //
      if (dispId == DISPID_MAGIC_GETGLOBALREF && myGlobalRef != 0) {
        // Handle specially.
        //
        return new Variant(myGlobalRef);
      } else if (dispId == 0) {
        if ((flags & COM.DISPATCH_METHOD) != 0) {
          // implicit call -- "m()"
          // not supported -- fall through to unsupported failure
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // implicit toString -- "'foo' + m"
          return new Variant(getTarget().toString());
        }
      } else if (dispId > 0) {
        if (javaDispatch.isMethod(dispId)) {
          MethodAdaptor method = javaDispatch.getMethod(dispId);
          if ((flags & COM.DISPATCH_METHOD) != 0) {
            // This is a method call.
            return callMethod(classLoader, dispIdOracle, getTarget(), params, method);
          } else if (flags == COM.DISPATCH_PROPERTYGET) {
            // The function is being accessed as a property.
            AccessibleObject obj = method.getUnderlyingObject();
            IDispatchImpl dispMethod =
                (IDispatchImpl) WrappersCache.getWrapperForObject(classLoader, obj);
            if (dispMethod == null || dispMethod.refCount < 1) {
              dispMethod = new MethodDispatch(classLoader, dispIdOracle, method);
              WrappersCache.putWrapperForObject(classLoader, obj, dispMethod);
            }
            IDispatch disp = new IDispatch(dispMethod.getAddress());
            disp.AddRef();
            return new Variant(disp);
          }
        } else if (javaDispatch.isField(dispId)) {
          Field field = javaDispatch.getField(dispId);
          if (flags == COM.DISPATCH_PROPERTYGET) {
            return SwtOleGlue.convertObjectToVariant(
              classLoader,
              dispIdOracle,
              field.getType(),
              javaDispatch.getFieldValue(dispId));
          } else if ((flags & (COM.DISPATCH_PROPERTYPUT | COM.DISPATCH_PROPERTYPUTREF)) != 0) {
            javaDispatch.setFieldValue(dispId, JsValueGlue.get(
              new JsValueIE6(params[0]),
              classLoader,
              field.getType(),
              "Setting field '" + field.getName() + "'"));
            return new Variant();
          }
        }
      } else {
        // The specified member id is out of range.
        throw new HResultException(COM.DISP_E_MEMBERNOTFOUND);
View Full Code Here

TOP

Related Classes of org.eclipse.swt.ole.win32.OleAutomation

Copyright © 2018 www.massapicom. 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.