| 1 |
/* |
| 2 |
* @progname d-rtf.ll |
| 3 |
* @version 1.1 of 2000-06-11 |
| 4 |
* @author Paul Buckley |
| 5 |
* @category |
| 6 |
* @output RTF |
| 7 |
* @description |
| 8 |
* |
| 9 |
* This report will produce a document in Rich Text Format modeled after some |
| 10 |
* typewritten and typeset Henry format genealogies I've seen. |
| 11 |
* All descendants of a selected person, their spouses and their spouses |
| 12 |
* parents, event dates, and NOTEs are included. I generally reserve TEXT |
| 13 |
* items for comments I would prefer not to export. |
| 14 |
* |
| 15 |
* This version requires shorten.li, a library with a lookup table |
| 16 |
* to abbreviate the elements of the long placenames I tend to use |
| 17 |
* (town, county, state, country). |
| 18 |
* If you remove the calls to "shorten()" and just use the output of |
| 19 |
* long() it should work fine without the library. |
| 20 |
* |
| 21 |
* Added support for printing reference numbers after data. |
| 22 |
* Set "refs" to 0 to omit references. |
| 23 |
* |
| 24 |
* Written by: Paul Buckley, 11 Jun 2000, contact via LifeLines mail list |
| 25 |
* (with a lot of help from the archives) |
| 26 |
*/ |
| 27 |
|
| 28 |
global(rtfH) /* string, RTF header and font info */ |
| 29 |
global(rulI) /* string, index person ruler */ |
| 30 |
global(rulS) /* string, spouse ruler */ |
| 31 |
global(rulC) /* string, children list ruler*/ |
| 32 |
global(rulN) /* string, notes ruler (same as spouse)*/ |
| 33 |
global(font_name) /* string, name of font */ |
| 34 |
global(font_size) /* int, font size in RTF values (2 x points) */ |
| 35 |
global(big_font) /* int, ~1.3 times font_size */ |
| 36 |
global(sml_font) /* int, ~2/3 times font_size */ |
| 37 |
|
| 38 |
include("shorten.li") |
| 39 |
|
| 40 |
proc main () |
| 41 |
{ |
| 42 |
set(refs,1) /*set this to have reference numbers printed*/ |
| 43 |
indiset(sibs) |
| 44 |
indiset(nextgen) |
| 45 |
table(abbvtab) |
| 46 |
call setupabbvtab() |
| 47 |
|
| 48 |
getindi(p) |
| 49 |
newfile(concat(database(), ".", key(p), "-d.rtf"),0) |
| 50 |
|
| 51 |
call GetUserOptions() |
| 52 |
set(genN,1) |
| 53 |
set(Icnt,1) |
| 54 |
addtoset(sibs,p,Icnt) |
| 55 |
set(l,1) |
| 56 |
/* set(mark,concat("\\fs", d(div(font_size,2)), "\\up4 +\\up0\\fs", d(font_size))) */ |
| 57 |
set(mark,"*") |
| 58 |
rtfH |
| 59 |
"\\pard\\fs" |
| 60 |
d(big_font) |
| 61 |
"The Descendants of " upper(name(p)) "." |
| 62 |
"\\ql\\ulnone\\\n\\fs" |
| 63 |
d(font_size) |
| 64 |
"\\\n" |
| 65 |
|
| 66 |
while(l) { |
| 67 |
"\\pard\\qc\\i1\\fs" |
| 68 |
d(big_font) " " capitalize(ord(genN))" Generation \\i0\\ql\\fs" |
| 69 |
d(font_size) |
| 70 |
"\\\n\\\n" |
| 71 |
forindiset(sibs,person,var,i) { |
| 72 |
rulI |
| 73 |
upper(alpha(genN)) "-" d(var) "\t" name(person) |
| 74 |
if(or(date(birth(person)),place(birth(person)))) { |
| 75 |
", b. " shorten(long(birth(person))) |
| 76 |
if(refs) {call refRTF(birth(person)) } |
| 77 |
} |
| 78 |
if(or(date(baptism(person)),place(baptism(person)))) { |
| 79 |
", bt. " shorten(long(baptism(person))) |
| 80 |
if(ifwitn(root(person))) {". "} |
| 81 |
if(refs) {call refRTF(baptism(person)) } |
| 82 |
} |
| 83 |
if(or(place(death(person)),date(death(person)))) { |
| 84 |
", d. " shorten(long(death(person))) |
| 85 |
if(refs) {call refRTF(death(person)) } |
| 86 |
} |
| 87 |
".\\\n" |
| 88 |
traverse(root(person),node,cnt) { |
| 89 |
if (not(strcmp(tag(node),"NOTE"))) { |
| 90 |
rulN value(node) call refRTF(node) " \n" |
| 91 |
} |
| 92 |
} |
| 93 |
families(person,family,spouse,j) { |
| 94 |
rulS |
| 95 |
if(spouse) { |
| 96 |
givens(person) " married " name(spouse) |
| 97 |
if(date(marriage(family))) { |
| 98 |
" " shorten(long(marriage(family))) |
| 99 |
} |
| 100 |
". " |
| 101 |
/*if(refs) {call refRTF(marriage(family))}*/ |
| 102 |
"\n" |
| 103 |
if(ifwitn(root(family))) {". "} |
| 104 |
set(comma,0) |
| 105 |
if(or(place(birth(spouse)),date(birth(spouse)))) { |
| 106 |
set(comma,1) |
| 107 |
pn(spouse,0) " was born " shorten(long(birth(spouse))) |
| 108 |
}elsif(parents(spouse)) { |
| 109 |
pn(spouse,0) " was born" shorten(long(birth(spouse))) |
| 110 |
} |
| 111 |
if(parents(spouse)) { |
| 112 |
" to " |
| 113 |
if(father(spouse)) { |
| 114 |
set(comma,1) |
| 115 |
name(father(spouse)) |
| 116 |
if(mother(spouse)) { |
| 117 |
set(comma,1) |
| 118 |
" and " name(mother(spouse)) |
| 119 |
} |
| 120 |
}elsif(mother(spouse)) { |
| 121 |
set(comma,1) |
| 122 |
name(mother(spouse)) |
| 123 |
} |
| 124 |
} |
| 125 |
if(or(date(death(spouse)),place(death(spouse)))) { |
| 126 |
if(comma) {", "} |
| 127 |
else { pn(spouse,0) " "} |
| 128 |
"died " shorten(long(death(spouse))) |
| 129 |
} |
| 130 |
if(comma) {". "} |
| 131 |
traverse(root(spouse),node,cnt) { |
| 132 |
if (not(strcmp(tag(node),"NOTE"))) { |
| 133 |
"\\\n" rulN value(node) call refRTF(node) |
| 134 |
} |
| 135 |
} |
| 136 |
"\\\n" |
| 137 |
} |
| 138 |
else {"Spouse unknown.\\\n"} |
| 139 |
children(family,kid,k) { |
| 140 |
if(kid) { |
| 141 |
set(genNx,add(genN,1)) |
| 142 |
rulC |
| 143 |
if(nfamilies(kid)) { |
| 144 |
addtoset(nextgen,kid,Icnt) |
| 145 |
upper(alpha(genNx)) "-" d(Icnt) mark "\t" name(kid) |
| 146 |
if(date(birth(kid))) { |
| 147 |
", b. " shorten(date(birth(kid))) |
| 148 |
} |
| 149 |
if(date(baptism(kid))) { |
| 150 |
", bt. " shorten(date(baptism(kid))) |
| 151 |
} |
| 152 |
if(date(death(kid))) { |
| 153 |
", d. " shorten(date(death(kid))) |
| 154 |
} |
| 155 |
".\\\n" |
| 156 |
}else { |
| 157 |
upper(alpha(genNx)) "-" d(Icnt) "\t" name(kid) |
| 158 |
if(or(date(birth(kid)),place(birth(kid)))) { |
| 159 |
", b. " shorten(long(birth(kid))) |
| 160 |
if(refs) {call refRTF(birth(kid)) } |
| 161 |
} |
| 162 |
if(or(date(baptism(kid)),place(baptism(kid)))) { |
| 163 |
", bt. " shorten(long(baptism(kid))) |
| 164 |
if(ifwitn(root(kid))) {""} |
| 165 |
if(refs) {call refRTF(baptism(kid)) } |
| 166 |
} |
| 167 |
if(or(date(death(kid)),place(death(kid)))) { |
| 168 |
", d. " shorten(long(death(kid))) |
| 169 |
if(refs) {call refRTF(death(kid)) } |
| 170 |
} |
| 171 |
".\\\n" |
| 172 |
traverse(root(kid),node,cnt) { |
| 173 |
if (not(strcmp(tag(node),"NOTE"))) { |
| 174 |
"\t" value(node) call refRTF(node) "\\\n" |
| 175 |
} |
| 176 |
} |
| 177 |
} |
| 178 |
set(Icnt,add(Icnt,1)) |
| 179 |
} |
| 180 |
} |
| 181 |
traverse(root(family),node,cnt) { |
| 182 |
if (not(strcmp(tag(node),"NOTE"))) { |
| 183 |
rulN value(node) call refRTF(node) " " |
| 184 |
} |
| 185 |
} |
| 186 |
} |
| 187 |
"\\\n" |
| 188 |
} |
| 189 |
set(l, lengthset(nextgen)) |
| 190 |
indiset(sibs) |
| 191 |
set(sibs,nextgen) |
| 192 |
|
| 193 |
indiset(nextgen) |
| 194 |
set(genN,add(genN,1)) |
| 195 |
set(Icnt,1) |
| 196 |
} |
| 197 |
rulI |
| 198 |
"\\\n Generated " |
| 199 |
date(gettoday()) |
| 200 |
" from " |
| 201 |
concat(database(),".gedcom") |
| 202 |
/* " by YOU " */ |
| 203 |
" using LifeLines genealogy software" |
| 204 |
". \\\n } " |
| 205 |
} |
| 206 |
|
| 207 |
proc GetUserOptions () |
| 208 |
{ |
| 209 |
/* |
| 210 |
** QUESTION: What font should be used? |
| 211 |
** |
| 212 |
** Because it is such a pain to enter a font name, and a spelling mistake |
| 213 |
** will get you an ugly default font, this should be set to a default. I |
| 214 |
** suggest one of: Times-Roman, NewCenturySchlbk-Roman, or ZapfChancery. |
| 215 |
** This is a modification of code from the original psanc uing NeXT fonts |
| 216 |
** -PB |
| 217 |
** |
| 218 |
*/ |
| 219 |
|
| 220 |
if (0) { |
| 221 |
list(options) |
| 222 |
setel(options, 1, "Roman") |
| 223 |
setel(options, 2, "Italic") |
| 224 |
set(ff, menuchoose(options, "Select font face: ")) |
| 225 |
if (eq(1,ff)) { |
| 226 |
list(options) |
| 227 |
setel(options,1,"Times") |
| 228 |
setel(options,2,"New Century Schoolbook") |
| 229 |
setel(options,3,"Garamond") |
| 230 |
set(mc, menuchoose(options, "Select font family: ")) |
| 231 |
if (eq(3,mc)) { |
| 232 |
set (font_name, "AGaramond-Regular") |
| 233 |
} elsif (eq(2,mc)) { |
| 234 |
set (font_name, "NewCenturySchlbk-Roman") |
| 235 |
} else { |
| 236 |
set (font_name, "Times-Roman") |
| 237 |
} |
| 238 |
}else { |
| 239 |
setel(options,1,"Times") |
| 240 |
setel(options,2,"New Century Schoolbook") |
| 241 |
setel(options,3,"Garamond") |
| 242 |
setel(options,4,"ZapfChancery") |
| 243 |
set(mc, menuchoose(options, "Select font: ")) |
| 244 |
if (eq(1,mc)) { |
| 245 |
set (font_name, "Times-Italic") |
| 246 |
} elsif (eq(2,mc)) { |
| 247 |
set (font_name, "NewCenturySchlbk-Italic") |
| 248 |
} elsif (eq(3,mc)) { |
| 249 |
set (font_name, "AGaramond-Italic") |
| 250 |
} elsif (eq(4,mc)) { |
| 251 |
set (font_name, "ZapfChancery-MediumItalic") |
| 252 |
} |
| 253 |
} |
| 254 |
} else { set (font_name, "Times-Roman") } |
| 255 |
|
| 256 |
/* |
| 257 |
** QUESTION: What font size should be used? |
| 258 |
** |
| 259 |
** I set this to 20 by default, which is about 10pt. |
| 260 |
** A title font is generated about 1/3 bigger (dividing integers here) |
| 261 |
** -PB |
| 262 |
** |
| 263 |
*/ |
| 264 |
if(0) { |
| 265 |
getintmsg (font_size, "Enter the font size in points.") |
| 266 |
set(font_size, mul(font_size,2)) |
| 267 |
} else { |
| 268 |
set(font_size, 20) |
| 269 |
} |
| 270 |
set(big_font,add(font_size,div(font_size,3))) |
| 271 |
set(sml_font,sub(font_size,div(font_size,3))) |
| 272 |
|
| 273 |
/* |
| 274 |
* Set RTF defaults. Modifed for Mac OS X TextEdit.app. |
| 275 |
* Don't forget the terminal space character. |
| 276 |
*/ |
| 277 |
|
| 278 |
set(rtfH, concat("{\\rtf1\\ansicpg1000{\\fonttbl\\f0\\fnil ", concat(font_name, ";}"))) |
| 279 |
set(rtfH, concat(rtfH, "\n\\margl720\\margr720\\margt720\\margb720\\viewkind1")) |
| 280 |
set(rtfH, concat(rtfH, "\n\\f0\\b0\\i0\\ulnone\\ql\\fs")) |
| 281 |
set(rtfH, concat(rtfH, d(font_size))) |
| 282 |
set(rtfH, concat(rtfH, "\\fi0\\li0")) |
| 283 |
set(rulI, "\\pard\\tx720\\fi-720\\li720 ") |
| 284 |
set(rulS, "\\pard\\fi-180\\li1080 ") |
| 285 |
set(rulC, "\\pard\\tx1800\\fi-720\\li1800 ") |
| 286 |
set(rulN, "\\pard\\fi-180\\li1080 ") |
| 287 |
} |
| 288 |
|
| 289 |
func ifwitn (thisnode) |
| 290 |
{ |
| 291 |
set(needand,0) |
| 292 |
set(amdone,0) |
| 293 |
traverse(thisnode,x,y) { |
| 294 |
if (not(strcmp(tag(x),"WITN"))) { |
| 295 |
if(needand) {" and"} |
| 296 |
" " value(x) |
| 297 |
set(needand,1) |
| 298 |
set(amdone,1) |
| 299 |
} else {set(needand,0)} |
| 300 |
} |
| 301 |
if(amdone) {" witnessed"} |
| 302 |
else {""} |
| 303 |
return(amdone) |
| 304 |
} |
| 305 |
|
| 306 |
proc refRTF (i) { |
| 307 |
fornodes(i,node) { |
| 308 |
if (not(strcmp(tag(node),"SOUR"))) { |
| 309 |
set(text,strsave(value(node))) |
| 310 |
if (index(text,"@",2)) { |
| 311 |
set(text,substring(value(node),3,sub(strlen(text),1))) |
| 312 |
} |
| 313 |
"\\fs" d(sml_font) |
| 314 |
"\\up" d(div(font_size,4)) |
| 315 |
"(" text ")" |
| 316 |
"\\fs" d(font_size) "\\up0" |
| 317 |
} |
| 318 |
} |
| 319 |
} |