<?xml version="1.0" encoding="ISO-8859-1"?>
<abiword version="unnumbered"  fileformat="1.0">
<!-- =====================================================================  -->
<!-- This file is an AbiWord document.                                      -->
<!-- AbiWord is a free, Open Source word processor.                         -->
<!-- You may obtain more information about AbiWord at www.abisource.com     -->
<!-- You should not edit this file by hand.                                 -->
<!-- =====================================================================  -->

<!--         Build_ID          = (none) -->
<!--         Build_Version     = unnumbered -->
<!--         Build_Options     = LicensedTrademarks:Off Debug:On BiDi:Off Bonobo:Off DirectPrint:On Gnome:On LibXML:Off Pspell:On -->
<!--         Build_Target      = /home/dom/abiword/abi/src/../src/Linux_2.2.16-22_i386_GNOME/obj -->
<!--         Build_CompileTime = 00:12:37 -->
<!--         Build_CompileDate = Mar 23 2001 -->

<styles>
<s name="Code" props="font-family:Courier; font-size:12pt; font-style:italic"/>
<s name="Definition" props="font-weight:bold; text-decoration:underline"/>
<s name="Hyperlink" props="color:0000ff; font-weight:bold; text-decoration:underline"/>
<s name="Reference" props="font-style:italic"/>
</styles>
<lists>
<l id="1480287237" parentid="0" type="0" start-value="1" list-delim="%L." list-decimal="."/>
<l id="1501980786" parentid="0" type="0" start-value="1" list-delim="%L." list-decimal="."/>
</lists>
<pagesize pagetype="Letter" orientation="portrait" width="8.500000" height="11.000000" units="inch" page-scale="1.000000"/>
<section footer="23832346" header="241560988" props="page-margin-bottom:1.0000in; page-margin-footer:0.0000in; page-margin-header:0.0000in; page-margin-left:0.7000in; page-margin-right:0.7000in; page-margin-top:1.0000in">
<p style="Heading 1" props="text-align:center">AbiWord's New Backend</p>
<p props="text-align:center"><c props="font-size:10 pt">by Dom Lachowicz &lt;</c><c style="Hyperlink" props="font-size:10 pt">cinamod@hotmail.com</c><c props="font-size:10 pt">&gt;</c></p>
<p></p>
<p props="tabstops:0.5000in/L">	As many of you may or may not know, the core of AbiWord's layout and rendering engine is about 3 years old and doing quite a bit more than it was ever designed to.  As such, the code is a bit dated and accumulating cruft.  After 3 years, it's time to consider consider redesigning our backend.  I don't take this job lightly or think that it will be easy, but I think that it will most certainly be beneficial.</p>
<p></p>
<p props="tabstops:0.5000in/L">	Most importantly, these documents should be considered <c props="font-weight:bold">extremely</c><c props="font-weight:normal"> fluid and only ideas thrown out to generate discussion and spark interest, and nothing more.  This isn't by any means set in stone or even close to finished for that matter.</c></p>
<p style="Heading 2">The File Format</p>
<p style="Normal" props="tabstops:0.5000in/L">	After AbiWord reaches milestone 1.0, it will no doubt have some changes to its file format.  What I'm looking to represent are extremely simple definitions and tags - a minimum of verbosity and complexity to accomplish the maximum effect.  A word processor (WP) is nothing more than a glorified content storing, editing, and layout engine, or more abstractly, just an editable container (or set of editable containers).  Our file format should reflect this need, and to a large extent, I think that it currently does. Some groundwork:</p>
<p style="Normal"></p>
<p level="1" listid="1480287237" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c style="Definition" type="list_label">Document</c><c type="list_label"> - a collection of </c><c style="Reference" type="list_label">sections</c></p>
<p level="1" listid="1480287237" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c style="Definition" type="list_label">Section</c><c type="list_label"> - a collection of </c><c style="Reference" type="list_label">paragraphs</c></p>
<p level="1" listid="1480287237" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c style="Definition" type="list_label">Paragraph</c><c type="list_label"> - a collection of </c><c style="Reference" type="list_label">runs</c></p>
<p level="1" listid="1480287237" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	</c><c style="Definition" type="list_label">Run</c><c type="list_label"> - our lowest-level container class, a collection some sort of </c><c style="Reference" type="list_label">primitive type</c><c type="list_label"> that is purposefully left undefined here</c></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; tabstops:0.5000in/L; text-decoration:none; text-indent:0in; text-position:normal">	It should be noticed that all of our 4 primitive types are collections or containers.  In line with AbiWord's current design paradigm, each child container may itself have <c props="font-weight:normal; text-decoration:none">properties</c> and also <c props="font-style:italic">inherit</c> properties from its parent container.  Basically this means that if a paragraph sets the property <c style="Code">"font-size:12pt"</c>, all of its child runs inherit this property.  So (for instance) TextRuns parented by this paragraph will all be displayed using a 12pt font unless otherwise <c props="font-weight:bold">explicitly</c> specified. </p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; tabstops:0.5000in/L; text-decoration:none; text-indent:0in; text-position:normal">	The goal of any file format should be to accurately and cleanly represent the internal state and implementation of its parent product (or generator).  As you see, this container model has two implicit concepts - those of:</p>
<p level="1" listid="1501980786" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	A Parent</c></p>
<p level="1" listid="1501980786" parentid="0" style="Numbered List" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:1.0000in; start-value:1; text-decoration:none; text-indent:-0.5000in; text-position:normal"><field type="list_label"></field><c type="list_label">	A Parent's Child/Children</c></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal">So a simple first cut at a C++ moc-up might look like this:</p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Code">class Container {</p>
<p level="1" listid="0" parentid="0" style="Code">	Container (Container * parent);</p>
<p level="1" listid="0" parentid="0" style="Code">	~Container ();</p>
<p level="1" listid="0" parentid="0" style="Code">	virtual Container * getParent (void);</p>
<p level="1" listid="0" parentid="0" style="Code">	virtual Vector &amp; enumChildren (void);<br/>};</p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; tabstops:0.5000in/L; text-decoration:none; text-indent:0in; text-position:normal">	This model allows for some quite powerful layout design decisions - namely, each container is responsible primarily <c props="font-weight:bold">only</c><c props="font-weight:normal"> </c>for its children: each container is responsible for drawing its children, handling all mouse and cursor activity within its extents, etc...</p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; tabstops:0.5000in/L; text-decoration:none; text-indent:0in; text-position:normal">	If no handler for a particular activity (such as a mouse click) exists in the originating container, the event gets propagated upwards to that container's parent, until the event is ultimately either handled at some intermediate level or ignored at a global (document) scope.  A simple example of this would be to allow us to launch a <c props="font-weight:bold">URI</c> if we click on this <c style="Code">&lt;c type="hyperlink" uri="http://www.abisource.com/"&gt;AbiSource&lt;/c&gt;</c></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; tabstops:0.5000in/L; text-decoration:none; text-indent:0in; text-position:normal">	The model I'm following here is similar to that which GTK+ uses - each container will use an allocation/requisition mechanism to determine its drawing area.  Each class is then responsible for drawing its children within the specified allocation.  My intent is to have these allocations be polygons.</p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; tabstops:0.5000in/L; text-decoration:none; text-indent:0in; text-position:normal">	An initial implementation of our drawing code will probably utilize rectangles for simplicity of code and design, but these polygons can be made arbitrarily complex.  This means that at some future point, we will be able to draw into arbitrary shapes, draw ourselves around or and inside of other shapes, wrap text around objects such as images, and so forth.</p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; tabstops:0.5000in/L; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; tabstops:0.5000in/L; text-decoration:none; text-indent:0in; text-position:normal">A simple first run at a C++ class might resemble the following:</p>
<p level="1" listid="0" parentid="0" style="Normal" props="bgcolor:ffffff; color:000000; field-font:NULL; font-family:Times New Roman; font-size:12pt; font-style:normal; font-weight:normal; lang:en-US; margin-left:0in; start-value:1; text-decoration:none; text-indent:0in; text-position:normal"></p>
<p level="1" listid="0" parentid="0" style="Code">struct Polygon{</p>
<p level="1" listid="0" parentid="0" style="Code"> 	Polygon (Point * points, size_t nPoints);</p>
<p level="1" listid="0" parentid="0" style="Code">	virtual ~Polygon ();</p>
<p level="1" listid="0" parentid="0" style="Code">	Point * m_pPoints;</p>
<p level="1" listid="0" parentid="0" style="Code">	size_t m_nPoints;</p>
<p level="1" listid="0" parentid="0" style="Code">};</p>
<p level="1" listid="0" parentid="0" style="Code"></p>
<p level="1" listid="0" parentid="0" style="Code">struct Rect : public Polygon {</p>
<p level="1" listid="0" parentid="0" style="Code">	Rect (int x1, int x2, int y1, int y2);</p>
<p level="1" listid="0" parentid="0" style="Code">	virtual ~Rect();</p>
<p level="1" listid="0" parentid="0" style="Code">};</p>
<p level="1" listid="0" parentid="0" style="Code"></p>
<p level="1" listid="0" parentid="0" style="Normal" props="tabstops:0.5000in/L">	In this scheme, each parent amounts to a controller for its children.</p>
</section>
<section id="23832346" listid="0" parentid="0" type="footer">
<p level="1" listid="0" parentid="0" style="Normal" props="text-align:right"><image dataid="/home/dom/A1.png_0" props="width:0.60in; height:0.60in"/></p>
</section>
<section id="241560988" listid="0" parentid="0" type="header">
<p level="1" listid="0" parentid="0" style="Normal" props="text-align:center"><image dataid="/home/dom/A.png_0" props="height:0.60in; width:5.11in"/></p>
</section>
<data>
<d name="/home/dom/A.png_0" mime-type="image/png" base64="yes">
[encoded data, 15184 characters]
vXZlPTw8PDz+r/D/AeBVHJCCh5ASAAAAAElFTkSuQmCC
</d>
<d name="/home/dom/A1.png_0" mime-type="image/png" base64="yes">
[encoded data, 5037 characters]
X63+cuj/n+M3+V7ebxL6/wBA5XglWkrDywAAAABJRU5ErkJggg==
</d>
</data>
</abiword>
