本文整理汇总了Java中com.sun.star.frame.XDesktop.getCurrentComponent方法的典型用法代码示例。如果您正苦于以下问题:Java XDesktop.getCurrentComponent方法的具体用法?Java XDesktop.getCurrentComponent怎么用?Java XDesktop.getCurrentComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.star.frame.XDesktop
的用法示例。
在下文中一共展示了XDesktop.getCurrentComponent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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
}
}
示例3: 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
}
}
示例4: 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
}
}
示例5: getXComponent
import com.sun.star.frame.XDesktop; //导入方法依赖的package包/类
@Nullable
private XComponent getXComponent() {
try {
XMultiComponentFactory xMCF = xContext.getServiceManager();
Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, desktop);
return xDesktop.getCurrentComponent();
} catch (Throwable t) {
showError(t);
return null;
}
}
示例6: getCurrentComponent
import com.sun.star.frame.XDesktop; //导入方法依赖的package包/类
/**
* Gets the current component.
* @return the current component
* @throws Exception
* the exception
*/
public static XComponent getCurrentComponent() throws Exception {
XComponentContext xRemoteContext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
// XComponentContext xRemoteContext =
// com.sun.star.comp.helper.Bootstrap.bootstrap();
XMultiComponentFactory xRemoteServiceManager = xRemoteContext.getServiceManager();
Object desktop = xRemoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", xRemoteContext); //$NON-NLS-1$
XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop);
XComponent currentComponent = xDesktop.getCurrentComponent();
return currentComponent;
}