Ejemplo n.º 1
0
  public boolean closeOutput(XStream xStream) {
    XOutputStream xOutTemp = null;
    try {
      xOutTemp = xStream.getOutputStream();
      if (xOutTemp == null) {
        Error("Can't get the output part of a stream!");
        return false;
      }
    } catch (Exception e) {
      Error("Can't get the output part of a stream, exception :" + e);
      return false;
    }

    try {
      xOutTemp.closeOutput();
    } catch (Exception e) {
      Error("Can't close output part of a stream, exception :" + e);
      return false;
    }

    return true;
  }
Ejemplo n.º 2
0
  public String CreateTempFile(XMultiServiceFactory xMSF) {
    String sResult = null;

    // try to get temporary file representation
    XPropertySet xTempFileProps = null;
    try {
      Object oTempFile = xMSF.createInstance("com.sun.star.io.TempFile");
      xTempFileProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTempFile);
    } catch (Exception e) {
    }

    if (xTempFileProps != null) {
      try {
        xTempFileProps.setPropertyValue("RemoveFile", new Boolean(false));
        sResult = AnyConverter.toString(xTempFileProps.getPropertyValue("Uri"));
      } catch (Exception e) {
        Error("Can't control TempFile properties, exception: " + e);
      }
    } else {
      Error("Can't create temporary file representation!");
    }

    // close temporary file explicitly
    try {
      XStream xStream = (XStream) UnoRuntime.queryInterface(XStream.class, xTempFileProps);
      if (xStream != null) {
        XOutputStream xOut = xStream.getOutputStream();
        if (xOut != null) xOut.closeOutput();

        XInputStream xIn = xStream.getInputStream();
        if (xIn != null) xIn.closeInput();
      } else Error("Can't close TempFile!");
    } catch (Exception e) {
      Error("Can't close TempFile, exception: " + e);
    }

    return sResult;
  }