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


Java UnoRuntime.queryInterface方法代码示例

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


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

示例1: print

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
public void print(String printerName, int amount, boolean blocking) {
    XPrintable xPrintable = UnoRuntime.queryInterface(com.sun.star.view.XPrintable.class, doc);

    if (printerName != null) {
        PropertyValue[] printerProps = new PropertyValue[1];
        printerProps[0] = new PropertyValue();
        printerProps[0].Name = "Name";
        printerProps[0].Value = printerName;
        xPrintable.setPrinter(printerProps);
    }

    PropertyValue[] printJobProps = new PropertyValue[2];
    printJobProps[0] = new PropertyValue();
    printJobProps[0].Name = "CopyCount";
    printJobProps[0].Value = amount;

    printJobProps[1] = new PropertyValue();
    printJobProps[1].Name = "Wait";
    printJobProps[1].Value = blocking;

    xPrintable.print(printJobProps);
}
 
开发者ID:kamax-io,项目名称:libreoffice4j,代码行数:23,代码来源:SpreadsheetDocument.java

示例2: saveTo

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
public File saveTo(File location) {
    try {
        location = location.getAbsoluteFile();
        String targetUrl = "file://" + location.toString();

        XStorable xStorable = UnoRuntime.queryInterface(XStorable.class, doc);
        PropertyValue[] docArgs = new PropertyValue[1];
        docArgs[0] = new PropertyValue();
        docArgs[0].Name = "Overwrite";
        docArgs[0].Value = Boolean.TRUE;
        xStorable.storeAsURL(targetUrl, docArgs);

        return location;
    } catch (IOException e) {
        throw new LibreOfficeException(e);
    }
}
 
开发者ID:kamax-io,项目名称:libreoffice4j,代码行数:18,代码来源:SpreadsheetDocument.java

示例3: showMessageBox

import com.sun.star.uno.UnoRuntime; //导入方法依赖的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

示例4: getDesktopService

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
/**
 * Returns desktop service of the application.
 * 
 * @return desktop service of the application
 * 
 * @throws OfficeApplicationException if the desktop service is not available
 * 
 * @author Andreas Bröker
 */
public IDesktopService getDesktopService() throws OfficeApplicationException {
  try {
    if (officeConnection == null)
      throw new OfficeApplicationException("Application is not active.");

    if (desktopService == null) {
      Object service = officeConnection.createService("com.sun.star.frame.Desktop");
      XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, service);
      desktopService = new DesktopService(desktop, officeConnection);
    }
    return desktopService;
  }
  catch (Exception exception) {
    OfficeApplicationException officeApplicationException = new OfficeApplicationException(exception.getMessage());
    officeApplicationException.initCause(exception);
    throw officeApplicationException;
  }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:28,代码来源:AbstractOfficeApplication.java

示例5: addDocumentListener

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
/**
 * Adds new document listener. Uses GlobalEventBroadcaster to listen to any events on any document.
 * 
 * @param documentListener new document listener
 * 
 * @throws DesktopException if document listener can not be registered
 * 
 * @author Markus Krüger
 */
public void addDocumentListener(IDocumentListener documentListener) throws DesktopException {      
  try {
    if(documentListeners == null)
      documentListeners = new Hashtable();      
    if(eventBroadcaster == null) {
     Object globalEventBroadcaster = officeConnection.getXMultiServiceFactory().createInstance( "com.sun.star.frame.GlobalEventBroadcaster" );
     eventBroadcaster = (XEventBroadcaster) UnoRuntime.queryInterface(XEventBroadcaster.class, globalEventBroadcaster);
    }
    DocumentListenerWrapper documentListenerWrapper = new DocumentListenerWrapper(documentListener,
        new ServiceProvider(officeConnection));
    eventBroadcaster.addEventListener(documentListenerWrapper);
    documentListeners.put(documentListener, documentListenerWrapper);
  } 
  catch (Exception exception) {
    throw new DesktopException(exception);
  }   
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:27,代码来源:DesktopService.java

示例6: getXEventAttacherManager

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
/**
 * Returns the OpenOffice.org XEventAttacherManager interface for the given form,
 * or null if not available.
 * 
 * @param form the form to be used
 * 
 * @return the OpenOffice.org XEventAttacherManager interface for the given form,
 * or null
 * 
 * @throws NOAException if the return of OpenOffice.org XEventAttacherManager interface fails
 * 
 * @author Markus Krüger
 * @date 26.01.2007
 */
public XEventAttacherManager getXEventAttacherManager(IForm form) throws NOAException {
  try {
    if(form != null) {
      XFormsSupplier formsSupplier = (XFormsSupplier) UnoRuntime.queryInterface(XFormsSupplier.class, xDrawPage);
      if(formsSupplier != null) {
        XNameContainer nameContainer = formsSupplier.getForms();
        XIndexContainer indexContainer = (XIndexContainer) UnoRuntime.queryInterface(XIndexContainer.class, nameContainer);
        int len = indexContainer.getCount();
        for(int i = 0; i < len; i++) { 
          XForm tmpForm = (XForm) UnoRuntime.queryInterface(XForm.class, indexContainer.getByIndex(i));
          if(tmpForm != null && UnoRuntime.areSame(form.getXFormComponent(),tmpForm)) {
            XEventAttacherManager tmpEventAttacherManager = 
              (XEventAttacherManager) UnoRuntime.queryInterface(XEventAttacherManager.class, tmpForm);
            return tmpEventAttacherManager;
          }
        }
      }
    }
    return null;
  }
  catch(Throwable throwable) {
    throw new NOAException(throwable);
  }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:39,代码来源:FormService.java

示例7: loadDocument

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
/**
 * Loads document on the basis of the submitted XInputStream implementation.
 * 
 * @param serviceProvider the service provider to be used
 * @param xInputStream OpenOffice.org XInputStream inplementation
 * @param properties properties for OpenOffice.org
 * 
 * @return loaded Document
 * 
 * @throws Exception if an OpenOffice.org communication error occurs
 * @throws IOException if document can not be found
 */
public static IDocument loadDocument(IServiceProvider serviceProvider, XInputStream xInputStream,
    PropertyValue[] properties) throws Exception, IOException {
  if (properties == null) {
    properties = new PropertyValue[0];
  }
  PropertyValue[] newProperties = new PropertyValue[properties.length + 1];
  for (int i = 0; i < properties.length; i++) {
    newProperties[i] = properties[i];
  }
  newProperties[properties.length] = new PropertyValue();
  newProperties[properties.length].Name = "InputStream";
  newProperties[properties.length].Value = xInputStream;

  Object oDesktop = serviceProvider.createServiceWithContext("com.sun.star.frame.Desktop");
  XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,
      oDesktop);
  return loadDocument(serviceProvider,
      xComponentLoader,
      "private:stream",
      "_blank",
      0,
      newProperties);
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:36,代码来源:DocumentLoader.java

示例8: getText

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
/**
 * Returns the text content of the annotation, or null if text content is not available.
 * 
 * @return the text content of the annotation, or null
 * 
 * @author Markus Krüger
 * @date 13.07.2006
 */
public String getText() {
  XServiceInfo info = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, getXTextContent());
  if(info.supportsService(ITextFieldService.ANNOTATION_TEXTFIELD_ID)) {
    XPropertySet properties = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getXTextContent());
    try {
      return (String) properties.getPropertyValue("Content");
    }
    catch(UnknownPropertyException unknownPropertyException) {
      //TODO exception handling if needed, do nothing for now
    }
    catch(WrappedTargetException wrappedTargetException) {
      //TODO exception handling if needed, do nothing for now
    }
  }
  return null;
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:25,代码来源:Annotation.java

示例9: storeDocument

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
/**
 * Stores document on the basis of the submitted xOutputStream implementation.
 * 
 * @param document document to be stored
 * @param xOutputStream OpenOffice.org XOutputStream inplementation
 * @param properties properties for OpenOffice.org
 * 
 * @throws IOException if any error occurs
 */
public static void storeDocument(IDocument document, XOutputStream xOutputStream, PropertyValue[] properties) 
throws IOException {
  if(properties == null) {
    properties = new PropertyValue[0];
  }
  
  PropertyValue[] newProperties = new PropertyValue[properties.length + 1];
  for(int i=0; i<properties.length; i++) {
    newProperties[i] = properties[i];
  }
  newProperties[properties.length] = new PropertyValue(); 
  newProperties[properties.length].Name = "OutputStream"; 
  newProperties[properties.length].Value = xOutputStream;
  
  XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, document.getXComponent());
  try {
    xStorable.storeToURL("private:stream", newProperties);
  }
  catch(com.sun.star.io.IOException ioException) {
    throw new IOException(ioException.getMessage());
  }    
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:32,代码来源:DocumentWriter.java

示例10: initContext

import com.sun.star.uno.UnoRuntime; //导入方法依赖的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: close

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
public void close() {
    try {
        XCloseable xCloseable = UnoRuntime.queryInterface(XCloseable.class, doc);

        if (xCloseable == null) {
            throw new IllegalStateException("XSpreadsheet is not closable");
        }

        xCloseable.close(false);
    } catch (CloseVetoException e) {
        throw new LibreOfficeException(e);
    }
}
 
开发者ID:kamax-io,项目名称:libreoffice4j,代码行数:14,代码来源:SpreadsheetDocument.java

示例12: getFilterNames

import com.sun.star.uno.UnoRuntime; //导入方法依赖的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

示例13: getCurrentDesktop

import com.sun.star.uno.UnoRuntime; //导入方法依赖的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.UnoRuntime; //导入方法依赖的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: stopOffice

import com.sun.star.uno.UnoRuntime; //导入方法依赖的package包/类
private void stopOffice() {
    try {
        if (componentContext != null) {
            // Only the uno test suite which started the office can stop it
            XMultiComponentFactory xMngr = componentContext.getServiceManager();
            Object oDesktop = xMngr.createInstanceWithContext("com.sun.star.frame.Desktop", componentContext);
            XDesktop xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class, oDesktop);
            
            xDesktop.terminate();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:indic-ocr,项目名称:LibreOCR,代码行数:15,代码来源:UnoSuite.java


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