gpt4 book ai didi

com.sun.star.lang.XMultiServiceFactory.createInstance()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 23:15:05 27 4
gpt4 key购买 nike

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

XMultiServiceFactory.createInstance介绍

暂无

代码示例

代码示例来源:origin: org.openoffice/jurt

public void setInstance(String serviceName) throws com.sun.star.uno.Exception {
  _instance = _serviceManager.createInstance(serviceName);
  _serviceName = serviceName;
}

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

public void setInstance(String serviceName) throws com.sun.star.uno.Exception {
  _instance = _serviceManager.createInstance(serviceName);
  _serviceName = serviceName;
}

代码示例来源:origin: org.cogroo.lang.pt_br/cogroo-addon-pt_br

protected void init(XMultiServiceFactory factory) {
  try {
    this.configProvider = (XMultiServiceFactory) UnoRuntime
        .queryInterface(XMultiServiceFactory.class, factory
            .createInstance(CONFIGURATION_SERVICE));
  } catch (Throwable e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: cogroo/cogroo4

protected void init(XMultiServiceFactory factory) {
  try {
    this.configProvider = (XMultiServiceFactory) UnoRuntime
        .queryInterface(XMultiServiceFactory.class, factory
            .createInstance(CONFIGURATION_SERVICE));
  } catch (Throwable e) {
    e.printStackTrace();
  }
}

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

public static void createAnnotation( XComponentContext xContext, XTextRange xTextRange )
{
 // per-document stuff
 XMultiComponentFactory xServiceManager= xContext.getServiceManager();
 Object desktop= xServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
 XComponent xComponent= xDesktop.getCurrentComponent();
 XTextDocument xTextDocument= UnoRunime.queryInterface(XTextDocument.class, xComponent);
 XText xText= xTextDocument.getText();
 XMultiServiceFactory xWriterFactory= UnoRuntime.queryInterface(XMultiServiceFactory.class, xComponent);

 // per-annotation stuff
 Object annotation= xWriterFactory.createInstance("com.sun.star.text.textfield.nnotation");
 XPropertySet annotProps=   UnoRuntime.queryInterface(XPropertySet.class, annotation);
 annotProps.setValue("Content", "It's a me!")
 annotProps.setValue("Author", "Mario");
 XTextField annotTextField= UnoRuntime.queryInterface(XTextfield.class, annotation);
 xText.insertTextContent( xTextRange, annotTextField, true ); // "true" spans the range
}

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

/** Returns the XDesktop interface of the OOo instance used by this OOoBean.
  @throws NoConnectionException
    if no connection is established and no default connection can be established.
 */
public synchronized com.sun.star.frame.XDesktop getOOoDesktop()
  throws NoConnectionException
{
  if ( xDesktop == null )
  {
    try
    {
      Object aObject = getMultiServiceFactory().createInstance( "com.sun.star.frame.Desktop");
      xDesktop = UnoRuntime.queryInterface(
          com.sun.star.frame.XDesktop.class, aObject );
    }
    catch ( com.sun.star.uno.Exception aExc )
    {} // TBD: what if no connection exists?
  }
  return xDesktop;
}

代码示例来源:origin: org.cogroo.lang.pt_br/cogroo-addon-pt_br

public void addImage(String url, String name, int x, int y, int width,
    int height, boolean scale) throws Exception {
  Object imageModel = multiServiceFactory.createInstance("com.sun.star.awt.UnoControlImageControlModel");
  XPropertySet imageProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, imageModel);
  imageProperties.setPropertyValue("PositionX", new Integer(x));
  imageProperties.setPropertyValue("PositionY", new Integer(y));
  imageProperties.setPropertyValue("Width", new Integer(width));
  imageProperties.setPropertyValue("Height", new Integer(height));
  imageProperties.setPropertyValue("Name", name);
  imageProperties.setPropertyValue("ScaleImage", new Boolean(scale));
  imageProperties.setPropertyValue("ImageURL", new String(url));
  this.nameContainer.insertByName(name, imageModel);
}

代码示例来源:origin: cogroo/cogroo4

public void addImage(String url, String name, int x, int y, int width,
    int height, boolean scale, short border) throws Exception {
  Object imageModel = multiServiceFactory.createInstance("com.sun.star.awt.UnoControlImageControlModel");
  XPropertySet imageProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, imageModel);
  imageProperties.setPropertyValue("PositionX", new Integer(x));
  imageProperties.setPropertyValue("PositionY", new Integer(y));
  imageProperties.setPropertyValue("Width", new Integer(width));
  imageProperties.setPropertyValue("Height", new Integer(height));
  imageProperties.setPropertyValue("Name", name);
  imageProperties.setPropertyValue("ScaleImage", new Boolean(scale));
  imageProperties.setPropertyValue("ImageURL", new String(url));
  imageProperties.setPropertyValue("Border", new Short((short) border));
  this.nameContainer.insertByName(name, imageModel);
}

代码示例来源:origin: cogroo/cogroo4

public void addImage(String url, String name, int x, int y, int width,
    int height, boolean scale) throws Exception {
  Object imageModel = multiServiceFactory.createInstance("com.sun.star.awt.UnoControlImageControlModel");
  XPropertySet imageProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, imageModel);
  imageProperties.setPropertyValue("PositionX", new Integer(x));
  imageProperties.setPropertyValue("PositionY", new Integer(y));
  imageProperties.setPropertyValue("Width", new Integer(width));
  imageProperties.setPropertyValue("Height", new Integer(height));
  imageProperties.setPropertyValue("Name", name);
  imageProperties.setPropertyValue("ScaleImage", new Boolean(scale));
  imageProperties.setPropertyValue("ImageURL", new String(url));
  this.nameContainer.insertByName(name, imageModel);
}

代码示例来源:origin: org.cogroo.lang.pt_br/cogroo-addon-pt_br

public void addImage(String url, String name, int x, int y, int width,
    int height, boolean scale, short border) throws Exception {
  Object imageModel = multiServiceFactory.createInstance("com.sun.star.awt.UnoControlImageControlModel");
  XPropertySet imageProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, imageModel);
  imageProperties.setPropertyValue("PositionX", new Integer(x));
  imageProperties.setPropertyValue("PositionY", new Integer(y));
  imageProperties.setPropertyValue("Width", new Integer(width));
  imageProperties.setPropertyValue("Height", new Integer(height));
  imageProperties.setPropertyValue("Name", name);
  imageProperties.setPropertyValue("ScaleImage", new Boolean(scale));
  imageProperties.setPropertyValue("ImageURL", new String(url));
  imageProperties.setPropertyValue("Border", new Short((short) border));
  this.nameContainer.insertByName(name, imageModel);
}

代码示例来源:origin: org.cogroo.lang.pt_br/cogroo-addon-pt_br

public Object insertControlModel(String ServiceName, String sName, String[] sProperties, Object[] sValues) throws com.sun.star.script.BasicErrorException{
  try {
    Object oControlModel = m_xMSFDialogModel.createInstance(ServiceName);
    XMultiPropertySet xControlMultiPropertySet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oControlModel);
    xControlMultiPropertySet.setPropertyValues(sProperties, sValues);
    m_xDlgModelNameContainer.insertByName(sName, oControlModel);
    return oControlModel;
  } catch (com.sun.star.uno.Exception exception) {
    exception.printStackTrace(System.out);
    return null;
  }
}

代码示例来源:origin: cogroo/cogroo4

public Object insertControlModel(String ServiceName, String sName, String[] sProperties, Object[] sValues) throws com.sun.star.script.BasicErrorException{
  try {
    Object oControlModel = m_xMSFDialogModel.createInstance(ServiceName);
    XMultiPropertySet xControlMultiPropertySet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oControlModel);
    xControlMultiPropertySet.setPropertyValues(sProperties, sValues);
    m_xDlgModelNameContainer.insertByName(sName, oControlModel);
    return oControlModel;
  } catch (com.sun.star.uno.Exception exception) {
    exception.printStackTrace(System.out);
    return null;
  }
}

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

/**
 * Returns an AWT toolkit.
 */
private XToolkit queryAWTToolkit() throws com.sun.star.uno.Exception
{
   // Create a UNO toolkit.
   XComponentContext xContext = mConnection.getComponentContext();
   XMultiComponentFactory compfactory = xContext.getServiceManager();
   XMultiServiceFactory factory = UnoRuntime.queryInterface(
       XMultiServiceFactory.class, compfactory);
   Object object  = factory.createInstance( "com.sun.star.awt.Toolkit");
   return UnoRuntime.queryInterface(XToolkit.class, object);
}

代码示例来源:origin: org.cogroo.lang.pt_br/cogroo-addon-pt_br

public XButton addButton(String title, String name, int x, int y,
    int width, int height) throws Exception {
  Object buttonModel = this.multiServiceFactory.createInstance("com.sun.star.awt.UnoControlButtonModel");
  XPropertySet buttonProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, buttonModel);
  buttonProperties.setPropertyValue("PositionX", new Integer(x));
  buttonProperties.setPropertyValue("PositionY", new Integer(y));
  buttonProperties.setPropertyValue("Width", new Integer(width));
  buttonProperties.setPropertyValue("Height", new Integer(height));
  buttonProperties.setPropertyValue("Name", name);
  buttonProperties.setPropertyValue("TabIndex", new Short(
      (short) tabcount++));
  buttonProperties.setPropertyValue("Label", title);
  this.nameContainer.insertByName(name, buttonModel);
  XControlContainer controlContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, this.oUnoDialog);
  Object objectButton = controlContainer.getControl(name);
  XButton button = (XButton) UnoRuntime.queryInterface(XButton.class,
      objectButton);
  return button;
}

代码示例来源:origin: cogroo/cogroo4

public XCheckBox addCheckBox(boolean state, String name, int x, int y,
    int width, int height) throws Exception {
  Object checkboxModel = multiServiceFactory.createInstance("com.sun.star.awt.UnoControlCheckBoxModel");
  XPropertySet imageProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, checkboxModel);
  imageProperties.setPropertyValue("PositionX", new Integer(x));
  imageProperties.setPropertyValue("PositionY", new Integer(y));
  imageProperties.setPropertyValue("Width", new Integer(width));
  imageProperties.setPropertyValue("Height", new Integer(height));
  imageProperties.setPropertyValue("Name", name);
  short value = 0;
  if (state) {
    value = 1;
  }
  imageProperties.setPropertyValue("State", new Short(value));
  this.nameContainer.insertByName(name, checkboxModel);
  XControlContainer controlContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, this.oUnoDialog);
  Object obj = controlContainer.getControl(name);
  XCheckBox checkbox = (XCheckBox) UnoRuntime.queryInterface(
      XCheckBox.class, obj);
  return checkbox;
}

代码示例来源:origin: org.cogroo.lang.pt_br/cogroo-addon-pt_br

public XCheckBox addCheckBox(boolean state, String name, int x, int y,
    int width, int height) throws Exception {
  Object checkboxModel = multiServiceFactory.createInstance("com.sun.star.awt.UnoControlCheckBoxModel");
  XPropertySet imageProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, checkboxModel);
  imageProperties.setPropertyValue("PositionX", new Integer(x));
  imageProperties.setPropertyValue("PositionY", new Integer(y));
  imageProperties.setPropertyValue("Width", new Integer(width));
  imageProperties.setPropertyValue("Height", new Integer(height));
  imageProperties.setPropertyValue("Name", name);
  short value = 0;
  if (state) {
    value = 1;
  }
  imageProperties.setPropertyValue("State", new Short(value));
  this.nameContainer.insertByName(name, checkboxModel);
  XControlContainer controlContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, this.oUnoDialog);
  Object obj = controlContainer.getControl(name);
  XCheckBox checkbox = (XCheckBox) UnoRuntime.queryInterface(
      XCheckBox.class, obj);
  return checkbox;
}

代码示例来源:origin: cogroo/cogroo4

public XListBox addListBox(String[] items, String name, int x, int y,
    int width, int height) throws Exception {
  Object listModel = multiServiceFactory.createInstance("com.sun.star.awt.UnoControlListBoxModel");
  XPropertySet listProperties = (XPropertySet) UnoRuntime.queryInterface(
      XPropertySet.class, listModel);
  listProperties.setPropertyValue("PositionX", new Integer(x));
  listProperties.setPropertyValue("PositionY", new Integer(y));
  listProperties.setPropertyValue("Width", new Integer(width));
  listProperties.setPropertyValue("Height", new Integer(height));
  listProperties.setPropertyValue("Border", new Short((short) 2));
  listProperties.setPropertyValue("Name", name);
  listProperties.setPropertyValue("TabIndex", new Short(
      (short) tabcount++));
  listProperties.setPropertyValue("StringItemList", items);
  // insert the control models into the dialog model
  this.nameContainer.insertByName(name, listModel);
  XControlContainer controlContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, this.oUnoDialog);
  Object obj = controlContainer.getControl(name);
  XListBox lbox = (XListBox) UnoRuntime.queryInterface(XListBox.class,
      obj);
  return lbox;
}

代码示例来源:origin: cogroo/cogroo4

public XButton addButton(String title, String name, int x, int y,
    int width, int height) throws Exception {
  Object buttonModel = this.multiServiceFactory.createInstance("com.sun.star.awt.UnoControlButtonModel");
  XPropertySet buttonProperties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, buttonModel);
  buttonProperties.setPropertyValue("PositionX", new Integer(x));
  buttonProperties.setPropertyValue("PositionY", new Integer(y));
  buttonProperties.setPropertyValue("Width", new Integer(width));
  buttonProperties.setPropertyValue("Height", new Integer(height));
  buttonProperties.setPropertyValue("Name", name);
  buttonProperties.setPropertyValue("TabIndex", new Short(
      (short) tabcount++));
  buttonProperties.setPropertyValue("Label", title);
  this.nameContainer.insertByName(name, buttonModel);
  XControlContainer controlContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, this.oUnoDialog);
  Object objectButton = controlContainer.getControl(name);
  XButton button = (XButton) UnoRuntime.queryInterface(XButton.class,
      objectButton);
  return button;
}

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

protected void insertImage(XComponent document, OfficeResourceProvider officeResourceProvider, XText destination, XTextRange textRange,
              Image image) throws Exception {
  XMultiServiceFactory xFactory = as(XMultiServiceFactory.class, document);
  XComponentContext xComponentContext = officeResourceProvider.getXComponentContext();
  XMultiComponentFactory serviceManager = xComponentContext.getServiceManager();
  Object oImage = xFactory.createInstance(TEXT_GRAPHIC_OBJECT);
  Object oGraphicProvider = serviceManager.createInstanceWithContext(GRAPHIC_PROVIDER_OBJECT, xComponentContext);
  XGraphicProvider xGraphicProvider = as(XGraphicProvider.class, oGraphicProvider);
  XPropertySet imageProperties = buildImageProperties(xGraphicProvider, oImage, image.imageContent);
  XTextContent xTextContent = as(XTextContent.class, oImage);
  destination.insertTextContent(textRange, xTextContent, true);
  setImageSize(image.width, image.height, oImage, imageProperties);
}

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

protected void insertImage(XComponent document, OfficeResourceProvider officeResourceProvider, XText destination, XTextRange textRange,
              Image image) throws Exception {
  XMultiServiceFactory xFactory = as(XMultiServiceFactory.class, document);
  XComponentContext xComponentContext = officeResourceProvider.getXComponentContext();
  XMultiComponentFactory serviceManager = xComponentContext.getServiceManager();
  Object oImage = xFactory.createInstance(TEXT_GRAPHIC_OBJECT);
  Object oGraphicProvider = serviceManager.createInstanceWithContext(GRAPHIC_PROVIDER_OBJECT, xComponentContext);
  XGraphicProvider xGraphicProvider = as(XGraphicProvider.class, oGraphicProvider);
  XPropertySet imageProperties = buildImageProperties(xGraphicProvider, oImage, image.imageContent);
  XTextContent xTextContent = as(XTextContent.class, oImage);
  destination.insertTextContent(textRange, xTextContent, true);
  setImageSize(image.width, image.height, oImage, imageProperties);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com