<?xml version="1.0"?>
<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 Scripting:Off -->
<!--         Build_Target      = /home/dom/abiword/abi/src/../src/Linux_2.2.14-5.0_i386_GNOME/obj -->
<!--         Build_CompileTime = 17:09:03 -->
<!--         Build_CompileDate = Jun 21 2001 -->

<pagesize pagetype="Letter" orientation="portrait" width="8.500000" height="11.000000" units="inch" page-scale="1.000000"/>
<section>
<p props="text-align:center"><c props="font-weight:bold; font-size:24pt">AbiSource File Import</c></p>
<p props="text-align:center">Version 1.0</p>
<p props="text-align:center">Copyright (C) 1999 AbiSource, Inc., All Rights Reserved.</p>
<p props="text-align:center"></p>
<p props="text-align:center">Jeff Hostetler</p>
<p props="text-align:center"><c props="font-family:Courier New">jeff@abisource.com</c></p>
<p props="text-align:center">AbiSource, Inc.</p>
<p></p>
<p><c props="font-weight:bold">1.  Introduction</c></p>
<p></p>
<p>AbiWord can import documents in various different file formats.  This document provides an overview of the import mechanism and instructions for adding support for a new format.</p>
<p></p>
<p><c props="font-weight:bold">2.  class IE_Imp</c></p>
<p></p>
<p>The code for our current set of importers can be found in abi/src/wp/impexp/xp.</p>
<p></p>
<p>Class IE_Imp defines the base class for all importers.  All file importers are derived from this class.</p>
<p></p>
<p>Class IE_Imp also defines some methods which the actual file-open and file-open-dialog code will use.  This includes code to enumerate through the set of derived classes and to instantiate a specific derived class by name.</p>
<p></p>
<p><c props="font-weight:bold">3.  Adding a New File Type</c></p>
<p></p>
<p>Currently, we have defined a class called IE_ImpSniffer. This class is responsible for various duties, including creating new instances of our IE_Imp subclass (i.e. the actual importer).  The duties of the sniffer include:</p>
<p></p>
<p>[1] Importer registration</p>
<p>[2] Automatic recognition of a file’s contents</p>
<p>[3] Automatic recognition of a file’s suffix</p>
<p>[4] Creating a new importer object</p>
<p><c></c></p>
<p><c></c>Here are the steps to add support for a new file type:</p>
<p></p>
<p props="tabstops:0.5000in/L0">[1]	Create  a new sniffer class and register it via the ie_impexp_Register.cpp file</p>
<p props="text-indent:-0.5000in; margin-left:0.5000in"></p>
<p props="text-indent:-0.5000in; margin-left:0.5000in">[2]	Clone one of the existing importers and start hacking.</p>
<p props="text-indent:-0.5000in; margin-left:0.5000in"></p>
<p props="text-indent:-0.5000in; margin-left:0.5000in">[3]	As a first step in creating your importer, I recommend that you start by just  extracting the text of the document without worrying about formatting.  The most trivial document contains one section, one block (paragraph), and some content (one or more spans).  So you should be able to get something on the screen with nothing more than this:</p>
<p props="text-indent:-0.5000in; margin-left:0.5000in"></p>
<p><c props="font-family:Courier New">		m_pDocument-&gt;appendStrux(PTX_Section,NULL);</c></p>
<p><c props="font-family:Courier New">		m_pDocument-&gt;appendStrux(PTX_Block,NULL);</c></p>
<p><c props="font-family:Courier New">		m_pDocument-&gt;appendSpan(data,length);</c></p>
<p><c props="font-family:Courier New">		m_pDocument-&gt;appendSpan(data,length);</c></p>
<p><c props="font-family:Courier New">		...</c></p>
<p></p>
<p props="margin-left:0.5000in">You can make as many calls to appendSpan() within a block as you need.</p>
<p></p>
<p props="text-indent:-0.5000in; margin-left:0.5000in">[4]	Once you get that working, you can start adding section, block and span formatting attributes using the second argument of appendStrux() and the appendFmt() method.  These consist of a series of CSS2-like name-value pairs.  See AbiWord_DocumentFormat.abw and the source for the other importers for details.</p>
<p></p>
<p></p>
</section>
</abiword>