Examples of XDocumentInsertable


Examples of com.sun.star.document.XDocumentInsertable

            FileUtils.writeByteArrayToFile(tempFile, contentBuilder.toString().getBytes());
            String fileUrl = "file:///" + tempFile.getCanonicalPath().replace("\\", "/");

            XTextCursor textCursor = destination.createTextCursorByRange(textRange);
            XDocumentInsertable insertable = as(XDocumentInsertable.class, textCursor);

            insertable.insertDocumentFromURL(fileUrl, new PropertyValue[0]);
        } finally {
            FileUtils.deleteQuietly(tempFile);
        }
    }
View Full Code Here

Examples of com.sun.star.document.XDocumentInsertable

   */
  public void insertDocument(String url) throws NOAException {
    if (url == null)
      return;
    try {
      XDocumentInsertable xDocumentInsertable = (XDocumentInsertable) UnoRuntime
          .queryInterface(XDocumentInsertable.class, xTextCursor);
      if (xDocumentInsertable != null)
        xDocumentInsertable.insertDocumentFromURL(URLAdapter
            .adaptURL(url), new PropertyValue[0]);
    } catch (Throwable throwable) {
      throw new NOAException(throwable);
    }
  }
View Full Code Here

Examples of com.sun.star.document.XDocumentInsertable

    if (inputStream == null || filter == null)
      return;
    FileOutputStream outputStream = null;
    File tempFile = null;
    try {
      XDocumentInsertable xDocumentInsertable = (XDocumentInsertable) UnoRuntime
          .queryInterface(XDocumentInsertable.class, xTextCursor);
      if (xDocumentInsertable != null) {
        boolean useOld = true;
        if (useOld) {
          byte buffer[] = new byte[0xffff];
          int bytes = -1;
          tempFile = File.createTempFile("noatemp"
              + System.currentTimeMillis(), "tmp");
          tempFile.deleteOnExit();
          outputStream = new FileOutputStream(tempFile);
          while ((bytes = inputStream.read(buffer)) != -1)
            outputStream.write(buffer, 0, bytes);
          insertDocument(tempFile.getAbsolutePath());
        } else {
          PropertyValue[] loadProps = new PropertyValue[2];
          loadProps[0] = new PropertyValue();
          loadProps[0].Name = "InputStream"; //$NON-NLS-1$
          loadProps[0].Value = new ByteArrayXInputStreamAdapter(
              inputStream, null);

          loadProps[1] = new PropertyValue();
          loadProps[1].Name = "FilterName"; //$NON-NLS-1$
          loadProps[1].Value = filter
              .getFilterDefinition(textDocument);

          xDocumentInsertable.insertDocumentFromURL("private:stream",
              loadProps);
        }
      }
    } catch (Throwable throwable) {
      throw new NOAException(throwable);
View Full Code Here

Examples of com.sun.star.document.XDocumentInsertable

   */
  public void insertDocument(String url) throws NOAException {
    if(url == null)
      return;
    try {
      XDocumentInsertable xDocumentInsertable = (XDocumentInsertable)UnoRuntime.queryInterface(XDocumentInsertable.class, xTextCursor);
      if(xDocumentInsertable != null)
        xDocumentInsertable.insertDocumentFromURL(URLAdapter.adaptURL(url), new PropertyValue[0]);
    }
    catch(Throwable throwable) {
      throw new NOAException(throwable);
    }
  }
View Full Code Here

Examples of com.sun.star.document.XDocumentInsertable

    if(inputStream == null || filter == null)
      return;
    FileOutputStream outputStream = null;
    File tempFile = null;
    try {
      XDocumentInsertable xDocumentInsertable = (XDocumentInsertable)UnoRuntime.queryInterface(XDocumentInsertable.class, xTextCursor);
      if(xDocumentInsertable != null) {
        boolean useOld = true;
        if(useOld) {
          byte buffer[]= new byte[0xffff];
          int bytes = -1;
          tempFile = File.createTempFile("noatemp"+System.currentTimeMillis(),"tmp");
          tempFile.deleteOnExit();
          outputStream = new FileOutputStream(tempFile);
          while((bytes = inputStream.read(buffer)) != -1)
            outputStream.write(buffer, 0, bytes);  
          insertDocument(tempFile.getAbsolutePath());
        }
        else {
          PropertyValue[] loadProps = new PropertyValue[2];
          loadProps[0] = new PropertyValue();
          loadProps[0].Name = "InputStream"//$NON-NLS-1$
          loadProps[0].Value = new ByteArrayXInputStreamAdapter(inputStream,null);
 
          loadProps[1] = new PropertyValue();
          loadProps[1].Name = "FilterName"//$NON-NLS-1$
          loadProps[1].Value = filter.getFilterDefinition(textDocument);
 
          xDocumentInsertable.insertDocumentFromURL("private:stream", loadProps)
        }
      }
    }
    catch(Throwable throwable) {
      throw new NOAException(throwable);
View Full Code Here
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.