如何找到com.sun.star.uno.RuntimeException的真正原因?

发布于 2024-07-13 09:00:22 字数 1574 浏览 4 评论 0原文

我正在尝试使用 OpenOffice Java API 替换 OpenOffice 文档中的字段。 我正在使用 insertString 方法:

  xText.insertString(((XTextField) fieldMaster).getAnchor(), value.toString(), false);

堆栈跟踪如下:

    [junit] com.sun.star.uno.RuntimeException: 
    [junit]     at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:182)
    [junit]     at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:148)
    [junit]     at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:344)
    [junit]     at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:313)
    [junit]     at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:101)
    [junit]     at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:652)
    [junit]     at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:154)
    [junit]     at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:136)
    [junit]     at $Proxy14.insertString(Unknown Source)
...

如果我正确解释这一点,它告诉我它连接到了与 Java 不同的进程,其他进程中的某些内容失败了,但事实并非如此告诉我问题是什么。

我发现有一些环境变量(PROT_REMOTE...)可以让我记录来自这些远程(不同进程,同一台计算机,顺便说一句)进程的消息,但前提是我运行启用了调试的 OpenOffice 版本?

我正在 Ubuntu 上使用 deb 存储库中的 OpenOffice 版本,并且有兴趣编译我自己的 OpenOffice 版本。

有什么方法可以从远程进程获取一些有用的错误消息来帮助我理解代码失败的原因吗?

I'm trying to replace a field in an OpenOffice document using the OpenOffice Java API. I'm using the insertString method:

  xText.insertString(((XTextField) fieldMaster).getAnchor(), value.toString(), false);

The stacktrace is as follows:

    [junit] com.sun.star.uno.RuntimeException: 
    [junit]     at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:182)
    [junit]     at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:148)
    [junit]     at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:344)
    [junit]     at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:313)
    [junit]     at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:101)
    [junit]     at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:652)
    [junit]     at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:154)
    [junit]     at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:136)
    [junit]     at $Proxy14.insertString(Unknown Source)
...

If I interpret this correctly, it's telling me that it connected to a different proces from Java, something in the other proces failed, but it's not telling me what the problem is.

I found that there are some environment variables (PROT_REMOTE...) that would let me log messages from these remote (different process, same computer, btw) processes, but only if I run an OpenOffice version with debugging enabled?

I'm using an OpenOffice version from an deb repository on Ubuntu, and have to interest in compiling my own OpenOffice version.

Is there any way I can get some useful error messages from the remote process to help me understand why my code is failing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掌心的温暖 2024-07-20 09:00:22

我仍然没有找到一个好的方法来确定导致 RuntimeExceptions 的原因,但是 OpenOffice.org 论坛上的某人解决了我的问题。 我以错误的方式使用 API。

而不是:

XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,document);
XText xText = xTextDocument.getText();
xText.insertString(((XTextField) fieldMaster).getAnchor(), value.toString(), false);

我应该使用锚点中的​​文本:

XTextRange anchor = ((XTextField) fieldMaster).getAnchor();
anchor.getText().insertString(anchor, value.toString(), true);

显然,标题中的文本不是文档的一部分。 如果您打开 OpenOffice 文件,这很有意义。 标头存储在 ODF 文件中的单独 XML 文档中...

I still haven't found a good way to determine what is causing RuntimeExceptions, but someone over on the OpenOffice.org forum solved my problem. I was using the API in a wrong way.

Instead of:

XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,document);
XText xText = xTextDocument.getText();
xText.insertString(((XTextField) fieldMaster).getAnchor(), value.toString(), false);

I should have used the text from the anchor:

XTextRange anchor = ((XTextField) fieldMaster).getAnchor();
anchor.getText().insertString(anchor, value.toString(), true);

Apparently, text in the headers isn't part of the document. Which makes sense if you open an OpenOffice file. The headers are stored in a separate XML document in your ODF file...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文