com.sun.star.frame.XComponentLoader.loadComponentFromURL()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中com.sun.star.frame.XComponentLoader.loadComponentFromURL()方法的一些代码示例,展示了XComponentLoader.loadComponentFromURL()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XComponentLoader.loadComponentFromURL()方法的具体详情如下:
包路径:com.sun.star.frame.XComponentLoader
类名称:XComponentLoader
方法名:loadComponentFromURL

XComponentLoader.loadComponentFromURL介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

XComponentContext xContext = Bootstrap.bootstrap();
XMultiComponentFactory xMCF = xContext.getServiceManager();
Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, oDesktop);
XComponentLoader xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);
XComponent xComp = xCompLoader.loadComponentFromURL("file:///C:/test.odt", "_blank", 0, new Boolean(true));
XTextDocument xDoc = UnoRuntime.queryInterface(XTextDocument.class, xComp);
XModel xModel =UnoRuntime.queryInterface( XModel.class, xDoc );
XDrawPageSupplier xDPS = UnoRuntime.queryInterface(XDrawPageSupplier.class, xModel);
XDrawPage xDrawPage = xDPS.getDrawPage();
XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xDrawPage );
for (int s=0;s<xDrawPage.getCount();s++) {
  XShape xShape = UnoRuntime.queryInterface( XShape.class, xShapes.getByIndex(s) );
  System.out.println(" -- sh.getShapeType: " + xShape.getShapeType());
  System.out.println(" -- sh.getPosition: " + xShape.getPosition().X + "x" + xShape.getPosition().Y);
  System.out.println(" -- sh.getSize: " + xShape.getSize().Width + "x" + xShape.getSize().Height);
}

代码示例来源:origin: com.artofsolving/jodconverter

private XComponent loadDocument(String inputUrl, Map loadProperties) throws com.sun.star.io.IOException, IllegalArgumentException {
  XComponentLoader desktop = openOfficeConnection.getDesktop();
  return desktop.loadComponentFromURL(inputUrl, "_blank", 0, toPropertyValues(loadProperties));
}

代码示例来源:origin: stackoverflow.com

final XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps);

代码示例来源:origin: com.haulmont.yarg/yarg

public XComponent loadXComponent(XInputStream inputStream) throws com.sun.star.lang.IllegalArgumentException, IOException {
  XComponentLoader xComponentLoader = getXComponentLoader();
  PropertyValue[] props = new PropertyValue[2];
  props[0] = new PropertyValue();
  props[1] = new PropertyValue();
  props[0].Name = "InputStream";
  props[0].Value = inputStream;
  props[1].Name = "Hidden";
  props[1].Value = true;
  return xComponentLoader.loadComponentFromURL("private:stream", "_blank", 0, props);
}

代码示例来源:origin: cuba-platform/yarg

public XComponent loadXComponent(XInputStream inputStream) throws com.sun.star.lang.IllegalArgumentException, IOException {
  XComponentLoader xComponentLoader = getXComponentLoader();
  PropertyValue[] props = new PropertyValue[2];
  props[0] = new PropertyValue();
  props[1] = new PropertyValue();
  props[0].Name = "InputStream";
  props[0].Value = inputStream;
  props[1].Name = "Hidden";
  props[1].Value = true;
  return xComponentLoader.loadComponentFromURL("private:stream", "_blank", 0, props);
}

代码示例来源:origin: cuba-platform/yarg

public XComponent loadXComponent(byte[] bytes) throws com.sun.star.lang.IllegalArgumentException, IOException {
  XComponentLoader xComponentLoader = getXComponentLoader();
  PropertyValue[] props = new PropertyValue[1];
  props[0] = new PropertyValue();
  props[0].Name = "Hidden";
  props[0].Value = Boolean.TRUE;
  File tempFile = createTempFile(bytes);
  return xComponentLoader.loadComponentFromURL(toURL(tempFile), "_blank", 0, props);
}

代码示例来源:origin: stackoverflow.com

XComponentContext xLocalContext = Bootstrap.bootstrap();
XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
Object desktop = xLocalServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", xLocalContext);
XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop);
PropertyValue[] mypv = new PropertyValue[3];
mypv[0] = new PropertyValue();
mypv[0].Name = new String("FilterName");
mypv[0].Value = new String("Text - txt - csv (StarCalc)");
mypv[1] = new PropertyValue();
mypv[1].Name = "Hidden";
mypv[1].Value = new Boolean(false);
mypv[1] = new PropertyValue();
mypv[1].Name = "CharacterSet";
mypv[1].Value = "UTF-8";
mypv[2] = new PropertyValue();
mypv[2].Name = "FilterOptions";
mypv[2].Value = "59,34,0,1,1/1/2/1/3/5";
String internalFile = ExternalUriReferenceTranslator.create(xLocalContext).translateToInternal("file://" + csvFile.getAbsolutePath());
XComponent comp = xComponentLoader.loadComponentFromURL(internalFile, "_parent", 0, mypv);

代码示例来源:origin: com.haulmont.yarg/yarg

public XComponent loadXComponent(byte[] bytes) throws com.sun.star.lang.IllegalArgumentException, IOException {
  XComponentLoader xComponentLoader = getXComponentLoader();
  PropertyValue[] props = new PropertyValue[1];
  props[0] = new PropertyValue();
  props[0].Name = "Hidden";
  props[0].Value = Boolean.TRUE;
  File tempFile = createTempFile(bytes);
  return xComponentLoader.loadComponentFromURL(toURL(tempFile), "_blank", 0, props);
}

代码示例来源:origin: com.artofsolving/jodconverter

private void loadAndExport(InputStream inputStream, Map/*<String,Object>*/ importOptions, OutputStream outputStream, Map/*<String,Object>*/ exportOptions) throws Exception {
    XComponentLoader desktop = openOfficeConnection.getDesktop();
    
    Map/*<String,Object>*/ loadProperties = new HashMap();
    loadProperties.putAll(getDefaultLoadProperties());
    loadProperties.putAll(importOptions);
    // doesn't work using InputStreamToXInputStreamAdapter; probably because it's not XSeekable 
    //property("InputStream", new InputStreamToXInputStreamAdapter(inputStream))
    loadProperties.put("InputStream", new ByteArrayToXInputStreamAdapter(IOUtils.toByteArray(inputStream)));
    
    XComponent document = desktop.loadComponentFromURL("private:stream", "_blank", 0, toPropertyValues(loadProperties));
    if (document == null) {
      throw new OpenOfficeException("conversion failed: input document is null after loading");
    }

    refreshDocument(document);
    
    Map/*<String,Object>*/ storeProperties = new HashMap();
    storeProperties.putAll(exportOptions);
    storeProperties.put("OutputStream", new OutputStreamToXOutputStreamAdapter(outputStream));
    
    try {
      XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, document);
      storable.storeToURL("private:stream", toPropertyValues(storeProperties));
    } finally {
      document.dispose();
    }
  }
}

代码示例来源:origin: stackoverflow.com

System.out.println("starting...");
       String oooExeFolder = "/usr/lib/openoffice/program";
       XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
       XMultiComponentFactory xMCF = xContext.getServiceManager();
       Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
       XComponentLoader xCLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);
       System.out.println("loading ");
       PropertyValue[] printerDesc = new PropertyValue[1];
       printerDesc[0] = new PropertyValue();
       printerDesc[0].Name = "PaperOrientation";
       printerDesc[0].Value = PaperOrientation.LANDSCAPE;
       // Create a document
       XComponent document = xCLoader.loadComponentFromURL(loadUrl, "_blank", 0, printerDesc);
       // Following property will convert doc into requested orientation.
       XPrintable xPrintable = (XPrintable) UnoRuntime.queryInterface(XPrintable.class, document);
       xPrintable.setPrinter(printerDesc);
       PropertyValue[] conversionProperties = new PropertyValue[3];
       conversionProperties[1] = new PropertyValue();
       conversionProperties[1].Name = "FilterName";
       conversionProperties[1].Value = "writer_pdf_Export";// 
       conversionProperties[0] = new PropertyValue();
       conversionProperties[0].Name = "Overwrite ";
       conversionProperties[0].Value = new Boolean(true);
       System.out.println("closing");
       XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, document);
       xstorable.storeToURL(storeUrl, conversionProperties);
       System.out.println("closing");
       XCloseable xcloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, document);
       xcloseable.close(false);

代码示例来源:origin: mirkonasato/jodconverter

private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
  if (!inputFile.exists()) {
    throw new OfficeException("input document not found");
  }
  XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
  Map<String,?> loadProperties = getLoadProperties(inputFile);
  XComponent document = null;
  try {
    document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
  } catch (IllegalArgumentException illegalArgumentException) {
    throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
  } catch (ErrorCodeIOException errorCodeIOException) {
    throw new OfficeException("could not load document: "  + inputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
  } catch (IOException ioException) {
    throw new OfficeException("could not load document: "  + inputFile.getName(), ioException);
  }
  if (document == null) {
    throw new OfficeException("could not load document: "  + inputFile.getName());
  }
  return document;
}

代码示例来源:origin: com.bbossgroups.plugins/bboss-jodconverter-core

private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
  if (!inputFile.exists()) {
    throw new OfficeException("input document not found");
  }
  XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
  Map<String,?> loadProperties = getLoadProperties(inputFile);
  XComponent document = null;
  try {
    document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
  } catch (IllegalArgumentException illegalArgumentException) {
    throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
  } catch (ErrorCodeIOException errorCodeIOException) {
    throw new OfficeException("could not load document: "  + inputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
  } catch (IOException ioException) {
    throw new OfficeException("could not load document: "  + inputFile.getName(), ioException);
  }
  if (document == null) {
    throw new OfficeException("could not load document: "  + inputFile.getName());
  }
  return document;
}

代码示例来源:origin: com.github.livesense/jodconverter-core

private XComponent loadDocument(OfficeContext context, File inputFile) throws OfficeException {
  if (!inputFile.exists()) {
    throw new OfficeException("input document not found");
  }
  XComponentLoader loader = cast(XComponentLoader.class, context.getService(SERVICE_DESKTOP));
  Map<String,?> loadProperties = getLoadProperties(inputFile);
  XComponent document = null;
  try {
    document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0, toUnoProperties(loadProperties));
  } catch (IllegalArgumentException illegalArgumentException) {
    throw new OfficeException("could not load document: " + inputFile.getName(), illegalArgumentException);
  } catch (ErrorCodeIOException errorCodeIOException) {
    throw new OfficeException("could not load document: "  + inputFile.getName() + "; errorCode: " + errorCodeIOException.ErrCode, errorCodeIOException);
  } catch (IOException ioException) {
    throw new OfficeException("could not load document: "  + inputFile.getName(), ioException);
  }
  if (document == null) {
    throw new OfficeException("could not load document: "  + inputFile.getName());
  }
  return document;
}

代码示例来源:origin: stackoverflow.com

document = xComponentLoader.loadComponentFromURL(fileName, "_blank", 0, properties);
} catch (IOException e) {
  e.printStackTrace();

代码示例来源:origin: org.alfresco/alfresco-repository

document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0,
      new PropertyValue[]{hiddenOOo, readOnly});
} catch (IllegalArgumentException illegalArgumentException)

代码示例来源:origin: Alfresco/alfresco-repository

document = loader.loadComponentFromURL(toUrl(inputFile), "_blank", 0,
      new PropertyValue[]{hiddenOOo, readOnly});
} catch (IllegalArgumentException illegalArgumentException)

代码示例来源:origin: org.libreoffice/officebean

com.sun.star.beans.PropertyState.DIRECT_VALUE ) );
com.sun.star.lang.XComponent xComponent = xLoader.loadComponentFromURL(
  aURL, "_self", 0, aArgs );

相关文章

微信公众号

最新文章

更多