gpt4 book ai didi

java - LibreOffice OpenOffice 容器窗口标题文本 java、C++

转载 作者:行者123 更新时间:2023-11-30 08:49:11 24 4
gpt4 key购买 nike

我正在使用 LibreOffice SDK。我正在测试打开编写器并在其中插入文本。但是我还没有找到使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com