Top > OOoBeanShell > Calc > headerfooter

ページヘッダとフッタ Edit

Java でのページヘッダとフッタのページで行っていることを OOoBeanShell で同じことをさせてみます。

以下のような簡単な記述で済みました。

import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XModel;

import drafts.com.sun.star.script.provider.XScriptContext;

import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.sheet.XSpreadsheets;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.table.XCell;
import com.sun.star.beans.XPropertySet;
import com.sun.star.beans.PropertyValue;
import com.sun.star.text.XText;
import com.sun.star.style.XStyleFamiliesSupplier;
import com.sun.star.container.XNameContainer;
import com.sun.star.container.XNameAccess;
import com.sun.star.sheet.XHeaderFooterContent;
oDoc = XSCRIPTCONTEXT.getDocument();
xSheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, oDoc);
xSpreadsheets = xSheetDoc.getSheets();
Object sheet = xSpreadsheets.getByName("Sheet1");
xSpreadsheet = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class, sheet);
xCell = xSpreadsheet.getCellByPosition(0, 0);
xCell.setValue(1);

xStyleFamiliesSupplier = (XStyleFamiliesSupplier) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xSheetDoc);
xStyleFamilies = (XNameAccess) xStyleFamiliesSupplier.getStyleFamilies();
xPageStyleContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xStyleFamilies.getByName("PageStyles"));
xPageStyles = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xPageStyleContainer);
Object xStyle = xPageStyles.getByName("Default");
xStylePropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle);
Object RightPageHeader = xStylePropertySet.getPropertyValue("RightPageHeaderContent");
xRightPageHeader = (XHeaderFooterContent) UnoRuntime.queryInterface(XHeaderFooterContent.class, RightPageHeader);

Object CenterText = xRightPageHeader.getCenterText();
xCenterText = (XText) UnoRuntime.queryInterface(XText.class, CenterText);
xCenterText.setString("Header Text!\nOpenOffice.org\nVersion 2.0");

xStylePropertySet.setPropertyValue("RightPageHeaderContent", RightPageHeader);

// BeanShell OpenOffice.org scripts should always return 0
return 0;

Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes