<?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>Roundtrip to Shanghai via Tokyo &#187; python</title>
	<atom:link href="http://kohei.us/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://kohei.us</link>
	<description>Kohei Yoshida's Webspace</description>
	<lastBuildDate>Fri, 09 Jul 2010 12:20:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>OOo module dependencies</title>
		<link>http://kohei.us/2010/07/07/ooo-module-dependencies/</link>
		<comments>http://kohei.us/2010/07/07/ooo-module-dependencies/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 23:56:00 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[openoffice.org]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=808</guid>
		<description><![CDATA[Below is a graphical representation of OOo&#8217;s module dependencies as of DEV300 milestone 84 generated via graphviz.  Click on the image to get the whole picture.

You can find the python script I wrote to generate this nice picture here.
]]></description>
			<content:encoded><![CDATA[<p>Below is a graphical representation of OOo&#8217;s module dependencies as of DEV300 milestone 84 generated via <a href="http://www.graphviz.org/">graphviz</a>.  Click on the image to get the whole picture.</p>
<p><a href="http://kohei.us/wp-content/uploads/2010/07/ooo-modules.png"><img src="http://kohei.us/wp-content/uploads/2010/07/ooo-modules-thumb.png" alt="ooo-modules-thumb" title="ooo-modules-thumb" width="400" height="264" class="alignnone size-full wp-image-812" /></a></p>
<p>You can find the python script I wrote to generate this nice picture <a href="http://cgit.freedesktop.org/ooo-build/ooo-build/tree/bin/check-deps.py">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2010/07/07/ooo-module-dependencies/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>mso-dumper now packaged in OBS</title>
		<link>http://kohei.us/2010/03/20/mso-dumper-now-packaged-in-obs/</link>
		<comments>http://kohei.us/2010/03/20/mso-dumper-now-packaged-in-obs/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 03:06:23 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[calc]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[mso-dumper]]></category>
		<category><![CDATA[power point]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=699</guid>
		<description><![CDATA[I&#8217;m happy to announce that the mso-dumper tool is now packaged in the openSUSE build service under my home repository.  This tool is written in Python, and allows you to dump the contents of MS Office documents stored in the BIFF-structured binary file format in a more human readable fashion.  It is an [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to announce that the mso-dumper tool is now <a href="http://download.opensuse.org/repositories/home:/kohei_yoshida/">packaged in the openSUSE build service under my home repository</a>.  This tool is written in Python, and allows you to dump the contents of MS Office documents stored in the BIFF-structured binary file format in a more human readable fashion.  It is an indispensable tool when dealing with importing from and/or exporting to the Office documents.  Right now, only Excel and Power Point formats are supported.</p>
<p>This package provides two new commands <code>xls-dump</code> and <code>ppt-dump</code>.  If you wish to dump the content of an Excel document, all you have to do is</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xls-dump .<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>mydoc.xls</pre></div></div>

<p>and it dumps its content to standard output.  What the output looks like depends on what&#8217;s stored with the document, but it will look something like this:</p>
<pre>
...
0085h: =============================================================
0085h: BOUNDSHEET - Sheet Information (0085h)
0085h:   size = 14
0085h: -------------------------------------------------------------
0085h: B4 09 00 00 00 00 06 00 53 68 65 65 74 31
0085h: -------------------------------------------------------------
0085h: BOF position in this stream: 2484
0085h: sheet name: Sheet1
0085h: hidden state: visible
0085h: sheet type: worksheet or dialog sheet

008Ch: =============================================================
008Ch: COUNTRY - Default Country and WIN.INI Country (008Ch)
008Ch:   size = 4
008Ch: -------------------------------------------------------------
008Ch: 01 00 01 00 

00EBh: =============================================================
00EBh: MSODRAWINGGROUP - Microsoft Office Drawing Group (00EBh)
00EBh:   size = 90
00EBh: -------------------------------------------------------------
00EBh: 0F 00 00 F0 52 00 00 00 00 00 06 F0 18 00 00 00
00EBh: 02 04 00 00 02 00 00 00 02 00 00 00 01 00 00 00
00EBh: 01 00 00 00 02 00 00 00 33 00 0B F0 12 00 00 00
00EBh: BF 00 08 00 08 00 81 01 09 00 00 08 C0 01 40 00
00EBh: 00 08 40 00 1E F1 10 00 00 00 0D 00 00 08 0C 00
00EBh: 00 08 17 00 00 08 F7 00 00 10 

00FCh: =============================================================
00FCh: SST - Shared String Table (00FCh)
00FCh:   size = 8
00FCh: -------------------------------------------------------------
00FCh: 00 00 00 00 00 00 00 00
00FCh: -------------------------------------------------------------
00FCh: total number of references: 0
00FCh: total number of unique strings: 0
...
</pre>
<p>I have originally written this tool to deal with the Excel import and export part of Calc&#8217;s development, and continue to develop it further.  <a href="http://blog.thebehrens.net/">Thorsten Behrens</a> has later joined forces and <a href="http://blog.thebehrens.net/2009/01/08/python-binary-ppt-fun/">added support for the Power Point format</a>.  Right now, I&#8217;m working on adding an XML output format option to make it easier to compare outputs, which is important for regression testing.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2010/03/20/mso-dumper-now-packaged-in-obs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hack Week: .src converter to convert ~700 .src files</title>
		<link>http://kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/</link>
		<comments>http://kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 05:21:03 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[hack week]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[novell]]></category>
		<category><![CDATA[openoffice.org]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[src2xml]]></category>

		<guid isPermaLink="false">http://blog.kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/</guid>
		<description><![CDATA[So, after some discussion with Ricardo, I have decided to take on the task of writing a converter script to convert ~700 .src files into xml files, which will be used as a starting point for re-designing each and every dialog for the new dialog layout engine.  I was initially thinking about working on [...]]]></description>
			<content:encoded><![CDATA[<p>So, after some discussion with Ricardo, I have decided to take on the <a href="http://wiki.services.openoffice.org/wiki/VCL_UI_Rework#.src_converter">task of writing a converter script to convert ~700 .src files into xml files</a>, which will be used as a starting point for re-designing each and every dialog for the new dialog layout engine.  I was initially thinking about working on the dialog editor, but sounds like Ricardo has it under control.  So better not mess with that. :-)</p>
<p>When writing a converter script, it of course involves parsing a source file in order to generate output.  Typically there are two ways to go about this.</p>
<ol>
<li> Parse the source file partially for just the information you need using a flat search, and ignore the rest, or</li>
<li>Parse the source file fully according to the syntax of the language, using a lexer-parser pattern.</li>
</ol>
<p>The advantage of the first method is simplicity; it&#8217;s pretty easy to set up a simple regexp-based parser and start parsing.  The disadvantage of it is that, once the parsing need grows, as you need to pick up more and more information, the parser code becomes complex with full of special case handling, and eventually requires a total re-write.  Good luck with extending such code as the need grows even further.</p>
<p>The second method, while it takes a little upfront effort, is extensible once the framework is set up, and the code usually becomes better structured with only a minimum special case handling if designed correctly.  This method is also well-suited for parsing a token-based language, where whitespace and linebreak characters are only for syntactic sugar and does not affect its semantics.   For example, C/C++ and Java are token-based, while Python is not.  Since the syntax of the src files is very similar to that of C, I&#8217;ve decided to use the second method for this task.</p>
<p>I spent yesterday and today writing this converter script from scratch (in Python), and I&#8217;ve come to a point where it parses a large number of src files and correctly generate their xml output files.  Here is one example case.</p>
<p><strong>The source file:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: crnrdlg.src,v $
 *
 *  $Revision: 1.44 $
 *
 *  last change: $Author: ihi $ $Date: 2007/04/19 16:36:48 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/</span>
<span style="color: #339933;">#include &quot;crnrdlg.hrc&quot;</span>
ModelessDialog RID_SCDLG_COLROWNAMERANGES
<span style="color: #009900;">&#123;</span>
    OutputSize <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    Hide <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    SVLook <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">256</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">181</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
    HelpId <span style="color: #339933;">=</span> HID_COLROWNAMERANGES <span style="color: #339933;">;</span>
    Moveable <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// Closeable = TRUE;   // Dieser Dialog hat einen Cancel-Button !</span>
    FixedLine FL_ASSIGN
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">6</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">3</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">188</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">8</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Range&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    ListBox LB_RANGE
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">12</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">179</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">85</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        VScroll <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Border <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    Edit ED_AREA
    <span style="color: #009900;">&#123;</span>
        Border <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">12</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">105</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">165</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">12</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    ImageButton RB_AREA
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">179</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">104</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">13</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">15</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> FALSE <span style="color: #339933;">;</span>
        QuickHelpText <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Shrink&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    RadioButton BTN_COLHEAD
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">20</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">121</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">171</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Contains ~column labels&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    RadioButton BTN_ROWHEAD
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">20</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">135</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">171</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Contains ~row labels&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    FixedText FT_DATA_LABEL
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">12</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">151</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">179</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">8</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;For ~data range&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    Edit ED_DATA
    <span style="color: #009900;">&#123;</span>
        Border <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">12</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">162</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">165</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">12</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    ImageButton RB_DATA
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">179</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">161</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">13</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">15</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> FALSE <span style="color: #339933;">;</span>
        QuickHelpText <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Shrink&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    OKButton BTN_OK
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">6</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    CancelButton BTN_CANCEL
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">23</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    PushButton BTN_ADD
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">104</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;~Add&quot;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        DefButton <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    PushButton BTN_REMOVE
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">122</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;~Delete&quot;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    HelpButton BTN_HELP
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">43</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Define Label Range&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and here is the output after the conversion:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modeless-dialog</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;181&quot;</span> <span style="color: #000066;">help-id</span>=<span style="color: #ff0000;">&quot;HID_COLROWNAMERANGES&quot;</span> <span style="color: #000066;">hide</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">moveable</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">output-size</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">sv-look</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Define Label Range&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;256&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://openoffice.org/2007/layout&quot;</span> <span style="color: #000066;">xmlns:cnt</span>=<span style="color: #ff0000;">&quot;http://openoffice.org/2007/layout/container&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vbox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fixed-line</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;FL_ASSIGN&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Range&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;188&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;6&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ok-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_OK&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;6&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list-box</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;LB_RANGE&quot;</span> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;85&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">vscroll</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;179&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;14&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cancel-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_CANCEL&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;23&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;help-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_HELP&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;43&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hbox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;RB_AREA&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;15&quot;</span> <span style="color: #000066;">quick-help-text</span>=<span style="color: #ff0000;">&quot;Shrink&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;13&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;179&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;104&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;push-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_ADD&quot;</span> <span style="color: #000066;">def-button</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;~Add&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;104&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hbox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;edit</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ED_AREA&quot;</span> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;165&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;105&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;radio-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_COLHEAD&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Contains ~column labels&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;171&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;121&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;push-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_REMOVE&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;~Delete&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;122&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;radio-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_ROWHEAD&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Contains ~row labels&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;171&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;135&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fixed-text</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;FT_DATA_LABEL&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;For ~data range&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;179&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;151&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;RB_DATA&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;15&quot;</span> <span style="color: #000066;">quick-help-text</span>=<span style="color: #ff0000;">&quot;Shrink&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;13&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;179&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;161&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;edit</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ED_DATA&quot;</span> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;165&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;162&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vbox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modeless-dialog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>These are the steps I take to convert each file.  First, the source file is read character-by-character to get tokenized by the lexer class, and this is where the comments (both multi-line and single line) get stripped out and the preprocessing macros are defined.  The tokens are then passed to the parser class to build a syntax tree (preprocessor macros are expanded here), which is then converted into an intermediate XML tree with names translated and some attribute types converted properly, such as the position and the size, which are originally given as MAP_APPFONT( a, b ) format.  Also, some unnecessary information is discarded at this stage.</p>
<p>Once that&#8217;s done, it further translates the intermediate XML tree into another XML tree that has layout elements.  The X and Y positions of each widget are used in order to layout the widgets properly by wrapping them with &lt;vbox&gt; and &lt;hbox&gt; elements as needed.  The tree is then dumped into a stream of text, which is what you see above.</p>
<p>Unfortunately this task is not done yet.  As it turns out, some src files even require inclusion of header files in order to be parsed correctly, which means I need to honor those <code>#include "foo.hrc"</code> header include directives.   Right now, they are ignored.  On top of that, there may also be cases where the <code>#ifdef</code> directives might need to be interpreted correctly, but so far ignoring them has not caused any side-effect.</p>
<p>I&#8217;m sure there are other problems I&#8217;ll encounter as I parse more src files, but I&#8217;d say the end is near. :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
