我正在使用 LibreOffice SDK。我正在测试打开 writer 并在其中插入文本。但我还没有找到使用SDK访问窗口标题栏标题的方法。
public class DocumentLoader {
public static void main(String args[]) {
if ( args.length < 1 ) {
System.out.println(
"usage: java -jar DocumentLoader.jar \"<URL|path>\"" );
System.out.println( "\ne.g.:" );
System.out.println(
"java -jar DocumentLoader.jar \"private:factory/swriter\"" );
System.exit(1);
}
com.sun.star.uno.XComponentContext xContext = null;
try {
// get the remote office component context
xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
// get the remote office service manager
com.sun.star.lang.XMultiComponentFactory xMCF =
xContext.getServiceManager();
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext);
com.sun.star.frame.XComponentLoader xCompLoader =
UnoRuntime.queryInterface(
com.sun.star.frame.XComponentLoader.class, oDesktop);
String sUrl = args[0];
if ( sUrl.indexOf("private:") != 0) {
java.io.File sourceFile = new java.io.File(args[0]);
StringBuffer sbTmp = new StringBuffer("file:///");
sbTmp.append(sourceFile.getCanonicalPath().replace('\\', '/'));
sUrl = sbTmp.toString();
}
// Load a Writer document, which will be automatically displayed
com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
sUrl, "_blank", 0, new com.sun.star.beans.PropertyValue[0]);
com.sun.star.lang.XComponent xTextDocument = UnoRuntime.queryInterface(
com.sun.star.frame.XTextDocument.class, xComp);
if ( xComp != null )
System.exit(0);
else
System.exit(1);
}
catch( Exception e ) {
e.printStackTrace(System.err);
System.exit(1);
}
}
}
因为我有 xTextDocument,所以我可以获得大小和不同的属性。
例如xTextDocument.getCurrentController().getFrame().getcontainerWindow().getPosSize();
但是如何获取标题栏文本呢?
最佳答案
经过长时间的尝试,我找到了解决方案。
我已经使用 XTitle 修复了它。该接口(interface)可用于将窗口的转换框架键入 XTitle。然后就可以正常工作了。
关于java - LibreOffice OpenOffice 容器窗口标题文本 java、C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31564223/