OpenOffice.org/LibreOffice Writerでタブ位置の設定


OpenOffice.org/LibreOfficeのBASICでWriter documentのタブストップの位置を設定する方法を探してさまよっていたが、やっと見つけた!

Formatting documents with OpenOffice.org Writer macros

・Setting tab stops (タブストップの設定)

Sub SetTabStops(optional doc)
	oDoc = IIf(IsMissing(doc), ThisComponent, doc)
	' create a text cursor (used for manipulating text) at the position of
	' view cursor (the one visible on screen)
	viewCursor = oDoc.currentController.getViewCursor()
	oCursor = oDoc.Text.createTextCursorByRange(viewCursor.getStart())
	' add tab stop
	Dim tabs as new com.sun.star.style.TabStop
	tabs.position = 25000 ' 25 cm from left - more than A4 page's width
	tabs.alignment = 2 ' magic constant: 2 = right tab
	tabs.FillChar = Asc(".")
	' tab stops need to be put in an array - in this case it contains
	' only one element
	oCursor.ParaTabStops = Array(tabs)
End Sub

他にもあとで役立ちそうなものがあったのでメモしておく。
・Changing page size (ページサイズの変更・設定)
・Changing page and paragraph margin size (ページと段落の余白の設定)
・Setting page headers and footers (ページのヘッダとフッタの設定)
・Setting text alignment (テキストの配置の設定)
・Setting tab stops (タブストップ・タブ位置の設定)
・Adding horizontal lines (水平線の追加)
・Modifying multiple documents (複数文書の編集)