home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / utils / rtfprsr / rtf2trof.h < prev    next >
C/C++ Source or Header  |  1995-05-18  |  8KB  |  292 lines

  1. /*
  2.     rtf2troff.h - rtf2troff defines, structures, externs
  3. */
  4.  
  5. # define    bcopy(src,dst,len)    ((void) memcpy(dst,src,len))
  6. typedef unsigned long    u_long;
  7. /* troff versions understood */
  8.  
  9. # define    TROFF    0    /* generic troff */
  10. # define    XROFF    1    /* Image Network xroff */
  11. # define    PSTROFF    2    /* ditroff + public domain tpscript backend */
  12.  
  13. /* macro packages understood */
  14.  
  15. # define    noMacros    0
  16. # define    meMacros    1
  17. # define    mmMacros    2
  18. # define    msMacros    3
  19.  
  20.  
  21. /*
  22.     macro/register names
  23. */
  24.  
  25. # define    mHeader        "He"
  26. # define    mHeaderAll    "Ha"
  27. # define    mHeaderFirst    "Hf"
  28. # define    mHeaderLeft    "Hl"
  29. # define    mHeaderRight    "Hr"
  30. # define    mFooter        "Fo"
  31. # define    mFooterAll    "Fa"
  32. # define    mFooterFirst    "Ff"
  33. # define    mFooterLeft    "Fl"
  34. # define    mFooterRight    "Fr"
  35.  
  36. /* normally Hp > Tm > Bm > Fp */
  37.  
  38. # define    rTitlePageSpecial    "Tp"
  39. # define    rTopMargin    "Tm"
  40. # define    rHeaderPos    "Hp"
  41. # define    rBottomMargin    "Bm"    /* from *top* of page! */
  42. # define    rFooterPos    "Fp"    /* from *top* of page! */
  43. # define    rHeaderAll    "Ha"
  44. # define    rHeaderFirst    "Hf"
  45. # define    rHeaderLeft    "Hl"
  46. # define    rHeaderRight    "Hr"
  47. # define    rFooterAll    "Fa"
  48. # define    rFooterFirst    "Ff"
  49. # define    rFooterLeft    "Fl"
  50. # define    rFooterRight    "Fr"
  51.  
  52.  
  53.  
  54. /*
  55.     rtfTabLeft is used to indicate the default tab type (left tab).
  56.     RTF assumes that if some other type is not specified, a tab is
  57.     a left tab and never indicates that explicitly.  It's given a
  58.     number here so the writer can refer to it by a constant known
  59.     to be different from the other tab types.  (All "real" token
  60.     numbers are non-negative.)
  61.  
  62.     rtfLeaderMotion is used to indicate default tab char (motion only),
  63.     which likewise is undefined in RTF.
  64.  
  65.     rtfNoDestination is used to indicate that a state has had no
  66.     destination specified yet.
  67.  
  68.     rtfNoBorderType indicates that a paragraph has no borders.
  69. */
  70.  
  71. # define    rtfTabLeft        (-1)
  72. # define    rtfLeaderMotion        (-1)
  73. # define    rtfNoDestination    (-1)
  74. # define    rtfNoBorderType        (-1)
  75.  
  76.  
  77. # define    styleBold    0x0001
  78. # define    styleItalic    0x0002
  79. # define    styleStrikeThru    0x0004
  80. # define    styleOutline    0x0008
  81. # define    styleShadow    0x0010
  82. # define    styleSmallCaps    0x0020
  83. # define    styleAllCaps    0x0040
  84. # define    styleInvisible    0x0080
  85. # define    styleUnderline    0x0100
  86. # define    styleWUnderline    0x0200
  87.  
  88. # define    StyleFontBits(s)    (s & (styleBold | styleItalic))
  89.  
  90. /*
  91.     Values for operations that map border positions onto bits
  92.     in flag word.
  93. */
  94.  
  95. # define    borderTop    0x0001
  96. # define    borderBottom    0x0002
  97. # define    borderLeft    0x0004
  98. # define    borderRight    0x0008
  99.  
  100. /*
  101.     Values for operations that map border positions to array indices.
  102.     Must be zero-based and sequential.
  103. */
  104.  
  105. # define    topIndex    0
  106. # define    leftIndex    1
  107. # define    bottomIndex    2
  108. # define    rightIndex    3
  109.  
  110.  
  111. # define    lineBreakLen    60    /* break lines after 60 columns */
  112.  
  113.  
  114. # define    maxIStack    10    /* internal state stack depth */
  115. # define    maxWStack    3    /* written state stack depth */
  116. # define    maxTab        20
  117. # define    maxCell        20
  118.  
  119.  
  120.  
  121. typedef    struct State        State;
  122. typedef    struct DocState        DocState;
  123. typedef    struct SectState    SectState;
  124. typedef    struct ParState        ParState;
  125. typedef    struct CharState    CharState;
  126.  
  127. typedef    struct TblState        TblState;    /* this is separate */
  128.  
  129.  
  130. /* document properties */
  131.  
  132. struct DocState
  133. {
  134.     int    landscape;        /* non-zero if landscape */
  135.     double    pageWidth;        /* paper width */
  136.     double    pageHeight;        /* paper height */
  137.     double    leftMargin;        /* left margin */
  138.     double    rightMargin;        /* right margin */
  139.     double    topMargin;        /* top margin */
  140.     double    bottomMargin;        /* bottom margin */
  141.     double    tabWidth;        /* default tab width */
  142. };
  143.  
  144.  
  145. /* section properties */
  146.  
  147. struct SectState
  148. {
  149.     int    breakType;        /* section break type */
  150.     int    pageStart;        /* section starting page number */
  151.     int    pageRestart;        /* restart page numbering each sect. */
  152.     double    headerPos;        /* from top of page */
  153.     double    footerPos;        /* from bottom of page */
  154.     int    titleSpecial;        /* first page special */
  155. };
  156.  
  157.  
  158. /* paragraph properties */
  159.  
  160. struct ParState
  161. {
  162.     double    firstIndent;        /* first indent */
  163.     double    leftIndent;        /* left indent */
  164.     double    rightIndent;        /* right indent */
  165.     double    spaceBefore;        /* space before lines */
  166.     double    spaceAfter;        /* space after lines */
  167.     double    spaceBetween;        /* space between lines */
  168.     int    tabFlag;        /* any tabs set yet? (0 = no) */
  169.     int    nTabs;            /* number of tabs (0 = defaults) */
  170.     double    tab[maxTab];        /* tab positions */
  171.     int    tabType[maxTab];    /* tab types */
  172.     int    tabChar;        /* tab (leader) character */
  173.     int    justification;        /* justification */
  174.     int    borderType;        /* type of border */
  175.     int    borderFlags;        /* where to draw borders */
  176. };
  177.  
  178.  
  179. /* character properties */
  180.  
  181. struct CharState
  182. {
  183.     int    fontSize;        /* font (point) size */
  184.     u_long    charStyle;        /* character style */
  185.     double    superScript;        /* superscript */
  186.     double    subScript;        /* subscript */
  187. };
  188.  
  189. struct State
  190. {
  191.     int        destination;    /* state destination */
  192.     DocState    docState;
  193.     SectState    sectState;
  194.     ParState    parState;
  195.     CharState    charState;
  196. };
  197.  
  198.  
  199. /* table properties */
  200.  
  201. struct TblState
  202. {
  203.     int    tableHeader;        /* non-zero if table header written */
  204.     int    nCells;            /* number of cells */
  205.     int    curCell;        /* current cell (0-based) */
  206.     double    cellPos[maxCell];    /* cell positions (right edge) */
  207.     double    tableLeft;        /* table left edge position */
  208.     double    cellGap;        /* horiz. gap between cells */
  209.     int    border[maxCell][4];    /* cell borders */
  210. };
  211.  
  212. extern int    tvers;        /* troff version */
  213. extern int    mvers;        /* macro package version */
  214.  
  215. extern TblState    *its;
  216. extern int    inTable;
  217.  
  218. extern FILE    *f;
  219.  
  220.  
  221. extern State        *is;        /* current internal state */
  222. extern DocState        *ids;        /* internal document state */
  223. extern SectState    *iss;        /* internal section state */
  224. extern ParState        *ips;        /* internal paragraph state */
  225. extern CharState    *ics;        /* internal character state */
  226.  
  227. extern State        *ws;        /* written state */
  228. extern DocState        *wds;        /* written document state */
  229. extern SectState    *wss;        /* written section state */
  230. extern ParState        *wps;        /* written paragraph state */
  231. extern CharState    *wcs;        /* written character state */
  232.  
  233. extern int    docStateChanged;    /* document properties have changed */
  234. extern int    sectStateChanged;    /* section properties have changed */
  235. extern int    parStateChanged;    /* paragraph properties have changed */
  236. extern int    charStateChanged;    /* character properties have changed */
  237.  
  238. # define    stateChanged    \
  239.     (docStateChanged||sectStateChanged||parStateChanged||charStateChanged)
  240.  
  241.  
  242. extern int    indirectionLevel;
  243.  
  244.  
  245. extern void    InitState ();
  246. extern void    CheckFinalState ();
  247. extern void    PushIState ();
  248. extern void    PopIState ();
  249. extern void    PushWState ();
  250. extern void    PopWState ();
  251. extern void    BeginDiversion ();
  252. extern void    EndDiversion ();
  253. extern void    RestoreSectDefaults ();
  254. extern void    RestoreParDefaults ();
  255. extern void    RestoreCharDefaults ();
  256.  
  257.  
  258. extern void    InitTabSet ();
  259.  
  260.  
  261. extern int    MapBorderLocation ();
  262.  
  263.  
  264. extern void    SelectFormatterMaps ();
  265. extern void    SelectMacPackMaps ();
  266. extern void    SelectCharSetMaps ();
  267. extern char    *CharMapping ();
  268.  
  269.  
  270. extern void    TblAttr ();
  271. extern void    BeginTbl ();
  272. extern void    EndTbl ();
  273. extern void    BeginCell ();
  274. extern void    EndCell ();
  275.  
  276.  
  277. extern void    FlushState ();
  278. extern void    FlushInitialState ();
  279. extern void    FlushSectState ();
  280. extern void    Flush ();
  281. extern void    SaveTblFPV ();
  282. extern void    FlushTblFPV ();
  283.  
  284. extern double    EnWidth ();
  285.  
  286. extern void    ResetPar ();
  287. extern void    ResetParLine ();
  288. extern void    Sect ();
  289. extern void    Par ();
  290. extern void    PutString ();
  291. extern void    Comment ();
  292.