[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice
Subject:    Re: Ascii Import Filter
From:       Thomas Zander <zander () xs4all ! nl>
Date:       2000-11-22 19:26:03
[Download RAW message or body]

On Wednesday 22 November 2000 17:34, you wrote:
> Thomas,
>
> The revised [ascii input] filter is attached. Everything is in two files 
> which are
> revisions of the originals with the same name. They are not diffs.
>

OK, I have commited this. 

Cool stuff, about everything I could throw at it worked perfectly!

well, that is, after I had disabled tables.

A number of problems on that:
 - when I have a text that is block aligned the ascii tends to have 2 spaces 
in the middle of sentences, it is not nice to start a table there.
 - After [,.:;] signs it is common to type multiple spaces as well.

Thinking out loud:
tables will always be 1 table per paragraph. So if you have a double space in 
line one and not at the same spot on line 2, forget that double space. 
On the same footing, if you have a single space on position 14 on line
one, and on line 2 and 3 you have multi-spaces leading up to position 14
your columnt 2 should start on character 14.
But the amount of lines in that paragraph should always be the same as the 
amount of rows in the table.

On second though, the first or last line could be table names :(

> The problem I have with tables is that they cannot be tagged as to
> where in the text they belong.

They can, with anchors. (aka floating)

1) create a dummy character in the former paragraph
2) put an anchor on that character with a pointer to your table.


    <PARAGRAPH>
    <TEXT>non-table para^A</TEXT>
    <FORMATS>
     <FORMAT id="1" pos="0" len="14">
      <FONT name="times"/>
     </FORMAT>
     <FORMAT id="6" pos="14">
      <ANCHOR type="grpMgr" instance="grpmgr_0"/>
     </FORMAT>

3) Create your table just like you do now and give it the name mentioned 
above in the instance var:

  <FRAMESET frameType="1" frameInfo="0" grpMgr="grpmgr_0" row="0" col="0" 
rows="1" cols="1" removable="0" visible="1" name="Cell 1,1">
   <FRAME left="28" top="36" right="295" bottom="63" bleftpt="2.83465" 
bleftmm="1" bleftinch="0.0393701" brightpt="2.83465" brightmm="1" 
brightinch="0.0393701" btoppt="2.83465" btopmm="1" btopinch="0.0393701" 
bbottompt="2.83465" bbottommm="1" bbottominch="0.0393701" 
autoCreateNewFrame="0" newFrameBehaviour="1" />
   <PARAGRAPH>
    <TEXT>table</TEXT>
    <FORMATS>
     <FORMAT id="1" pos="0" len="5">
      <FONT name="times"/>
     </FORMAT>
    </FORMATS>
    <LAYOUT>
     <NAME value="Standard"/>
     <FOLLOWING name="Standard"/>
     <FORMAT>
      <FONT name="times"/>
     </FORMAT>
     <TABULATOR mmpos="63" ptpos="179" inchpos="1.6061e-19"/>
     <TABULATOR mmpos="128" ptpos="363" inchpos="1.1009e+15"/>
    </LAYOUT>
   </PARAGRAPH>
  </FRAMESET>
  <FRAMESET frameType="1" frameInfo="0" grpMgr="grpmgr_0" row="0" col="1" 
rows="1" cols="1" removable="0" visible="1" name="Cell 2,1">
   <FRAME left="298" top="36" right="565" bottom="63" bleftpt="2.83465" 
bleftmm="1" bleftinch="0.0393701" brightpt="2.83465" brightmm="1" 
brightinch="0.0393701" btoppt="2.83465" btopmm="1" btopinch="0.0393701" 
bbottompt="2.83465" bbottommm="1" bbottominch="0.0393701" 
autoCreateNewFrame="0" newFrameBehaviour="1" />
   <PARAGRAPH>
    <TEXT>para</TEXT>
    <FORMATS>
     <FORMAT id="1" pos="0" len="4">
      <FONT name="times"/>
     </FORMAT>
    </FORMATS>
    <LAYOUT>
     <NAME value="Standard"/>
     <FOLLOWING name="Standard"/>
     <FORMAT>
      <FONT name="times"/>
     </FORMAT>
     <TABULATOR mmpos="63" ptpos="179" inchpos="1.6061e-19"/>
     <TABULATOR mmpos="128" ptpos="363" inchpos="1.1009e+15"/>
    </LAYOUT>
   </PARAGRAPH>
  </FRAMESET>
 </FRAMESETS>                                                                 
                                   

4) Positioning of the table is relative to the anchor, so the top and bottom 
should be small. Not to small or you will have big problems. I used 36, 30 
should do.. The X position is not relative to the anchor so you should 
probably stick to left: 28 right=565 for A4 and split that available space 
between the columns. Also keep a 3pt interval. So: 
colSize=(565-28)/cols; left = 28+col*colSize; right=left+colSize-3;

Col1:  left: 28 right: 204
Col2:  left 207 right: 383
Col3:  left 386 right: 565

5) every row should have a minimum height that is taken into account with the 
creation of the next row. With a 3 pt interval So:

 row1: top 30, bottom 57
 row2: top 60 bottom 87
etc.

6) When you start kword from the konsole you will see lots of error messages 
with your code, things like "Found duplicate cell", "Missing cell, creating a 
new one" all have to do with inconsistencies in the numbering of table cells. 
For example if you have 2 cells in a table that are both in row 0 and col 0 
you get an error.
Kword does its best to correct this, but duplicate cells are for example 
placed on an extra row which will look really wierd.

> Hope you like it and thanks for the help.
>
> Michael
>
> P.S. I found a CVS client for windows so in the future I should be
> able to handle things without becoming a pest.

Everyone has to start somewhere, and I like to see people who start coding on 
koffice to sent the first couple of messages to a co-developer. Something 
like peer-reviewing. Just until you are comfortable in using cvs and the 
koffice sourcetree.

It seems you got a long way in quite a short time. Hope this helps you put 
more functionality in an already very good import filter ;)

ps. Cc'd this to the list so others can learn from the examples as well.

-- 
Thomas Zander                                            zander@earthling.net
The only thing worse than failure is the fear of trying something new

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic