Initial commit
[profile/ivi/openjade.git] / style / FOTBuilder.h
1 // Copyright (c) 1996, 1997 James Clark
2 // See the file copying.txt for copying permission.
3
4 #ifndef FOTBuilder_INCLUDED
5 #define FOTBuilder_INCLUDED 1
6
7 #include "types.h"
8 #include "StringC.h"
9 #include "Boolean.h"
10 #include "Node.h"
11 #include "Link.h"
12 #include "IList.h"
13 #include "Vector.h"
14 #include "Resource.h"
15 #include "Ptr.h"
16 #include "Owner.h"
17 #include <stddef.h>
18 #include <string.h>
19 #include "dsssl_ns.h"
20
21 // This is a work around for a bug in Sun C++ 4.1.
22 // The class local typedef of PublicId will cause it to reject a
23 // subsequent declaration of the class PublicId, but it's happy
24 // if it sees the class first.
25 #ifdef __SUNPRO_CC
26 #include "ExternalId.h"
27 #endif
28
29 #ifdef SP_USE_DLL
30 #ifdef BUILD_LIBSTYLE
31 #define STYLE_API SP_DLLEXPORT
32 #else
33 #define STYLE_API SP_DLLIMPORT
34 #endif
35 #else /* not SP_USE_DLL */
36 #define STYLE_API /* as nothing */
37 #endif /* not SP_USE_DLL */
38
39 #ifdef DSSSL_NAMESPACE
40 namespace DSSSL_NAMESPACE {
41 #endif
42
43 class SaveFOTBuilder;
44
45 class STYLE_API FOTBuilder {
46 public:
47   enum Symbol {
48     symbolFalse,
49     symbolTrue,
50     symbolNotApplicable,
51     // These are guaranteed to be in increasing order of weight,
52     // and expansion.
53     symbolUltraCondensed,
54     symbolExtraCondensed,
55     symbolCondensed,
56     symbolSemiCondensed,
57     symbolUltraLight,
58     symbolExtraLight,
59     symbolLight,
60     symbolSemiLight,
61     symbolMedium,
62     symbolSemiExpanded,
63     symbolExpanded,
64     symbolExtraExpanded,
65     symbolUltraExpanded,
66     symbolSemiBold,
67     symbolBold,
68     symbolExtraBold,
69     symbolUltraBold,
70     symbolUpright,
71     symbolOblique,
72     symbolBackSlantedOblique,
73     symbolItalic,
74     symbolBackSlantedItalic,
75     symbolStart,
76     symbolEnd,
77     symbolCenter,
78     symbolJustify,
79     symbolSpreadInside,
80     symbolSpreadOutside,
81     symbolPageInside,
82     symbolPageOutside,
83     symbolWrap,
84     symbolAsis,
85     symbolAsisWrap,
86     symbolAsisTruncate,
87     symbolNone,
88     symbolBefore,
89     symbolThrough,
90     symbolAfter,
91     symbolTopToBottom,
92     symbolLeftToRight,
93     symbolBottomToTop,
94     symbolRightToLeft,
95     symbolInside,
96     symbolOutside,
97     symbolHorizontal,
98     symbolVertical,
99     symbolEscapement,
100     symbolLineProgression,
101     symbolMath,
102     symbolOrdinary,
103     symbolOperator,
104     symbolBinary,
105     symbolRelation,
106     symbolOpening,
107     symbolClosing,
108     symbolPunctuation,
109     symbolInner,
110     symbolSpace,
111     symbolPage,
112     symbolPageRegion,
113     symbolColumnSet,
114     symbolColumn,
115     symbolMax,
116     symbolMaxUniform,
117     symbolMiter,
118     symbolRound,
119     symbolBevel,
120     symbolButt,
121     symbolSquare,
122     symbolLoose,
123     symbolNormal,
124     symbolKern,
125     symbolTight,
126     symbolTouch,
127     symbolPreserve,
128     symbolCollapse,
129     symbolIgnore,
130     symbolRelative,
131     symbolDisplay,
132     symbolInline,
133     symbolBorder,
134     symbolBackground,
135     symbolBoth,
136     symbolBase,
137     symbolFont,
138     symbolTop,
139     symbolBottom,
140     symbolSpread,
141     symbolSolid,
142     symbolOutline,
143     symbolWith,
144     symbolAgainst,
145     symbolForce,
146     symbolIndependent,
147     symbolPile,
148     symbolSupOut,
149     symbolSubOut,
150     symbolLeadEdge,
151     symbolTrailEdge,
152     symbolExplicit,
153     symbolRowMajor,
154     symbolColumnMajor
155   };
156   enum { nSymbols = symbolColumnMajor + 1 };
157   typedef const char *PublicId;
158   struct GlyphId {
159     GlyphId() : publicId(0), suffix(0) { }
160     GlyphId(const char *s, unsigned long n = 0) : publicId(s), suffix(n) { }
161     PublicId publicId;
162     // If suffix is non-zero, then add a double-colon plus
163     // the suffix in decimal onto publicId to get the complete
164     // public identifier of the glyph id.
165     unsigned long suffix;
166   };
167   struct GlyphSubstTable : public Resource {
168     unsigned uniqueId;
169     Vector<GlyphId> pairs;
170     GlyphId subst(const GlyphId &) const;
171   };
172   // SP_LETTER2('U', 'K')
173 #define SP_LETTER2(c1, c2) (((c1) << 8) | (c2))
174   typedef unsigned Letter2;
175   typedef long Length;
176   struct LengthSpec {
177     LengthSpec(long len = 0) : length(len), displaySizeFactor(0.0) { }
178     long length;
179     double displaySizeFactor;
180     operator bool() const { return length != 0 || displaySizeFactor != 0.0; }
181   };
182   struct TableLengthSpec : LengthSpec {
183     TableLengthSpec() : tableUnitFactor(0.0) { }
184     double tableUnitFactor;
185   };
186   struct OptLengthSpec {
187     OptLengthSpec() : hasLength(0) { }
188     bool hasLength;
189     LengthSpec length;
190   };
191   struct DisplaySpace {
192     DisplaySpace() : priority(0), conditional(1), force(0) { }
193     LengthSpec nominal;
194     LengthSpec min;
195     LengthSpec max;
196     long priority;
197     bool conditional;
198     bool force;
199   };
200   struct InlineSpace {
201     LengthSpec nominal;
202     LengthSpec min;
203     LengthSpec max;
204   };
205   struct OptInlineSpace {
206     OptInlineSpace() : hasSpace(0) { }
207     bool hasSpace;
208     InlineSpace space;
209   };
210   // non-inherited characteristics for all displayed flow objects
211   struct DisplayNIC {
212     DisplayNIC();
213     DisplaySpace spaceBefore;
214     DisplaySpace spaceAfter;
215     Symbol positionPreference;
216     Symbol keep;
217     Symbol breakBefore;
218     Symbol breakAfter;
219     bool keepWithPrevious;
220     bool keepWithNext;
221     bool mayViolateKeepBefore;
222     bool mayViolateKeepAfter;
223   };
224   struct InlineNIC {
225     InlineNIC();
226     long breakBeforePriority;
227     long breakAfterPriority;
228   };
229   struct DisplayGroupNIC : DisplayNIC {
230     DisplayGroupNIC();
231     bool hasCoalesceId;
232     StringC coalesceId;
233   };
234   struct ExternalGraphicNIC : DisplayNIC, InlineNIC {
235     ExternalGraphicNIC();
236     bool isDisplay;
237     Symbol scaleType; // symbolFalse if not a symbol
238     double scale[2]; // if scaleType == symbolFalse
239     StringC entitySystemId;
240     StringC notationSystemId;
241     bool hasMaxWidth;
242     LengthSpec maxWidth;
243     bool hasMaxHeight;
244     LengthSpec maxHeight;
245     // These apply only if !isDisplay
246     // symbolFalse if no escapementDirection
247     Symbol escapementDirection;
248     LengthSpec positionPointX;
249     LengthSpec positionPointY;
250   };
251   struct BoxNIC : DisplayNIC, InlineNIC {
252     BoxNIC();
253     bool isDisplay;
254   };
255   struct RuleNIC : DisplayNIC, InlineNIC {
256     RuleNIC();
257     Symbol orientation;
258     bool hasLength;
259     LengthSpec length;
260   };
261   struct LeaderNIC : InlineNIC {
262     LeaderNIC();
263     bool hasLength;
264     LengthSpec length;
265   };
266   // A paragraph has the same non-inherited characteristics
267   // as a display-group.
268   typedef DisplayNIC ParagraphNIC;
269   struct CharacterNIC {
270     CharacterNIC();
271     enum {
272       cIsDropAfterLineBreak,
273       cIsDropUnlessBeforeLineBreak,
274       cIsPunct,
275       cIsInputWhitespace,
276       cIsInputTab,
277       cIsRecordEnd,
278       cIsSpace,
279       cChar,
280       cGlyphId,
281       cScript,
282       cMathClass,
283       cMathFontPosture,
284       cBreakBeforePriority,
285       cBreakAfterPriority
286     };
287     bool valid;
288     unsigned specifiedC;
289     Char ch;
290     GlyphId glyphId;
291     long breakBeforePriority;
292     long breakAfterPriority;
293     Symbol mathClass;
294     Symbol mathFontPosture;
295     PublicId script;
296     bool isDropAfterLineBreak;
297     bool isDropUnlessBeforeLineBreak;
298     bool isPunct;
299     bool isInputWhitespace;
300     bool isInputTab;
301     bool isRecordEnd;
302     bool isSpace;
303     // This doesn't have a flag in specifiedC,
304     // because it has a fixed default.
305     double stretchFactor;
306   };
307   typedef InlineNIC LineFieldNIC;
308   struct TableNIC : public DisplayNIC {
309     TableNIC();
310     enum WidthType {
311       widthFull,
312       widthMinimum,
313       widthExplicit
314     };
315     WidthType widthType;
316     LengthSpec width;
317   };
318   typedef DisplayNIC TablePartNIC;
319   struct TableColumnNIC {
320     TableColumnNIC();
321     unsigned columnIndex;  // zero-based
322     unsigned nColumnsSpanned;
323     bool hasWidth;
324     TableLengthSpec width;
325   };
326   struct TableCellNIC {
327     TableCellNIC();
328     // If true, this isn't a real table cell.
329     // Rather it's one that can be used to fill in cells missing in this row.
330     bool missing;
331     unsigned columnIndex;  // zero-based
332     unsigned nColumnsSpanned;
333     unsigned nRowsSpanned;
334   };
335   struct DeviceRGBColor {
336     unsigned char red;
337     unsigned char green;
338     unsigned char blue;
339   };
340   struct MultiMode {
341     MultiMode();
342     bool hasDesc;
343     StringC name;
344     StringC desc;
345   };
346   struct Address {
347     enum Type {
348       // An address of #f
349       none,
350       // An address that was resolved by the front-end to a node
351       // Only the node member is valid.
352       resolvedNode,
353       // node contains current node, params[0] is string.
354       idref,
355       entity,
356       sgmlDocument,
357       hytimeLinkend,
358       tei,
359       html
360     };
361     Type type;
362     // Gives current node or resolved node.
363     NodePtr node;
364     StringC params[3];
365   };
366   virtual SaveFOTBuilder *asSaveFOTBuilder();
367   virtual ~FOTBuilder();
368   // Default for compound flow objects
369   virtual void start();
370   virtual void end();
371   // Default for atomic flow objects: defaults to start(); end();
372   virtual void atomic();
373   // Atomic flow objects
374   virtual void characters(const Char *, size_t);
375   // Like characters(), but data comes from charChunk() on a NodePtr.
376   // If you are building a tree, then the NodePtr can be saved instead
377   // of the data.  The default implementation calls characters().
378   virtual void charactersFromNode(const NodePtr &, const Char *, size_t);
379   virtual void character(const CharacterNIC &);
380   virtual void paragraphBreak(const ParagraphNIC &);
381   virtual void externalGraphic(const ExternalGraphicNIC &);
382   virtual void rule(const RuleNIC &);
383   virtual void alignmentPoint();
384   // For flow object class public id
385   // "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction"
386   virtual void formattingInstruction(const StringC &);
387   // Non-atomic flow objects
388   virtual void startSequence();
389   virtual void endSequence();
390   virtual void startLineField(const LineFieldNIC &);
391   virtual void endLineField();
392   virtual void startParagraph(const ParagraphNIC &);
393   virtual void endParagraph();
394   virtual void startDisplayGroup(const DisplayGroupNIC &);
395   virtual void endDisplayGroup();
396   virtual void startScroll();
397   virtual void endScroll();
398   virtual void startLink(const Address &);
399   virtual void endLink();
400   virtual void startMarginalia();
401   virtual void endMarginalia();
402   virtual void startMultiMode(const MultiMode *principalPort,  // null if no principal port
403                               const Vector<MultiMode> &namedPorts,
404                               Vector<FOTBuilder *> &);
405   virtual void endMultiMode();
406   virtual void startScore(Char);
407   virtual void startScore(const LengthSpec &);
408   virtual void startScore(Symbol);
409   virtual void endScore();
410   virtual void startLeader(const LeaderNIC &);
411   virtual void endLeader();
412   virtual void startSideline();
413   virtual void endSideline();
414   virtual void startBox(const BoxNIC &);
415   virtual void endBox();
416   // Tables
417   virtual void startTable(const TableNIC &);
418   virtual void endTable();
419   // A call for each border is made immediately
420   // after startTable(), each preceded by any appropriate set*() calls.
421   virtual void tableBeforeRowBorder();
422   virtual void tableAfterRowBorder();
423   virtual void tableBeforeColumnBorder();
424   virtual void tableAfterColumnBorder();
425   virtual void startTablePart(const TablePartNIC &, FOTBuilder *&header, FOTBuilder *&footer);
426   virtual void endTablePart();
427   virtual void tableColumn(const TableColumnNIC &);
428   virtual void startTableRow();
429   virtual void endTableRow();
430   virtual void startTableCell(const TableCellNIC &);
431   virtual void endTableCell();
432   virtual void tableCellBeforeRowBorder();
433   virtual void tableCellAfterRowBorder();
434   virtual void tableCellBeforeColumnBorder();
435   virtual void tableCellAfterColumnBorder();
436   // Implementation must set numerator and denominator
437   // must be set to non-null values.
438   virtual void startMathSequence();
439   virtual void endMathSequence();
440   virtual void startFraction(FOTBuilder *&numerator, FOTBuilder *&denominator);
441   // startFraction is followed by call to fractionBar with set...() calls
442   // intervening
443   virtual void fractionBar();
444   virtual void endFraction();
445   virtual void startUnmath();
446   virtual void endUnmath();
447   virtual void startSuperscript();
448   virtual void endSuperscript();
449   virtual void startSubscript();
450   virtual void endSubscript();
451   virtual void startScript(FOTBuilder *&preSup,
452                            FOTBuilder *&preSub,
453                            FOTBuilder *&postSup,
454                            FOTBuilder *&postSub,
455                            FOTBuilder *&midSup,
456                            FOTBuilder *&midSub);
457   virtual void endScript();
458   virtual void startMark(FOTBuilder *&overMark, FOTBuilder *&underMark);
459   virtual void endMark();
460   virtual void startFence(FOTBuilder *&open, FOTBuilder *&close);
461   virtual void endFence();
462   virtual void startRadical(FOTBuilder *&degree);
463   // startRadical is followed by one of the following
464   virtual void radicalRadical(const CharacterNIC &);
465   virtual void radicalRadicalDefaulted();
466   virtual void endRadical();
467   virtual void startMathOperator(FOTBuilder *&oper,
468                                  FOTBuilder *&lowerLimit,
469                                  FOTBuilder *&upperLimit);
470   virtual void endMathOperator();
471   
472   struct GridNIC {
473     GridNIC();
474     unsigned nColumns;
475     unsigned nRows;
476   };
477   virtual void startGrid(const GridNIC &);
478   virtual void endGrid();
479
480   struct GridCellNIC {
481     GridCellNIC();
482     unsigned columnNumber;
483     unsigned rowNumber;
484   };
485   virtual void startGridCell(const GridCellNIC &);
486   virtual void endGridCell();
487
488   // Simple page
489   // Headers and footers are treated like a separate port.
490   // There are 24 different parts to the headers and footers
491   // numbered 0 to 027; the numbers are computed by or'ing the
492   // following flags.
493   enum HF {
494     // first page or other page
495     firstHF = 01,
496     otherHF = 0,
497     // front page or back page
498     frontHF = 02,
499     backHF = 0,
500     // header or footer
501     headerHF = 04,
502     footerHF = 0,
503     // left, center or right part of header
504     leftHF = 0,
505     centerHF = 010,
506     rightHF = 020,
507     // number of different HF calls
508     nHF = 030
509   };
510   virtual void startSimplePageSequence(FOTBuilder* headerFooter[nHF]);
511   virtual void endSimplePageSequenceHeaderFooter();
512   virtual void endSimplePageSequence();
513
514   // page-number sosofo
515   virtual void pageNumber();
516   // Inherited characteristics
517   // Set the value of the characteristic for the next flow object.
518   // Inherited characteristics that are not explicitly set have
519   // the same value as the parent flow object.
520   virtual void setFontSize(Length);
521   virtual void setFontFamilyName(const StringC &);
522   virtual void setFontWeight(Symbol);
523   virtual void setFontPosture(Symbol);
524   virtual void setStartIndent(const LengthSpec &);
525   virtual void setEndIndent(const LengthSpec &);
526   virtual void setFirstLineStartIndent(const LengthSpec &);
527   virtual void setLastLineEndIndent(const LengthSpec &);
528   virtual void setLineSpacing(const LengthSpec &);
529   virtual void setFieldWidth(const LengthSpec &);
530   virtual void setMarginaliaSep(const LengthSpec &);
531   virtual void setLines(Symbol);
532   virtual void setQuadding(Symbol);
533   virtual void setDisplayAlignment(Symbol);
534   virtual void setFieldAlign(Symbol);
535   virtual void setColor(const DeviceRGBColor &);
536   virtual void setBackgroundColor(); // background of #f
537   virtual void setBackgroundColor(const DeviceRGBColor &);
538   virtual void setBorderPresent(bool);
539   virtual void setLineThickness(Length);
540   virtual void setCellBeforeRowMargin(Length);
541   virtual void setCellAfterRowMargin(Length);
542   virtual void setCellBeforeColumnMargin(Length);
543   virtual void setCellAfterColumnMargin(Length);
544   virtual void setLineSep(Length);
545   virtual void setBoxSizeBefore(Length);
546   virtual void setBoxSizeAfter(Length);
547   virtual void setPositionPointShift(const LengthSpec &);
548   virtual void setStartMargin(const LengthSpec &);
549   virtual void setEndMargin(const LengthSpec &);
550   virtual void setSidelineSep(const LengthSpec &);
551   virtual void setAsisWrapIndent(const LengthSpec &);
552   virtual void setLineNumberSep(const LengthSpec &);
553   virtual void setLastLineJustifyLimit(const LengthSpec &);
554   virtual void setJustifyGlyphSpaceMaxAdd(const LengthSpec &);
555   virtual void setJustifyGlyphSpaceMaxRemove(const LengthSpec &);
556   virtual void setTableCornerRadius(const LengthSpec &);
557   virtual void setBoxCornerRadius(const LengthSpec &);
558   virtual void setMinPreLineSpacing(const OptLengthSpec &);
559   virtual void setMinPostLineSpacing(const OptLengthSpec &);
560   virtual void setMinLeading(const OptLengthSpec &);
561   virtual void setInhibitLineBreaks(bool);
562   virtual void setHyphenate(bool);
563   virtual void setKern(bool);
564   virtual void setLigature(bool);
565   virtual void setScoreSpaces(bool);
566   virtual void setFloatOutMarginalia(bool);
567   virtual void setFloatOutSidelines(bool);
568   virtual void setFloatOutLineNumbers(bool);
569   virtual void setCellBackground(bool);
570   virtual void setSpanWeak(bool);
571   virtual void setIgnoreRecordEnd(bool);
572   virtual void setNumberedLines(bool);
573   virtual void setHangingPunct(bool);
574   virtual void setBoxOpenEnd(bool);
575   virtual void setTruncateLeader(bool);
576   virtual void setAlignLeader(bool);
577   virtual void setTablePartOmitMiddleHeader(bool);
578   virtual void setTablePartOmitMiddleFooter(bool);
579   virtual void setBorderOmitAtBreak(bool);
580   virtual void setPrincipalModeSimultaneous(bool);
581   virtual void setMarginaliaKeepWithPrevious(bool);
582   virtual void setGridEquidistantRows(bool);
583   virtual void setGridEquidistantColumns(bool);
584   virtual void setLineJoin(Symbol);
585   virtual void setLineCap(Symbol);
586   virtual void setLineNumberSide(Symbol);
587   virtual void setKernMode(Symbol);
588   virtual void setInputWhitespaceTreatment(Symbol);
589   virtual void setFillingDirection(Symbol);
590   virtual void setWritingMode(Symbol);
591   virtual void setLastLineQuadding(Symbol);
592   virtual void setMathDisplayMode(Symbol);
593   virtual void setScriptPreAlign(Symbol);
594   virtual void setScriptPostAlign(Symbol);
595   virtual void setScriptMidSupAlign(Symbol);
596   virtual void setScriptMidSubAlign(Symbol);
597   virtual void setNumeratorAlign(Symbol);
598   virtual void setDenominatorAlign(Symbol);
599   virtual void setGridPositionCellType(Symbol);
600   virtual void setGridColumnAlignment(Symbol);
601   virtual void setGridRowAlignment(Symbol);
602   virtual void setBoxType(Symbol);
603   virtual void setGlyphAlignmentMode(Symbol);
604   virtual void setBoxBorderAlignment(Symbol);
605   virtual void setCellRowAlignment(Symbol);
606   virtual void setBorderAlignment(Symbol);
607   virtual void setSidelineSide(Symbol);
608   virtual void setHyphenationKeep(Symbol);
609   virtual void setFontStructure(Symbol);
610   virtual void setFontProportionateWidth(Symbol);
611   virtual void setCellCrossed(Symbol);
612   virtual void setMarginaliaSide(Symbol);
613   virtual void setLayer(long);
614   virtual void setBackgroundLayer(long);
615   virtual void setBorderPriority(long);
616   virtual void setLineRepeat(long);
617   virtual void setSpan(long);
618   virtual void setMinLeaderRepeat(long);
619   virtual void setHyphenationRemainCharCount(long);
620   virtual void setHyphenationPushCharCount(long);
621   virtual void setWidowCount(long);
622   virtual void setOrphanCount(long);
623   // 0 means #f
624   virtual void setExpandTabs(long);
625   virtual void setHyphenationLadderCount(long);
626   // public id or #f
627   virtual void setBackgroundTile(PublicId);
628   virtual void setLineBreakingMethod(PublicId);
629   virtual void setLineCompositionMethod(PublicId);
630   virtual void setImplicitBidiMethod(PublicId);
631   virtual void setGlyphSubstMethod(PublicId);
632   virtual void setGlyphReorderMethod(PublicId);
633   virtual void setHyphenationMethod(PublicId);
634   virtual void setTableAutoWidthMethod(PublicId);
635   virtual void setFontName(PublicId);
636   // Two-letter code
637   virtual void setLanguage(Letter2);
638   virtual void setCountry(Letter2);
639   virtual void setEscapementSpaceBefore(const InlineSpace &);
640   virtual void setEscapementSpaceAfter(const InlineSpace &);
641   virtual void setInlineSpaceSpace(const OptInlineSpace &);
642   // For simple page sequence
643   virtual void setPageWidth(Length);
644   virtual void setPageHeight(Length);
645   virtual void setLeftMargin(Length);
646   virtual void setRightMargin(Length);
647   virtual void setTopMargin(Length);
648   virtual void setBottomMargin(Length);
649   virtual void setHeaderMargin(Length);
650   virtual void setFooterMargin(Length);
651   // Others
652   virtual void setGlyphSubstTable(const Vector<ConstPtr<GlyphSubstTable> > &);
653   // Backlinks
654   // processingMode is empty for initial processing mode.
655   virtual void startNode(const NodePtr &, const StringC &processingMode);
656   virtual void endNode();
657   virtual void currentNodePageNumber(const NodePtr &);
658
659   class CompoundExtensionFlowObj;
660   class STYLE_API ExtensionFlowObj {
661   public:
662     virtual ~ExtensionFlowObj();
663     class Value {
664     public:
665       virtual bool convertString(StringC &) const = 0;
666       virtual bool convertStringPairList(Vector<StringC> &) const = 0;
667       virtual bool convertStringList(Vector<StringC> &) const = 0;
668       virtual bool convertBoolean(bool &) const = 0;
669     };
670     virtual CompoundExtensionFlowObj *asCompoundExtensionFlowObj();
671     virtual const CompoundExtensionFlowObj *asCompoundExtensionFlowObj() const;
672     virtual bool hasNIC(const StringC &) const;
673     virtual void setNIC(const StringC &, const Value &);
674     virtual ExtensionFlowObj *copy() const = 0;
675   };
676   class STYLE_API CompoundExtensionFlowObj : public ExtensionFlowObj {
677   public:
678     CompoundExtensionFlowObj *asCompoundExtensionFlowObj();
679     const CompoundExtensionFlowObj *asCompoundExtensionFlowObj() const;
680     virtual bool hasPrincipalPort() const;
681     virtual void portNames(Vector<StringC> &) const;
682   };
683
684   // extension inherited characteristics
685
686   virtual void extensionSet(void (FOTBuilder::*)(bool), bool);
687   virtual void extensionSet(void (FOTBuilder::*)(const StringC &), const StringC &);
688   virtual void extensionSet(void (FOTBuilder::*)(long), long);
689   
690   // extension flow objects
691   virtual void extension(const ExtensionFlowObj &, const NodePtr &);
692   virtual void startExtension(const CompoundExtensionFlowObj &,
693                               const NodePtr &,
694                               Vector<FOTBuilder *> &ports);
695   virtual void endExtension(const CompoundExtensionFlowObj &);
696
697   struct Extension {
698     const char *pubid;
699     void (FOTBuilder::*boolSetter)(bool);
700     void (FOTBuilder::*stringSetter)(const StringC &);
701     void (FOTBuilder::*integerSetter)(long);
702     void (FOTBuilder::*lengthSetter)(Length);
703     const ExtensionFlowObj *flowObj;
704   };
705
706   static const char *symbolName(Symbol);
707 };
708
709 class STYLE_API SaveFOTBuilder : public Link, public FOTBuilder {
710 public:
711   SaveFOTBuilder();
712   SaveFOTBuilder(const NodePtr &, const StringC &processingMode);
713  ~SaveFOTBuilder();
714   SaveFOTBuilder *asSaveFOTBuilder();
715   void emit(FOTBuilder &);
716   void characters(const Char *, size_t);
717   void charactersFromNode(const NodePtr &, const Char *, size_t);
718   void character(const CharacterNIC &);
719   void paragraphBreak(const ParagraphNIC &);
720   void externalGraphic(const ExternalGraphicNIC &);
721   void rule(const RuleNIC &);
722   void alignmentPoint();
723   void formattingInstruction(const StringC &);
724   void startSequence();
725   void endSequence();
726   void startLineField(const LineFieldNIC &);
727   void endLineField();
728   void startParagraph(const ParagraphNIC &);
729   void endParagraph();
730   void startDisplayGroup(const DisplayGroupNIC &);
731   void endDisplayGroup();
732   void startScroll();
733   void endScroll();
734   void startLink(const Address &);
735   void endLink();
736   void startMultiMode(const MultiMode *principalPort,
737                       const Vector<MultiMode> &namedPorts,
738                       Vector<FOTBuilder *> &);
739   void endMultiMode();
740   void startMarginalia();
741   void endMarginalia();
742   void startScore(Char);
743   void startScore(const LengthSpec &);
744   void startScore(Symbol);
745   void endScore();
746   void startLeader(const LeaderNIC &);
747   void endLeader();
748   void startSideline();
749   void endSideline();
750   void startBox(const BoxNIC &);
751   void endBox();
752   void startSimplePageSequence(FOTBuilder* headerFooter[nHF]);
753   void endSimplePageSequenceHeaderFooter();
754   void endSimplePageSequence();
755   // page-number sosofo
756   void pageNumber();
757   // math
758   void startMathSequence();
759   void endMathSequence();
760   void startFraction(FOTBuilder *&numerator, FOTBuilder *&denominator);
761   void fractionBar();
762   void endFraction();
763   void startUnmath();
764   void endUnmath();
765   void startSuperscript();
766   void endSuperscript();
767   void startSubscript();
768   void endSubscript();
769   void startScript(FOTBuilder *&preSup,
770                    FOTBuilder *&preSub,
771                    FOTBuilder *&postSup,
772                    FOTBuilder *&postSub,
773                    FOTBuilder *&midSup,
774                    FOTBuilder *&midSub);
775   void endScript();
776   void startMark(FOTBuilder *&overMark, FOTBuilder *&underMark);
777   void endMark();
778   void startFence(FOTBuilder *&open, FOTBuilder *&close);
779   void endFence();
780   void startRadical(FOTBuilder *&degree);
781   void endRadical();
782   void radicalRadical(const CharacterNIC &);
783   void radicalRadicalDefaulted();
784   void startMathOperator(FOTBuilder *&oper,
785                          FOTBuilder *&lowerLimit,
786                          FOTBuilder *&upperLimit);
787   void endMathOperator();
788   void startGrid(const GridNIC &);
789   void endGrid();
790   void startGridCell(const GridCellNIC &);
791   void endGridCell();
792
793   // Tables
794   void startTable(const TableNIC &);
795   void endTable();
796   void tableBeforeRowBorder();
797   void tableAfterRowBorder();
798   void tableBeforeColumnBorder();
799   void tableAfterColumnBorder();
800   void startTablePart(const TablePartNIC &, FOTBuilder *&header, FOTBuilder *&footer);
801   void endTablePart();
802   void tableColumn(const TableColumnNIC &);
803   void startTableRow();
804   void endTableRow();
805   void startTableCell(const TableCellNIC &);
806   void endTableCell();
807   void tableCellBeforeRowBorder();
808   void tableCellAfterRowBorder();
809   void tableCellBeforeColumnBorder();
810   void tableCellAfterColumnBorder();
811   // Inherited characteristics
812   void setFontSize(Length);
813   void setFontFamilyName(const StringC &);
814   void setFontWeight(Symbol);
815   void setFontPosture(Symbol);
816   void setStartIndent(const LengthSpec &);
817   void setEndIndent(const LengthSpec &);
818   void setFirstLineStartIndent(const LengthSpec &);
819   void setLastLineEndIndent(const LengthSpec &);
820   void setLineSpacing(const LengthSpec &);
821   void setFieldWidth(const LengthSpec &);
822   void setLines(Symbol);
823   void setQuadding(Symbol);
824   void setDisplayAlignment(Symbol);
825   void setFieldAlign(Symbol);
826   void setColor(const DeviceRGBColor &);
827   void setBackgroundColor(const DeviceRGBColor &);
828   void setBackgroundColor();
829   void setPageWidth(Length);
830   void setPageHeight(Length);
831   void setLeftMargin(Length);
832   void setRightMargin(Length);
833   void setTopMargin(Length);
834   void setBottomMargin(Length);
835   void setHeaderMargin(Length);
836   void setFooterMargin(Length);
837   void setBorderPresent(bool);
838   void setLineThickness(Length);
839   void setCellBeforeRowMargin(Length);
840   void setCellAfterRowMargin(Length);
841   void setCellBeforeColumnMargin(Length);
842   void setCellAfterColumnMargin(Length);
843   void setLineSep(Length);
844   void setBoxSizeBefore(Length);
845   void setBoxSizeAfter(Length);
846   void setPositionPointShift(const LengthSpec &);
847   void setStartMargin(const LengthSpec &);
848   void setEndMargin(const LengthSpec &);
849   void setSidelineSep(const LengthSpec &);
850   void setAsisWrapIndent(const LengthSpec &);
851   void setLineNumberSep(const LengthSpec &);
852   void setLastLineJustifyLimit(const LengthSpec &);
853   void setJustifyGlyphSpaceMaxAdd(const LengthSpec &);
854   void setJustifyGlyphSpaceMaxRemove(const LengthSpec &);
855   void setTableCornerRadius(const LengthSpec &);
856   void setBoxCornerRadius(const LengthSpec &);
857   void setMarginaliaSep(const LengthSpec &);
858   void setMinPreLineSpacing(const OptLengthSpec &);
859   void setMinPostLineSpacing(const OptLengthSpec &);
860   void setMinLeading(const OptLengthSpec &);
861   void setInhibitLineBreaks(bool);
862   void setHyphenate(bool);
863   void setKern(bool);
864   void setLigature(bool);
865   void setScoreSpaces(bool);
866   void setFloatOutMarginalia(bool);
867   void setFloatOutSidelines(bool);
868   void setFloatOutLineNumbers(bool);
869   void setCellBackground(bool);
870   void setSpanWeak(bool);
871   void setIgnoreRecordEnd(bool);
872   void setNumberedLines(bool);
873   void setHangingPunct(bool);
874   void setBoxOpenEnd(bool);
875   void setTruncateLeader(bool);
876   void setAlignLeader(bool);
877   void setTablePartOmitMiddleHeader(bool);
878   void setTablePartOmitMiddleFooter(bool);
879   void setBorderOmitAtBreak(bool);
880   void setPrincipalModeSimultaneous(bool);
881   void setMarginaliaKeepWithPrevious(bool);
882   void setGridEquidistantRows(bool);
883   void setGridEquidistantColumns(bool);
884   void setLineJoin(Symbol);
885   void setLineCap(Symbol);
886   void setLineNumberSide(Symbol);
887   void setKernMode(Symbol);
888   void setInputWhitespaceTreatment(Symbol);
889   void setFillingDirection(Symbol);
890   void setWritingMode(Symbol);
891   void setLastLineQuadding(Symbol);
892   void setMathDisplayMode(Symbol);
893   void setScriptPreAlign(Symbol);
894   void setScriptPostAlign(Symbol);
895   void setScriptMidSupAlign(Symbol);
896   void setScriptMidSubAlign(Symbol);
897   void setNumeratorAlign(Symbol);
898   void setDenominatorAlign(Symbol);
899   void setGridPositionCellType(Symbol);
900   void setGridColumnAlignment(Symbol);
901   void setGridRowAlignment(Symbol);
902   void setBoxType(Symbol);
903   void setGlyphAlignmentMode(Symbol);
904   void setBoxBorderAlignment(Symbol);
905   void setCellRowAlignment(Symbol);
906   void setBorderAlignment(Symbol);
907   void setSidelineSide(Symbol);
908   void setHyphenationKeep(Symbol);
909   void setFontStructure(Symbol);
910   void setFontProportionateWidth(Symbol);
911   void setCellCrossed(Symbol);
912   void setMarginaliaSide(Symbol);
913   void setLayer(long);
914   void setBackgroundLayer(long);
915   void setBorderPriority(long);
916   void setLineRepeat(long);
917   void setSpan(long);
918   void setMinLeaderRepeat(long);
919   void setHyphenationRemainCharCount(long);
920   void setHyphenationPushCharCount(long);
921   void setWidowCount(long);
922   void setOrphanCount(long);
923   void setExpandTabs(long);
924   void setHyphenationLadderCount(long);
925   void setBackgroundTile(PublicId);
926   void setLineBreakingMethod(PublicId);
927   void setLineCompositionMethod(PublicId);
928   void setImplicitBidiMethod(PublicId);
929   void setGlyphSubstMethod(PublicId);
930   void setGlyphReorderMethod(PublicId);
931   void setHyphenationMethod(PublicId);
932   void setTableAutoWidthMethod(PublicId);
933   void setFontName(PublicId);
934   void setLanguage(Letter2);
935   void setCountry(Letter2);
936   void setEscapementSpaceBefore(const InlineSpace &);
937   void setEscapementSpaceAfter(const InlineSpace &);
938   void setGlyphSubstTable(const Vector<ConstPtr<GlyphSubstTable> > &);
939   void startNode(const NodePtr &, const StringC &processingMode);
940   void endNode();
941   void currentNodePageNumber(const NodePtr &);
942   void extensionSet(void (FOTBuilder::*)(bool), bool);
943   void extensionSet(void (FOTBuilder::*)(const StringC &), const StringC &);
944   void extensionSet(void (FOTBuilder::*)(long), long);
945   void extension(const ExtensionFlowObj &, const NodePtr &);
946   void startExtension(const CompoundExtensionFlowObj &,
947                       const NodePtr &,
948                       Vector<FOTBuilder *> &ports);
949   void endExtension(const CompoundExtensionFlowObj &);
950
951   struct Call {
952     virtual ~Call();
953     virtual void emit(FOTBuilder &) = 0;
954     Call *next;
955   };
956 private:
957   SaveFOTBuilder(const SaveFOTBuilder &); // undefined
958   void operator=(const SaveFOTBuilder &); // undefined
959   struct NoArgCall : Call {
960     typedef void (FOTBuilder::*FuncPtr)();
961     NoArgCall(FuncPtr f) : func(f) { }
962     void emit(FOTBuilder &);
963     FuncPtr func;
964   };
965   struct LongArgCall : Call {
966     typedef void (FOTBuilder::*FuncPtr)(long);
967     LongArgCall(FuncPtr f, long n) : func(f), arg(n) { }
968     void emit(FOTBuilder &);
969     FuncPtr func;
970     long arg;
971   };
972   struct ExtensionLongArgCall : Call {
973     typedef void (FOTBuilder::*FuncPtr)(long);
974     ExtensionLongArgCall(FuncPtr f, long n) : func(f), arg(n) { }
975     void emit(FOTBuilder &);
976     FuncPtr func;
977     long arg;
978   };
979   struct LengthSpecArgCall : Call {
980     typedef void (FOTBuilder::*FuncPtr)(const LengthSpec &);
981     LengthSpecArgCall(FuncPtr f, const LengthSpec &ls) : func(f), arg(ls) { }
982     void emit(FOTBuilder &);
983     FuncPtr func;
984     LengthSpec arg;
985   };
986   struct OptLengthSpecArgCall : Call {
987     typedef void (FOTBuilder::*FuncPtr)(const OptLengthSpec &);
988     OptLengthSpecArgCall(FuncPtr f, const OptLengthSpec &ols) : func(f), arg(ols) { }
989     void emit(FOTBuilder &);
990     FuncPtr func;
991     OptLengthSpec arg;
992   };
993   struct NodePtrArgCall : Call {
994     typedef void (FOTBuilder::*FuncPtr)(const NodePtr &);
995     NodePtrArgCall(FuncPtr f, const NodePtr &nd) : func(f), arg(nd) { }
996     void emit(FOTBuilder &);
997     FuncPtr func;
998     NodePtr arg;
999   };
1000   struct StringArgCall : Call {
1001     typedef void (FOTBuilder::*FuncPtr)(const StringC &);
1002     StringArgCall(FuncPtr f, const StringC &s) : func(f), arg(s) { }
1003     void emit(FOTBuilder &);
1004     FuncPtr func;
1005     StringC arg;
1006   };
1007   struct ExtensionStringArgCall : Call {
1008     typedef void (FOTBuilder::*FuncPtr)(const StringC &);
1009     ExtensionStringArgCall(FuncPtr f, const StringC &s) : func(f), arg(s) { }
1010     void emit(FOTBuilder &);
1011     FuncPtr func;
1012     StringC arg;
1013   };
1014    struct CharArgCall : Call {
1015     typedef void (FOTBuilder::*FuncPtr)(Char);
1016     CharArgCall(FuncPtr f, Char c) : func(f), arg(c) { }
1017     void emit(FOTBuilder &);
1018     FuncPtr func;
1019     Char arg;
1020   };
1021   struct BoolArgCall : Call {
1022     typedef void (FOTBuilder::*FuncPtr)(bool);
1023     BoolArgCall(FuncPtr f, bool b) : func(f), arg(b) { }
1024     void emit(FOTBuilder &);
1025     FuncPtr func;
1026     bool arg;
1027   };
1028   struct ExtensionBoolArgCall : Call {
1029     typedef void (FOTBuilder::*FuncPtr)(bool);
1030     ExtensionBoolArgCall(FuncPtr f, bool b) : func(f), arg(b) { }
1031     void emit(FOTBuilder &);
1032     FuncPtr func;
1033     bool arg;
1034   };
1035   struct SymbolArgCall : Call {
1036     typedef void (FOTBuilder::*FuncPtr)(Symbol);
1037     SymbolArgCall(FuncPtr f, Symbol sym) : func(f), arg(sym) { }
1038     void emit(FOTBuilder &);
1039     FuncPtr func;
1040     Symbol arg;
1041   };
1042   struct PublicIdArgCall : Call {
1043     typedef void (FOTBuilder::*FuncPtr)(PublicId);
1044     PublicIdArgCall(FuncPtr f, PublicId pubid) : func(f), arg(pubid) { }
1045     void emit(FOTBuilder &);
1046     FuncPtr func;
1047     PublicId arg;
1048   };
1049   struct UnsignedArgCall : Call {
1050     typedef void (FOTBuilder::*FuncPtr)(unsigned);
1051     UnsignedArgCall(FuncPtr f, unsigned n) : func(f), arg(n) { }
1052     void emit(FOTBuilder &);
1053     FuncPtr func;
1054     unsigned arg;
1055   };
1056   struct DeviceRGBColorArgCall : Call {
1057     typedef void (FOTBuilder::*FuncPtr)(const DeviceRGBColor &);
1058     DeviceRGBColorArgCall(FuncPtr f, const DeviceRGBColor &color) : func(f), arg(color) { }
1059     void emit(FOTBuilder &);
1060     FuncPtr func;
1061     DeviceRGBColor arg;
1062   };
1063   struct InlineSpaceArgCall : Call {
1064     typedef void (FOTBuilder::*FuncPtr)(const InlineSpace &);
1065     InlineSpaceArgCall(FuncPtr f, InlineSpace is) : func(f), arg(is) { }
1066     void emit(FOTBuilder &);
1067     FuncPtr func;
1068     InlineSpace arg;
1069   };
1070   struct CharactersFromNodeCall : Call {
1071     CharactersFromNodeCall(const NodePtr &, const Char *, size_t);
1072     void emit(FOTBuilder &);
1073     const Char *data;
1074     size_t size;
1075     NodePtr node;
1076   };
1077   struct CharactersCall : Call {
1078     CharactersCall(const Char *, size_t);
1079     void emit(FOTBuilder &);
1080     StringC str;
1081   };
1082   struct CharacterCall : Call {
1083     CharacterCall(const CharacterNIC &nic) : arg(nic) { }
1084     void emit(FOTBuilder &);
1085     CharacterNIC arg;
1086   };
1087   struct StartNodeCall : Call {
1088     StartNodeCall(const NodePtr &, const StringC &);
1089     void emit(FOTBuilder &);
1090     NodePtr node;
1091     StringC mode;
1092   };
1093   struct StartParagraphCall : Call {
1094     StartParagraphCall(const ParagraphNIC &nic);
1095     void emit(FOTBuilder &);
1096     ParagraphNIC arg;
1097   };
1098   struct ParagraphBreakCall : Call {
1099     ParagraphBreakCall(const ParagraphNIC &nic);
1100     void emit(FOTBuilder &);
1101     ParagraphNIC arg;
1102   };
1103   struct StartDisplayGroupCall : Call {
1104     StartDisplayGroupCall(const DisplayGroupNIC &nic);
1105     void emit(FOTBuilder &);
1106     DisplayGroupNIC arg;
1107   };
1108   struct StartBoxCall : Call {
1109     StartBoxCall(const BoxNIC &nic) : arg(nic) { }
1110     void emit(FOTBuilder &);
1111     BoxNIC arg;
1112   };
1113   struct StartLineFieldCall : Call {
1114     StartLineFieldCall(const LineFieldNIC &nic) : arg(nic) { }
1115     void emit(FOTBuilder &);
1116     LineFieldNIC arg;
1117   };
1118   struct ExternalGraphicCall : Call {
1119     ExternalGraphicCall(const ExternalGraphicNIC &nic) : arg(nic) { }
1120     void emit(FOTBuilder &);
1121     ExternalGraphicNIC arg;
1122   };
1123   struct RuleCall : Call {
1124     RuleCall(const RuleNIC &nic) : arg(nic) { }
1125     void emit(FOTBuilder &);
1126     RuleNIC arg;
1127   };
1128   struct StartLeaderCall : Call {
1129     StartLeaderCall(const LeaderNIC &nic) : arg(nic) { }
1130     void emit(FOTBuilder &);
1131     LeaderNIC arg;
1132   };
1133   struct StartTableCall : Call {
1134     StartTableCall(const TableNIC &nic) : arg(nic) { }
1135     void emit(FOTBuilder &);
1136     TableNIC arg;
1137   };
1138   struct TableColumnCall : Call {
1139     TableColumnCall(const TableColumnNIC &nic) : arg(nic) { }
1140     void emit(FOTBuilder &);
1141     TableColumnNIC arg;
1142   };
1143   struct StartTableCellCall : Call {
1144     StartTableCellCall(const TableCellNIC &nic) : arg(nic) { }
1145     void emit(FOTBuilder &);
1146     TableCellNIC arg;
1147   };
1148   struct StartLinkCall : Call {
1149     StartLinkCall(const Address &addr) : arg(addr) { }
1150     void emit(FOTBuilder &);
1151     Address arg;
1152   };
1153   struct SetGlyphSubstTableCall : Call {
1154     SetGlyphSubstTableCall(const Vector<ConstPtr<GlyphSubstTable> > &tables) : arg(tables) { }
1155     void emit(FOTBuilder &);
1156     Vector<ConstPtr<GlyphSubstTable> > arg;
1157   };
1158   struct StartGridCall : Call {
1159     StartGridCall(const GridNIC &nic) : arg(nic) { }
1160     void emit(FOTBuilder &);
1161     GridNIC arg;
1162   };
1163   struct StartGridCellCall : Call {
1164     StartGridCellCall(const GridCellNIC &nic) : arg(nic) { }
1165     void emit(FOTBuilder &);
1166     GridCellNIC arg;
1167   };
1168   struct RadicalRadicalCall : Call {
1169     RadicalRadicalCall(const CharacterNIC &nic) : arg(nic) { }
1170     void emit(FOTBuilder &);
1171     CharacterNIC arg;
1172   };
1173   struct ExtensionCall : Call {
1174     ExtensionCall(const ExtensionFlowObj &fo, const NodePtr &nd)
1175       : arg(fo.copy()), node(nd) { }
1176     void emit(FOTBuilder &);
1177     Owner<ExtensionFlowObj> arg;
1178     NodePtr node;
1179   };
1180   struct EndExtensionCall : Call {
1181     EndExtensionCall(const CompoundExtensionFlowObj &fo)
1182       : arg(fo.copy()->asCompoundExtensionFlowObj()) { }
1183     void emit(FOTBuilder &);
1184     Owner<CompoundExtensionFlowObj> arg;
1185   };
1186   Call *calls_;
1187   Call **tail_;
1188   NodePtr currentNode_;
1189   StringC processingMode_;
1190 };
1191
1192 // Would like to make this a member of SaveFOTBuilder, but can't because
1193 // it has members that are instances of SaveFOTBuilder.
1194
1195 struct StartSimplePageSequenceCall : SaveFOTBuilder::Call {
1196   StartSimplePageSequenceCall(FOTBuilder* headerFooter[FOTBuilder::nHF]);
1197   void emit(FOTBuilder&);
1198   SaveFOTBuilder headerFooter[FOTBuilder::nHF];
1199 };
1200
1201 struct StartFractionCall : SaveFOTBuilder::Call {
1202   StartFractionCall(FOTBuilder *&numerator, FOTBuilder *&denominator);
1203   void emit(FOTBuilder &);
1204   SaveFOTBuilder numerator;
1205   SaveFOTBuilder denominator;
1206 };
1207
1208 struct StartScriptCall : SaveFOTBuilder::Call {
1209   StartScriptCall(FOTBuilder *&preSup,
1210                   FOTBuilder *&preSub,
1211                   FOTBuilder *&postSup,
1212                   FOTBuilder *&postSub,
1213                   FOTBuilder *&midSup,
1214                   FOTBuilder *&midSub);
1215   void emit(FOTBuilder &);
1216   SaveFOTBuilder preSup;
1217   SaveFOTBuilder preSub;
1218   SaveFOTBuilder postSup;
1219   SaveFOTBuilder postSub;
1220   SaveFOTBuilder midSup;
1221   SaveFOTBuilder midSub;
1222 };
1223
1224 struct StartMarkCall : public SaveFOTBuilder::Call {
1225   StartMarkCall(FOTBuilder *&overMark, FOTBuilder *&underMark);
1226   void emit(FOTBuilder &);
1227   SaveFOTBuilder overMark;
1228   SaveFOTBuilder underMark;
1229 };
1230
1231 struct StartFenceCall : public SaveFOTBuilder::Call {
1232   StartFenceCall(FOTBuilder *&open, FOTBuilder *&close);
1233   void emit(FOTBuilder &);
1234   SaveFOTBuilder open;
1235   SaveFOTBuilder close;
1236 };
1237
1238 struct StartRadicalCall : public SaveFOTBuilder::Call {
1239   StartRadicalCall(FOTBuilder *&degree);
1240   void emit(FOTBuilder &);
1241   SaveFOTBuilder degree;
1242 };
1243
1244 struct StartMathOperatorCall : public SaveFOTBuilder::Call {
1245   StartMathOperatorCall(FOTBuilder *&oper,
1246                         FOTBuilder *&lowerLimit,
1247                         FOTBuilder *&upperLimit);
1248   void emit(FOTBuilder &);
1249   SaveFOTBuilder oper;
1250   SaveFOTBuilder lowerLimit;
1251   SaveFOTBuilder upperLimit;
1252 };
1253
1254 struct StartTablePartCall : SaveFOTBuilder::Call {
1255   StartTablePartCall(const FOTBuilder::TablePartNIC &nic, FOTBuilder *&header, FOTBuilder *&footer);
1256   void emit(FOTBuilder &);
1257   FOTBuilder::TablePartNIC arg;
1258   SaveFOTBuilder header;
1259   SaveFOTBuilder footer;
1260 };
1261
1262 struct StartMultiModeCall : SaveFOTBuilder::Call {
1263   StartMultiModeCall(const FOTBuilder::MultiMode *principalMode,
1264                      const Vector<FOTBuilder::MultiMode> &namedModes,
1265                      Vector<FOTBuilder *> &ports);
1266   void emit(FOTBuilder &);
1267   FOTBuilder::MultiMode principalMode;
1268   bool hasPrincipalMode;
1269   Vector<FOTBuilder::MultiMode> namedModes;
1270   IList<SaveFOTBuilder> ports;
1271 };
1272
1273 struct StartExtensionCall : SaveFOTBuilder::Call {
1274   StartExtensionCall(const FOTBuilder::CompoundExtensionFlowObj &,
1275                      const NodePtr &,
1276                      Vector<FOTBuilder *> &);
1277   void emit(FOTBuilder &);
1278   IList<SaveFOTBuilder> ports;
1279   NodePtr node;
1280   Owner<FOTBuilder::CompoundExtensionFlowObj> flowObj;
1281 };
1282
1283 // This uses SaveFOTBuilder to provide a serial view of multi-port objects.
1284
1285 class STYLE_API SerialFOTBuilder : public FOTBuilder {
1286 public:
1287   SerialFOTBuilder();
1288   // Instead of overriding these
1289   void startSimplePageSequence(FOTBuilder* headerFooter[nHF]);
1290   void endSimplePageSequenceHeaderFooter();
1291   void endSimplePageSequence();
1292   void startTablePart(const TablePartNIC &,
1293                       FOTBuilder *&header, FOTBuilder *&footer);
1294   void endTablePart();
1295   void startFraction(FOTBuilder *&numerator, FOTBuilder *&denominator);
1296   void endFraction();
1297   void startScript(FOTBuilder *&preSup,
1298                    FOTBuilder *&preSub,
1299                    FOTBuilder *&postSup,
1300                    FOTBuilder *&postSub,
1301                    FOTBuilder *&midSup,
1302                    FOTBuilder *&midSub);
1303   void endScript();
1304   void startMark(FOTBuilder *&overMark, FOTBuilder *&underMark);
1305   void endMark();
1306   void startFence(FOTBuilder *&open, FOTBuilder *&close);
1307   void endFence();
1308   void startRadical(FOTBuilder *&degree);
1309   void endRadical();
1310   void startMathOperator(FOTBuilder *&oper,
1311                          FOTBuilder *&lowerLimit,
1312                          FOTBuilder *&upperLimit);
1313   void endMathOperator();
1314   void startMultiMode(const MultiMode *,
1315                       const Vector<MultiMode> &,
1316                       Vector<FOTBuilder *> &);
1317   void endMultiMode();
1318   void startExtension(const CompoundExtensionFlowObj &,
1319                       const NodePtr &,
1320                       Vector<FOTBuilder *> &ports);
1321   void endExtension(const CompoundExtensionFlowObj &);
1322   // Override these
1323   virtual void startSimplePageSequenceSerial();
1324   virtual void endSimplePageSequenceSerial();
1325   virtual void startSimplePageSequenceHeaderFooter(unsigned);
1326   virtual void endSimplePageSequenceHeaderFooter(unsigned);
1327   virtual void endAllSimplePageSequenceHeaderFooter();
1328   virtual void startFractionSerial();
1329   virtual void endFractionSerial();
1330   virtual void startFractionNumerator();
1331   virtual void endFractionNumerator();
1332   virtual void startFractionDenominator();
1333   virtual void endFractionDenominator();
1334   virtual void startScriptSerial();
1335   virtual void endScriptSerial();
1336   virtual void startScriptPreSup();
1337   virtual void endScriptPreSup();
1338   virtual void startScriptPreSub();
1339   virtual void endScriptPreSub();
1340   virtual void startScriptPostSup();
1341   virtual void endScriptPostSup();
1342   virtual void startScriptPostSub();
1343   virtual void endScriptPostSub();
1344   virtual void startScriptMidSup();
1345   virtual void endScriptMidSup();
1346   virtual void startScriptMidSub();
1347   virtual void endScriptMidSub();
1348   virtual void startMarkSerial();
1349   virtual void endMarkSerial();
1350   virtual void startMarkOver();
1351   virtual void endMarkOver();
1352   virtual void startMarkUnder();
1353   virtual void endMarkUnder();
1354   virtual void startFenceSerial();
1355   virtual void endFenceSerial();
1356   virtual void startFenceOpen();
1357   virtual void endFenceOpen();
1358   virtual void startFenceClose();
1359   virtual void endFenceClose();
1360   virtual void startRadicalSerial();
1361   virtual void endRadicalSerial();
1362   virtual void startRadicalDegree();
1363   virtual void endRadicalDegree();
1364   virtual void startMathOperatorSerial();
1365   virtual void endMathOperatorSerial();
1366   virtual void startMathOperatorOperator();
1367   virtual void endMathOperatorOperator();
1368   virtual void startMathOperatorLowerLimit();
1369   virtual void endMathOperatorLowerLimit();
1370   virtual void startMathOperatorUpperLimit();
1371   virtual void endMathOperatorUpperLimit();
1372   virtual void startTablePartSerial(const TablePartNIC &);
1373   virtual void endTablePartSerial();
1374   virtual void startTablePartHeader();
1375   virtual void endTablePartHeader();
1376   virtual void startTablePartFooter();
1377   virtual void endTablePartFooter();
1378   virtual void startMultiModeSerial(const MultiMode *);
1379   virtual void endMultiModeSerial();
1380   virtual void startMultiModeMode(const MultiMode &);
1381   virtual void endMultiModeMode();
1382   virtual void startExtensionSerial(const CompoundExtensionFlowObj &, const NodePtr &);
1383   virtual void endExtensionSerial(const CompoundExtensionFlowObj &);
1384   virtual void startExtensionStream(const StringC &);
1385   virtual void endExtensionStream(const StringC &);
1386 private:
1387   IList<SaveFOTBuilder> save_;
1388   Vector<Vector<MultiMode> > multiModeStack_;
1389 };
1390
1391 inline
1392 bool operator==(const FOTBuilder::GlyphId &g1, const FOTBuilder::GlyphId &g2)
1393 {
1394   return g1.publicId == g2.publicId && g1.suffix == g2.suffix;
1395 }
1396
1397 bool STYLE_API operator==(const StringC &, const char *);
1398
1399 #ifdef DSSSL_NAMESPACE
1400 }
1401 #endif
1402
1403 #endif /* not FOTBuilder_INCLUDED */
1404