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


Java XDesktop类代码示例

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


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

示例1: getDesktopService

import com.sun.star.frame.XDesktop; //导入依赖的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

示例2: getCurrentDocuments

import com.sun.star.frame.XDesktop; //导入依赖的package包/类
/**
 * Returns current documents of an application.
 * 
 * @return documents of an application
 * 
 * @throws DocumentException if the documents cannot be provided
 * 
 * @author Markus Krüger
 * @date 11.11.2008
 */
public static IDocument[] getCurrentDocuments(IServiceProvider serviceProvider)
    throws DocumentException {
  try {
    if (serviceProvider == null)
      return new IDocument[0];
    Object desktop = serviceProvider.createService("com.sun.star.frame.Desktop"); //$NON-NLS-1$
    XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
    XEnumeration aktComponents = xDesktop.getComponents().createEnumeration();
    List arrayList = new ArrayList();
    while (aktComponents.hasMoreElements()) {
      Any a = (Any) aktComponents.nextElement();
      arrayList.add(DocumentLoader.getDocument((XComponent) a.getObject(), serviceProvider, null));
    }
    IDocument[] documents = new IDocument[arrayList.size()];
    documents = (IDocument[]) arrayList.toArray(documents);
    return documents;
  }
  catch (Exception exception) {
    throw new DocumentException(exception);
  }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:32,代码来源:DocumentService.java

示例3: getCurrentDocumentCount

import com.sun.star.frame.XDesktop; //导入依赖的package包/类
/**
 * Returns current number of documents of an application.
 * 
 * @param serviceProvider the serviceProvider to be used
 * 
 * @return number documents of an application
 * 
 * @author Markus Krüger
 * @date 11.11.2008
 */
public static int getCurrentDocumentCount(IServiceProvider serviceProvider)
    throws DocumentException {
  try {
    int i = 0;
    if (serviceProvider == null)
      return i;
    Object desktop = serviceProvider.createService("com.sun.star.frame.Desktop"); //$NON-NLS-1$
    XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
    XEnumeration aktComponents = xDesktop.getComponents().createEnumeration();
    while (aktComponents.hasMoreElements()) {
      aktComponents.nextElement();
      i++;
    }
    return i;
  }
  catch (Exception exception) {
    throw new DocumentException(exception);
  }
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:30,代码来源:DocumentService.java

示例4: getCurrentDesktop

import com.sun.star.frame.XDesktop; //导入依赖的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

示例5: getCurrentDesktop

import com.sun.star.frame.XDesktop; //导入依赖的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

示例6: getCurrentDesktop

import com.sun.star.frame.XDesktop; //导入依赖的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

示例7: doStopProcess

import com.sun.star.frame.XDesktop; //导入依赖的package包/类
private void doStopProcess() {
	try {
		XDesktop desktop = OfficeUtils.cast(XDesktop.class, connection.getService(OfficeUtils.SERVICE_DESKTOP));
		desktop.terminate();
	} catch (DisposedException disposedException) {
		// expected
	} catch (Exception exception) {
		// in case we can't get hold of the desktop
		doTerminateProcess();
	}
	doEnsureProcessExited();
}
 
开发者ID:qjx378,项目名称:wenku,代码行数:13,代码来源:ManagedOfficeProcess.java

示例8: stopOffice

import com.sun.star.frame.XDesktop; //导入依赖的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

示例9: getXDesktop

import com.sun.star.frame.XDesktop; //导入依赖的package包/类
/**
 * Returns the XDesktop interface from the OpenOffice.org desktop service.
 * 
 * @param xMultiServiceFactory factory in order to construct the service
 * 
 * @return XDesktop interface from the OpenOffice.org desktop service
 * 
 * @throws Exception if any error occurs
 */
public static XDesktop getXDesktop(XMultiServiceFactory xMultiServiceFactory) throws Exception {
	Object service = xMultiServiceFactory.createInstance("com.sun.star.frame.Desktop");
	if(service != null) {
		return (XDesktop)UnoRuntime.queryInterface(XDesktop.class, service);
	}
	else {
		return null;
	}
}
 
开发者ID:LibreOffice,项目名称:noa-libre,代码行数:19,代码来源:ServiceInterfaceSupplier.java

示例10: getXComponent

import com.sun.star.frame.XDesktop; //导入依赖的package包/类
private XComponent getXComponent() {
  try {
    final XMultiComponentFactory xMCF = xContext.getServiceManager();
    final Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
    final XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, desktop);
    return xDesktop.getCurrentComponent();
  } catch (final Throwable t) {
    showError(t);
    return null;
  }
}
 
开发者ID:prowritingaid,项目名称:openoffice-extension,代码行数:12,代码来源:Main.java

示例11: simpleBootstrap

import com.sun.star.frame.XDesktop; //导入依赖的package包/类
private XDesktop simpleBootstrap(String pathToExecutable)
        throws IllegalAccessException, InvocationTargetException, BootstrapException,
        CreationException, IOException {

    ClassLoader loader = ClassLoader.getSystemClassLoader();
    if (loader instanceof URLClassLoader) {
        URLClassLoader cl = (URLClassLoader) loader;
        Class<URLClassLoader> sysclass = URLClassLoader.class;
        try {
            Method method = sysclass.getDeclaredMethod("addURL", URL.class);
            method.setAccessible(true);
            method.invoke(cl, new File(pathToExecutable).toURI().toURL());
        } catch (SecurityException | NoSuchMethodException | MalformedURLException t) {
            LOGGER.error("Error, could not add URL to system classloader", t);
            cl.close();
            throw new IOException("Error, could not add URL to system classloader", t);
        }
    } else {
        LOGGER.error("Error occured, URLClassLoader expected but " + loader.getClass()
                + " received. Could not continue.");
    }

    //Get the office component context:
    XComponentContext xContext = Bootstrap.bootstrap();
    //Get the office service manager:
    XMultiComponentFactory xServiceManager = xContext.getServiceManager();
    //Create the desktop, which is the root frame of the
    //hierarchy of frames that contain viewable components:
    Object desktop;
    try {
        desktop = xServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
    } catch (Exception e) {
        throw new CreationException(e.getMessage());
    }
    XDesktop resultDesktop = UnoRuntime.queryInterface(XDesktop.class, desktop);

    UnoRuntime.queryInterface(XComponentLoader.class, desktop);

    return resultDesktop;
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:41,代码来源:OOBibBase.java

示例12: disconnect

import com.sun.star.frame.XDesktop; //导入依赖的package包/类
/**
 * Disconnects from an OOo server using the connection string from the
 * previous connect.
 * 
 * If there has been no previous connect, the disconnects does nothing.
 * 
 * If there has been a previous connect, disconnect tries to terminate
 * the OOo server and kills the OOo server process the connect started.
 */
public void disconnect() {

    if (oooConnectionString == null)
        return;

    // call office to terminate itself
    try {
        // get local context
        XComponentContext xLocalContext = getLocalContext();

        // create a URL resolver
        XUnoUrlResolver xUrlResolver = UnoUrlResolver.create(xLocalContext);

        // get remote context
        XComponentContext xRemoteContext = getRemoteContext(xUrlResolver);

        // get desktop to terminate office
        Object desktop = xRemoteContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.Desktop",xRemoteContext);
        XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
        xDesktop.terminate();
    }
    catch (Exception e) {
        // Bad luck, unable to terminate office
    }

    oooServer.kill();
    oooConnectionString = null;
}
 
开发者ID:cuba-platform,项目名称:yarg,代码行数:38,代码来源:BootstrapConnector.java

示例13: getCurrentComponent

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

示例14: getCurrentComponent

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

示例15: getViewCursor

import com.sun.star.frame.XDesktop; //导入依赖的package包/类
/** 
 * Returns ViewCursor 
 * Returns null if it fails
 */
@Nullable
private static XTextViewCursor getViewCursor(XComponentContext xContext) {
  try {
    XDesktop xDesktop = getCurrentDesktop(xContext);
    if(xDesktop == null) {
      return null;
    }
    XComponent xCurrentComponent = xDesktop.getCurrentComponent();
    if(xCurrentComponent == null) {
      return null;
    }
    XModel xModel = UnoRuntime.queryInterface(XModel.class, xCurrentComponent);
    if(xModel == null) {
      return null;
    }
    XController xController = xModel.getCurrentController();
    if(xController == null) {
      return null;
    }
    XTextViewCursorSupplier xViewCursorSupplier =
        UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
    if(xViewCursorSupplier == null) {
      return null;
    }
    return xViewCursorSupplier.getViewCursor();
  } catch (Exception e) {
    printException(e);     // all Exceptions thrown by UnoRuntime.queryInterface are caught
    return null;           // Return null as method failed
  }
}
 
开发者ID:languagetool-org,项目名称:languagetool,代码行数:35,代码来源:LOCursor.java


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