<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hacking at 0300 &#187; OpenOffice.org</title>
	<atom:link href="http://bililite.com/blog/category/openoffice-org/feed/" rel="self" type="application/rss+xml" />
	<link>http://bililite.com/blog</link>
	<description>Thoughts on web design and programming from a very occasional volunteer webmaster</description>
	<lastBuildDate>Fri, 23 Jul 2010 09:00:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Column Widths in OOo Tables</title>
		<link>http://bililite.com/blog/2009/10/16/column-widths-in-ooo-tables/</link>
		<comments>http://bililite.com/blog/2009/10/16/column-widths-in-ooo-tables/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 06:07:13 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[OpenOffice.org]]></category>

		<guid isPermaLink="false">http://bililite.com/blog/?p=1114</guid>
		<description><![CDATA[Finding the width of a column in a table in OpenOffice.org 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 [...]]]></description>
			<content:encoded><![CDATA[<p>Finding the width of a column in a table in OpenOffice.org 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 <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Tables">the object model has no concept of "columns" and there is no way to find the widths of cells</a>. But, based on the <a href="http://wiki.services.openoffice.org/wiki/API/Samples/Java/Writer/TextTable">table tutorial</a>, I've written this function:</p>
<pre><code class="language-vb">function colwidth (table, index) ' index is 0-based
	' need the table to be oriented (http://api.openoffice.org/servlets/ReadMsg?list=dev&#038;msgNo=12552) 
	table.horiOrient = com.sun.star.text.HoriOrientation.LEFT_AND_WIDTH
	' tricks from http://wiki.services.openoffice.org/wiki/API/Samples/Java/Writer/TextTable
	dim n
	n = table.columns.count
	if index >= n then
		colwidth = 0
	elseif n = 1 then ' single column table
		colwidth = table.width
	else
		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
		else
			colwidth = (pos(index).position - pos(index-1).position) * ratio
		end if
	end if
end function</code></pre>]]></content:encoded>
			<wfw:commentRss>http://bililite.com/blog/2009/10/16/column-widths-in-ooo-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenOffice.org FontDescriptor</title>
		<link>http://bililite.com/blog/2009/10/15/openoffice-org-fontdescriptor/</link>
		<comments>http://bililite.com/blog/2009/10/15/openoffice-org-fontdescriptor/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 05:57:00 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[OpenOffice.org]]></category>

		<guid isPermaLink="false">http://bililite.com/blog/?p=1110</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>OOo controls have a Struct <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/awt/FontDescriptor.html">FontDescriptor</a> 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</p>
<pre><code class="language-vb">textField.fontDescriptor = textRange.fontDescriptor</code></pre>
<p>but no such luck. FontDescriptors apply to <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/awt/FontDescriptor-xref.html">everything but actual text</a>; text has all those properties as part of the <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/style/CharacterProperties.html">CharacterProperties</a> service, so each property has to be accessed separately:</p>
<pre><code class="language-vb">fontDescriptor = textField.fontDescriptor
fontDescriptor.name = textRange.CharFontName
fontDescriptor.height = textRange.CharHeight
' etc.
textField.fontDescriptor = fontDescriptor</code></pre>
<p>Note that you can't do <code class="language-vb">textField.fontDescriptor.name = textRange.CharFontName</code>, because <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/Mapping_of_Structs">Structs are always copied</a>. Even if it makes no sense.<code class="language-vb">textField.fontDescriptor.name</code> creates a temporary copy of <code class="language-vb">textField.fontDescriptor</code> and modifies <em>its</em> <code class="language-vb">name</code>, leaving the original <code class="language-vb">textField.fontDescriptor</code> untouched]]></content:encoded>
			<wfw:commentRss>http://bililite.com/blog/2009/10/15/openoffice-org-fontdescriptor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OOo Tutorial on Exporting to PDF</title>
		<link>http://bililite.com/blog/2009/10/06/ooo-tutorial-on-exporting-to-pdf/</link>
		<comments>http://bililite.com/blog/2009/10/06/ooo-tutorial-on-exporting-to-pdf/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 09:47:18 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[OpenOffice.org]]></category>

		<guid isPermaLink="false">http://bililite.com/blog/?p=1103</guid>
		<description><![CDATA[There's a great tutorial on exporting from OpenOffice.org Writer to PDF, but as far as I can tell it's orphaned on the openoffice.org 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 [...]]]></description>
			<content:encoded><![CDATA[There's a <a href="http://wiki.services.openoffice.org/wiki/API/Tutorials/PDF_export">great tutorial</a>  on exporting from <a href="http://www.openoffice.org/">OpenOffice.org</a> Writer to PDF, but as far as I can tell it's orphaned on the openoffice.org website; there's no link from the <a href="http://wiki.services.openoffice.org/wiki/API/Tutorials">tutorials page</a>. 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.]]></content:encoded>
			<wfw:commentRss>http://bililite.com/blog/2009/10/06/ooo-tutorial-on-exporting-to-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenOffice.org quirks</title>
		<link>http://bililite.com/blog/2009/09/22/openoffice-org-quirks/</link>
		<comments>http://bililite.com/blog/2009/09/22/openoffice-org-quirks/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 01:13:47 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[OpenOffice.org]]></category>

		<guid isPermaLink="false">http://bililite.com/blog/?p=1094</guid>
		<description><![CDATA[Some of the first things I needed to get straight to move from Microsoft Office scripting to Open Office scripting: The BASIC isn't quite compatible: I know the object model is completely different, but even the underlying language isn't quite the same. I wanted to use the InStrRev function, but it wasn't there! Then I [...]]]></description>
			<content:encoded><![CDATA[<p>Some of the first things I needed to get straight to move from Microsoft Office scripting to Open Office scripting:</p>
<ul>
<li>The BASIC isn't quite compatible: I know the object model is completely different, but even the underlying language isn't quite the same. I wanted to use the <a href="http://msdn.microsoft.com/en-us/library/t2ekk41a%28VS.80%29.aspx"><code>InStrRev</code></a> function, but it wasn't there! Then I found <code>option VBASupport 1</code> which puts it in. It's (as far as I can tell) undocumented but mentioned all over on the web. I'm not sure what else it changes (again, in the language, not the object model).</li>
<li>The name of the program is OpenOffice.org; evidently Open Office is trademarked by someone else. I'll do my best to comply.</li>
<li>Sizes are in hundredths of a millimeter (<a href="http://www.unc.edu/~rowlett/units/prefixes.html">dekamicrons</a>? abbreviated as da&micro;; I can't find anyone using a better abbreviation), so my code has a lot of <code>x = y * 2540/72</code>: 2540 mm per inch, 72 points per inch.</li>
<li>Inserting control elements is more complicated than I would have thought; the object model divides them into "model" and "view" and figuring out which properties belong to which takes some searching and experimenting:
<pre><code class="language-vb">	Dim rng as com.sun.star.text.TextRange, checkModel, checkbox
	checkModel = doc.createInstance("com.sun.star.form.component.CheckBox")
	checkView = doc.createInstance("com.sun.star.drawing.ControlShape")
	checkView.control = checkModel
	rng.Text.insertTextContent(rng, checkView, True)
</code></pre></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://bililite.com/blog/2009/09/22/openoffice-org-quirks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Diving into OpenOffice.org</title>
		<link>http://bililite.com/blog/2009/09/08/diving-into-openoffice-org/</link>
		<comments>http://bililite.com/blog/2009/09/08/diving-into-openoffice-org/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 02:41:38 +0000</pubDate>
		<dc:creator>Danny</dc:creator>
				<category><![CDATA[Medical Informatics]]></category>
		<category><![CDATA[OpenOffice.org]]></category>

		<guid isPermaLink="false">http://bililite.com/blog/?p=1070</guid>
		<description><![CDATA[My hospital isn't fully electronic yet; they use a hybrid system where doctors notes and orders are written on paper, to be scanned into the electronic chart at the end of the patient's stay. Everything else (nurse's notes, labs, radiology results) are electronic. It actually works pretty well, with most of the advantages of an [...]]]></description>
			<content:encoded><![CDATA[<p>My hospital isn't fully electronic yet; they use a hybrid system where doctors notes and orders are written on paper, to be scanned into the electronic chart at the end of the patient's stay. Everything else (nurse's notes, labs, radiology results) are electronic. It actually works pretty well, with most of the advantages of an <abbr title="Electronic Medical Record">EMR</abbr> (Electronic Medical Record) without forcing the older doctors to use the computer. That's coming, of course, but it won't be pretty.</p>
<p>But those of us for whom the computer is mother's milk, and whose handwriting is somewhere between <a href="http://www.cartoonstock.com/cartoonview.asp?catref=jdin372">chicken scratch</a> and <a href="http://en.wikipedia.org/wiki/Linear_A">Linear A</a>, we'd rather do it all online. I've been writing my admission notes for a few years with a Microsoft Word template, printing them out and putting them in the chart, with nary a problem. And the medical records department clearly used PDF's for the pages, both the blank order sheets and the preprinted, fill-in-the-blanks "standard orders" since they were available on the hospital intranet. So let's create PDF's with actual editable text boxes and check boxes (these are mockups, but they look right):</p>
<p><a href="/blog/blogfiles/orders.pdf"><img src="/blog/blogfiles/orders.png" alt="physician order sheet" title="Blank Physician Order Sheet" /></a><a href="/blog/blogfiles/gastro.pdf"><img src="/blog/blogfiles/gastro.png" alt="gastroenteritis order sheet" title="Gastroenteritis Order Sheet" /></a></p>
<span id="more-1070"></span>
<p>The response from medical records: not an option. It's too hard, inserting all those textboxes by hand on all those lines, and they don't "possess the very expensive software that makes this possible." They had to go to the graphic arts department to use their copy of Pagemaker. And any change means having to put all those controls back in the form again, by hand.</p>
<p>Never tell me something on the computer is impossible. I have <a href="http://en.wikipedia.org/wiki/Script_kiddies">teh l33t hax0r ski1z</a>! The expensive software problem is easy to solve; <a href="http://www.openoffice.org/">OpenOffice.org Writer</a> can generate PDF's, and a little experimentation shows that form elements are preserved. The "too hard" problem should be solvable, too; Writer is <a href="http://dlc.sun.com/pdf//817-1826/817-1826.pdf">scriptable</a> and I've scripted Microsoft Word with VBA often enough; how hard could it be?</p>
<p>Famous last words.</p>
<p>Scripting Microsoft Office is like pulling teeth; Basic is verbose and tedious, and the documentation for the object model is sparse. But scripting OpenOffice.org is like pulling teeth with your eyes closed. The documentation (the bane of all open source software) is virtually nonexistent; the macro recorder (so useful for Microsoft Office) records the user interface interactions, not the underlying object model; and there is no object browser to explore the methods and properties of each object (there is the <a href="http://wiki.services.openoffice.org/wiki/Extensions_development_basic#X-Ray_tool">xray tool</a> to look at objects one at a time as part of a macro).</p>
<p>So I just went to the <a href="http://wiki.services.openoffice.org/wiki/Documentation">documentation wiki</a> and dived in, spending a few hours browsing, trying to find a place to start. I'd recommend the <a href="http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide">BASIC guide</a> and the <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Introduction">Introduction to UNO</a>, which is Sun's answer to Microsoft's <a href="http://en.wikipedia.org/wiki/Component_Object_Model">COM</a> and the basis for the OpenOffice.org document object model, then the <a href="http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/OpenOffice.org_Basic">BASIC Binding chapter</a> to put them together. The <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/module-ix.html">documentation of the object model</a> is near impossible to find but it's there.</p>
<p>You really need to be able to read Java to understand the rest of the documentation, since both the examples and the underlying concepts are in that language. I wouldn't use anything but Basic, though, since it abstracts away all the underlying interface querying and dispatching and type casting.</p>
<p>The code I developed is <a href="/blog//blogfiles/createPDFForm.bas.txt">here</a>;  I'll blog about the things I learned as I get the time.</p>]]></content:encoded>
			<wfw:commentRss>http://bililite.com/blog/2009/09/08/diving-into-openoffice-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
