当前位置: 首页>>代码示例>>Java>>正文


Java XComponentContext类代码示例

本文整理汇总了Java中com.sun.star.uno.XComponentContext的典型用法代码示例。如果您正苦于以下问题:Java XComponentContext类的具体用法?Java XComponentContext怎么用?Java XComponentContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XComponentContext类属于com.sun.star.uno包,在下文中一共展示了XComponentContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showMessageBox

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
public static void showMessageBox(XComponentContext context, XDialog dialog, MessageBoxType type, String sTitle, String sMessage) {
	XToolkit xToolkit;
	try {
		xToolkit = UnoRuntime.queryInterface(XToolkit.class,
					context.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit", context));
	} catch (Exception e) {
		return;
	}
	XMessageBoxFactory xMessageBoxFactory = UnoRuntime.queryInterface(XMessageBoxFactory.class, xToolkit);
	XWindowPeer xParentWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, dialog);
       XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(xParentWindowPeer, type,
       		com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, sTitle, sMessage);
       if (xMessageBox == null)
       	return;
       
       xMessageBox.execute();
}
 
开发者ID:smehrbrodt,项目名称:libreoffice-starter-extension,代码行数:18,代码来源:DialogHelper.java

示例2: connect

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/**
 * Establishes the connection to the office.
 * 
 * @return constructed component context
 * 
 * @author Andreas Bröker
 */
private XComponentContext connect() {
	try {
		if (officeProgressMonitor != null)
			officeProgressMonitor
					.beginSubTask(Messages
							.getString("LocalOfficeConnectionGhost_monitor_constructing_initial_context_message")); //$NON-NLS-1$

		XComponentContext xContext = Bootstrap.bootstrap();
		return xContext;
	} catch (java.lang.Exception exception) {
		System.out.println("java.lang.Exception: "); //$NON-NLS-1$
		System.out.println(exception);
		exception.printStackTrace();
		System.out.println("--- end."); //$NON-NLS-1$
		throw new com.sun.star.uno.RuntimeException(exception.toString());
	}
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:25,代码来源:LocalOfficeConnectionGhost.java

示例3: openConnection

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/**
 * Opens connection to OpenOffice.org.
 * 
 * @return information whether the connection is available
 * 
 * @throws Exception if any error occurs
 */
public boolean openConnection() throws Exception {
  String unoUrl = "uno:socket,host=" + host + ",port=" + port +";urp;StarOffice.ServiceManager";
  XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
  Object connector = xLocalContext.getServiceManager().createInstanceWithContext("com.sun.star.connection.Connector", xLocalContext);
  XConnector xConnector = (XConnector) UnoRuntime.queryInterface(XConnector.class, connector);
  
  String url[] = parseUnoUrl(unoUrl);
  if (null == url) {
    throw new com.sun.star.uno.Exception("Couldn't parse UNO URL "+ unoUrl);
  }
  
  XConnection connection = xConnector.connect(url[0]);
  Object bridgeFactory = xLocalContext.getServiceManager().createInstanceWithContext("com.sun.star.bridge.BridgeFactory", xLocalContext);
  XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime.queryInterface(XBridgeFactory.class, bridgeFactory);
  xBridge = xBridgeFactory.createBridge("", url[1], connection ,null);
  bridgeFactory = xBridge.getInstance(url[2]);
  xMultiComponentFactory = (XMultiComponentFactory)UnoRuntime.queryInterface(XMultiComponentFactory.class, bridgeFactory);
  XPropertySet xProperySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xMultiComponentFactory);
  Object remoteContext = xProperySet.getPropertyValue("DefaultContext");
  xRemoteContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, remoteContext);
  xMultiServiceFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xMultiComponentFactory);
  isConnectionEstablished = true;
  return true;      
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:32,代码来源:RemoteOfficeConnection.java

示例4: insertImage

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
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);
}
 
开发者ID:cuba-platform,项目名称:yarg,代码行数:17,代码来源:AbstractInliner.java

示例5: open

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
public void open() throws OpenOfficeException {
    if (this.closed) {
        try {
            XComponentContext localContext = bsc.connect("127.0.0.1", port);
            String connectionString = "socket,host=127.0.0.1,port=" + port;
            XMultiComponentFactory localServiceManager = localContext.getServiceManager();
            XConnector connector = as(XConnector.class,
                    localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext));
            XConnection connection = connector.connect(connectionString);
            XBridgeFactory bridgeFactory = as(XBridgeFactory.class,
                    localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext));
            String bridgeName = "yarg_" + bridgeIndex.incrementAndGet();
            XBridge bridge = bridgeFactory.createBridge(bridgeName, "urp", connection, null);
            XMultiComponentFactory serviceManager = as(XMultiComponentFactory.class, bridge.getInstance("StarOffice.ServiceManager"));
            XPropertySet properties = as(XPropertySet.class, serviceManager);
            xComponentContext = as(XComponentContext.class, properties.getPropertyValue("DefaultContext"));

            officeResourceProvider = new OfficeResourceProvider(xComponentContext, officeIntegration);
            closed = false;
        } catch (Exception e) {
            close();
            throw new OpenOfficeException("Unable to create Open office components.", e);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:yarg,代码行数:26,代码来源:OfficeConnection.java

示例6: getCurrentDesktop

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/**
 * Returns the current XDesktop
 * Returns null if it fails
 */
@Nullable
private static XDesktop getCurrentDesktop(XComponentContext xContext) throws Exception {
  try {
    if (xContext == null) {
      return null;
    }
    XMultiComponentFactory xMCF = UnoRuntime.queryInterface(XMultiComponentFactory.class,
            xContext.getServiceManager());
    if (xMCF == null) {
      return null;
    }
    Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
    if (desktop == null) {
      return null;
    }
    return UnoRuntime.queryInterface(XDesktop.class, desktop);
  } catch (Exception e) {
    printException(e);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
    return null;           // Return null as method failed
  }
}
 
开发者ID:languagetool-org,项目名称:languagetool,代码行数:26,代码来源:LOFlatParagraph.java

示例7: getXFlatParagraphIterator

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/**
 * Returns XFlatParagraphIterator 
 * Returns null if it fails
 */
@Nullable
private static XFlatParagraphIterator getXFlatParagraphIterator (XComponentContext xContext) throws Exception {
  try {
    XComponent xCurrentComponent = getCurrentComponent(xContext);
    if(xCurrentComponent == null) {
      return null;
    }
    XFlatParagraphIteratorProvider xFlatParaItPro 
        = UnoRuntime.queryInterface(XFlatParagraphIteratorProvider.class, xCurrentComponent);
    if(xFlatParaItPro == null) {
      return null;
    }
    return xFlatParaItPro.getFlatParagraphIterator(TextMarkupType.PROOFREADING, true);
  } catch (Exception e) {
    printException(e);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
    return null;           // Return null as method failed
  }
}
 
开发者ID:languagetool-org,项目名称:languagetool,代码行数:23,代码来源:LOFlatParagraph.java

示例8: getCurrentDesktop

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/**
 * Returns the current XDesktop
 * Returns null if it fails
 */
@Nullable
private static XDesktop getCurrentDesktop(XComponentContext xContext) {
  try {
    if (xContext == null) {
      return null;
    }
    XMultiComponentFactory xMCF = UnoRuntime.queryInterface(XMultiComponentFactory.class,
            xContext.getServiceManager());
    if (xMCF == null) {
      return null;
    }
    Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
    if (desktop == null) {
      return null;
    }
    return UnoRuntime.queryInterface(XDesktop.class, desktop);
  } catch (Exception e) {
    printException(e);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
    return null;           // Return null as method failed
  }
}
 
开发者ID:languagetool-org,项目名称:languagetool,代码行数:26,代码来源:LOCursor.java

示例9: getCursor

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/** 
 * Returns the text cursor (if any)
 * Returns null if it fails
 */
@Nullable
private static XTextCursor getCursor(XComponentContext xContext) {
  try {
    XTextDocument curdoc = getCurrentDocument(xContext);
    if (curdoc == null) {
      return null;
    }
    XText xText = curdoc.getText();
    if (xText == null) {
      return null;
    }
    else return xText.createTextCursor();
  } catch (Exception e) {
    printException(e);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
    return null;           // Return null as method failed
  }
}
 
开发者ID:languagetool-org,项目名称:languagetool,代码行数:22,代码来源:LOCursor.java

示例10: initContext

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
private static XComponentLoader initContext() {
    try {
        XComponentContext xContext = Bootstrap.bootstrap();
        XMultiComponentFactory xMCF = xContext.getServiceManager();
        Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
        return UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);
    } catch (Exception e) {
        throw new LibreOfficeException(e);
    }
}
 
开发者ID:kamax-io,项目名称:libreoffice4j,代码行数:11,代码来源:LibreOfficeManager.java

示例11: getFilterNames

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
public static List getFilterNames(XMultiComponentFactory xmulticomponentfactory) throws Exception {
    XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory);
    Object oDefaultContext = xPropertySet.getPropertyValue("DefaultContext");
    XComponentContext xComponentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, oDefaultContext);


    Object filterFactory = xmulticomponentfactory.createInstanceWithContext("com.sun.star.document.FilterFactory", xComponentContext);
    XNameAccess xNameAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, filterFactory);
    String [] filterNames = xNameAccess.getElementNames();

    //String [] serviceNames = filterFactory.getAvailableServiceNames();
    for (int i=0; i < filterNames.length; i++) {
        String s = filterNames[i];
        Debug.logInfo(s, module);
        /*
        if (s.toLowerCase().indexOf("filter") >= 0) {
            Debug.logInfo("FILTER: " + s, module);
        }
        if (s.toLowerCase().indexOf("desktop") >= 0) {
            Debug.logInfo("DESKTOP: " + s, module);
        }
        */
    }

    List filterNameList = UtilMisc.toListArray(filterNames);
    return filterNameList;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:28,代码来源:OpenOfficeWorker.java

示例12: convertToUrl

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
public static String convertToUrl(String filePath, XComponentContext xComponentContext) throws MalformedURLException {

        String returnUrl = null;
        File f = new File(filePath);
        URL u = f.toURL();
        returnUrl =  ExternalUriReferenceTranslator.create(xComponentContext).translateToInternal(u.toExternalForm());

        return returnUrl;
    }
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:10,代码来源:OpenOfficeWorker.java

示例13: getCurrentDesktop

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/** Returns the curerent XDesktop */
public static XDesktop getCurrentDesktop(XComponentContext xContext) {
	XMultiComponentFactory xMCF = (XMultiComponentFactory) UnoRuntime.queryInterface(XMultiComponentFactory.class,
			xContext.getServiceManager());
       Object desktop = null;
	try {
		desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
	} catch (Exception e) {
		return null;
	}
       return (XDesktop) UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop);
}
 
开发者ID:smehrbrodt,项目名称:libreoffice-starter-extension,代码行数:13,代码来源:DocumentHelper.java

示例14: createDialog

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/**
 * Create a dialog from an xdl file.
 *
 * @param xdlFile
 *            The filename in the `dialog` folder
 * @param context
 * @return XDialog
 */
public static XDialog createDialog(String xdlFile, XComponentContext context, XDialogEventHandler handler) {
	Object oDialogProvider;
	try {
		oDialogProvider = context.getServiceManager().createInstanceWithContext("com.sun.star.awt.DialogProvider2",
				context);
		XDialogProvider2 xDialogProv = (XDialogProvider2) UnoRuntime.queryInterface(XDialogProvider2.class,
				oDialogProvider);
		File dialogFile = FileHelper.getDialogFilePath(xdlFile, context);
		return xDialogProv.createDialogWithHandler(convertToURL(context, dialogFile), handler);
	} catch (Exception e) {
		return null;
	}
}
 
开发者ID:smehrbrodt,项目名称:libreoffice-starter-extension,代码行数:22,代码来源:DialogHelper.java

示例15: convertToURL

import com.sun.star.uno.XComponentContext; //导入依赖的package包/类
/** Returns a URL to be used with XDialogProvider to create a dialog */
public static String convertToURL(XComponentContext xContext, File dialogFile) {
	String sURL = null;
	try {
		com.sun.star.ucb.XFileIdentifierConverter xFileConverter = (com.sun.star.ucb.XFileIdentifierConverter) UnoRuntime
				.queryInterface(com.sun.star.ucb.XFileIdentifierConverter.class, xContext.getServiceManager()
						.createInstanceWithContext("com.sun.star.ucb.FileContentProvider", xContext));
		sURL = xFileConverter.getFileURLFromSystemPath("", dialogFile.getAbsolutePath());
	} catch (com.sun.star.uno.Exception ex) {
		return null;
	}
	return sURL;
}
 
开发者ID:smehrbrodt,项目名称:libreoffice-starter-extension,代码行数:14,代码来源:DialogHelper.java


注:本文中的com.sun.star.uno.XComponentContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。