| 1 |
// Copyright (c) 1996, 1997 James Clark |
| 2 |
// See the file copying.txt for copying permission. |
| 3 |
|
| 4 |
// Possible improvements: |
| 5 |
// Don't serialize ports |
| 6 |
// Extension flow objects |
| 7 |
// Merge text chunks |
| 8 |
// Handle input-whitespace-treatment/tabs |
| 9 |
// Table processing |
| 10 |
// When element has an ID, output both ID anchor and numeric anchor |
| 11 |
|
| 12 |
#include "config.h" |
| 13 |
#include "SgmlFOTBuilder.h" |
| 14 |
#include <OpenSP/macros.h> |
| 15 |
#include "dsssl_ns.h" |
| 16 |
#include <stdio.h> |
| 17 |
#include <string.h> |
| 18 |
#include <stdlib.h> |
| 19 |
|
| 20 |
#ifdef DSSSL_NAMESPACE |
| 21 |
namespace DSSSL_NAMESPACE { |
| 22 |
#endif |
| 23 |
|
| 24 |
class SgmlFOTBuilder : public SerialFOTBuilder { |
| 25 |
public: |
| 26 |
SgmlFOTBuilder(OutputCharStream *); |
| 27 |
~SgmlFOTBuilder(); |
| 28 |
void setFontSize(Length); |
| 29 |
void setFontFamilyName(const StringC &); |
| 30 |
void setFontWeight(Symbol); |
| 31 |
void setFontPosture(Symbol); |
| 32 |
void setStartIndent(const LengthSpec &); |
| 33 |
void setEndIndent(const LengthSpec &); |
| 34 |
void setFirstLineStartIndent(const LengthSpec &); |
| 35 |
void setLastLineEndIndent(const LengthSpec &); |
| 36 |
void setLineSpacing(const LengthSpec &); |
| 37 |
void setFieldWidth(const LengthSpec &); |
| 38 |
void setPositionPointShift(const LengthSpec &); |
| 39 |
void setStartMargin(const LengthSpec &); |
| 40 |
void setEndMargin(const LengthSpec &); |
| 41 |
void setSidelineSep(const LengthSpec &); |
| 42 |
void setAsisWrapIndent(const LengthSpec &); |
| 43 |
void setLineNumberSep(const LengthSpec &); |
| 44 |
void setLastLineJustifyLimit(const LengthSpec &); |
| 45 |
void setJustifyGlyphSpaceMaxAdd(const LengthSpec &); |
| 46 |
void setJustifyGlyphSpaceMaxRemove(const LengthSpec &); |
| 47 |
void setTableCornerRadius(const LengthSpec &); |
| 48 |
void setBoxCornerRadius(const LengthSpec &); |
| 49 |
void setMarginaliaSep(const LengthSpec &); |
| 50 |
void setMinPreLineSpacing(const OptLengthSpec &); |
| 51 |
void setMinPostLineSpacing(const OptLengthSpec &); |
| 52 |
void setMinLeading(const OptLengthSpec &); |
| 53 |
void setLines(Symbol); |
| 54 |
void setQuadding(Symbol); |
| 55 |
void setDisplayAlignment(Symbol sym); |
| 56 |
void setFieldAlign(Symbol); |
| 57 |
void setLineJoin(Symbol); |
| 58 |
void setLineCap(Symbol); |
| 59 |
void setLineNumberSide(Symbol); |
| 60 |
void setKernMode(Symbol); |
| 61 |
void setInputWhitespaceTreatment(Symbol); |
| 62 |
void setFillingDirection(Symbol); |
| 63 |
void setWritingMode(Symbol); |
| 64 |
void setLastLineQuadding(Symbol); |
| 65 |
void setMathDisplayMode(Symbol); |
| 66 |
void setScriptPreAlign(Symbol); |
| 67 |
void setScriptPostAlign(Symbol); |
| 68 |
void setScriptMidSupAlign(Symbol); |
| 69 |
void setScriptMidSubAlign(Symbol); |
| 70 |
void setNumeratorAlign(Symbol); |
| 71 |
void setDenominatorAlign(Symbol); |
| 72 |
void setGridPositionCellType(Symbol); |
| 73 |
void setGridColumnAlignment(Symbol); |
| 74 |
void setGridRowAlignment(Symbol); |
| 75 |
void setBoxType(Symbol); |
| 76 |
void setSideBySideOverlapControl(Symbol sym); |
| 77 |
void setSideBySidePreAlign(Symbol sym); |
| 78 |
void setSideBySidePostAlign(Symbol sym); |
| 79 |
void setGlyphAlignmentMode(Symbol); |
| 80 |
void setBoxBorderAlignment(Symbol); |
| 81 |
void setCellRowAlignment(Symbol); |
| 82 |
void setBorderAlignment(Symbol); |
| 83 |
void setSidelineSide(Symbol); |
| 84 |
void setHyphenationKeep(Symbol); |
| 85 |
void setFontStructure(Symbol); |
| 86 |
void setFontProportionateWidth(Symbol); |
| 87 |
void setCellCrossed(Symbol); |
| 88 |
void setMarginaliaSide(Symbol); |
| 89 |
void setColor(const DeviceRGBColor &); |
| 90 |
void setBackgroundColor(const DeviceRGBColor &); |
| 91 |
void setBackgroundColor(); |
| 92 |
void setPageWidth(Length); |
| 93 |
void setPageHeight(Length); |
| 94 |
void setLeftMargin(Length); |
| 95 |
void setRightMargin(Length); |
| 96 |
void setTopMargin(Length); |
| 97 |
void setBottomMargin(Length); |
| 98 |
void setHeaderMargin(Length); |
| 99 |
void setFooterMargin(Length); |
| 100 |
void setLineThickness(Length); |
| 101 |
void setCellBeforeRowMargin(Length); |
| 102 |
void setCellAfterRowMargin(Length); |
| 103 |
void setCellBeforeColumnMargin(Length); |
| 104 |
void setCellAfterColumnMargin(Length); |
| 105 |
void setLineSep(Length); |
| 106 |
void setBoxSizeBefore(Length); |
| 107 |
void setBoxSizeAfter(Length); |
| 108 |
void setLayer(long); |
| 109 |
void setBackgroundLayer(long); |
| 110 |
void setBorderPriority(long); |
| 111 |
void setLineRepeat(long); |
| 112 |
void setSpan(long); |
| 113 |
void setMinLeaderRepeat(long); |
| 114 |
void setHyphenationRemainCharCount(long); |
| 115 |
void setHyphenationPushCharCount(long); |
| 116 |
void setWidowCount(long); |
| 117 |
void setOrphanCount(long); |
| 118 |
void setExpandTabs(long); |
| 119 |
void setHyphenationLadderCount(long); |
| 120 |
void setLanguage(Letter2); |
| 121 |
void setCountry(Letter2); |
| 122 |
void setBackgroundTile(PublicId); |
| 123 |
void setLineBreakingMethod(PublicId); |
| 124 |
void setLineCompositionMethod(PublicId); |
| 125 |
void setImplicitBidiMethod(PublicId); |
| 126 |
void setGlyphSubstMethod(PublicId); |
| 127 |
void setGlyphReorderMethod(PublicId); |
| 128 |
void setHyphenationMethod(PublicId); |
| 129 |
void setTableAutoWidthMethod(PublicId); |
| 130 |
void setFontName(PublicId); |
| 131 |
void setBorderPresent(bool); |
| 132 |
void setInhibitLineBreaks(bool); |
| 133 |
void setHyphenate(bool); |
| 134 |
void setKern(bool); |
| 135 |
void setLigature(bool); |
| 136 |
void setScoreSpaces(bool); |
| 137 |
void setFloatOutMarginalia(bool); |
| 138 |
void setFloatOutSidelines(bool); |
| 139 |
void setFloatOutLineNumbers(bool); |
| 140 |
void setCellBackground(bool); |
| 141 |
void setSpanWeak(bool); |
| 142 |
void setIgnoreRecordEnd(bool); |
| 143 |
void setNumberedLines(bool); |
| 144 |
void setHangingPunct(bool); |
| 145 |
void setBoxOpenEnd(bool); |
| 146 |
void setTruncateLeader(bool); |
| 147 |
void setAlignLeader(bool); |
| 148 |
void setTablePartOmitMiddleHeader(bool); |
| 149 |
void setTablePartOmitMiddleFooter(bool); |
| 150 |
void setBorderOmitAtBreak(bool); |
| 151 |
void setPrincipalModeSimultaneous(bool); |
| 152 |
void setMarginaliaKeepWithPrevious(bool); |
| 153 |
void setGridEquidistantRows(bool); |
| 154 |
void setGridEquidistantColumns(bool); |
| 155 |
void setEscapementSpaceBefore(const InlineSpace &); |
| 156 |
void setEscapementSpaceAfter(const InlineSpace &); |
| 157 |
void setInlineSpaceSpace(const OptInlineSpace &); |
| 158 |
void setCharMap(Symbol); |
| 159 |
void setGlyphSubstTable(const Vector<ConstPtr<GlyphSubstTable> > &tables); |
| 160 |
|
| 161 |
void paragraphBreak(const ParagraphNIC &); |
| 162 |
void characters(const Char *, size_t); |
| 163 |
void charactersFromNode(const NodePtr &nd, const Char *s, size_t n); |
| 164 |
void character(const CharacterNIC &); |
| 165 |
void externalGraphic(const ExternalGraphicNIC &); |
| 166 |
void rule(const RuleNIC &); |
| 167 |
void alignmentPoint(); |
| 168 |
|
| 169 |
void startSimplePageSequenceSerial(); |
| 170 |
void endSimplePageSequenceSerial(); |
| 171 |
void pageNumber(); |
| 172 |
void startSimplePageSequenceHeaderFooter(unsigned); |
| 173 |
void endSimplePageSequenceHeaderFooter(unsigned); |
| 174 |
void endAllSimplePageSequenceHeaderFooter(); |
| 175 |
void startScroll(); |
| 176 |
void endScroll(); |
| 177 |
void startLink(const Address &); |
| 178 |
void endLink(); |
| 179 |
void startMarginalia(); |
| 180 |
void endMarginalia(); |
| 181 |
void startMultiModeSerial(const MultiMode *); |
| 182 |
void endMultiModeSerial(); |
| 183 |
void startMultiModeMode(const MultiMode &); |
| 184 |
void endMultiModeMode(); |
| 185 |
void startScore(Char); |
| 186 |
void startScore(const LengthSpec &); |
| 187 |
void startScore(Symbol); |
| 188 |
void endScore(); |
| 189 |
void startLeader(const LeaderNIC &); |
| 190 |
void endLeader(); |
| 191 |
void startSideline(); |
| 192 |
void endSideline(); |
| 193 |
void startBox(const BoxNIC &); |
| 194 |
void endBox(); |
| 195 |
void startSideBySide(const DisplayNIC&); |
| 196 |
void endSideBySide(); |
| 197 |
void startSideBySideItem(); |
| 198 |
void endSideBySideItem(); |
| 199 |
void startParagraph(const ParagraphNIC &); |
| 200 |
void endParagraph(); |
| 201 |
void startSequence(); |
| 202 |
void endSequence(); |
| 203 |
void startLineField(const LineFieldNIC &); |
| 204 |
void endLineField(); |
| 205 |
void startDisplayGroup(const DisplayGroupNIC &); |
| 206 |
void endDisplayGroup(); |
| 207 |
|
| 208 |
void startTable(const TableNIC &); |
| 209 |
void endTable(); |
| 210 |
void tableBeforeRowBorder(); |
| 211 |
void tableAfterRowBorder(); |
| 212 |
void tableBeforeColumnBorder(); |
| 213 |
void tableAfterColumnBorder(); |
| 214 |
void tableColumn(const TableColumnNIC &); |
| 215 |
void startTablePartSerial(const TablePartNIC &); |
| 216 |
void endTablePartSerial(); |
| 217 |
void startTablePartHeader(); |
| 218 |
void endTablePartHeader(); |
| 219 |
void startTablePartFooter(); |
| 220 |
void endTablePartFooter(); |
| 221 |
void startTableRow(); |
| 222 |
void endTableRow(); |
| 223 |
void startTableCell(const TableCellNIC &); |
| 224 |
void endTableCell(); |
| 225 |
void tableCellBeforeRowBorder(); |
| 226 |
void tableCellAfterRowBorder(); |
| 227 |
void tableCellBeforeColumnBorder(); |
| 228 |
void tableCellAfterColumnBorder(); |
| 229 |
void startMathSequence(); |
| 230 |
void endMathSequence(); |
| 231 |
void startFractionSerial(); |
| 232 |
void endFractionSerial(); |
| 233 |
void startFractionNumerator(); |
| 234 |
void endFractionNumerator(); |
| 235 |
void startFractionDenominator(); |
| 236 |
void endFractionDenominator(); |
| 237 |
void fractionBar(); |
| 238 |
void startUnmath(); |
| 239 |
void endUnmath(); |
| 240 |
void startSuperscript(); |
| 241 |
void endSuperscript(); |
| 242 |
void startSubscript(); |
| 243 |
void endSubscript(); |
| 244 |
void startScriptSerial(); |
| 245 |
void endScriptSerial(); |
| 246 |
void startScriptPreSup(); |
| 247 |
void endScriptPreSup(); |
| 248 |
void startScriptPreSub(); |
| 249 |
void endScriptPreSub(); |
| 250 |
void startScriptPostSup(); |
| 251 |
void endScriptPostSup(); |
| 252 |
void startScriptPostSub(); |
| 253 |
void endScriptPostSub(); |
| 254 |
void startScriptMidSup(); |
| 255 |
void endScriptMidSup(); |
| 256 |
void startScriptMidSub(); |
| 257 |
void endScriptMidSub(); |
| 258 |
void startMarkSerial(); |
| 259 |
void endMarkSerial(); |
| 260 |
void startMarkOver(); |
| 261 |
void endMarkOver(); |
| 262 |
void startMarkUnder(); |
| 263 |
void endMarkUnder(); |
| 264 |
void startFenceSerial(); |
| 265 |
void endFenceSerial(); |
| 266 |
void startFenceOpen(); |
| 267 |
void endFenceOpen(); |
| 268 |
void startFenceClose(); |
| 269 |
void endFenceClose(); |
| 270 |
void startRadicalSerial(); |
| 271 |
void endRadicalSerial(); |
| 272 |
void startRadicalDegree(); |
| 273 |
void endRadicalDegree(); |
| 274 |
void radicalRadical(const CharacterNIC &); |
| 275 |
void radicalRadicalDefaulted(); |
| 276 |
void startMathOperatorSerial(); |
| 277 |
void endMathOperatorSerial(); |
| 278 |
void startMathOperatorOperator(); |
| 279 |
void endMathOperatorOperator(); |
| 280 |
void startMathOperatorLowerLimit(); |
| 281 |
void endMathOperatorLowerLimit(); |
| 282 |
void startMathOperatorUpperLimit(); |
| 283 |
void endMathOperatorUpperLimit(); |
| 284 |
void startGrid(const GridNIC &); |
| 285 |
void endGrid(); |
| 286 |
void startGridCell(const GridCellNIC &); |
| 287 |
void endGridCell(); |
| 288 |
void startNode(const NodePtr &, const StringC &); |
| 289 |
void endNode(); |
| 290 |
void currentNodePageNumber(const NodePtr &); |
| 291 |
struct Data { |
| 292 |
Data(const StringC &str) : ptr(str.data()), size(str.size()) { } |
| 293 |
Data(const Char *p, size_t n) : ptr(p), size(n) { } |
| 294 |
const Char *ptr; |
| 295 |
size_t size; |
| 296 |
}; |
| 297 |
struct Units { |
| 298 |
Units(long i) : n(i) { } |
| 299 |
long n; |
| 300 |
}; |
| 301 |
private: |
| 302 |
OutputCharStream &os() { return *curOs_; } |
| 303 |
void outputIcs(); |
| 304 |
void startSimpleFlowObj(const char *name); |
| 305 |
void simpleFlowObj(const char *name); |
| 306 |
void startPortFlow(const char *name); |
| 307 |
void endFlow(const char *name); |
| 308 |
void characterNIC(const CharacterNIC &nic); |
| 309 |
void displayNIC(const DisplayNIC &nic); |
| 310 |
void inlineNIC(const InlineNIC &nic); |
| 311 |
void boolC(const char *, bool); |
| 312 |
void lengthC(const char *, Length); |
| 313 |
void lengthSpecC(const char *, const LengthSpec &); |
| 314 |
void optLengthSpecC(const char *, const OptLengthSpec &); |
| 315 |
void symbolC(const char *name, Symbol sym); |
| 316 |
void integerC(const char *, long); |
| 317 |
void publicIdC(const char *, PublicId); |
| 318 |
void inlineSpaceC(const char *name, const InlineSpace &); |
| 319 |
void optInlineSpaceC(const char*, const OptInlineSpace &); |
| 320 |
void displaySpaceNIC(const char *name, const DisplaySpace &); |
| 321 |
void flushPendingElements(); |
| 322 |
void outputElementName(unsigned long groveIndex, const Char *, size_t); |
| 323 |
void outputElementName(const NodePtr &node); |
| 324 |
static bool nodeIsElement(const NodePtr &node) { |
| 325 |
GroveString gi; |
| 326 |
return node->getGi(gi) == accessOK; |
| 327 |
} |
| 328 |
|
| 329 |
Owner<OutputCharStream> os_; |
| 330 |
StrOutputCharStream ics_; |
| 331 |
StrOutputCharStream hfs_; |
| 332 |
OutputCharStream *curOs_; |
| 333 |
Vector<PackedBoolean> multiModeHasPrincipalMode_; |
| 334 |
Vector<PackedBoolean> glyphSubstTableDefined_; |
| 335 |
|
| 336 |
Vector<NodePtr> pendingElements_; |
| 337 |
Vector<unsigned> pendingElementLevels_; |
| 338 |
unsigned nPendingElementsNonEmpty_; |
| 339 |
unsigned nodeLevel_; |
| 340 |
bool suppressAnchors_; |
| 341 |
StringC hf_[nHF]; |
| 342 |
}; |
| 343 |
|
| 344 |
const char RE = '\r'; |
| 345 |
const char quot = '"'; |
| 346 |
const char *const trueString = "true"; |
| 347 |
const char *const falseString = "false"; |
| 348 |
// May change this to "null" |
| 349 |
const char *const nullString = "false"; |
| 350 |
|
| 351 |
typedef SgmlFOTBuilder::Units Units; |
| 352 |
|
| 353 |
inline |
| 354 |
OutputCharStream &operator<<(OutputCharStream &os, |
| 355 |
#ifdef GROVE_NAMESPACE |
| 356 |
GROVE_NAMESPACE:: |
| 357 |
#endif |
| 358 |
GroveString &str) |
| 359 |
{ |
| 360 |
return os.write(str.data(), str.size()); |
| 361 |
} |
| 362 |
|
| 363 |
inline |
| 364 |
OutputCharStream &operator<<(OutputCharStream &os, long n) |
| 365 |
{ |
| 366 |
if (n < 0) |
| 367 |
return os << '-' << (unsigned long)-n; |
| 368 |
else |
| 369 |
return os << (unsigned long)n; |
| 370 |
} |
| 371 |
|
| 372 |
inline |
| 373 |
const char *boolString(bool b) |
| 374 |
{ |
| 375 |
return b ? trueString : falseString; |
| 376 |
} |
| 377 |
|
| 378 |
inline |
| 379 |
OutputCharStream &operator<<(OutputCharStream &os, FOTBuilder::Symbol sym) |
| 380 |
{ |
| 381 |
switch (sym) { |
| 382 |
case FOTBuilder::symbolFalse: |
| 383 |
os << falseString; |
| 384 |
break; |
| 385 |
case FOTBuilder::symbolTrue: |
| 386 |
os << trueString; |
| 387 |
break; |
| 388 |
default: |
| 389 |
os << FOTBuilder::symbolName(sym); |
| 390 |
break; |
| 391 |
} |
| 392 |
return os; |
| 393 |
} |
| 394 |
|
| 395 |
inline |
| 396 |
OutputCharStream &operator<<(OutputCharStream &os, double d) |
| 397 |
{ |
| 398 |
char buf[128]; |
| 399 |
sprintf(buf, "%g", d); |
| 400 |
return os << buf; |
| 401 |
} |
| 402 |
|
| 403 |
OutputCharStream &operator<<(OutputCharStream &os, Units u) |
| 404 |
{ |
| 405 |
char buf[32]; |
| 406 |
sprintf(buf, "%03d", u.n); |
| 407 |
int len = strlen(buf); |
| 408 |
int i = 0; |
| 409 |
for (; i < 3 && buf[len - i - 1] == '0'; i++) |
| 410 |
; |
| 411 |
if (i == 3) { |
| 412 |
i = len - 3; |
| 413 |
if (i == 0) |
| 414 |
buf[i++] = '0'; |
| 415 |
} |
| 416 |
else { |
| 417 |
int j = len + 1 - i; |
| 418 |
for (; i < 3; i++) |
| 419 |
buf[len - i] = buf[len - i - 1]; |
| 420 |
buf[len - 3] = '.'; |
| 421 |
i = j; |
| 422 |
} |
| 423 |
strcpy(buf + i, "pt"); |
| 424 |
return os << buf; |
| 425 |
} |
| 426 |
|
| 427 |
inline |
| 428 |
OutputCharStream &operator<<(OutputCharStream &os, |
| 429 |
const FOTBuilder::LengthSpec &ls) |
| 430 |
{ |
| 431 |
if (ls.displaySizeFactor != 0.0) { |
| 432 |
// 100+20% |
| 433 |
if (ls.length) { |
| 434 |
os << Units(ls.length); |
| 435 |
if (ls.displaySizeFactor >= 0.0) |
| 436 |
os << '+'; |
| 437 |
} |
| 438 |
char buf[128]; |
| 439 |
sprintf(buf, "%.2f%%", ls.displaySizeFactor * 100.0); |
| 440 |
} |
| 441 |
else |
| 442 |
os << Units(ls.length); |
| 443 |
return os; |
| 444 |
} |
| 445 |
|
| 446 |
OutputCharStream &operator<<(OutputCharStream &os, |
| 447 |
const FOTBuilder::TableLengthSpec &ls) |
| 448 |
{ |
| 449 |
if (ls.displaySizeFactor != 0.0 || ls.tableUnitFactor != 0.0) { |
| 450 |
// 100+20% |
| 451 |
bool needSign = 0; |
| 452 |
if (ls.length) { |
| 453 |
os << Units(ls.length); |
| 454 |
needSign = 1; |
| 455 |
} |
| 456 |
char buf[128]; |
| 457 |
if (ls.displaySizeFactor != 0.0) { |
| 458 |
if (needSign && ls.displaySizeFactor >= 0.0) |
| 459 |
os << '+'; |
| 460 |
sprintf(buf, "%.2f%%", ls.displaySizeFactor * 100.0); |
| 461 |
needSign = 1; |
| 462 |
os << buf; |
| 463 |
} |
| 464 |
if (ls.tableUnitFactor != 0.0) { |
| 465 |
if (needSign && ls.tableUnitFactor >= 0.0) |
| 466 |
os << '+'; |
| 467 |
sprintf(buf, "%.2f*", ls.tableUnitFactor); |
| 468 |
os << buf; |
| 469 |
} |
| 470 |
} |
| 471 |
else |
| 472 |
os << Units(ls.length); |
| 473 |
return os; |
| 474 |
} |
| 475 |
|
| 476 |
OutputCharStream &operator<<(OutputCharStream &os, |
| 477 |
SgmlFOTBuilder::Data data) |
| 478 |
{ |
| 479 |
const Char *s = data.ptr; |
| 480 |
size_t n = data.size; |
| 481 |
for (; n > 0; n--, s++) { |
| 482 |
switch (*s) { |
| 483 |
case '&': |
| 484 |
os << "&"; |
| 485 |
break; |
| 486 |
case '<': |
| 487 |
os << "<"; |
| 488 |
break; |
| 489 |
case '>': |
| 490 |
os << ">"; |
| 491 |
break; |
| 492 |
case '"': |
| 493 |
os << """; |
| 494 |
break; |
| 495 |
default: |
| 496 |
if (*s < 0x80) |
| 497 |
os.put(*s); |
| 498 |
else |
| 499 |
os << "&#" << (unsigned long)*s << ';'; |
| 500 |
break; |
| 501 |
} |
| 502 |
} |
| 503 |
return os; |
| 504 |
} |
| 505 |
|
| 506 |
inline |
| 507 |
OutputCharStream &operator<<(OutputCharStream &os, |
| 508 |
const FOTBuilder::GlyphId &gid) |
| 509 |
{ |
| 510 |
if (gid.publicId) { |
| 511 |
os << gid.publicId; |
| 512 |
if (gid.suffix) |
| 513 |
os << "::" << gid.suffix; |
| 514 |
} |
| 515 |
else |
| 516 |
os << falseString; |
| 517 |
return os; |
| 518 |
} |
| 519 |
|
| 520 |
FOTBuilder *makeSgmlFOTBuilder(OutputCharStream *os, |
| 521 |
const FOTBuilder::Description *&descr) |
| 522 |
{ |
| 523 |
static const FOTBuilder::Feature features[] = { |
| 524 |
{ "sideline", 0}, |
| 525 |
{ "side-by-side", 0}, |
| 526 |
{ "table", 0}, |
| 527 |
{ "math", 0}, |
| 528 |
{ "simple-page", 0}, |
| 529 |
{ "online", 0}, |
| 530 |
{ 0, 0} |
| 531 |
}; |
| 532 |
|
| 533 |
static const char *media[] = { 0 }; |
| 534 |
|
| 535 |
static FOTBuilder::Description description = { |
| 536 |
0, // Extension |
| 537 |
features, |
| 538 |
false, |
| 539 |
media |
| 540 |
}; |
| 541 |
descr = &description; |
| 542 |
|
| 543 |
return new SgmlFOTBuilder(os); |
| 544 |
} |
| 545 |
|
| 546 |
static |
| 547 |
void outputNumericCharRef(OutputCharStream &os, Char c) |
| 548 |
{ |
| 549 |
os << "&#" << (unsigned long)c << ';'; |
| 550 |
} |
| 551 |
|
| 552 |
SgmlFOTBuilder::SgmlFOTBuilder(OutputCharStream *os) |
| 553 |
: os_(os), |
| 554 |
curOs_(os), |
| 555 |
nodeLevel_(0), |
| 556 |
nPendingElementsNonEmpty_(0), |
| 557 |
suppressAnchors_(0) |
| 558 |
{ |
| 559 |
os->setEscaper(outputNumericCharRef); |
| 560 |
*os_ << "<?xml version=\"1.0\"?>" << RE; |
| 561 |
#if 0 |
| 562 |
*os_ << "<!DOCTYPE fot PUBLIC \"-//James Clark//DTD DSSSL Flow Object Tree//EN\">" |
| 563 |
<< RE; |
| 564 |
#endif |
| 565 |
*os_ << "<fot>" << RE; |
| 566 |
} |
| 567 |
|
| 568 |
SgmlFOTBuilder::~SgmlFOTBuilder() |
| 569 |
{ |
| 570 |
os() << "</fot>" << RE; |
| 571 |
} |
| 572 |
|
| 573 |
void SgmlFOTBuilder::characters(const Char *s, size_t n) |
| 574 |
{ |
| 575 |
if (n == 0) |
| 576 |
return; |
| 577 |
flushPendingElements(); |
| 578 |
os() << "<text>" << Data(s, n) << "</text>" << RE; |
| 579 |
} |
| 580 |
|
| 581 |
void SgmlFOTBuilder::charactersFromNode(const NodePtr &nd, const Char *s, size_t n) |
| 582 |
{ |
| 583 |
GroveString name; |
| 584 |
GroveString text; |
| 585 |
NodePtr entity; |
| 586 |
if (n == 1 |
| 587 |
&& *s == 0xFFFD |
| 588 |
&& nd->getEntityName(name) == accessOK |
| 589 |
&& nd->getEntity(entity) == accessOK |
| 590 |
&& entity->getText(text) == accessOK) |
| 591 |
os() << "<sdata name=" << quot << Data(name.data(), name.size()) << quot |
| 592 |
<< " text=" << quot << Data(text.data(), text.size()) << quot |
| 593 |
<< "/>" << RE; |
| 594 |
else |
| 595 |
SgmlFOTBuilder::characters(s, n); |
| 596 |
} |
| 597 |
|
| 598 |
void SgmlFOTBuilder::characterNIC(const CharacterNIC &nic) |
| 599 |
{ |
| 600 |
if (nic.specifiedC) { |
| 601 |
if (nic.specifiedC & (1 << CharacterNIC::cChar)) |
| 602 |
os() << " char=" << quot << "&#" << (unsigned long)nic.ch << ";" << quot; |
| 603 |
if (nic.specifiedC & (1 << CharacterNIC::cGlyphId)) |
| 604 |
os() << " glyph-id=" << quot << nic.glyphId << quot; |
| 605 |
if (nic.specifiedC & (1 << CharacterNIC::cIsDropAfterLineBreak)) |
| 606 |
os() << " drop-after-line-break=" << quot << boolString(nic.isDropAfterLineBreak) << quot; |
| 607 |
if (nic.specifiedC & (1 << CharacterNIC::cIsDropUnlessBeforeLineBreak)) |
| 608 |
os() << " drop-unless-before-line-break=" << quot << boolString(nic.isDropUnlessBeforeLineBreak) << quot; |
| 609 |
if (nic.specifiedC & (1 << CharacterNIC::cIsPunct)) |
| 610 |
os() << " punct=" << quot << boolString(nic.isPunct) << quot; |
| 611 |
if (nic.specifiedC & (1 << CharacterNIC::cIsInputWhitespace)) |
| 612 |
os() << " input-whitespace=" << quot << boolString(nic.isInputWhitespace) << quot; |
| 613 |
if (nic.specifiedC & (1 << CharacterNIC::cIsInputTab)) |
| 614 |
os() << " input-tab=" << quot << boolString(nic.isInputTab) << quot; |
| 615 |
if (nic.specifiedC & (1 << CharacterNIC::cIsRecordEnd)) |
| 616 |
os() << " record-end=" << quot << boolString(nic.isRecordEnd) << quot; |
| 617 |
if (nic.specifiedC & (1 << CharacterNIC::cIsSpace)) |
| 618 |
os() << " space=" << quot << boolString(nic.isSpace) << quot; |
| 619 |
if (nic.specifiedC & (1 << CharacterNIC::cScript)) { |
| 620 |
if (nic.script) |
| 621 |
os() << " script=" << quot << nic.script << quot; |
| 622 |
else |
| 623 |
os() << " script=" << quot << falseString << quot; |
| 624 |
} |
| 625 |
if (nic.specifiedC & (1 << CharacterNIC::cMathClass)) |
| 626 |
os() << " math-class=" << quot << nic.mathClass << quot; |
| 627 |
if (nic.specifiedC & (1 << CharacterNIC::cMathFontPosture)) |
| 628 |
os() << " math-font-posture=" << quot << nic.mathFontPosture << quot; |
| 629 |
if (nic.specifiedC & (1 << CharacterNIC::cBreakBeforePriority)) |
| 630 |
os() << " break-before-priority=" << quot << nic.breakBeforePriority << quot; |
| 631 |
if (nic.specifiedC & (1 << CharacterNIC::cBreakAfterPriority)) |
| 632 |
os() << " break-after-priority=" << quot << nic.breakAfterPriority << quot; |
| 633 |
} |
| 634 |
if (nic.stretchFactor != 1.0) |
| 635 |
os() << " stretch-factor=" << quot << nic.stretchFactor << quot; |
| 636 |
} |
| 637 |
|
| 638 |
void SgmlFOTBuilder::character(const CharacterNIC &nic) |
| 639 |
{ |
| 640 |
flushPendingElements(); |
| 641 |
os() << "<character"; |
| 642 |
characterNIC(nic); |
| 643 |
outputIcs(); |
| 644 |
os() << RE << "/>"; |
| 645 |
} |
| 646 |
|
| 647 |
void SgmlFOTBuilder::outputIcs() |
| 648 |
{ |
| 649 |
StringC str; |
| 650 |
ics_.extractString(str); |
| 651 |
os() << str; |
| 652 |
} |
| 653 |
|
| 654 |
void SgmlFOTBuilder::setFontSize(Length n) |
| 655 |
{ |
| 656 |
lengthC("font-size", n); |
| 657 |
} |
| 658 |
|
| 659 |
void SgmlFOTBuilder::setFontFamilyName(const StringC &str) |
| 660 |
{ |
| 661 |
ics_ << " font-family-name=" << quot << str << quot; |
| 662 |
} |
| 663 |
|
| 664 |
void SgmlFOTBuilder::setFontWeight(Symbol weight) |
| 665 |
{ |
| 666 |
symbolC("font-weight", weight); |
| 667 |
} |
| 668 |
|
| 669 |
void SgmlFOTBuilder::setFontPosture(Symbol posture) |
| 670 |
{ |
| 671 |
symbolC("font-posture", posture); |
| 672 |
} |
| 673 |
|
| 674 |
void SgmlFOTBuilder::setStartIndent(const LengthSpec &ls) |
| 675 |
{ |
| 676 |
lengthSpecC("start-indent", ls); |
| 677 |
} |
| 678 |
|
| 679 |
void SgmlFOTBuilder::setEndIndent(const LengthSpec &ls) |
| 680 |
{ |
| 681 |
lengthSpecC("end-indent", ls); |
| 682 |
} |
| 683 |
|
| 684 |
void SgmlFOTBuilder::setFirstLineStartIndent(const LengthSpec &ls) |
| 685 |
{ |
| 686 |
lengthSpecC("first-line-start-indent", ls); |
| 687 |
} |
| 688 |
|
| 689 |
void SgmlFOTBuilder::setLastLineEndIndent(const LengthSpec &ls) |
| 690 |
{ |
| 691 |
lengthSpecC("last-line-end-indent", ls); |
| 692 |
} |
| 693 |
|
| 694 |
void SgmlFOTBuilder::setLineSpacing(const LengthSpec &ls) |
| 695 |
{ |
| 696 |
lengthSpecC("line-spacing", ls); |
| 697 |
} |
| 698 |
|
| 699 |
void SgmlFOTBuilder::setFieldWidth(const LengthSpec &ls) |
| 700 |
{ |
| 701 |
lengthSpecC("field-width", ls); |
| 702 |
} |
| 703 |
|
| 704 |
void SgmlFOTBuilder::setPositionPointShift(const LengthSpec &ls) |
| 705 |
{ |
| 706 |
lengthSpecC("position-point-shift", ls); |
| 707 |
} |
| 708 |
|
| 709 |
void SgmlFOTBuilder::setStartMargin(const LengthSpec &ls) |
| 710 |
{ |
| 711 |
lengthSpecC("start-margin", ls); |
| 712 |
} |
| 713 |
|
| 714 |
void SgmlFOTBuilder::setEndMargin(const LengthSpec &ls) |
| 715 |
{ |
| 716 |
lengthSpecC("end-margin", ls); |
| 717 |
} |
| 718 |
|
| 719 |
void SgmlFOTBuilder::setSidelineSep(const LengthSpec &ls) |
| 720 |
{ |
| 721 |
lengthSpecC("sideline-sep", ls); |
| 722 |
} |
| 723 |
|
| 724 |
void SgmlFOTBuilder::setAsisWrapIndent(const LengthSpec &ls) |
| 725 |
{ |
| 726 |
lengthSpecC("asis-wrap-indent", ls); |
| 727 |
} |
| 728 |
|
| 729 |
void SgmlFOTBuilder::setLineNumberSep(const LengthSpec &ls) |
| 730 |
{ |
| 731 |
lengthSpecC("line-number-sep", ls); |
| 732 |
} |
| 733 |
|
| 734 |
void SgmlFOTBuilder::setLastLineJustifyLimit(const LengthSpec &ls) |
| 735 |
{ |
| 736 |
lengthSpecC("last-line-justify-limit", ls); |
| 737 |
} |
| 738 |
|
| 739 |
void SgmlFOTBuilder::setJustifyGlyphSpaceMaxAdd(const LengthSpec &ls) |
| 740 |
{ |
| 741 |
lengthSpecC("justify-glyph-space-max-add", ls); |
| 742 |
} |
| 743 |
|
| 744 |
void SgmlFOTBuilder::setJustifyGlyphSpaceMaxRemove(const LengthSpec &ls) |
| 745 |
{ |
| 746 |
lengthSpecC("justify-glyph-space-max-remove", ls); |
| 747 |
} |
| 748 |
|
| 749 |
void SgmlFOTBuilder::setTableCornerRadius(const LengthSpec &ls) |
| 750 |
{ |
| 751 |
lengthSpecC("table-corner-radius", ls); |
| 752 |
} |
| 753 |
|
| 754 |
void SgmlFOTBuilder::setBoxCornerRadius(const LengthSpec &ls) |
| 755 |
{ |
| 756 |
lengthSpecC("box-corner-radius", ls); |
| 757 |
} |
| 758 |
|
| 759 |
void SgmlFOTBuilder::setMarginaliaSep(const LengthSpec &ls) |
| 760 |
{ |
| 761 |
lengthSpecC("marginalia-sep", ls); |
| 762 |
} |
| 763 |
|
| 764 |
void SgmlFOTBuilder::lengthSpecC(const char *s, const LengthSpec &ls) |
| 765 |
{ |
| 766 |
ics_ << ' ' << s << '=' << quot << ls << quot; |
| 767 |
} |
| 768 |
|
| 769 |
void SgmlFOTBuilder::setMinPreLineSpacing(const OptLengthSpec &ols) |
| 770 |
{ |
| 771 |
optLengthSpecC("min-pre-line-spacing", ols); |
| 772 |
} |
| 773 |
|
| 774 |
void SgmlFOTBuilder::setMinPostLineSpacing(const OptLengthSpec &ols) |
| 775 |
{ |
| 776 |
optLengthSpecC("min-post-line-spacing", ols); |
| 777 |
} |
| 778 |
|
| 779 |
void SgmlFOTBuilder::setMinLeading(const OptLengthSpec &ols) |
| 780 |
{ |
| 781 |
optLengthSpecC("min-leading", ols); |
| 782 |
} |
| 783 |
|
| 784 |
void SgmlFOTBuilder::optLengthSpecC(const char *s, const OptLengthSpec &ols) |
| 785 |
{ |
| 786 |
if (ols.hasLength) |
| 787 |
lengthSpecC(s, ols.length); |
| 788 |
else |
| 789 |
ics_ << ' ' << s << quot << falseString << quot; |
| 790 |
} |
| 791 |
|
| 792 |
void SgmlFOTBuilder::setLines(Symbol sym) |
| 793 |
{ |
| 794 |
symbolC("lines", sym); |
| 795 |
} |
| 796 |
|
| 797 |
void SgmlFOTBuilder::setQuadding(Symbol sym) |
| 798 |
{ |
| 799 |
symbolC("quadding", sym); |
| 800 |
} |
| 801 |
|
| 802 |
void SgmlFOTBuilder::setDisplayAlignment(Symbol sym) |
| 803 |
{ |
| 804 |
symbolC("display-alignment", sym); |
| 805 |
} |
| 806 |
|
| 807 |
void SgmlFOTBuilder::setFieldAlign(Symbol sym) |
| 808 |
{ |
| 809 |
symbolC("field-align", sym); |
| 810 |
} |
| 811 |
|
| 812 |
void SgmlFOTBuilder::setLineJoin(Symbol sym) |
| 813 |
{ |
| 814 |
symbolC("line-join", sym); |
| 815 |
} |
| 816 |
|
| 817 |
void SgmlFOTBuilder::setLineCap(Symbol sym) |
| 818 |
{ |
| 819 |
symbolC("line-cap", sym); |
| 820 |
} |
| 821 |
|
| 822 |
void SgmlFOTBuilder::setLineNumberSide(Symbol sym) |
| 823 |
{ |
| 824 |
symbolC("line-number-side", sym); |
| 825 |
} |
| 826 |
|
| 827 |
void SgmlFOTBuilder::setKernMode(Symbol sym) |
| 828 |
{ |
| 829 |
symbolC("kern-mode", sym); |
| 830 |
} |
| 831 |
|
| 832 |
void SgmlFOTBuilder::setInputWhitespaceTreatment(Symbol sym) |
| 833 |
{ |
| 834 |
symbolC("input-whitespace-treatment", sym); |
| 835 |
} |
| 836 |
|
| 837 |
void SgmlFOTBuilder::setFillingDirection(Symbol sym) |
| 838 |
{ |
| 839 |
symbolC("filling-direction", sym); |
| 840 |
} |
| 841 |
|
| 842 |
void SgmlFOTBuilder::setWritingMode(Symbol sym) |
| 843 |
{ |
| 844 |
symbolC("writing-mode", sym); |
| 845 |
} |
| 846 |
|
| 847 |
void SgmlFOTBuilder::setLastLineQuadding(Symbol sym) |
| 848 |
{ |
| 849 |
symbolC("last-line-quadding", sym); |
| 850 |
} |
| 851 |
|
| 852 |
void SgmlFOTBuilder::setMathDisplayMode(Symbol sym) |
| 853 |
{ |
| 854 |
symbolC("math-display-mode", sym); |
| 855 |
} |
| 856 |
|
| 857 |
void SgmlFOTBuilder::setScriptPreAlign(Symbol sym) |
| 858 |
{ |
| 859 |
symbolC("script-pre-align", sym); |
| 860 |
} |
| 861 |
|
| 862 |
void SgmlFOTBuilder::setScriptPostAlign(Symbol sym) |
| 863 |
{ |
| 864 |
symbolC("script-post-align", sym); |
| 865 |
} |
| 866 |
|
| 867 |
void SgmlFOTBuilder::setScriptMidSupAlign(Symbol sym) |
| 868 |
{ |
| 869 |
symbolC("script-mid-sup-align", sym); |
| 870 |
} |
| 871 |
|
| 872 |
void SgmlFOTBuilder::setScriptMidSubAlign(Symbol sym) |
| 873 |
{ |
| 874 |
symbolC("script-mid-sub-align", sym); |
| 875 |
} |
| 876 |
|
| 877 |
void SgmlFOTBuilder::setNumeratorAlign(Symbol sym) |
| 878 |
{ |
| 879 |
symbolC("numerator-align", sym); |
| 880 |
} |
| 881 |
|
| 882 |
void SgmlFOTBuilder::setDenominatorAlign(Symbol sym) |
| 883 |
{ |
| 884 |
symbolC("denominator-align", sym); |
| 885 |
} |
| 886 |
|
| 887 |
void SgmlFOTBuilder::setGridPositionCellType(Symbol sym) |
| 888 |
{ |
| 889 |
symbolC("grid-position-cell-type", sym); |
| 890 |
} |
| 891 |
|
| 892 |
void SgmlFOTBuilder::setGridColumnAlignment(Symbol sym) |
| 893 |
{ |
| 894 |
symbolC("grid-column-alignment", sym); |
| 895 |
} |
| 896 |
|
| 897 |
void SgmlFOTBuilder::setGridRowAlignment(Symbol sym) |
| 898 |
{ |
| 899 |
symbolC("grid-row-alignment", sym); |
| 900 |
} |
| 901 |
|
| 902 |
void SgmlFOTBuilder::setBoxType(Symbol sym) |
| 903 |
{ |
| 904 |
symbolC("box-type", sym); |
| 905 |
} |
| 906 |
|
| 907 |
void SgmlFOTBuilder::setSideBySideOverlapControl(Symbol sym) |
| 908 |
{ |
| 909 |
symbolC("side-by-side-overlap-control", sym); |
| 910 |
} |
| 911 |
|
| 912 |
void SgmlFOTBuilder::setSideBySidePreAlign(Symbol sym) |
| 913 |
{ |
| 914 |
symbolC("side-by-side-pre-align", sym); |
| 915 |
} |
| 916 |
|
| 917 |
void SgmlFOTBuilder::setSideBySidePostAlign(Symbol sym) |
| 918 |
{ |
| 919 |
symbolC("side-by-side-post-align", sym); |
| 920 |
} |
| 921 |
|
| 922 |
void SgmlFOTBuilder::setGlyphAlignmentMode(Symbol sym) |
| 923 |
{ |
| 924 |
symbolC("glyph-alignment-mode", sym); |
| 925 |
} |
| 926 |
|
| 927 |
void SgmlFOTBuilder::setBoxBorderAlignment(Symbol sym) |
| 928 |
{ |
| 929 |
symbolC("box-border-alignment", sym); |
| 930 |
} |
| 931 |
|
| 932 |
void SgmlFOTBuilder::setCellRowAlignment(Symbol sym) |
| 933 |
{ |
| 934 |
symbolC("cell-row-alignment", sym); |
| 935 |
} |
| 936 |
|
| 937 |
void SgmlFOTBuilder::setBorderAlignment(Symbol sym) |
| 938 |
{ |
| 939 |
symbolC("border-alignment", sym); |
| 940 |
} |
| 941 |
|
| 942 |
void SgmlFOTBuilder::setSidelineSide(Symbol sym) |
| 943 |
{ |
| 944 |
symbolC("sideline-side", sym); |
| 945 |
} |
| 946 |
|
| 947 |
void SgmlFOTBuilder::setHyphenationKeep(Symbol sym) |
| 948 |
{ |
| 949 |
symbolC("hyphenation-keep", sym); |
| 950 |
} |
| 951 |
|
| 952 |
void SgmlFOTBuilder::setFontStructure(Symbol sym) |
| 953 |
{ |
| 954 |
symbolC("font-structure", sym); |
| 955 |
} |
| 956 |
|
| 957 |
void SgmlFOTBuilder::setFontProportionateWidth(Symbol sym) |
| 958 |
{ |
| 959 |
symbolC("font-proportionate-width", sym); |
| 960 |
} |
| 961 |
|
| 962 |
void SgmlFOTBuilder::setCellCrossed(Symbol sym) |
| 963 |
{ |
| 964 |
symbolC("cell-crossed", sym); |
| 965 |
} |
| 966 |
|
| 967 |
void SgmlFOTBuilder::setMarginaliaSide(Symbol sym) |
| 968 |
{ |
| 969 |
symbolC("marginalia-side", sym); |
| 970 |
} |
| 971 |
|
| 972 |
void SgmlFOTBuilder::symbolC(const char *name, Symbol sym) |
| 973 |
{ |
| 974 |
ics_ << ' ' << name << '=' << quot << sym << quot; |
| 975 |
} |
| 976 |
|
| 977 |
inline |
| 978 |
void hex2(OutputCharStream &os, unsigned char c) |
| 979 |
{ |
| 980 |
static const char hexDigits[] = "0123456789ABCDEF"; |
| 981 |
os << hexDigits[c >> 4] << hexDigits[c & 0xF]; |
| 982 |
} |
| 983 |
|
| 984 |
inline |
| 985 |
OutputCharStream &operator<<(OutputCharStream &os, const FOTBuilder::DeviceRGBColor &color) |
| 986 |
{ |
| 987 |
os << '#'; |
| 988 |
hex2(os, color.red); |
| 989 |
hex2(os, color.green); |
| 990 |
hex2(os, color.blue); |
| 991 |
return os; |
| 992 |
} |
| 993 |
|
| 994 |
void SgmlFOTBuilder::setColor(const DeviceRGBColor &color) |
| 995 |
{ |
| 996 |
ics_ << " color=" << quot << color << quot; |
| 997 |
} |
| 998 |
|
| 999 |
void SgmlFOTBuilder::setBackgroundColor() |
| 1000 |
{ |
| 1001 |
ics_ << " background-color=" << quot << falseString << quot; |
| 1002 |
} |
| 1003 |
|
| 1004 |
void SgmlFOTBuilder::setBackgroundColor(const DeviceRGBColor &color) |
| 1005 |
{ |
| 1006 |
ics_ << " background-color=" << quot << color << quot; |
| 1007 |
} |
| 1008 |
|
| 1009 |
void SgmlFOTBuilder::setPageWidth(Length units) |
| 1010 |
{ |
| 1011 |
lengthC("page-width", units); |
| 1012 |
} |
| 1013 |
|
| 1014 |
void SgmlFOTBuilder::setPageHeight(Length units) |
| 1015 |
{ |
| 1016 |
lengthC("page-height", units); |
| 1017 |
} |
| 1018 |
|
| 1019 |
void SgmlFOTBuilder::setLeftMargin(Length units) |
| 1020 |
{ |
| 1021 |
lengthC("left-margin", units); |
| 1022 |
} |
| 1023 |
|
| 1024 |
void SgmlFOTBuilder::setRightMargin(Length units) |
| 1025 |
{ |
| 1026 |
lengthC("right-margin", units); |
| 1027 |
} |
| 1028 |
|
| 1029 |
void SgmlFOTBuilder::setTopMargin(Length units) |
| 1030 |
{ |
| 1031 |
lengthC("top-margin", units); |
| 1032 |
} |
| 1033 |
|
| 1034 |
void SgmlFOTBuilder::setBottomMargin(Length units) |
| 1035 |
{ |
| 1036 |
lengthC("bottom-margin", units); |
| 1037 |
} |
| 1038 |
|
| 1039 |
void SgmlFOTBuilder::setHeaderMargin(Length units) |
| 1040 |
{ |
| 1041 |
lengthC("header-margin", units); |
| 1042 |
} |
| 1043 |
|
| 1044 |
void SgmlFOTBuilder::setFooterMargin(Length units) |
| 1045 |
{ |
| 1046 |
lengthC("footer-margin", units); |
| 1047 |
} |
| 1048 |
|
| 1049 |
void SgmlFOTBuilder::setLineThickness(Length units) |
| 1050 |
{ |
| 1051 |
lengthC("line-thickness", units); |
| 1052 |
} |
| 1053 |
|
| 1054 |
void SgmlFOTBuilder::setCellBeforeRowMargin(Length units) |
| 1055 |
{ |
| 1056 |
lengthC("cell-before-row-margin", units); |
| 1057 |
} |
| 1058 |
|
| 1059 |
void SgmlFOTBuilder::setCellAfterRowMargin(Length units) |
| 1060 |
{ |
| 1061 |
lengthC("cell-after-row-margin", units); |
| 1062 |
} |
| 1063 |
|
| 1064 |
void SgmlFOTBuilder::setCellBeforeColumnMargin(Length units) |
| 1065 |
{ |
| 1066 |
lengthC("cell-before-column-margin", units); |
| 1067 |
} |
| 1068 |
|
| 1069 |
void SgmlFOTBuilder::setCellAfterColumnMargin(Length units) |
| 1070 |
{ |
| 1071 |
lengthC("cell-after-column-margin", units); |
| 1072 |
} |
| 1073 |
|
| 1074 |
void SgmlFOTBuilder::setLineSep(Length units) |
| 1075 |
{ |
| 1076 |
lengthC("line-sep", units); |
| 1077 |
} |
| 1078 |
|
| 1079 |
void SgmlFOTBuilder::setBoxSizeBefore(Length units) |
| 1080 |
{ |
| 1081 |
lengthC("box-size-before", units); |
| 1082 |
} |
| 1083 |
|
| 1084 |
void SgmlFOTBuilder::setBoxSizeAfter(Length units) |
| 1085 |
{ |
| 1086 |
lengthC("box-size-after", units); |
| 1087 |
} |
| 1088 |
|
| 1089 |
void SgmlFOTBuilder::lengthC(const char *s, Length units) |
| 1090 |
{ |
| 1091 |
ics_ << ' ' << s << '=' << quot << Units(units) << quot; |
| 1092 |
} |
| 1093 |
|
| 1094 |
void SgmlFOTBuilder::setLayer(long n) |
| 1095 |
{ |
| 1096 |
integerC("layer", n); |
| 1097 |
} |
| 1098 |
|
| 1099 |
void SgmlFOTBuilder::setBackgroundLayer(long n) |
| 1100 |
{ |
| 1101 |
integerC("background-layer", n); |
| 1102 |
} |
| 1103 |
|
| 1104 |
void SgmlFOTBuilder::setBorderPriority(long n) |
| 1105 |
{ |
| 1106 |
integerC("border-priority", n); |
| 1107 |
} |
| 1108 |
|
| 1109 |
void SgmlFOTBuilder::setLineRepeat(long n) |
| 1110 |
{ |
| 1111 |
integerC("line-repeat", n); |
| 1112 |
} |
| 1113 |
|
| 1114 |
void SgmlFOTBuilder::setSpan(long n) |
| 1115 |
{ |
| 1116 |
integerC("span", n); |
| 1117 |
} |
| 1118 |
|
| 1119 |
void SgmlFOTBuilder::setMinLeaderRepeat(long n) |
| 1120 |
{ |
| 1121 |
integerC("min-leader-repeat", n); |
| 1122 |
} |
| 1123 |
|
| 1124 |
void SgmlFOTBuilder::setHyphenationRemainCharCount(long n) |
| 1125 |
{ |
| 1126 |
integerC("hyphenation-remain-char-count", n); |
| 1127 |
} |
| 1128 |
|
| 1129 |
void SgmlFOTBuilder::setHyphenationPushCharCount(long n) |
| 1130 |
{ |
| 1131 |
integerC("hyphenation-push-char-count", n); |
| 1132 |
} |
| 1133 |
|
| 1134 |
void SgmlFOTBuilder::setWidowCount(long n) |
| 1135 |
{ |
| 1136 |
integerC("widow-count", n); |
| 1137 |
} |
| 1138 |
|
| 1139 |
void SgmlFOTBuilder::setOrphanCount(long n) |
| 1140 |
{ |
| 1141 |
integerC("orphan-count", n); |
| 1142 |
} |
| 1143 |
|
| 1144 |
void SgmlFOTBuilder::integerC(const char *s, long n) |
| 1145 |
{ |
| 1146 |
ics_ << ' ' << s << '=' << quot << n << quot; |
| 1147 |
} |
| 1148 |
|
| 1149 |
void SgmlFOTBuilder::setExpandTabs(long n) |
| 1150 |
{ |
| 1151 |
integerC("expand-tabs", n); |
| 1152 |
} |
| 1153 |
|
| 1154 |
void SgmlFOTBuilder::setHyphenationLadderCount(long n) |
| 1155 |
{ |
| 1156 |
integerC("hyphenation-ladder-count", n); |
| 1157 |
} |
| 1158 |
|
| 1159 |
void SgmlFOTBuilder::setCountry(Letter2 code) |
| 1160 |
{ |
| 1161 |
ics_ << " country=" << quot; |
| 1162 |
if (code) |
| 1163 |
ics_ << char((code >> 8) & 0xff) << char(code & 0xff); |
| 1164 |
else |
| 1165 |
ics_ << falseString; |
| 1166 |
ics_ << quot; |
| 1167 |
} |
| 1168 |
|
| 1169 |
void SgmlFOTBuilder::setLanguage(Letter2 code) |
| 1170 |
{ |
| 1171 |
ics_ << " language=" << quot; |
| 1172 |
if (code) |
| 1173 |
ics_ << char((code >> 8) & 0xff) << char(code & 0xff); |
| 1174 |
else |
| 1175 |
ics_ << falseString; |
| 1176 |
ics_ << quot; |
| 1177 |
} |
| 1178 |
|
| 1179 |
void SgmlFOTBuilder::setBackgroundTile(PublicId pubid) |
| 1180 |
{ |
| 1181 |
publicIdC("background-tile", pubid); |
| 1182 |
} |
| 1183 |
|
| 1184 |
void SgmlFOTBuilder::setLineBreakingMethod(PublicId pubid) |
| 1185 |
{ |
| 1186 |
publicIdC("line-breaking-method", pubid); |
| 1187 |
} |
| 1188 |
|
| 1189 |
void SgmlFOTBuilder::setLineCompositionMethod(PublicId pubid) |
| 1190 |
{ |
| 1191 |
publicIdC("line-composition-method", pubid); |
| 1192 |
} |
| 1193 |
|
| 1194 |
void SgmlFOTBuilder::setImplicitBidiMethod(PublicId pubid) |
| 1195 |
{ |
| 1196 |
publicIdC("implicit-bidi-method", pubid); |
| 1197 |
} |
| 1198 |
|
| 1199 |
void SgmlFOTBuilder::setGlyphSubstMethod(PublicId pubid) |
| 1200 |
{ |
| 1201 |
publicIdC("glyph-subst-method", pubid); |
| 1202 |
} |
| 1203 |
|
| 1204 |
void SgmlFOTBuilder::setGlyphReorderMethod(PublicId pubid) |
| 1205 |
{ |
| 1206 |
publicIdC("glyph-reorder-method", pubid); |
| 1207 |
} |
| 1208 |
|
| 1209 |
void SgmlFOTBuilder::setHyphenationMethod(PublicId pubid) |
| 1210 |
{ |
| 1211 |
publicIdC("hyphenation-method", pubid); |
| 1212 |
} |
| 1213 |
|
| 1214 |
void SgmlFOTBuilder::setTableAutoWidthMethod(PublicId pubid) |
| 1215 |
{ |
| 1216 |
publicIdC("table-auto-width-method", pubid); |
| 1217 |
} |
| 1218 |
|
| 1219 |
void SgmlFOTBuilder::setFontName(PublicId pubid) |
| 1220 |
{ |
| 1221 |
publicIdC("font-name", pubid); |
| 1222 |
} |
| 1223 |
|
| 1224 |
void SgmlFOTBuilder::publicIdC(const char *s, PublicId pubid) |
| 1225 |
{ |
| 1226 |
ics_ << ' ' << s << '=' << quot; |
| 1227 |
if (pubid) |
| 1228 |
ics_ << pubid; |
| 1229 |
else |
| 1230 |
ics_ << falseString; |
| 1231 |
ics_ << quot; |
| 1232 |
} |
| 1233 |
|
| 1234 |
void SgmlFOTBuilder::setBorderPresent(bool b) |
| 1235 |
{ |
| 1236 |
boolC("border-present", b); |
| 1237 |
} |
| 1238 |
|
| 1239 |
void SgmlFOTBuilder::setInhibitLineBreaks(bool b) |
| 1240 |
{ |
| 1241 |
boolC("border-present", b); |
| 1242 |
} |
| 1243 |
|
| 1244 |
void SgmlFOTBuilder::setHyphenate(bool b) |
| 1245 |
{ |
| 1246 |
boolC("hyphenate", b); |
| 1247 |
} |
| 1248 |
|
| 1249 |
void SgmlFOTBuilder::setKern(bool b) |
| 1250 |
{ |
| 1251 |
boolC("kern", b); |
| 1252 |
} |
| 1253 |
|
| 1254 |
void SgmlFOTBuilder::setLigature(bool b) |
| 1255 |
{ |
| 1256 |
boolC("ligature", b); |
| 1257 |
} |
| 1258 |
|
| 1259 |
void SgmlFOTBuilder::setScoreSpaces(bool b) |
| 1260 |
{ |
| 1261 |
boolC("score-spaces", b); |
| 1262 |
} |
| 1263 |
|
| 1264 |
void SgmlFOTBuilder::setFloatOutMarginalia(bool b) |
| 1265 |
{ |
| 1266 |
boolC("float-out-marginalia", b); |
| 1267 |
} |
| 1268 |
|
| 1269 |
void SgmlFOTBuilder::setFloatOutSidelines(bool b) |
| 1270 |
{ |
| 1271 |
boolC("float-out-sidelines", b); |
| 1272 |
} |
| 1273 |
|
| 1274 |
void SgmlFOTBuilder::setFloatOutLineNumbers(bool b) |
| 1275 |
{ |
| 1276 |
boolC("float-out-line-numbers", b); |
| 1277 |
} |
| 1278 |
|
| 1279 |
void SgmlFOTBuilder::setCellBackground(bool b) |
| 1280 |
{ |
| 1281 |
boolC("cell-background", b); |
| 1282 |
} |
| 1283 |
|
| 1284 |
void SgmlFOTBuilder::setSpanWeak(bool b) |
| 1285 |
{ |
| 1286 |
boolC("span-weak", b); |
| 1287 |
} |
| 1288 |
|
| 1289 |
void SgmlFOTBuilder::setIgnoreRecordEnd(bool b) |
| 1290 |
{ |
| 1291 |
boolC("ignore-record-end", b); |
| 1292 |
} |
| 1293 |
|
| 1294 |
void SgmlFOTBuilder::setNumberedLines(bool b) |
| 1295 |
{ |
| 1296 |
boolC("numbered-lines", b); |
| 1297 |
} |
| 1298 |
|
| 1299 |
void SgmlFOTBuilder::setHangingPunct(bool b) |
| 1300 |
{ |
| 1301 |
boolC("hanging-punct", b); |
| 1302 |
} |
| 1303 |
|
| 1304 |
void SgmlFOTBuilder::setBoxOpenEnd(bool b) |
| 1305 |
{ |
| 1306 |
boolC("box-open-end", b); |
| 1307 |
} |
| 1308 |
|
| 1309 |
void SgmlFOTBuilder::setTruncateLeader(bool b) |
| 1310 |
{ |
| 1311 |
boolC("truncate-leader", b); |
| 1312 |
} |
| 1313 |
|
| 1314 |
void SgmlFOTBuilder::setAlignLeader(bool b) |
| 1315 |
{ |
| 1316 |
boolC("align-leader", b); |
| 1317 |
} |
| 1318 |
|
| 1319 |
void SgmlFOTBuilder::setTablePartOmitMiddleHeader(bool b) |
| 1320 |
{ |
| 1321 |
boolC("table-part-omit-middle-header", b); |
| 1322 |
} |
| 1323 |
|
| 1324 |
void SgmlFOTBuilder::setTablePartOmitMiddleFooter(bool b) |
| 1325 |
{ |
| 1326 |
boolC("table-part-omit-middle-footer", b); |
| 1327 |
} |
| 1328 |
|
| 1329 |
void SgmlFOTBuilder::setBorderOmitAtBreak(bool b) |
| 1330 |
{ |
| 1331 |
boolC("border-omit-at-break", b); |
| 1332 |
} |
| 1333 |
|
| 1334 |
void SgmlFOTBuilder::setPrincipalModeSimultaneous(bool b) |
| 1335 |
{ |
| 1336 |
boolC("principal-mode-simultaneous", b); |
| 1337 |
} |
| 1338 |
|
| 1339 |
void SgmlFOTBuilder::setMarginaliaKeepWithPrevious(bool b) |
| 1340 |
{ |
| 1341 |
boolC("marginalia-keep-with-previous", b); |
| 1342 |
} |
| 1343 |
|
| 1344 |
void SgmlFOTBuilder::setGridEquidistantRows(bool b) |
| 1345 |
{ |
| 1346 |
boolC("grid-equidistant-rows", b); |
| 1347 |
} |
| 1348 |
|
| 1349 |
void SgmlFOTBuilder::setGridEquidistantColumns(bool b) |
| 1350 |
{ |
| 1351 |
boolC("grid-equidistant-columns", b); |
| 1352 |
} |
| 1353 |
|
| 1354 |
void SgmlFOTBuilder::boolC(const char *s, bool b) |
| 1355 |
{ |
| 1356 |
ics_ << ' ' << s << '=' << quot << boolString(b) << quot; |
| 1357 |
} |
| 1358 |
|
| 1359 |
void SgmlFOTBuilder::setEscapementSpaceBefore(const InlineSpace &is) |
| 1360 |
{ |
| 1361 |
inlineSpaceC("escapement-space-before", is); |
| 1362 |
} |
| 1363 |
|
| 1364 |
void SgmlFOTBuilder::setEscapementSpaceAfter(const InlineSpace &is) |
| 1365 |
{ |
| 1366 |
inlineSpaceC("escapement-space-after", is); |
| 1367 |
} |
| 1368 |
|
| 1369 |
void SgmlFOTBuilder::setInlineSpaceSpace(const OptInlineSpace &s) |
| 1370 |
{ |
| 1371 |
optInlineSpaceC("inline-space-space", s); |
| 1372 |
} |
| 1373 |
|
| 1374 |
void SgmlFOTBuilder::setCharMap(Symbol sym) |
| 1375 |
{ |
| 1376 |
symbolC("char-map", sym); |
| 1377 |
} |
| 1378 |
|
| 1379 |
void SgmlFOTBuilder::setGlyphSubstTable(const Vector<ConstPtr<GlyphSubstTable> > &tables) |
| 1380 |
{ |
| 1381 |
if (tables.size() == 0) { |
| 1382 |
ics_ << " glyph-subst-table=" << quot << quot; |
| 1383 |
return; |
| 1384 |
} |
| 1385 |
static const char idPrefix[] = "gst"; |
| 1386 |
ics_ << " glyph-subst-table=" << quot; |
| 1387 |
for (size_t i = 0; i < tables.size(); i++) { |
| 1388 |
unsigned long n = tables[i]->uniqueId; |
| 1389 |
if (n >= glyphSubstTableDefined_.size()) { |
| 1390 |
for (size_t j = glyphSubstTableDefined_.size(); j < n + 1; j++) |
| 1391 |
glyphSubstTableDefined_.push_back(0); |
| 1392 |
} |
| 1393 |
if (!glyphSubstTableDefined_[n]) { |
| 1394 |
glyphSubstTableDefined_[n] = 1; |
| 1395 |
os() << "<define-glyph-subst-table id=" << quot << idPrefix << n << quot << '>' << RE; |
| 1396 |
const Vector<GlyphId> &pairs = tables[i]->pairs; |
| 1397 |
for (size_t i = 0; i < pairs.size(); i += 2) |
| 1398 |
os() << "<glyph-subst old=" << quot << pairs[i] << quot |
| 1399 |
<< " new=" << quot << pairs[i + 1] << quot << "/>" << RE; |
| 1400 |
os() << "</define-glyph-subst-table>"; |
| 1401 |
} |
| 1402 |
if (i > 0) |
| 1403 |
ics_ << ' '; |
| 1404 |
ics_ << idPrefix << n; |
| 1405 |
} |
| 1406 |
ics_ << quot; |
| 1407 |
} |
| 1408 |
|
| 1409 |
void SgmlFOTBuilder::inlineSpaceC(const char *s, const InlineSpace &is) |
| 1410 |
{ |
| 1411 |
if (is.nominal || is.min || is.max) { |
| 1412 |
ics_ << ' ' << s << '=' << quot << is.nominal; |
| 1413 |
if (is.min.length != is.nominal.length |
| 1414 |
|| is.min.displaySizeFactor != is.nominal.displaySizeFactor |
| 1415 |
|| is.max.length != is.nominal.length |
| 1416 |
|| is.max.displaySizeFactor != is.nominal.displaySizeFactor) |
| 1417 |
ics_ << ',' << is.min << ',' << is.max; |
| 1418 |
} |
| 1419 |
} |
| 1420 |
|
| 1421 |
void SgmlFOTBuilder::optInlineSpaceC(const char *ch, const OptInlineSpace &ois) |
| 1422 |
{ |
| 1423 |
if (ois.hasSpace) |
| 1424 |
inlineSpaceC(ch, ois.space); |
| 1425 |
else |
| 1426 |
ics_ << ' ' << ch << "=" << quot << falseString << quot; |
| 1427 |
} |
| 1428 |
|
| 1429 |
void SgmlFOTBuilder::displayNIC(const DisplayNIC &nic) |
| 1430 |
{ |
| 1431 |
if (nic.keepWithPrevious) |
| 1432 |
os() << " keep-with-previous=" << quot << trueString << quot; |
| 1433 |
if (nic.keepWithNext) |
| 1434 |
os() << " keep-with-next=" << quot << trueString << quot; |
| 1435 |
if (nic.mayViolateKeepBefore) |
| 1436 |
os() << " may-violate-keep-before=" << quot << trueString << quot; |
| 1437 |
if (nic.mayViolateKeepAfter) |
| 1438 |
os() << " may-violate-keep-after=" << quot << trueString << quot; |
| 1439 |
if (nic.positionPreference != symbolFalse) |
| 1440 |
os() << " position-preference=" << quot << nic.positionPreference << quot; |
| 1441 |
if (nic.keep != symbolFalse) |
| 1442 |
os() << " keep=" << quot << nic.keep << quot; |
| 1443 |
if (nic.breakBefore != symbolFalse) |
| 1444 |
os() << " break-before=" << quot << nic.breakBefore << quot; |
| 1445 |
if (nic.breakAfter != symbolFalse) |
| 1446 |
os() << " break-after=" << quot << nic.breakAfter << quot; |
| 1447 |
displaySpaceNIC("space-before", nic.spaceBefore); |
| 1448 |
displaySpaceNIC("space-after", nic.spaceAfter); |
| 1449 |
} |
| 1450 |
|
| 1451 |
void SgmlFOTBuilder::displaySpaceNIC(const char *s, const DisplaySpace &ds) |
| 1452 |
{ |
| 1453 |
if (ds.nominal || ds.min || ds.max) { |
| 1454 |
os() << ' ' << s << '=' << quot << ds.nominal; |
| 1455 |
if (ds.min.length != ds.nominal.length |
| 1456 |
|| ds.min.displaySizeFactor != ds.nominal.displaySizeFactor |
| 1457 |
|| ds.max.length != ds.nominal.length |
| 1458 |
|| ds.max.displaySizeFactor != ds.nominal.displaySizeFactor) |
| 1459 |
os() << ',' << ds.min << ',' << ds.max; |
| 1460 |
os() << quot; |
| 1461 |
} |
| 1462 |
if (ds.force) |
| 1463 |
os() << ' ' << s << "-priority=" << quot << "force" << quot; |
| 1464 |
else if (ds.priority) |
| 1465 |
os() << ' ' << s << "-priority=" << quot << ds.priority << quot; |
| 1466 |
if (!ds.conditional) |
| 1467 |
os() << ' ' << s << "-conditional=" << quot << falseString << quot; |
| 1468 |
} |
| 1469 |
|
| 1470 |
void SgmlFOTBuilder::inlineNIC(const InlineNIC &nic) |
| 1471 |
{ |
| 1472 |
if (nic.breakBeforePriority) |
| 1473 |
os() << " break-before-priority=" << quot << nic.breakBeforePriority << quot; |
| 1474 |
if (nic.breakAfterPriority) |
| 1475 |
os() << " break-after-priority=" << quot << nic.breakAfterPriority << quot; |
| 1476 |
} |
| 1477 |
|
| 1478 |
void SgmlFOTBuilder::startParagraph(const ParagraphNIC &nic) |
| 1479 |
{ |
| 1480 |
os() << "<paragraph"; |
| 1481 |
displayNIC(nic); |
| 1482 |
outputIcs(); |
| 1483 |
os() << ">" << RE; |
| 1484 |
} |
| 1485 |
|
| 1486 |
void SgmlFOTBuilder::endParagraph() |
| 1487 |
{ |
| 1488 |
endFlow("paragraph"); |
| 1489 |
} |
| 1490 |
|
| 1491 |
void SgmlFOTBuilder::paragraphBreak(const ParagraphNIC &nic) |
| 1492 |
{ |
| 1493 |
os() << "<paragraph-break"; |
| 1494 |
displayNIC(nic); |
| 1495 |
outputIcs(); |
| 1496 |
os() << "/>" << RE; |
| 1497 |
} |
| 1498 |
|
| 1499 |
void SgmlFOTBuilder::startDisplayGroup(const DisplayGroupNIC &nic) |
| 1500 |
{ |
| 1501 |
os() << "<display-group"; |
| 1502 |
if (nic.hasCoalesceId) |
| 1503 |
os() << " coalesce-id=" << quot << Data(nic.coalesceId) << quot; |
| 1504 |
displayNIC(nic); |
| 1505 |
outputIcs(); |
| 1506 |
os() << ">" << RE; |
| 1507 |
} |
| 1508 |
|
| 1509 |
void SgmlFOTBuilder::endDisplayGroup() |
| 1510 |
{ |
| 1511 |
endFlow("display-group"); |
| 1512 |
} |
| 1513 |
|
| 1514 |
void SgmlFOTBuilder::simpleFlowObj(const char *name) |
| 1515 |
{ |
| 1516 |
os() << '<' << name; |
| 1517 |
outputIcs(); |
| 1518 |
os() << "/>" << RE; |
| 1519 |
} |
| 1520 |
|
| 1521 |
void SgmlFOTBuilder::startSimpleFlowObj(const char *name) |
| 1522 |
{ |
| 1523 |
os() << '<' << name; |
| 1524 |
outputIcs(); |
| 1525 |
os() << ">" << RE; |
| 1526 |
} |
| 1527 |
|
| 1528 |
void SgmlFOTBuilder::startPortFlow(const char *name) |
| 1529 |
{ |
| 1530 |
os() << "<" << name << ">" << RE; |
| 1531 |
} |
| 1532 |
|
| 1533 |
void SgmlFOTBuilder::endFlow(const char *name) |
| 1534 |
{ |
| 1535 |
os() << "</" << name << ">" << RE; |
| 1536 |
} |
| 1537 |
|
| 1538 |
void SgmlFOTBuilder::startSequence() |
| 1539 |
{ |
| 1540 |
startSimpleFlowObj("sequence"); |
| 1541 |
} |
| 1542 |
|
| 1543 |
void SgmlFOTBuilder::endSequence() |
| 1544 |
{ |
| 1545 |
endFlow("sequence"); |
| 1546 |
} |
| 1547 |
|
| 1548 |
void SgmlFOTBuilder::startLineField(const LineFieldNIC &) |
| 1549 |
{ |
| 1550 |
flushPendingElements(); |
| 1551 |
startSimpleFlowObj("line-field"); |
| 1552 |
} |
| 1553 |
|
| 1554 |
void SgmlFOTBuilder::endLineField() |
| 1555 |
{ |
| 1556 |
endFlow("line-field"); |
| 1557 |
} |
| 1558 |
|
| 1559 |
void SgmlFOTBuilder::startScroll() |
| 1560 |
{ |
| 1561 |
startSimpleFlowObj("scroll"); |
| 1562 |
} |
| 1563 |
|
| 1564 |
void SgmlFOTBuilder::endScroll() |
| 1565 |
{ |
| 1566 |
endFlow("scroll"); |
| 1567 |
} |
| 1568 |
|
| 1569 |
void SgmlFOTBuilder::startLink(const Address &addr) |
| 1570 |
{ |
| 1571 |
os() << "<link"; |
| 1572 |
outputIcs(); |
| 1573 |
switch (addr.type) { |
| 1574 |
case Address::sgmlDocument: |
| 1575 |
// FIXME |
| 1576 |
break; |
| 1577 |
case Address::resolvedNode: |
| 1578 |
if (!nodeIsElement(addr.node)) |
| 1579 |
break; |
| 1580 |
os() << " destination=" << quot; |
| 1581 |
outputElementName(addr.node); |
| 1582 |
os() << quot; |
| 1583 |
break; |
| 1584 |
case Address::idref: |
| 1585 |
os() << " destination=" << quot; |
| 1586 |
outputElementName(addr.node->groveIndex(), addr.params[0].data(), addr.params[0].size()); |
| 1587 |
os() << quot; |
| 1588 |
break; |
| 1589 |
case Address::entity: |
| 1590 |
// FIXME |
| 1591 |
break; |
| 1592 |
default: |
| 1593 |
break; |
| 1594 |
} |
| 1595 |
os() << '>' << RE; |
| 1596 |
} |
| 1597 |
|
| 1598 |
void SgmlFOTBuilder::endLink() |
| 1599 |
{ |
| 1600 |
endFlow("link"); |
| 1601 |
} |
| 1602 |
|
| 1603 |
void SgmlFOTBuilder::startMarginalia() |
| 1604 |
{ |
| 1605 |
startSimpleFlowObj("marginalia"); |
| 1606 |
} |
| 1607 |
|
| 1608 |
void SgmlFOTBuilder::endMarginalia() |
| 1609 |
{ |
| 1610 |
endFlow("marginalia"); |
| 1611 |
} |
| 1612 |
|
| 1613 |
void SgmlFOTBuilder::startMultiModeSerial(const MultiMode *principalMode) |
| 1614 |
{ |
| 1615 |
startSimpleFlowObj("multi-mode"); |
| 1616 |
if (principalMode) { |
| 1617 |
os() << "<multi-mode.mode"; |
| 1618 |
if (principalMode->hasDesc) |
| 1619 |
os() << " desc=" << quot << Data(principalMode->desc) << quot; |
| 1620 |
os() << '>' << RE; |
| 1621 |
} |
| 1622 |
multiModeHasPrincipalMode_.push_back(principalMode != 0); |
| 1623 |
} |
| 1624 |
|
| 1625 |
void SgmlFOTBuilder::endMultiModeSerial() |
| 1626 |
{ |
| 1627 |
if (multiModeHasPrincipalMode_.back()) |
| 1628 |
endFlow("multi-mode.mode"); |
| 1629 |
multiModeHasPrincipalMode_.resize(multiModeHasPrincipalMode_.size() - 1); |
| 1630 |
endFlow("multi-mode"); |
| 1631 |
} |
| 1632 |
|
| 1633 |
void SgmlFOTBuilder::startMultiModeMode(const MultiMode &mode) |
| 1634 |
{ |
| 1635 |
if (multiModeHasPrincipalMode_.back()) { |
| 1636 |
endFlow("multi-mode.mode"); |
| 1637 |
multiModeHasPrincipalMode_.back() = 0; |
| 1638 |
} |
| 1639 |
os() << "<multi-mode.mode name=" << quot << Data(mode.name) << quot; |
| 1640 |
if (mode.hasDesc) |
| 1641 |
os() << " desc=" << quot << Data(mode.desc) << quot; |
| 1642 |
os () << '>' << RE; |
| 1643 |
} |
| 1644 |
|
| 1645 |
void SgmlFOTBuilder::endMultiModeMode() |
| 1646 |
{ |
| 1647 |
endFlow("multi-mode.mode"); |
| 1648 |
} |
| 1649 |
|
| 1650 |
void SgmlFOTBuilder::startScore(Symbol type) |
| 1651 |
{ |
| 1652 |
const char *s = symbolName(type); |
| 1653 |
if (s) { |
| 1654 |
os() << "<score type=" << quot << s << quot; |
| 1655 |
outputIcs(); |
| 1656 |
os() << '>' << RE; |
| 1657 |
} |
| 1658 |
} |
| 1659 |
|
| 1660 |
void SgmlFOTBuilder::startScore(const LengthSpec &ls) |
| 1661 |
{ |
| 1662 |
os() << "<score type=" << quot << ls << quot; |
| 1663 |
outputIcs(); |
| 1664 |
os() << '>' << RE; |
| 1665 |
} |
| 1666 |
|
| 1667 |
void SgmlFOTBuilder::startScore(Char c) |
| 1668 |
{ |
| 1669 |
os() << "<score type=\"char\" char=" << quot; |
| 1670 |
os().put(c); |
| 1671 |
os() << quot; |
| 1672 |
outputIcs(); |
| 1673 |
os() << '>' << RE; |
| 1674 |
} |
| 1675 |
|
| 1676 |
void SgmlFOTBuilder::endScore() |
| 1677 |
{ |
| 1678 |
endFlow("score"); |
| 1679 |
} |
| 1680 |
|
| 1681 |
void SgmlFOTBuilder::startSimplePageSequenceSerial() |
| 1682 |
{ |
| 1683 |
startSimpleFlowObj("simple-page-sequence"); |
| 1684 |
suppressAnchors_ = 1; |
| 1685 |
curOs_ = &hfs_; |
| 1686 |
} |
| 1687 |
|
| 1688 |
void SgmlFOTBuilder::endSimplePageSequenceSerial() |
| 1689 |
{ |
| 1690 |
endFlow("simple-page-sequence"); |
| 1691 |
} |
| 1692 |
|
| 1693 |
void SgmlFOTBuilder::startSimplePageSequenceHeaderFooter(unsigned flags) |
| 1694 |
{ |
| 1695 |
} |
| 1696 |
|
| 1697 |
void SgmlFOTBuilder::endSimplePageSequenceHeaderFooter(unsigned flags) |
| 1698 |
{ |
| 1699 |
hfs_.extractString(hf_[flags]); |
| 1700 |
} |
| 1701 |
|
| 1702 |
void SgmlFOTBuilder::endAllSimplePageSequenceHeaderFooter() |
| 1703 |
{ |
| 1704 |
curOs_ = os_.pointer(); |
| 1705 |
suppressAnchors_ = 0; |
| 1706 |
for (int i = 0; i < nHF; i += nHF/6) { |
| 1707 |
int front; |
| 1708 |
if (hf_[i + (firstHF|frontHF)] != hf_[i + (firstHF|backHF)] |
| 1709 |
|| hf_[i + (otherHF|frontHF)] != hf_[i + (otherHF|backHF)]) |
| 1710 |
front = frontHF; |
| 1711 |
else |
| 1712 |
front = 0; |
| 1713 |
int first; |
| 1714 |
if (hf_[i + (firstHF|frontHF)] != hf_[i + (otherHF|frontHF)] |
| 1715 |
|| hf_[i + (firstHF|backHF)] != hf_[i + (otherHF|backHF)]) |
| 1716 |
first = firstHF; |
| 1717 |
else |
| 1718 |
first = 0; |
| 1719 |
for (int j = 0; j <= front; j += frontHF) { |
| 1720 |
for (int k = 0; k <= first; k += firstHF) { |
| 1721 |
const StringC &str = hf_[i + j + k]; |
| 1722 |
if (str.size() != 0) { |
| 1723 |
const char *side; |
| 1724 |
if (i & centerHF) |
| 1725 |
side = "center"; |
| 1726 |
else if (i & rightHF) |
| 1727 |
side = "right"; |
| 1728 |
else |
| 1729 |
side = "left"; |
| 1730 |
const char *hf = (i & headerHF) ? "header" : "footer"; |
| 1731 |
os() << "<simple-page-sequence." << side << '-' << hf; |
| 1732 |
if (front) |
| 1733 |
os() << " front=" << quot << boolString(j != 0) << quot; |
| 1734 |
if (first) |
| 1735 |
os() << " first=" << quot << boolString(k != 0) << quot; |
| 1736 |
os() << '>' << RE; |
| 1737 |
os() << str << "</simple-page-sequence." << side << '-' << hf << '>' << RE; |
| 1738 |
} |
| 1739 |
} |
| 1740 |
} |
| 1741 |
} |
| 1742 |
|
| 1743 |
} |
| 1744 |
|
| 1745 |
void SgmlFOTBuilder::pageNumber() |
| 1746 |
{ |
| 1747 |
os() << "<page-number/>" << RE; |
| 1748 |
} |
| 1749 |
|
| 1750 |
void SgmlFOTBuilder::startMathSequence() |
| 1751 |
{ |
| 1752 |
startSimpleFlowObj("math-sequence"); |
| 1753 |
} |
| 1754 |
|
| 1755 |
void SgmlFOTBuilder::endMathSequence() |
| 1756 |
{ |
| 1757 |
endFlow("math-sequence"); |
| 1758 |
} |
| 1759 |
|
| 1760 |
void SgmlFOTBuilder::startFractionSerial() |
| 1761 |
{ |
| 1762 |
startSimpleFlowObj("fraction"); |
| 1763 |
} |
| 1764 |
|
| 1765 |
void SgmlFOTBuilder::endFractionSerial() |
| 1766 |
{ |
| 1767 |
endFlow("fraction"); |
| 1768 |
} |
| 1769 |
|
| 1770 |
void SgmlFOTBuilder::startFractionNumerator() |
| 1771 |
{ |
| 1772 |
startPortFlow("fraction.numerator"); |
| 1773 |
} |
| 1774 |
|
| 1775 |
void SgmlFOTBuilder::endFractionNumerator() |
| 1776 |
{ |
| 1777 |
endFlow("fraction.numerator"); |
| 1778 |
} |
| 1779 |
|
| 1780 |
void SgmlFOTBuilder::startFractionDenominator() |
| 1781 |
{ |
| 1782 |
startPortFlow("fraction.denominator"); |
| 1783 |
} |
| 1784 |
|
| 1785 |
void SgmlFOTBuilder::endFractionDenominator() |
| 1786 |
{ |
| 1787 |
endFlow("fraction.denominator"); |
| 1788 |
} |
| 1789 |
|
| 1790 |
void SgmlFOTBuilder::fractionBar() |
| 1791 |
{ |
| 1792 |
simpleFlowObj("fraction.fraction-bar"); |
| 1793 |
} |
| 1794 |
|
| 1795 |
void SgmlFOTBuilder::startUnmath() |
| 1796 |
{ |
| 1797 |
startSimpleFlowObj("unmath"); |
| 1798 |
} |
| 1799 |
|
| 1800 |
void SgmlFOTBuilder::endUnmath() |
| 1801 |
{ |
| 1802 |
endFlow("unmath"); |
| 1803 |
} |
| 1804 |
|
| 1805 |
void SgmlFOTBuilder::startSuperscript() |
| 1806 |
{ |
| 1807 |
startSimpleFlowObj("superscript"); |
| 1808 |
} |
| 1809 |
|
| 1810 |
void SgmlFOTBuilder::endSuperscript() |
| 1811 |
{ |
| 1812 |
endFlow("superscript"); |
| 1813 |
} |
| 1814 |
|
| 1815 |
void SgmlFOTBuilder::startSubscript() |
| 1816 |
{ |
| 1817 |
startSimpleFlowObj("subscript"); |
| 1818 |
} |
| 1819 |
|
| 1820 |
void SgmlFOTBuilder::endSubscript() |
| 1821 |
{ |
| 1822 |
endFlow("subscript"); |
| 1823 |
} |
| 1824 |
|
| 1825 |
void SgmlFOTBuilder::startScriptSerial() |
| 1826 |
{ |
| 1827 |
startSimpleFlowObj("script"); |
| 1828 |
startPortFlow("script.principal"); |
| 1829 |
} |
| 1830 |
|
| 1831 |
void SgmlFOTBuilder::endScriptSerial() |
| 1832 |
{ |
| 1833 |
endFlow("script"); |
| 1834 |
} |
| 1835 |
|
| 1836 |
void SgmlFOTBuilder::startScriptPreSup() |
| 1837 |
{ |
| 1838 |
endFlow("script.principal"); |
| 1839 |
startPortFlow("script.pre-sup"); |
| 1840 |
} |
| 1841 |
|
| 1842 |
void SgmlFOTBuilder::endScriptPreSup() |
| 1843 |
{ |
| 1844 |
endFlow("script.pre-sup"); |
| 1845 |
} |
| 1846 |
|
| 1847 |
void SgmlFOTBuilder::startScriptPreSub() |
| 1848 |
{ |
| 1849 |
startPortFlow("script.pre-sub"); |
| 1850 |
} |
| 1851 |
|
| 1852 |
void SgmlFOTBuilder::endScriptPreSub() |
| 1853 |
{ |
| 1854 |
endFlow("script.pre-sub"); |
| 1855 |
} |
| 1856 |
|
| 1857 |
void SgmlFOTBuilder::startScriptPostSup() |
| 1858 |
{ |
| 1859 |
startPortFlow("script.post-sup"); |
| 1860 |
} |
| 1861 |
|
| 1862 |
void SgmlFOTBuilder::endScriptPostSup() |
| 1863 |
{ |
| 1864 |
endFlow("script.post-sup"); |
| 1865 |
} |
| 1866 |
|
| 1867 |
void SgmlFOTBuilder::startScriptPostSub() |
| 1868 |
{ |
| 1869 |
startPortFlow("script.post-sub"); |
| 1870 |
} |
| 1871 |
|
| 1872 |
void SgmlFOTBuilder::endScriptPostSub() |
| 1873 |
{ |
| 1874 |
endFlow("script.post-sub"); |
| 1875 |
} |
| 1876 |
|
| 1877 |
void SgmlFOTBuilder::startScriptMidSup() |
| 1878 |
{ |
| 1879 |
startPortFlow("script.mid-sup"); |
| 1880 |
} |
| 1881 |
|
| 1882 |
void SgmlFOTBuilder::endScriptMidSup() |
| 1883 |
{ |
| 1884 |
endFlow("script.mid-sup"); |
| 1885 |
} |
| 1886 |
|
| 1887 |
void SgmlFOTBuilder::startScriptMidSub() |
| 1888 |
{ |
| 1889 |
startPortFlow("script.mid-sub"); |
| 1890 |
} |
| 1891 |
|
| 1892 |
void SgmlFOTBuilder::endScriptMidSub() |
| 1893 |
{ |
| 1894 |
endFlow("script.mid-sub"); |
| 1895 |
} |
| 1896 |
|
| 1897 |
void SgmlFOTBuilder::startMarkSerial() |
| 1898 |
{ |
| 1899 |
startSimpleFlowObj("mark"); |
| 1900 |
startPortFlow("mark.principal"); |
| 1901 |
} |
| 1902 |
|
| 1903 |
void SgmlFOTBuilder::endMarkSerial() |
| 1904 |
{ |
| 1905 |
endFlow("mark"); |
| 1906 |
} |
| 1907 |
|
| 1908 |
void SgmlFOTBuilder::startMarkOver() |
| 1909 |
{ |
| 1910 |
endFlow("mark.principal"); |
| 1911 |
startPortFlow("mark.over-mark"); |
| 1912 |
} |
| 1913 |
|
| 1914 |
void SgmlFOTBuilder::endMarkOver() |
| 1915 |
{ |
| 1916 |
endFlow("mark.over-mark"); |
| 1917 |
} |
| 1918 |
|
| 1919 |
void SgmlFOTBuilder::startMarkUnder() |
| 1920 |
{ |
| 1921 |
startPortFlow("mark.under-mark"); |
| 1922 |
} |
| 1923 |
|
| 1924 |
void SgmlFOTBuilder::endMarkUnder() |
| 1925 |
{ |
| 1926 |
endFlow("mark.under-mark"); |
| 1927 |
} |
| 1928 |
|
| 1929 |
void SgmlFOTBuilder::startFenceSerial() |
| 1930 |
{ |
| 1931 |
startSimpleFlowObj("fence"); |
| 1932 |
startPortFlow("fence.principal"); |
| 1933 |
} |
| 1934 |
|
| 1935 |
void SgmlFOTBuilder::endFenceSerial() |
| 1936 |
{ |
| 1937 |
endFlow("fence"); |
| 1938 |
} |
| 1939 |
|
| 1940 |
void SgmlFOTBuilder::startFenceOpen() |
| 1941 |
{ |
| 1942 |
endFlow("fence.principal"); |
| 1943 |
startPortFlow("fence.open"); |
| 1944 |
} |
| 1945 |
|
| 1946 |
void SgmlFOTBuilder::endFenceOpen() |
| 1947 |
{ |
| 1948 |
endFlow("fence.open"); |
| 1949 |
} |
| 1950 |
|
| 1951 |
void SgmlFOTBuilder::startFenceClose() |
| 1952 |
{ |
| 1953 |
startPortFlow("fence.close"); |
| 1954 |
} |
| 1955 |
|
| 1956 |
void SgmlFOTBuilder::endFenceClose() |
| 1957 |
{ |
| 1958 |
endFlow("fence.close"); |
| 1959 |
} |
| 1960 |
|
| 1961 |
void SgmlFOTBuilder::startRadicalSerial() |
| 1962 |
{ |
| 1963 |
startSimpleFlowObj("radical"); |
| 1964 |
} |
| 1965 |
|
| 1966 |
void SgmlFOTBuilder::endRadicalSerial() |
| 1967 |
{ |
| 1968 |
endFlow("radical"); |
| 1969 |
} |
| 1970 |
|
| 1971 |
void SgmlFOTBuilder::startRadicalDegree() |
| 1972 |
{ |
| 1973 |
endFlow("radical.principal"); |
| 1974 |
startPortFlow("radical.degree"); |
| 1975 |
} |
| 1976 |
|
| 1977 |
void SgmlFOTBuilder::endRadicalDegree() |
| 1978 |
{ |
| 1979 |
endFlow("radical.degree"); |
| 1980 |
} |
| 1981 |
|
| 1982 |
void SgmlFOTBuilder::radicalRadical(const CharacterNIC &nic) |
| 1983 |
{ |
| 1984 |
os() << "<radical.radical"; |
| 1985 |
characterNIC(nic); |
| 1986 |
outputIcs(); |
| 1987 |
os() << "/>" << RE; |
| 1988 |
startPortFlow("radical.principal"); |
| 1989 |
} |
| 1990 |
|
| 1991 |
void SgmlFOTBuilder::radicalRadicalDefaulted() |
| 1992 |
{ |
| 1993 |
startPortFlow("radical.principal"); |
| 1994 |
} |
| 1995 |
|
| 1996 |
void SgmlFOTBuilder::startMathOperatorSerial() |
| 1997 |
{ |
| 1998 |
startSimpleFlowObj("math-operator"); |
| 1999 |
startPortFlow("math-operator.principal"); |
| 2000 |
} |
| 2001 |
|
| 2002 |
void SgmlFOTBuilder::endMathOperatorSerial() |
| 2003 |
{ |
| 2004 |
endFlow("math-operator"); |
| 2005 |
} |
| 2006 |
|
| 2007 |
void SgmlFOTBuilder::startMathOperatorOperator() |
| 2008 |
{ |
| 2009 |
endFlow("math-operator.principal"); |
| 2010 |
startPortFlow("math-operator.operator"); |
| 2011 |
} |
| 2012 |
|
| 2013 |
void SgmlFOTBuilder::endMathOperatorOperator() |
| 2014 |
{ |
| 2015 |
endFlow("math-operator.operator"); |
| 2016 |
} |
| 2017 |
|
| 2018 |
void SgmlFOTBuilder::startMathOperatorLowerLimit() |
| 2019 |
{ |
| 2020 |
startPortFlow("math-operator.lower-limit"); |
| 2021 |
} |
| 2022 |
|
| 2023 |
void SgmlFOTBuilder::endMathOperatorLowerLimit() |
| 2024 |
{ |
| 2025 |
endFlow("math-operator.lower-limit"); |
| 2026 |
} |
| 2027 |
|
| 2028 |
void SgmlFOTBuilder::startMathOperatorUpperLimit() |
| 2029 |
{ |
| 2030 |
startPortFlow("math-operator.upper-limit"); |
| 2031 |
} |
| 2032 |
|
| 2033 |
void SgmlFOTBuilder::endMathOperatorUpperLimit() |
| 2034 |
{ |
| 2035 |
endFlow("math-operator.upper-limit"); |
| 2036 |
} |
| 2037 |
|
| 2038 |
void SgmlFOTBuilder::startGrid(const GridNIC &nic) |
| 2039 |
{ |
| 2040 |
os() << "<grid"; |
| 2041 |
if (nic.nColumns) |
| 2042 |
os() << " grid-n-columns=" << quot << (unsigned long)nic.nColumns << quot; |
| 2043 |
if (nic.nRows) |
| 2044 |
os() << " grid-n-rows=" << quot << (unsigned long)nic.nRows << quot; |
| 2045 |
outputIcs(); |
| 2046 |
os() << '>' << RE; |
| 2047 |
} |
| 2048 |
|
| 2049 |
void SgmlFOTBuilder::endGrid() |
| 2050 |
{ |
| 2051 |
endFlow("grid"); |
| 2052 |
} |
| 2053 |
|
| 2054 |
void SgmlFOTBuilder::startGridCell(const GridCellNIC &nic) |
| 2055 |
{ |
| 2056 |
os() << "<grid-cell"; |
| 2057 |
if (nic.columnNumber) |
| 2058 |
os() << " column-number=" << quot << (unsigned long)nic.columnNumber << quot; |
| 2059 |
if (nic.rowNumber) |
| 2060 |
os() << " row-number=" << quot << (unsigned long)nic.rowNumber << quot; |
| 2061 |
outputIcs(); |
| 2062 |
os() << '>' << RE; |
| 2063 |
} |
| 2064 |
|
| 2065 |
void SgmlFOTBuilder::endGridCell() |
| 2066 |
{ |
| 2067 |
endFlow("grid-cell"); |
| 2068 |
} |
| 2069 |
|
| 2070 |
void SgmlFOTBuilder::externalGraphic(const ExternalGraphicNIC &nic) |
| 2071 |
{ |
| 2072 |
flushPendingElements(); |
| 2073 |
os() << "<external-graphic entity-system-id=" |
| 2074 |
<< quot << Data(nic.entitySystemId) << quot |
| 2075 |
<< " notation-system-id=" |
| 2076 |
<< quot << Data(nic.notationSystemId) << quot; |
| 2077 |
if (nic.scaleType != symbolFalse) |
| 2078 |
os() << " scale=" << quot << nic.scaleType << quot; |
| 2079 |
else |
| 2080 |
os() << " scale-x=" << quot << nic.scale[0] << quot |
| 2081 |
<< " scale-y=" << quot << nic.scale[1] << quot; |
| 2082 |
if (nic.hasMaxWidth) |
| 2083 |
os() << " max-width=" << quot << nic.maxWidth << quot; |
| 2084 |
if (nic.hasMaxHeight) |
| 2085 |
os() << " max-height=" << quot << nic.maxHeight << quot; |
| 2086 |
if (nic.isDisplay) { |
| 2087 |
os() << " display=" << quot << trueString << quot; |
| 2088 |
displayNIC(nic); |
| 2089 |
} |
| 2090 |
else { |
| 2091 |
if (nic.escapementDirection != symbolFalse) |
| 2092 |
os() << " escapement-direction=" << quot << nic.escapementDirection << quot; |
| 2093 |
if (nic.positionPointX) |
| 2094 |
os() << " position-point-x=" << quot << nic.positionPointX << quot; |
| 2095 |
if (nic.positionPointY) |
| 2096 |
os() << " position-point-y=" << quot << nic.positionPointY << quot; |
| 2097 |
inlineNIC(nic); |
| 2098 |
} |
| 2099 |
outputIcs(); |
| 2100 |
os() << "/>" << RE; |
| 2101 |
} |
| 2102 |
|
| 2103 |
void SgmlFOTBuilder::rule(const RuleNIC &nic) |
| 2104 |
{ |
| 2105 |
flushPendingElements(); |
| 2106 |
const char *s = symbolName(nic.orientation); |
| 2107 |
if (!s) |
| 2108 |
return; |
| 2109 |
os() << "<rule orientation=" << quot << s << quot; |
| 2110 |
switch (nic.orientation) { |
| 2111 |
case symbolHorizontal: |
| 2112 |
case symbolVertical: |
| 2113 |
displayNIC(nic); |
| 2114 |
break; |
| 2115 |
default: |
| 2116 |
inlineNIC(nic); |
| 2117 |
break; |
| 2118 |
} |
| 2119 |
if (nic.hasLength) |
| 2120 |
os() << " length=" << quot << nic.length << quot; |
| 2121 |
outputIcs(); |
| 2122 |
os() << "/>" << RE; |
| 2123 |
} |
| 2124 |
|
| 2125 |
void SgmlFOTBuilder::startLeader(const LeaderNIC &nic) |
| 2126 |
{ |
| 2127 |
flushPendingElements(); |
| 2128 |
os() << "<leader"; |
| 2129 |
if (nic.hasLength) |
| 2130 |
os() << " length=" << nic.length; |
| 2131 |
inlineNIC(nic); |
| 2132 |
outputIcs(); |
| 2133 |
os() << '>' << RE; |
| 2134 |
} |
| 2135 |
|
| 2136 |
void SgmlFOTBuilder::endLeader() |
| 2137 |
{ |
| 2138 |
endFlow("leader"); |
| 2139 |
} |
| 2140 |
|
| 2141 |
void SgmlFOTBuilder::startSideline() |
| 2142 |
{ |
| 2143 |
startSimpleFlowObj("sideline"); |
| 2144 |
} |
| 2145 |
|
| 2146 |
void SgmlFOTBuilder::endSideline() |
| 2147 |
{ |
| 2148 |
endFlow("sideline"); |
| 2149 |
} |
| 2150 |
|
| 2151 |
void SgmlFOTBuilder::startBox(const BoxNIC &nic) |
| 2152 |
{ |
| 2153 |
flushPendingElements(); |
| 2154 |
os() << "<box"; |
| 2155 |
if (nic.isDisplay) { |
| 2156 |
os() << " display=" << quot << trueString << quot; |
| 2157 |
displayNIC(nic); |
| 2158 |
} |
| 2159 |
else |
| 2160 |
inlineNIC(nic); |
| 2161 |
outputIcs(); |
| 2162 |
os() << '>' << RE; |
| 2163 |
} |
| 2164 |
|
| 2165 |
void SgmlFOTBuilder::endBox() |
| 2166 |
{ |
| 2167 |
endFlow("box"); |
| 2168 |
} |
| 2169 |
|
| 2170 |
void SgmlFOTBuilder::startSideBySide(const DisplayNIC& nic) |
| 2171 |
{ |
| 2172 |
flushPendingElements(); |
| 2173 |
os() << "<side-by-side"; |
| 2174 |
displayNIC(nic); |
| 2175 |
outputIcs(); |
| 2176 |
os() << '>' << RE; |
| 2177 |
} |
| 2178 |
|
| 2179 |
void SgmlFOTBuilder::endSideBySide() |
| 2180 |
{ |
| 2181 |
endFlow("side-by-side"); |
| 2182 |
} |
| 2183 |
|
| 2184 |
void SgmlFOTBuilder::startSideBySideItem() |
| 2185 |
{ |
| 2186 |
os() << "<side-by-side-item"; |
| 2187 |
flushPendingElements(); |
| 2188 |
outputIcs(); |
| 2189 |
os() << '>' << RE; |
| 2190 |
} |
| 2191 |
|
| 2192 |
void SgmlFOTBuilder::endSideBySideItem() |
| 2193 |
{ |
| 2194 |
endFlow("side-by-side-item"); |
| 2195 |
} |
| 2196 |
|
| 2197 |
void SgmlFOTBuilder::alignmentPoint() |
| 2198 |
{ |
| 2199 |
simpleFlowObj("alignment-point"); |
| 2200 |
} |
| 2201 |
|
| 2202 |
void SgmlFOTBuilder::startTable(const TableNIC &nic) |
| 2203 |
{ |
| 2204 |
flushPendingElements(); |
| 2205 |
os() << "<table"; |
| 2206 |
switch (nic.widthType) { |
| 2207 |
case TableNIC::widthExplicit: |
| 2208 |
os() << " width=" << quot << nic.width << quot; |
| 2209 |
break; |
| 2210 |
case TableNIC::widthMinimum: |
| 2211 |
os() << " minimum-width=" << quot << trueString << quot; |
| 2212 |
break; |
| 2213 |
default: |
| 2214 |
break; |
| 2215 |
} |
| 2216 |
displayNIC(nic); |
| 2217 |
outputIcs(); |
| 2218 |
os() << '>' << RE; |
| 2219 |
} |
| 2220 |
|
| 2221 |
void SgmlFOTBuilder::endTable() |
| 2222 |
{ |
| 2223 |
endFlow("table"); |
| 2224 |
} |
| 2225 |
|
| 2226 |
void SgmlFOTBuilder::tableBeforeRowBorder() |
| 2227 |
{ |
| 2228 |
simpleFlowObj("table.before-row-border"); |
| 2229 |
} |
| 2230 |
|
| 2231 |
void SgmlFOTBuilder::tableAfterRowBorder() |
| 2232 |
{ |
| 2233 |
simpleFlowObj("table.after-row-border"); |
| 2234 |
} |
| 2235 |
|
| 2236 |
void SgmlFOTBuilder::tableBeforeColumnBorder() |
| 2237 |
{ |
| 2238 |
simpleFlowObj("table.before-column-border"); |
| 2239 |
} |
| 2240 |
|
| 2241 |
void SgmlFOTBuilder::tableAfterColumnBorder() |
| 2242 |
{ |
| 2243 |
simpleFlowObj("table.after-column-border"); |
| 2244 |
} |
| 2245 |
|
| 2246 |
void SgmlFOTBuilder::tableColumn(const TableColumnNIC &nic) |
| 2247 |
{ |
| 2248 |
os() << "<table-column column-number=" |
| 2249 |
<< quot << (unsigned long)nic.columnIndex + 1 << quot; |
| 2250 |
if (nic.nColumnsSpanned != 1) |
| 2251 |
os() << " n-columns-spanned=" << quot << (unsigned long)nic.nColumnsSpanned << quot; |
| 2252 |
if (nic.hasWidth) |
| 2253 |
os() << " width=" << quot << nic.width << quot; |
| 2254 |
outputIcs(); |
| 2255 |
os() << "/>" << RE; |
| 2256 |
} |
| 2257 |
|
| 2258 |
void SgmlFOTBuilder::startTablePartSerial(const TablePartNIC &nic) |
| 2259 |
{ |
| 2260 |
os() << "<table-part"; |
| 2261 |
displayNIC(nic); |
| 2262 |
outputIcs(); |
| 2263 |
os() << '>' << RE; |
| 2264 |
startPortFlow("table-part.principal"); |
| 2265 |
} |
| 2266 |
|
| 2267 |
void SgmlFOTBuilder::endTablePartSerial() |
| 2268 |
{ |
| 2269 |
endFlow("table-part"); |
| 2270 |
} |
| 2271 |
|
| 2272 |
void SgmlFOTBuilder::startTablePartHeader() |
| 2273 |
{ |
| 2274 |
endFlow("table-part.principal"); |
| 2275 |
os() << "<table-part.header>" << RE; |
| 2276 |
} |
| 2277 |
|
| 2278 |
void SgmlFOTBuilder::endTablePartHeader() |
| 2279 |
{ |
| 2280 |
endFlow("table-part.header"); |
| 2281 |
} |
| 2282 |
|
| 2283 |
void SgmlFOTBuilder::startTablePartFooter() |
| 2284 |
{ |
| 2285 |
os() << "<table-part.footer>" << RE; |
| 2286 |
} |
| 2287 |
|
| 2288 |
void SgmlFOTBuilder::endTablePartFooter() |
| 2289 |
{ |
| 2290 |
endFlow("table-part.footer"); |
| 2291 |
} |
| 2292 |
|
| 2293 |
void SgmlFOTBuilder::startTableRow() |
| 2294 |
{ |
| 2295 |
startSimpleFlowObj("table-row"); |
| 2296 |
} |
| 2297 |
|
| 2298 |
void SgmlFOTBuilder::endTableRow() |
| 2299 |
{ |
| 2300 |
endFlow("table-row"); |
| 2301 |
} |
| 2302 |
|
| 2303 |
void SgmlFOTBuilder::startTableCell(const TableCellNIC &nic) |
| 2304 |
{ |
| 2305 |
if (nic.missing) |
| 2306 |
os() << "<table-cell column-number=" << quot << 0 << quot; |
| 2307 |
else { |
| 2308 |
os() << "<table-cell column-number=" |
| 2309 |
<< quot << (unsigned long)nic.columnIndex + 1 << quot; |
| 2310 |
if (nic.nColumnsSpanned != 1) |
| 2311 |
os() << " n-columns-spanned=" << quot << (unsigned long)nic.nColumnsSpanned << quot; |
| 2312 |
if (nic.nRowsSpanned != 1) |
| 2313 |
os() << " n-rows-spanned=" << quot << (unsigned long)nic.nRowsSpanned << quot; |
| 2314 |
} |
| 2315 |
outputIcs(); |
| 2316 |
os() << '>' << RE; |
| 2317 |
} |
| 2318 |
|
| 2319 |
void SgmlFOTBuilder::endTableCell() |
| 2320 |
{ |
| 2321 |
endFlow("table-cell"); |
| 2322 |
} |
| 2323 |
|
| 2324 |
void SgmlFOTBuilder::tableCellBeforeRowBorder() |
| 2325 |
{ |
| 2326 |
simpleFlowObj("table-cell.before-row-border"); |
| 2327 |
} |
| 2328 |
|
| 2329 |
void SgmlFOTBuilder::tableCellAfterRowBorder() |
| 2330 |
{ |
| 2331 |
simpleFlowObj("table-cell.after-row-border"); |
| 2332 |
} |
| 2333 |
|
| 2334 |
void SgmlFOTBuilder::tableCellBeforeColumnBorder() |
| 2335 |
{ |
| 2336 |
simpleFlowObj("table-cell.before-column-border"); |
| 2337 |
} |
| 2338 |
|
| 2339 |
void SgmlFOTBuilder::tableCellAfterColumnBorder() |
| 2340 |
{ |
| 2341 |
simpleFlowObj("table-cell.after-column-border"); |
| 2342 |
} |
| 2343 |
|
| 2344 |
void SgmlFOTBuilder::startNode(const NodePtr &node, const StringC &mode) |
| 2345 |
{ |
| 2346 |
nodeLevel_++; |
| 2347 |
if (mode.size() != 0 || !nodeIsElement(node)) |
| 2348 |
return; |
| 2349 |
for (size_t i = 0; i < pendingElements_.size(); i++) |
| 2350 |
if (*pendingElements_[i] == *node) |
| 2351 |
return; |
| 2352 |
pendingElements_.push_back(node); |
| 2353 |
pendingElementLevels_.push_back(nodeLevel_); |
| 2354 |
} |
| 2355 |
|
| 2356 |
void SgmlFOTBuilder::endNode() |
| 2357 |
{ |
| 2358 |
// The idea is not to put out a bookmark if there were |
| 2359 |
// no flow objects associated with the node. |
| 2360 |
// The flow objects might have been labeled, in which case |
| 2361 |
// we will get a startNode for the node later. |
| 2362 |
if (pendingElements_.size() > 0 && pendingElementLevels_.back() == nodeLevel_ |
| 2363 |
&& nPendingElementsNonEmpty_ < pendingElements_.size()) { |
| 2364 |
pendingElementLevels_.resize(pendingElements_.size() - 1); |
| 2365 |
pendingElements_.resize(pendingElements_.size() - 1); |
| 2366 |
} |
| 2367 |
nodeLevel_--; |
| 2368 |
} |
| 2369 |
|
| 2370 |
void SgmlFOTBuilder::currentNodePageNumber(const NodePtr &node) |
| 2371 |
{ |
| 2372 |
if (!nodeIsElement(node)) |
| 2373 |
return; |
| 2374 |
os() << "<page-number ref=" << quot; |
| 2375 |
outputElementName(node); |
| 2376 |
os() << quot << "/>" << RE; |
| 2377 |
} |
| 2378 |
|
| 2379 |
void SgmlFOTBuilder::outputElementName(unsigned long groveIndex, |
| 2380 |
const Char *idData, |
| 2381 |
size_t idSize) |
| 2382 |
{ |
| 2383 |
if (groveIndex) |
| 2384 |
os() << groveIndex << '.'; |
| 2385 |
os() << Data(idData, idSize); |
| 2386 |
} |
| 2387 |
|
| 2388 |
void SgmlFOTBuilder::outputElementName(const NodePtr &node) |
| 2389 |
{ |
| 2390 |
GroveString id; |
| 2391 |
if (node->getId(id) == accessOK) |
| 2392 |
outputElementName(node->groveIndex(), id.data(), id.size()); |
| 2393 |
else { |
| 2394 |
unsigned long n; |
| 2395 |
n = node->groveIndex(); |
| 2396 |
if (n) |
| 2397 |
os() << n << '.'; |
| 2398 |
if (node->elementIndex(n) == accessOK) |
| 2399 |
os() << n; |
| 2400 |
} |
| 2401 |
} |
| 2402 |
|
| 2403 |
void SgmlFOTBuilder::flushPendingElements() |
| 2404 |
{ |
| 2405 |
if (suppressAnchors_) |
| 2406 |
return; |
| 2407 |
for (size_t i = 0; i < pendingElements_.size(); i++) { |
| 2408 |
const NodePtr &node = pendingElements_[i]; |
| 2409 |
os() << "<a name=" << quot; |
| 2410 |
outputElementName(node); |
| 2411 |
os() << quot << "/>" << RE; |
| 2412 |
} |
| 2413 |
nPendingElementsNonEmpty_ = 0; |
| 2414 |
pendingElements_.resize(0); |
| 2415 |
pendingElementLevels_.resize(0); |
| 2416 |
} |
| 2417 |
|
| 2418 |
#ifdef DSSSL_NAMESPACE |
| 2419 |
} |
| 2420 |
#endif |