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

标签 java sdk openoffice.org libreoffice titlebar

我正在使用 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/

相关文章:

java - 如何在android上全屏显示ImageView?

android - 如果我使用 Android 4 平台编写应用程序,该应用程序可以在 Android 2 设备上运行吗?

c# - Azure SDK C# - 获取自定义域验证 ID

regex - OpenOffice.org:正则表达式 - 跳过第一个匹配项

vba - 如何将 Excel VBA 宏移植到 OpenOffice 宏?

java - 在 servlet 过滤器中提交响应后无法转发

java - Android 主页按钮箭头方向

java - 在接口(interface)中声明枚举时出错

Android 从命令行构建 .jar 失败

java - 使用 Java 获取 Open Office 中的工作表数量