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


Java UnoRuntime类代码示例

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


UnoRuntime类属于com.sun.star.uno包,在下文中一共展示了UnoRuntime类的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: getScriptsInternal

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Collects scripts of the submitted type and library.
 * 
 * @param type type to be used (can be null - all types will be considered)
 * @param library library to be used
 * 
 * @return scripts of the submitted type and library
 * 
 * @author Andreas Bröker
 * @date 13.06.2006
 */
private IScript[] getScriptsInternal(String type, String library) {
	XBrowseNode rootNode = (XBrowseNode)UnoRuntime.queryInterface(XBrowseNode.class, scriptProvider);
	XBrowseNode[] typeNodes = rootNode.getChildNodes();
	List list = new ArrayList();
	for(int i=0, n=typeNodes.length; i<n; i++) {
		XBrowseNode typeNode = typeNodes[i];	
		if(type == null || typeNode.getName().equals(type)) {
			XBrowseNode libraryNode = getLibraryNode(typeNode, library);
			if(libraryNode != null) {
				buildScripts(list, libraryNode);
			}
		}
	}
	return (IScript[])list.toArray(new IScript[list.size()]);
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:27,代码来源:ScriptProvider.java

示例5: getTextTable

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Returns table with the submitted name.
 * 
 * @param name name of the table
 * 
 * @return table with the submitted name
 * 
 * @throws TextException if the table does not exist
 * 
 * @author Andreas Bröker
 */
public ITextTable getTextTable(String name) throws TextException {
  try {
    XTextTablesSupplier xTextTablesSupplier = (XTextTablesSupplier)UnoRuntime.queryInterface(XTextTablesSupplier.class, textDocument.getXTextDocument());
    XNameAccess xNameAccess = xTextTablesSupplier.getTextTables();
    Any any = (Any)xNameAccess.getByName(name);
    XTextTable textTable = (XTextTable)any.getObject();
    if(textTable.getColumns().getCount() <= ITextTable.MAX_COLUMNS_IN_TABLE) {
    	return new TextTable(textDocument, textTable);
    }
    else {
    	throw new TextException("The submitted table is not valid");
    }
  }
  catch(Exception exception) {
    TextException textException = new TextException(exception.getMessage());
    textException.initCause(exception);
    throw textException;
  }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:31,代码来源:TextTableService.java

示例6: getTextTables

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Returns all available text tables.
 * 
 * @return all available text tables
 * 
 * @author Andreas Bröker
 */
public ITextTable[] getTextTables() {
  XTextTablesSupplier xTextTablesSupplier = (XTextTablesSupplier)UnoRuntime.queryInterface(XTextTablesSupplier.class, textDocument.getXTextDocument());
  XNameAccess xNameAccess = xTextTablesSupplier.getTextTables();
  XIndexAccess xIndexAccess = (XIndexAccess)UnoRuntime.queryInterface(XIndexAccess.class, xNameAccess);
  ITextTable[] textTables = new ITextTable[xIndexAccess.getCount()];
  for(int i=0, n=xIndexAccess.getCount(); i<n; i++) {
    try {
      Any any = (Any)xIndexAccess.getByIndex(i);
      XTextTable textTable = (XTextTable)any.getObject();
      if(textTable.getColumns().getCount() <= ITextTable.MAX_COLUMNS_IN_TABLE) {
        textTables[i] = new TextTable(textDocument, textTable);
    	}
    }
    catch(Exception exception) {
      //do nothing
    }
  }
  return textTables;
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:27,代码来源:TextTableService.java

示例7: getActivePrinter

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Returns the active printer.
 * 
 * @return the active printer
 * 
 * @throws NOAException if printer could not be retrieved
 * 
 * @author Markus Krüger
 * @date 16.08.2007
 */
public IPrinter getActivePrinter() throws NOAException {
  try {
    XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(XPrintable.class, document.getXComponent());
    PropertyValue[] printerProps = xPrintable.getPrinter();
    String name = null;
    for(int i = 0; i < printerProps.length; i++) {
      if(printerProps[i].Name.equals("Name"))
        name = (String)printerProps[i].Value;
    }
    return new Printer(name);
  }
  catch(Throwable throwable) {
    throw new NOAException(throwable);
  }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:26,代码来源:PrintService.java

示例8: loadDocument

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Loads document from the submitted URL into the OpenOffice.org frame.
 * 
 * @param serviceProvider the service provider to be used
 * @param xFrame frame to used for document
 * @param URL URL of the document
 * @param searchFlags search flags for the target frame
 * @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, XFrame xFrame, String URL,
    int searchFlags, PropertyValue[] properties) throws Exception, IOException {
  if (xFrame != null) {
    if (properties == null) {
      properties = new PropertyValue[0];
    }
    XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,
        xFrame);
    return loadDocument(serviceProvider,
        xComponentLoader,
        URL,
        xFrame.getName(),
        searchFlags,
        properties);
  }
  return null;
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:32,代码来源:DocumentLoader.java

示例9: 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

示例10: getDocumentIndexes

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Returns available document indexes.
 * 
 * @return available document indexes
 * 
 * @author Andreas Bröker
 * @date 17.08.2006
 */
public IDocumentIndex[] getDocumentIndexes() {
  XDocumentIndexesSupplier documentIndexesSupplier = (XDocumentIndexesSupplier)UnoRuntime.queryInterface(XDocumentIndexesSupplier.class, textDocument);
  if(documentIndexesSupplier == null)
    return new IDocumentIndex[0];
  
  XIndexAccess indexAccess = documentIndexesSupplier.getDocumentIndexes();
  List list = new ArrayList();
  for(int i=0, n=indexAccess.getCount(); i<n; i++) {
    try {
      Object object = indexAccess.getByIndex(i);
      XDocumentIndex documentIndex = (XDocumentIndex)UnoRuntime.queryInterface(XDocumentIndex.class, object);
      if(documentIndex != null)
        list.add(new DocumentIndex(documentIndex));
    }
    catch(Throwable throwable) {
      //do not consume
    }
  }
  return (IDocumentIndex[])list.toArray(new IDocumentIndex[list.size()]);
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:29,代码来源:DocumentIndexService.java

示例11: getAnnotations

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Returns all annotations.
 * 
 * @return all annotations
 * 
 * @author Markus Krüger
 * @date 13.07.2006
 */
public IAnnotation[] getAnnotations() {
  try {
    ITextField[] fields = textDocument.getTextFieldService().getUserTextFields();
    List annotations = new ArrayList();
    for(int i = 0; i < fields.length; i++) {
      XServiceInfo info = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, fields[i].getXTextContent());
      if(info.supportsService(ITextFieldService.ANNOTATION_TEXTFIELD_ID)) {
        annotations.add(new Annotation(textDocument,fields[i]));
      }
    } 
    return (IAnnotation[]) annotations.toArray(new IAnnotation[annotations.size()]);
  }
  catch (Throwable throwable) {
    return new IAnnotation[0];
  }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:25,代码来源:AnnotationService.java

示例12: hideElement

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Hide UI element with the submitted resource URL.
 * 
 * @param resourceURL URL of the UI resource to be hidden
 * @param if changes should be persistent
 * 
 * @return information whether the UI resource is hidden after method call
 * 
 * @author Markus Krüger
 * @date 06.05.2010
 */
public boolean hideElement(String resourceURL, boolean persistent) {
  if (resourceURL != null) {
    try {
      XUIElement element = xLayoutManager.getElement(resourceURL);
      if (element != null) {
        XPropertySet xps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, element);
        xps.setPropertyValue("Persistent", new Boolean(persistent));
        return xLayoutManager.hideElement(resourceURL);
      }
    }
    catch (Exception e) {
      //ignore and return false
    }
  }
  return false;

}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:29,代码来源:LayoutManager.java

示例13: exportDocument

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Exports document on the basis of the submitted filter and URL.
 * 
 * @param document document to be exported
 * @param URL URL to be used
 * @param filter OpenOffice.org filter to be used
 * @param properties properties properties for OpenOffice.org
 * 
 * @throws IOException if any error occurs
 */
public static void exportDocument(IDocument document, String URL, IFilter filter, 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 = "FilterName"; 
  newProperties[properties.length].Value = filter.getFilterDefinition(document);
  
  XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, document.getXComponent());
  try {
    xStorable.storeToURL(URL, newProperties);
  }
  catch(com.sun.star.io.IOException ioException) {
    throw new IOException(ioException.getMessage());
  }    
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:33,代码来源:DocumentExporter.java

示例14: 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

示例15: getAutoHeight

import com.sun.star.uno.UnoRuntime; //导入依赖的package包/类
/**
 * Returns if the row height is set to automatically be adjusted or not.
 * 
 * @return if the row height is set to automatically be adjusted or not
 * 
 * @author Markus Krüger
 */
public boolean getAutoHeight() {
  if(textTableCellRange == null)
    return false;
  try {      
    XTextTable xTextTable = (XTextTable)textTableCellRange.getCell(0,0).getTextTable().getXTextContent();
    XTableRows tableRows = xTextTable.getRows();
    int rowIndex = textTableCellRange.getRangeName().getRangeStartRowIndex();
    Object row = tableRows.getByIndex(rowIndex);
    XPropertySet propertySetRow = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, row);
    Boolean rowAutoHeight = (Boolean)propertySetRow.getPropertyValue("IsAutoHeight");      
    return rowAutoHeight.booleanValue();
  }
  catch (Exception exception) {
    return false;
  }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:24,代码来源:TextTableRow.java


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