OpenOffice API:如何关闭页眉和页脚
OpenOffice API: How to turn off headers and footers
我正在努力理解 OpenOffice API。感谢 SO 我弄清楚了如何打开行编号。现在我需要关闭页眉和页脚。
获取文档 XComponent 的 XPropertySet
XPropertySet propSet = UnoRuntime.queryInterface(XPropertySet.class, 文档);
和设置
propSet.setPropertyValue("HeaderIsOn", Boolean.FALSE);
propSet.setPropertyValue("FooterIsOn", Boolean.FALSE);
无效。像很多其他人一样,我无法理解文档。
我看过一个 Perl 示例 (Perl OpenOffice::OODoc - accessing header/footer elements),但不知道如何在 Java 中获取 "master page" header/styles。
求助!
获取页面样式并设置其属性。这是对我有用的代码:
XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
UnoRuntime.queryInterface(
XStyleFamiliesSupplier.class, xTextDocument);
XNameAccess xFamilies = (XNameAccess) UnoRuntime.queryInterface (
XNameAccess.class, xSupplier.getStyleFamilies());
XNameContainer xFamily = (XNameContainer) UnoRuntime.queryInterface(
XNameContainer.class, xFamilies.getByName("PageStyles"));
// The style name may be "Default Style" or just "Default" -- check your document.
XStyle xStyle = (XStyle) UnoRuntime.queryInterface(
XStyle.class, xFamily.getByName("Default Style"));
XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xStyle);
xStyleProps.setPropertyValue ("HeaderIsOn", Boolean.FALSE);
xStyleProps.setPropertyValue ("FooterIsOn", Boolean.FALSE);
Perl UNO 示例可能很棘手,可能是因为它们使用了自己的特殊 OpenOffice 库。相反,我发现这些很有用:
- Styles Example in Java,在页面底部。
- Changing the Text of Headers and Footers,页面中间的基本示例。
我正在努力理解 OpenOffice API。感谢 SO 我弄清楚了如何打开行编号。现在我需要关闭页眉和页脚。 获取文档 XComponent 的 XPropertySet XPropertySet propSet = UnoRuntime.queryInterface(XPropertySet.class, 文档);
和设置
propSet.setPropertyValue("HeaderIsOn", Boolean.FALSE); propSet.setPropertyValue("FooterIsOn", Boolean.FALSE);
无效。像很多其他人一样,我无法理解文档。
我看过一个 Perl 示例 (Perl OpenOffice::OODoc - accessing header/footer elements),但不知道如何在 Java 中获取 "master page" header/styles。
求助!
获取页面样式并设置其属性。这是对我有用的代码:
XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
UnoRuntime.queryInterface(
XStyleFamiliesSupplier.class, xTextDocument);
XNameAccess xFamilies = (XNameAccess) UnoRuntime.queryInterface (
XNameAccess.class, xSupplier.getStyleFamilies());
XNameContainer xFamily = (XNameContainer) UnoRuntime.queryInterface(
XNameContainer.class, xFamilies.getByName("PageStyles"));
// The style name may be "Default Style" or just "Default" -- check your document.
XStyle xStyle = (XStyle) UnoRuntime.queryInterface(
XStyle.class, xFamily.getByName("Default Style"));
XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, xStyle);
xStyleProps.setPropertyValue ("HeaderIsOn", Boolean.FALSE);
xStyleProps.setPropertyValue ("FooterIsOn", Boolean.FALSE);
Perl UNO 示例可能很棘手,可能是因为它们使用了自己的特殊 OpenOffice 库。相反,我发现这些很有用:
- Styles Example in Java,在页面底部。
- Changing the Text of Headers and Footers,页面中间的基本示例。