Archive for October, 2009

Finding the width of a column in a table in writer is a bit of a black art, because the widths aren't stored anywhere, just the relative widths in arbitrary units. And if cells have been combined, then the object model has no concept of "columns" and there is no way to find the widths of cells. But, based on the table tutorial, I've written this function:

function colwidth (table, index) ' index is 0-based
	' need the table to be oriented ( 
	table.horiOrient =
	' tricks from
	dim n
	n = table.columns.count
	if index >= n then
		colwidth = 0
	elseif n = 1 then ' single column table
		colwidth = table.width
		dim ratio as double
		ratio = table.width / table.tableColumnRelativeSum
		dim pos
		pos = table.tableColumnSeparators
		if index = 0 then
			colwidth = pos(0).position * ratio
		elseif index = n-1 then ' last column
			colwidth = (table.tableColumnRelativeSum - pos (ubound(pos)).position) * ratio
			colwidth = (pos(index).position - pos(index-1).position) * ratio
		end if
	end if
end function

OOo controls have a Struct FontDescriptor that contains all the information about the text (font name, point size, etc.) so one would hope that to make an editbox have the same font as the containing text range, all you would have to do is

textField.fontDescriptor = textRange.fontDescriptor

but no such luck. FontDescriptors apply to everything but actual text; text has all those properties as part of the CharacterProperties service, so each property has to be accessed separately:

fontDescriptor = textField.fontDescriptor = textRange.CharFontName
fontDescriptor.height = textRange.CharHeight
' etc.
textField.fontDescriptor = fontDescriptor

Note that you can't do = textRange.CharFontName, because Structs are always copied. Even if it makes no creates a temporary copy of textField.fontDescriptor and modifies its name, leaving the original textField.fontDescriptor untouched

Today was the last day of a 3-month locum stint and they had a lunch for me. Ham and cheese subs.

And someone who knew what kosher meant brought in Cheezits (my main vice). But it's sukkot, so I couldn't eat those in the office either.

Continue reading ‘Preventing Irony Deficiency’ »
There's a great tutorial on exporting from Writer to PDF, but as far as I can tell it's orphaned on the website; there's no link from the tutorials page. It documents all the properties of the export filter and goes through the process in great detail. Hopefully the link from this blog will help keep it from staying orphaned.