- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.sun.star.lang.XMultiServiceFactory.createInstance()
方法的一些代码示例,展示了XMultiServiceFactory.createInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMultiServiceFactory.createInstance()
方法的具体详情如下:
包路径:com.sun.star.lang.XMultiServiceFactory
类名称: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);
}
这些调用有什么区别? 最佳答案 没有。 Assembly.CreateInstance 实际上在幕后调用了 Activator.CreateInstance。 在 Assembly.CreateIns
1)如果我们想在运行时创建给定类型的实例(因此使用后期绑定(bind)),那么我们需要调用 Activator.CreateInstance。但是如果Type类有这样的方法不是更高效吗?如果不出意外,
我想问一个问题来了解AppDomain和Activator之间的区别,我通过appdomain.CreateInstance加载了我的dll。但我意识到更多的方法来创建实例。因此,我何时何地选择这种方
这些调用有什么区别? 最佳答案 没有。 Assembly.CreateInstance 实际上在幕后调用了 Activator.CreateInstance。 在 Assembly.CreateIns
不,这不是关于泛型的问题。 我有一个工厂模式,其中包含几个带有内部构造函数的类(如果不通过工厂,我不希望它们被实例化)。 我的问题是 CreateInstance 失败并出现“没有为此对象定义无参数构
如果这个问题已经被问过和回答过,请原谅我。 给定一个类型为 T 的类,下面的区别是什么? T myObj = Activator.CreateInstance(); T myObj = typeof(
我正在尝试将插件系统与 .NET 放在一起,但我不确定我是否正确地做。系统的基础是一个特定的目录({apppath}/Plugins/)会有一堆预编译的DLL,我想用反射查看每一个,对于每个可用的类,
我需要获取 DataContext 的子类,我在某处找到了下面的函数,它确实找到了我的子类,但我无法实例化它:( public static IEnumerable GetSubclassesFo
这是我的构造函数: CMSATools::CMSATools() { m_pInterface = NULL; HRESULT hr; hr = m_pInterface.Cr
当我们使用 AppDomain.CreateInstance("Assembly name", Type name) 我的类继承自 MarshalByRefObject 内部发生了什么?它是否创建了一
我做了以下创建接口(interface)实例的方法。 static IFBIndexItem* CreateFBIndexItemPtr() { IFBIndexItemPtr pFBComW
我一直在我的一些代码中使用 Activator.CreateInstance()。使用它创建实例有任何风险吗? 最佳答案 好吧,你的代码存在弱类型的风险,你不会发现你不小心尝试将它与一个直到执行时才没
我想我缺乏了解,究竟发生了什么: 用户可以输入程序集的路径和对象类型,然后我尝试创建它的实例。 我的做法: Assembly a = Assembly.LoadFile(txtAsse
什么是System.Activator.CreateInstance,什么时候应该使用它? 最佳答案 它允许您创建其类型仅在运行时已知的对象的实例。因此,假设您有一些类(class) public c
有谁知道如何使用只有 1 个可选参数的构造函数来实例化一个类? 我都试过了 (T)Activator.CreateInstance(typeof(T), new object[] { Type.Mis
我们有一些使用 MSXML 的代码,这样做是为了创建 XML 文档对象: MSXML2::IXMLDOMDocumentPtr doc_in; doc_in.CreateInstance("Msxm
使用这段代码: public static class ChocolateFactory { private static Func Func { get; set; } static
我想将变量从一种形式传递到另一种形式。 这是 form2 中的构造函数: public Form2 (int getId,string getText) 在 form1 中我试图像这样传递变量 var
Activator.CreateInstance 和工厂有什么区别?它们可以互换使用吗?或者我们还需要工厂模式吗? 最佳答案 Activator.CreateInstance是一个静态方法,它使用该类
拥有Remember.cs: namespace Tasks { public class Remember : Task { new public string na
我是一名优秀的程序员,十分优秀!