OpenOffice API - 表的最佳宽度选项(所有列)
我正在研究 Java API,它通过 UNO 与 OpenOffice(swriter) 交互。 对于 TextTable,我很难设置 TableColumn 的“OptimalWidth”属性。
我已尝试以下代码,似乎 getColumns() 方法无法将我带到 TableColumn 的属性,而只能让您插入和删除列。
XTableColumns xColumns = xTextTable.getColumns();
XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, xColumns);
for (int i = 0; i < xIndexAccess.getCount(); i++) {
XPropertySet xColumnProps = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class,
(Any) xIndexAccess.getByIndex(i));
if (xColumnProps != null) {
xColumn.setPropertyValue("OptimalWidth", new Boolean(true));
}
}
任何人都可以帮助我或给我任何设置表格 OptimalWidth 属性的提示吗? 预先非常感谢您!
I am working on Java API which interacts with OpenOffice(swriter) through UNO.
For TextTable, I am having hard time setting TableColumn's "OptimalWidth" property.
I have tried the following code and it seems that getColumns() method cannot take me to TableColumn's property and let you only insert and remove columns.
XTableColumns xColumns = xTextTable.getColumns();
XIndexAccess xIndexAccess = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, xColumns);
for (int i = 0; i < xIndexAccess.getCount(); i++) {
XPropertySet xColumnProps = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class,
(Any) xIndexAccess.getByIndex(i));
if (xColumnProps != null) {
xColumn.setPropertyValue("OptimalWidth", new Boolean(true));
}
}
Can anyone help me out or give me any tips setting OptimalWidth property for a table?
Thank you very much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个相当艰辛的过程,但我最终成功地创建了一个函数来完成这个任务:
重要的是,dispatchHelper 来自 OpenOffice 上下文,而不是来自当前文档。我这样检索了dispatchHelper:
It was quite an odyssey to find out, but I finally managed to create a function which does exactly that:
It is important that the dispatchHelper comes from the OpenOffice context, and not from the current document. I retrieved the dispatchHelper this way: