PageRenderTime 97ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 2ms

/batch/prs.c

https://github.com/pffy/Amaya-Editor
C | 7368 lines | 5905 code | 179 blank | 1284 comment | 1701 complexity | a40097fcc40f9fa398a3f22ca83b42ec MD5 | raw file
  1. /*
  2. *
  3. * (c) COPYRIGHT INRIA 1996-2009
  4. * Please first read the full copyright statement in file COPYRIGHT.
  5. *
  6. */
  7. /*
  8. * Ce programme compile un schema de presentation contenu dans un fichier
  9. * de type .P
  10. * Il est dirige par la grammaire du langage de presentation
  11. * contenue, sous forme codee, dans le fichier PRESEN.GRM.
  12. * Il produit un fichier de type .PRS qui sera ensuite utilise par Thot
  13. *
  14. * Authors: V. Quint (INRIA)
  15. * R. Guetari (W3C/INRIA): Windows routines.
  16. *
  17. */
  18. #undef THOT_EXPORT
  19. #define THOT_EXPORT extern
  20. #include "thot_sys.h"
  21. #include "constgrm.h"
  22. #include "constmedia.h"
  23. #include "compilmsg.h"
  24. #include "prsmsg.h"
  25. #include "message.h"
  26. #include "typemedia.h"
  27. #include "typegrm.h"
  28. #include "fileaccess.h"
  29. #include "prsdef.h"
  30. #include "fileaccess.h"
  31. #include "compil_tv.h"
  32. #include "thotcolor.h"
  33. #include "thotcolor_tv.h"
  34. #include "thotpattern.h"
  35. #include "analsynt_tv.h"
  36. #include "compil_tv.h"
  37. #ifdef _WINGUI
  38. #define FATAL_EXIT_CODE 33
  39. #define COMP_SUCCESS 0
  40. #else /* !_WINGUI */
  41. #define FATAL_EXIT_CODE -1
  42. #endif /* _WINGUI */
  43. int LineNum; /* compteur de lignes dans le fichier source */
  44. static PtrPSchema pPSchema; /* Schema de presentation genere */
  45. static PtrSSchema pSSchema; /* Schema de structure */
  46. static int CurView; /* numero de la vue courante */
  47. static PtrPRule FirstRule; /* pointeur sur la premiere regle de la suite
  48. de regles courante */
  49. static PtrPRule CurRule; /* pointeur sur la regle de present. courante*/
  50. static PtrPRule NextRule; /* pointeur sur la regle de present. suivante*/
  51. static int CurAttrNum; /* numero de l'attribut en cours */
  52. static AttributePres *CurAttrPRule;
  53. static int CurAttrVal; /* numero de la valeur d'attr en cours*/
  54. static int CurComparAttr; /* numero de l'attribut de comparaison */
  55. static int CurElemHeritAttr; /* numero de l'element heritant de cet
  56. attribut */
  57. static ThotBool CurElemHeritAttrSelf; /* la presentation s'applique meme
  58. si c'est l'element lui-meme qui
  59. porte l'attribut herite' */
  60. static int CurAttrLowerBound; /* borne inferieure de comparaison */
  61. static int CurAttrUpperBound; /* borne superieure de comparaison */
  62. static ThotBool CurTextDefined; /* une valeur d'attribut a ete definie
  63. dans un selecteur */
  64. static Name CurTextEqual; /* valeur d'attribut textuel */
  65. static int CurType; /* numero de la regle de struct definissant
  66. le type dont on analyse les regles de
  67. presentation */
  68. static int CurPresBox; /* numero de la boite de presentation courante */
  69. static ThotBool ViewDef; /* on est dans la definition des vues */
  70. static ThotBool CounterDef; /* on est dans la definition des compteurs */
  71. static ThotBool ConstantDef; /* on est dans la definition des constantes*/
  72. static ThotBool VariableDef; /* on est dans la definition des variables */
  73. static CounterValue CurMinMax; /* SyntacticType de la valeur du compteur */
  74. static ThotBool PresBoxDef; /* on est dans la definition des boites */
  75. static ThotBool DefaultRuleDef; /* on est dans la definition des regles
  76. par defaut */
  77. static ThotBool RuleDef; /* on est dans la definition des regles */
  78. static ThotBool AttributeDef; /* on est dans la definition des attributs */
  79. static ThotBool NewAttributeDef; /* definition d'un nouveau paquet de regles
  80. de presentation d'un attribut */
  81. static int TransmittedCounter; /* numero du compteur dont on traite la regle
  82. de transmission */
  83. static int TransmittedElem; /* type de l'element dont on traite la regle
  84. de transmission */
  85. static ThotBool InInLineRule; /* on est dans une regle 'InLine' */
  86. static ThotBool IncludedColumn;
  87. static ThotBool InRule; /* on est dans une regle */
  88. static ThotBool InWithinCond; /* on est dans une condition 'Within' */
  89. static ThotBool CondInheritedAttr; /* on est dans une condition 'Inherited attr' */
  90. static ThotBool AxisDef; /* le prochain repere boite rencontre est une
  91. definition de repere */
  92. static ThotBool Forward; /* on est dans une reference en avant pour une
  93. boite */
  94. static ThotBool CondBlock; /* on est dans un bloc de condition */
  95. static ThotBool ViewBlock; /* on est dans un bloc de vues */
  96. static ThotBool RuleBlock; /* on est dans un bloc de regles */
  97. static ThotBool RulesForView; /* on est dans les regles d'une vue */
  98. static ThotBool NewVariableDef; /* on definit une nouvelle variable */
  99. static int LatestNumber; /* valeur absolue du dernier nombre recontre */
  100. static ThotBool LatestNumberAttr; /* LatestNumber est un numero d'attribut numerique */
  101. static int PrevSign; /* signe du dernier nombre rencontre */
  102. static int AncestorSign; /* signe du dernier niveau d'ancetre rencontre'
  103. dans un compteur */
  104. static enum
  105. {
  106. Centimeter, Millimeter, Point, Pica, Inch, ScreenPixel, FontHeight,
  107. XHeight, Percent
  108. }
  109. CurUnit;
  110. static int AttrValSign; /* signe (+1 ou -1) de la derniere valeur
  111. d'attribut rencontree (AttrRelat) */
  112. static PtrCondition Conditions; /* les conditions du IF */
  113. static ThotBool Immediately; /* Pour les conditions avec Immediately Within */
  114. static ThotBool SignGreaterOrLess; /* il y a un signe > ou < dans la condition
  115. Within en cours de traitement */
  116. static int CurCondCntSign; /* signe dans une condition */
  117. static Name CopyType; /* nom du type qui apparait dans la regle Copy */
  118. static int BeginCopyType; /* indice dans la ligne du debut de ce nom */
  119. static PtrSSchema pExternalSS; /* pointeur sur le schema de structure externe */
  120. static ThotBool InCondPage; /* on est dans une condition Even, Odd ou One */
  121. static ThotBool InclusionRefName; /* le nom de type qui suit doit etre interprete
  122. comme le nom d'une reference d'inclusion
  123. sans expansion */
  124. static ThotBool VCondLess; /* on est dans une condition 'Less' */
  125. static ThotBool VCondGreater; /* on est dans une condition 'Greater' */
  126. static ThotBool CondEqual; /* on est dans une condition 'Equal' */
  127. static ThotBool FirstInPair; /* on a rencontre' "First" */
  128. static ThotBool SecondInPair; /* on a rencontre' "Second" */
  129. static ThotBool AttrInitCounter; /* on a rencontre' "Init" dans une definition
  130. de compteur */
  131. #include "compilmsg_f.h"
  132. #include "parser_f.h"
  133. #include "platform_f.h"
  134. #include "prs_f.h"
  135. #include "memory_f.h"
  136. #include "message_f.h"
  137. #include "readstr_f.h"
  138. #include "registry_f.h"
  139. #include "writeprs_f.h"
  140. #ifdef _WINGUI
  141. #include "compilers_f.h"
  142. #ifndef DLLEXPORT
  143. #define DLLEXPORT __declspec (dllexport)
  144. #endif /* DLLEXPORT */
  145. #endif /* _WINGUI */
  146. /*----------------------------------------------------------------------
  147. Initialize
  148. ----------------------------------------------------------------------*/
  149. static void Initialize ()
  150. {
  151. int size;
  152. /* acquiert un schema de presentation */
  153. GetSchPres (&pPSchema);
  154. if (pPSchema == NULL)
  155. /* memoire insuffisante */
  156. CompilerMessage (0, PRS, FATAL, NO_MORE_MEM_LEFT, inputLine, LineNum);
  157. else
  158. {
  159. /* acquiert un schema de structure pour les structures externes */
  160. GetSchStruct (&pExternalSS);
  161. if (pExternalSS == NULL)
  162. TtaDisplaySimpleMessage (FATAL, PRS, NO_MORE_MEM_LEFT);
  163. else
  164. {
  165. size = pSSchema->SsNAttributes * sizeof (PtrAttributePres);
  166. pPSchema->PsAttrPRule = (AttrPresTable*) malloc (size);
  167. if (pPSchema->PsAttrPRule)
  168. memset (pPSchema->PsAttrPRule, 0, size);
  169. size = pSSchema->SsNAttributes * sizeof (int);
  170. pPSchema->PsNAttrPRule = (NumberTable*) malloc (size);
  171. if (pPSchema->PsNAttrPRule)
  172. memset (pPSchema->PsNAttrPRule, 0, size);
  173. size = pSSchema->SsNRules * sizeof (PtrPRule);
  174. pPSchema->PsElemPRule = (PtrPRuleTable*) malloc (size);
  175. if (pPSchema->PsElemPRule)
  176. memset (pPSchema->PsElemPRule, 0, size);
  177. size = pSSchema->SsNAttributes * sizeof (int);
  178. pPSchema->PsNHeirElems = (NumberTable*) malloc (size);
  179. if (pPSchema->PsNHeirElems)
  180. memset (pPSchema->PsNHeirElems, 0, size);
  181. size = pSSchema->SsNRules * sizeof (int);
  182. pPSchema->PsNInheritedAttrs = (NumberTable*) malloc (size);
  183. if (pPSchema->PsNInheritedAttrs)
  184. memset (pPSchema->PsNInheritedAttrs, 0, size);
  185. /****
  186. size = pSSchema->SsNRules * sizeof (PtrInheritAttrTable);
  187. pPSchema->PsInheritedAttr = (InheritAttrTbTb*) malloc (size);
  188. if (pPSchema->PsInheritedAttr)
  189. memset (pPSchema->PsInheritedAttr, 0, size);
  190. ***/
  191. size = pSSchema->SsNAttributes * sizeof (int);
  192. pPSchema->PsNComparAttrs = (NumberTable*) malloc (size);
  193. if (pPSchema->PsNComparAttrs)
  194. memset (pPSchema->PsNComparAttrs, 0, size);
  195. size = pSSchema->SsNAttributes * sizeof (PtrAttributePres);
  196. pPSchema->PsComparAttr = (CompAttrTbTb*) malloc (size);
  197. if (pPSchema->PsComparAttr)
  198. memset (pPSchema->PsComparAttr, 0, size);
  199. size = pSSchema->SsNRules * sizeof (int);
  200. pPSchema->PsElemTransmit = (NumberTable*) malloc (size);
  201. if (pPSchema->PsElemTransmit)
  202. memset (pPSchema->PsElemTransmit, 0, size);
  203. CurMinMax = CntCurVal;
  204. /* initialise les indicateurs du compilateur */
  205. ViewDef = False;
  206. CounterDef = False;
  207. ConstantDef = False;
  208. VariableDef = False;
  209. PresBoxDef = False;
  210. DefaultRuleDef = False;
  211. RuleDef = False;
  212. AttributeDef = False;
  213. CurAttrNum = 0;
  214. NewAttributeDef = False;
  215. InInLineRule = False;
  216. IncludedColumn = False;
  217. InRule = False;
  218. InWithinCond = False;
  219. AxisDef = False;
  220. Forward = False;
  221. CondBlock = False;
  222. ViewBlock = False;
  223. RuleBlock = False;
  224. RulesForView = False;
  225. NewVariableDef = False;
  226. LatestNumber = 0;
  227. LatestNumberAttr = False;
  228. PrevSign = 1;
  229. CurUnit = FontHeight;
  230. AttrValSign = 1;
  231. CurView = 1;
  232. CurRule = NULL;
  233. FirstRule = NULL;
  234. CurType = 1;
  235. GetPresentRule (&NextRule);
  236. if (NextRule == NULL)
  237. /* memoire insuffisante */
  238. CompilerMessage (0, PRS, FATAL, NO_MORE_MEM_LEFT, inputLine,
  239. LineNum);
  240. Conditions = NULL;
  241. InclusionRefName = False;
  242. CopyType[0] = EOS;
  243. BeginCopyType = 0;
  244. FirstInPair = False;
  245. SecondInPair = False;
  246. }
  247. }
  248. }
  249. /*----------------------------------------------------------------------
  250. CopyName copy the word of length wl startig at position
  251. wi in buffer inputLine into string n.
  252. ----------------------------------------------------------------------*/
  253. static void CopyName (Name n, indLine wi, indLine wl)
  254. {
  255. if (wl > MAX_NAME_LENGTH - 1)
  256. CompilerMessage (wi, PRS, FATAL, WORD_SIZE_OVERFLOW, inputLine, LineNum);
  257. else
  258. {
  259. strncpy ((char *)n, (char *)&inputLine[wi - 1], MAX_NAME_LENGTH);
  260. n[wl] = EOS;
  261. }
  262. }
  263. /*----------------------------------------------------------------------
  264. CheckConditions verifie qu'il n'y a aucune condition courante
  265. ou qu'il n'y a que des conditions Within ou Root.
  266. ----------------------------------------------------------------------*/
  267. static void CheckConditions (indLine wi)
  268. {
  269. PtrCondition pCond;
  270. pCond = Conditions;
  271. while (pCond != NULL)
  272. if (pCond->CoCondition != PcWithin &&
  273. pCond->CoCondition != PcDefaultCond &&
  274. pCond->CoCondition != PcRoot &&
  275. pCond->CoCondition != PcElemType)
  276. {
  277. CompilerMessage (wi, PRS, FATAL, ONLY_CONDITION_WITHIN, inputLine,
  278. LineNum);
  279. pCond = NULL;
  280. }
  281. else
  282. pCond = pCond->CoNextCondition;
  283. }
  284. /*----------------------------------------------------------------------
  285. ConditionEnd
  286. ----------------------------------------------------------------------*/
  287. static void ConditionEnd ()
  288. {
  289. InWithinCond = False;
  290. if (CopyType[0] != EOS)
  291. /* on n'a pas encore traite' le nom de type suppose' externe */
  292. /* ce nom de type est donc erronne' */
  293. {
  294. CompilerMessage (BeginCopyType, PRS, FATAL, UNDECLARED_IDENTIFIER,
  295. inputLine, LineNum);
  296. CopyType[0] = EOS;
  297. BeginCopyType = 0;
  298. }
  299. }
  300. /*----------------------------------------------------------------------
  301. CreatePRule cree une nouvelle regle de type t
  302. ----------------------------------------------------------------------*/
  303. static void CreatePRule (PRuleType t, indLine wi)
  304. {
  305. PtrPRule pPRuleV;
  306. ConditionEnd ();
  307. if (t != PtFunction)
  308. /* ce n'est pas une regle fonction. Verifie qu'il n'y a que des
  309. conditions Within parmi les conditions courantes */
  310. CheckConditions (wi);
  311. CurRule = NextRule;
  312. GetPresentRule (&NextRule);
  313. if (NextRule == NULL)
  314. /* memoire insuffisante */
  315. CompilerMessage (0, PRS, FATAL, NO_MORE_MEM_LEFT, inputLine, LineNum);
  316. CurRule->PrType = t;
  317. CurRule->PrCond = Conditions;
  318. CurRule->PrNextPRule = NextRule;
  319. CurRule->PrViewNum = CurView;
  320. CurRule->PrPresMode = PresImmediate;
  321. switch (t)
  322. {
  323. case PtVisibility:
  324. case PtListStyleImage:
  325. case PtDepth:
  326. case PtFillPattern:
  327. case PtBackground:
  328. case PtForeground:
  329. case PtColor:
  330. case PtStopColor:
  331. case PtBorderTopColor:
  332. case PtBorderRightColor:
  333. case PtBorderBottomColor:
  334. case PtBorderLeftColor:
  335. CurRule->PrValueType = PrNumValue;
  336. CurRule->PrIntValue = 0;
  337. break;
  338. case PtOpacity:
  339. case PtStrokeOpacity:
  340. case PtFillOpacity:
  341. case PtStopOpacity:
  342. CurRule->PrValueType = PrNumValue;
  343. CurRule->PrIntValue = 1000;
  344. case PtListStyleType:
  345. CurRule->PrChrValue = 'N'; /* None par defaut */
  346. case PtListStylePosition:
  347. CurRule->PrChrValue = 'O'; /* Outside par defaut */
  348. case PtDisplay:
  349. CurRule->PrChrValue = 'U'; /* Undefined par defaut */
  350. case PtFont:
  351. CurRule->PrChrValue = 'T'; /* Times par defaut */
  352. break;
  353. case PtStyle:
  354. CurRule->PrChrValue = 'R'; /* Romain par defaut */
  355. break;
  356. case PtWeight:
  357. CurRule->PrChrValue = 'N'; /* Normal par defaut */
  358. break;
  359. case PtUnderline:
  360. CurRule->PrChrValue = 'N'; /* Pas de souligne par defaut*/
  361. break;
  362. case PtThickness:
  363. CurRule->PrChrValue = 'N'; /* souligne mince par defaut */
  364. break;
  365. case PtDirection:
  366. CurRule->PrChrValue = 'L'; /* Left to right by default */
  367. break;
  368. case PtUnicodeBidi:
  369. CurRule->PrChrValue = 'N'; /* Normal by default */
  370. break;
  371. case PtFloat:
  372. case PtClear:
  373. CurRule->PrChrValue = 'N'; /* None by default */
  374. break;
  375. case PtLineStyle:
  376. case PtBorderTopStyle:
  377. case PtBorderRightStyle:
  378. case PtBorderBottomStyle:
  379. case PtBorderLeftStyle:
  380. CurRule->PrChrValue = 'S'; /* trait continu par defaut */
  381. break;
  382. case PtBreak1:
  383. case PtBreak2:
  384. case PtIndent:
  385. case PtSize:
  386. case PtLineSpacing:
  387. case PtLineWeight:
  388. case PtMarginTop:
  389. case PtMarginRight:
  390. case PtMarginBottom:
  391. case PtMarginLeft:
  392. case PtPaddingTop:
  393. case PtPaddingRight:
  394. case PtPaddingBottom:
  395. case PtPaddingLeft:
  396. case PtBorderTopWidth:
  397. case PtBorderRightWidth:
  398. case PtBorderBottomWidth:
  399. case PtBorderLeftWidth:
  400. CurRule->PrMinUnit = UnRelative;
  401. CurRule->PrMinAttr = False;
  402. CurRule->PrMinValue = 0;
  403. break;
  404. case PtAdjust:
  405. CurRule->PrAdjust = AlignLeft;
  406. break;
  407. case PtVertRef:
  408. case PtHorizRef:
  409. case PtVertPos:
  410. case PtHorizPos:
  411. CurRule->PrPosRule.PoPosDef = NoEdge;
  412. CurRule->PrPosRule.PoPosRef = NoEdge;
  413. CurRule->PrPosRule.PoDistUnit = UnRelative;
  414. CurRule->PrPosRule.PoDeltaUnit = UnRelative;
  415. CurRule->PrPosRule.PoDistAttr = False;
  416. CurRule->PrPosRule.PoDistance = 0;
  417. CurRule->PrPosRule.PoDistDelta = 0;
  418. CurRule->PrPosRule.PoRelation = RlSameLevel;
  419. CurRule->PrPosRule.PoNotRel = False;
  420. CurRule->PrPosRule.PoRefKind = RkAnyBox;
  421. CurRule->PrPosRule.PoUserSpecified = False;
  422. CurRule->PrPosRule.PoRefIdent = 0;
  423. break;
  424. case PtHeight:
  425. case PtWidth:
  426. CurRule->PrDimRule.DrPosition = False;
  427. CurRule->PrDimRule.DrAbsolute = True;
  428. CurRule->PrDimRule.DrUnit = UnRelative;
  429. CurRule->PrDimRule.DrAttr = False;
  430. CurRule->PrDimRule.DrValue = 0;
  431. CurRule->PrDimRule.DrRelation = RlSameLevel;
  432. CurRule->PrDimRule.DrNotRelat = False;
  433. CurRule->PrDimRule.DrRefKind = RkAnyBox;
  434. CurRule->PrDimRule.DrMin = False;
  435. CurRule->PrDimRule.DrUserSpecified = False;
  436. CurRule->PrDimRule.DrRefIdent = 0;
  437. break;
  438. default:
  439. break;
  440. }
  441. /* verifie que cette regle n'est pas deja presente pour cette vue */
  442. pPRuleV = FirstRule;
  443. while (pPRuleV != NULL && pPRuleV != CurRule)
  444. {
  445. if (pPRuleV->PrViewNum == CurView)
  446. if (pPRuleV->PrType == t)
  447. if (t != PtFunction)
  448. /* seules les fonctions peuvent etre en plusieurs exemplaires */
  449. if (CurRule->PrCond == NULL)
  450. /* les regles sans condition ne peuvent pas figurer en
  451. plusieurs exemplaires */
  452. CompilerMessage (wi, PRS, FATAL, RULE_ALREADY_DEFINED,
  453. inputLine, LineNum);
  454. pPRuleV = pPRuleV->PrNextPRule;
  455. }
  456. }
  457. /*----------------------------------------------------------------------
  458. SetLevel
  459. ----------------------------------------------------------------------*/
  460. static void SetLevel (Level lev, indLine wi)
  461. {
  462. if ((CurRule->PrType == PtVertRef || CurRule->PrType == PtHorizRef) &&
  463. !(lev == RlEnclosed || lev == RlSelf))
  464. CompilerMessage (wi, PRS, FATAL, ONLY_ENCLOSED_AND_ARE_ALLOWED,
  465. inputLine, LineNum);
  466. else if (lev == RlEnclosed && (CurRule->PrType == PtVertPos ||
  467. CurRule->PrType == PtHorizPos))
  468. /* position par rapport au contenu, erreur */
  469. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_A_POSITION, inputLine,
  470. LineNum);
  471. else
  472. switch (CurRule->PrType)
  473. {
  474. case PtVertRef:
  475. case PtHorizRef:
  476. case PtVertPos:
  477. case PtHorizPos:
  478. CurRule->PrPosRule.PoRelation = lev;
  479. break;
  480. case PtHeight:
  481. case PtWidth:
  482. if (CurRule->PrDimRule.DrPosition)
  483. CurRule->PrDimRule.DrPosRule.PoRelation = lev;
  484. else
  485. CurRule->PrDimRule.DrRelation = lev;
  486. break;
  487. default:
  488. break;
  489. }
  490. }
  491. /*----------------------------------------------------------------------
  492. CheckBoxEnd
  493. ----------------------------------------------------------------------*/
  494. static void CheckBoxEnd ()
  495. {
  496. if (PresBoxDef)
  497. /* fin des regles de presentation d'une boite */
  498. {
  499. if (pPSchema->PsPresentBox->PresBox[CurPresBox - 1]->PbFirstPRule == NextRule)
  500. /* aucune regle (seulement 'Content') */
  501. pPSchema->PsPresentBox->PresBox[CurPresBox - 1]->PbFirstPRule = NULL;
  502. }
  503. if (CurRule != NULL)
  504. CurRule->PrNextPRule = NULL;
  505. }
  506. /*----------------------------------------------------------------------
  507. EndOfRulesForType fin des regles de presentation associees
  508. a un type d'element structure' ou a une valeur
  509. d'attribut. On verifie si au moins une regle a
  510. ete definie pour ce type ou cet attribut.
  511. ----------------------------------------------------------------------*/
  512. static void EndOfRulesForType ()
  513. {
  514. AttributePres *pPRuleA;
  515. NumAttrCase *pAttrCase;
  516. int l;
  517. if (RuleDef && CurType > 0)
  518. {
  519. if (pPSchema->PsElemPRule->ElemPres[CurType - 1] == NextRule)
  520. /* aucune regle de presentation pour ce type d'element */
  521. pPSchema->PsElemPRule->ElemPres[CurType - 1] = NULL;
  522. }
  523. else if (AttributeDef && CurAttrNum > 0)
  524. {
  525. pPRuleA = pPSchema->PsAttrPRule->AttrPres[CurAttrNum - 1];
  526. for (l = pPSchema->PsNAttrPRule->Num[CurAttrNum - 1]; --l > 0;
  527. pPRuleA = pPRuleA->ApNextAttrPres)
  528. if (pPRuleA->ApElemType == CurElemHeritAttr)
  529. break;
  530. if (pPRuleA)
  531. {
  532. /* selon le type de l'attribut */
  533. switch (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType)
  534. {
  535. case AtNumAttr:
  536. pAttrCase = &pPRuleA->ApCase[pPRuleA->ApNCases - 1];
  537. if (pAttrCase->CaFirstPRule == NextRule)
  538. pAttrCase->CaFirstPRule = NULL;
  539. break;
  540. case AtTextAttr:
  541. if (pPRuleA->ApTextFirstPRule == NextRule)
  542. pPRuleA->ApTextFirstPRule = NULL;
  543. break;
  544. case AtReferenceAttr:
  545. if (pPRuleA->ApRefFirstPRule == NextRule)
  546. pPRuleA->ApRefFirstPRule = NULL;
  547. break;
  548. case AtEnumAttr:
  549. if (pPRuleA->ApEnumFirstPRule[CurAttrVal] == NextRule)
  550. pPRuleA->ApEnumFirstPRule[CurAttrVal] = NULL;
  551. break;
  552. default:
  553. break;
  554. }
  555. }
  556. }
  557. }
  558. /*----------------------------------------------------------------------
  559. NewVarListItem alloue une nouvelle entree dans la table des
  560. items constituant une variable de presentation.
  561. ----------------------------------------------------------------------*/
  562. static void NewVarListItem (PresVariable * pVar, indLine wi)
  563. {
  564. if (pVar->PvNItems > 0)
  565. /* ce n'est pas le premier element de la variable */
  566. /* si le 1er element n'est pas du texte, on n'accepte pas le */
  567. /* nouvel element */
  568. if (pVar->PvItem[0].ViType == VarText)
  569. if (pPSchema->PsConstant[pVar->PvItem[0].ViConstant - 1].PdType !=
  570. CharString)
  571. CompilerMessage (wi, PRS, FATAL,
  572. MAX_FUNCTIONS_IN_A_VARIABLE_OVERFLOW, inputLine,
  573. LineNum);
  574. if (pVar->PvNItems >= MAX_PRES_VAR_ITEM)
  575. CompilerMessage (wi, PRS, FATAL, MAX_FUNCTIONS_IN_A_VARIABLE_OVERFLOW,
  576. inputLine, LineNum);
  577. else
  578. pVar->PvNItems++;
  579. }
  580. /*----------------------------------------------------------------------
  581. NewCondition alloue une nouvelle condition
  582. ----------------------------------------------------------------------*/
  583. static void NewCondition (indLine wi)
  584. {
  585. PtrCondition newCond;
  586. /* acquiert un bloc memoire pour une nouvelle condition */
  587. GetPresentRuleCond (&newCond);
  588. if (newCond == NULL)
  589. /* memoire insuffisante */
  590. CompilerMessage (0, PRS, FATAL, NO_MORE_MEM_LEFT, inputLine, LineNum);
  591. else
  592. {
  593. Immediately = False;
  594. /* chaine la nouvelle condition en tete */
  595. newCond->CoNextCondition = Conditions;
  596. Conditions = newCond;
  597. /* initialise la nouvelle condition */
  598. newCond->CoNotNegative = True;
  599. newCond->CoTarget = False;
  600. CurCondCntSign = 1;
  601. InCondPage = False;
  602. }
  603. }
  604. /*----------------------------------------------------------------------
  605. NewConst alloue une nouvelle entree dans la table des
  606. constantes du schema de presentation
  607. ----------------------------------------------------------------------*/
  608. static void NewConst (indLine wi)
  609. {
  610. if (pPSchema->PsNConstants >= MAX_PRES_CONST)
  611. CompilerMessage (wi, PRS, FATAL, MAX_CONSTANTS_OVERFLOW, inputLine,
  612. LineNum);
  613. else
  614. {
  615. pPSchema->PsConstant[pPSchema->PsNConstants].PdScript = 'L';
  616. pPSchema->PsConstant[pPSchema->PsNConstants].PdType = CharString;
  617. pPSchema->PsNConstants++;
  618. }
  619. }
  620. /*----------------------------------------------------------------------
  621. NewVar alloue une nouvelle entree dans la table des variables
  622. variables du schema de presentation
  623. ----------------------------------------------------------------------*/
  624. static void NewVar (indLine wi)
  625. {
  626. PtrPresVariable var;
  627. int i, size;
  628. if (pPSchema->PsNVariables >= pPSchema->PsVariableTableSize)
  629. /* the variable table is full. Extend it */
  630. {
  631. /* add 10 new entries */
  632. size = pPSchema->PsNVariables + 10;
  633. i = size * sizeof (PtrPresVariable);
  634. if (!pPSchema->PsVariable)
  635. pPSchema->PsVariable = (PresVarTable*) malloc (i);
  636. else
  637. pPSchema->PsVariable = (PresVarTable*) realloc (pPSchema->PsVariable, i);
  638. if (!pPSchema->PsVariable)
  639. {
  640. CompilerMessage (wi, PRS, FATAL, MAX_VARIABLES_OVERFLOW, inputLine,
  641. LineNum);
  642. return;
  643. }
  644. else
  645. {
  646. pPSchema->PsVariableTableSize = size;
  647. for (i = pPSchema->PsNVariables; i < size; i++)
  648. pPSchema->PsVariable->PresVar[i] = NULL;
  649. }
  650. }
  651. /* allocate and initialize a new variable */
  652. var = (PtrPresVariable) malloc (sizeof (PresVariable));
  653. if (var == NUL)
  654. /* can't allocate a new variable */
  655. {
  656. CompilerMessage (wi, PRS, FATAL, MAX_VARIABLES_OVERFLOW, inputLine,
  657. LineNum);
  658. return;
  659. }
  660. memset (var, 0, sizeof (PresVariable));
  661. pPSchema->PsVariable->PresVar[pPSchema->PsNVariables] = var;
  662. pPSchema->PsNVariables++;
  663. var->PvNItems = 0;
  664. }
  665. /*----------------------------------------------------------------------
  666. Round arrondit un float en un int.
  667. ----------------------------------------------------------------------*/
  668. static int Round (float e)
  669. {
  670. register int result;
  671. if (e < 0.0)
  672. result = (int) (e - 0.5);
  673. else
  674. result = (int) (e + 0.5);
  675. return result;
  676. }
  677. /*----------------------------------------------------------------------
  678. EndOfNumber
  679. ----------------------------------------------------------------------*/
  680. static void EndOfNumber ()
  681. {
  682. TypeUnit unit;
  683. unit = UnRelative;
  684. if (LatestNumber != 0)
  685. {
  686. if (LatestNumberAttr)
  687. /* on ne convertit pas les numeros d'attribut */
  688. switch (CurUnit)
  689. {
  690. case Centimeter:
  691. case Millimeter:
  692. case Point:
  693. case Pica:
  694. case Inch:
  695. unit = UnPoint;
  696. break;
  697. case ScreenPixel:
  698. unit = UnPixel;
  699. break;
  700. case FontHeight:
  701. unit = UnRelative;
  702. break;
  703. case XHeight:
  704. unit = UnXHeight;
  705. break;
  706. case Percent:
  707. unit = UnPercent;
  708. break;
  709. default:
  710. fprintf (stderr, "Invalid distance unit %X\n", CurUnit);
  711. break;
  712. }
  713. else
  714. /* convertit les unite's de longueur */
  715. switch (CurUnit)
  716. {
  717. case Centimeter:
  718. /* convertit les centimetres en points typo */
  719. LatestNumber = Round ((float) (LatestNumber * 72) / 2540);
  720. unit = UnPoint;
  721. break;
  722. case Millimeter:
  723. /* convertit les millimetres en points typo */
  724. LatestNumber = Round ((float) (LatestNumber * 72) / 25400);
  725. unit = UnPoint;
  726. break;
  727. case Point:
  728. /* arrondit en points typo */
  729. LatestNumber = Round ((float) LatestNumber / 1000);
  730. unit = UnPoint;
  731. break;
  732. case Pica:
  733. /* convertit les picas en points typo */
  734. LatestNumber = Round ((float) (LatestNumber * 12) / 1000);
  735. unit = UnPoint;
  736. break;
  737. case Inch:
  738. /* convertit les pouces en points typo */
  739. LatestNumber = Round ((float) (LatestNumber * 72) / 1000);
  740. unit = UnPoint;
  741. break;
  742. case ScreenPixel:
  743. /* arrondit en pixels */
  744. LatestNumber = Round ((float) LatestNumber / 1000);
  745. unit = UnPixel;
  746. break;
  747. case FontHeight:
  748. /* convertit en 1/10 */
  749. LatestNumber = Round ((float) LatestNumber / 100);
  750. unit = UnRelative;
  751. break;
  752. case XHeight:
  753. /* convertit en 1/10 */
  754. LatestNumber = Round ((float) LatestNumber / 100);
  755. unit = UnXHeight;
  756. break;
  757. case Percent:
  758. LatestNumber = Round ((float) LatestNumber / 1000);
  759. unit = UnPercent;
  760. break;
  761. default:
  762. fprintf (stderr, "Invalid distance unit %X\n", CurUnit);
  763. break;
  764. }
  765. LatestNumber = LatestNumber * PrevSign;
  766. if (CurRule->PrPresMode == PresInherit)
  767. {
  768. if (CurRule->PrType == PtIndent ||
  769. CurRule->PrType == PtLineSpacing ||
  770. CurRule->PrType == PtLineWeight)
  771. {
  772. CurRule->PrInhDelta = LatestNumber;
  773. CurRule->PrInhAttr = LatestNumberAttr;
  774. CurRule->PrInhUnit = unit;
  775. }
  776. }
  777. else
  778. switch (CurRule->PrType)
  779. {
  780. case PtBreak1:
  781. case PtBreak2:
  782. case PtIndent:
  783. case PtSize:
  784. case PtLineSpacing:
  785. case PtLineWeight:
  786. case PtMarginTop:
  787. case PtMarginRight:
  788. case PtMarginBottom:
  789. case PtMarginLeft:
  790. case PtPaddingTop:
  791. case PtPaddingRight:
  792. case PtPaddingBottom:
  793. case PtPaddingLeft:
  794. case PtBorderTopWidth:
  795. case PtBorderRightWidth:
  796. case PtBorderBottomWidth:
  797. case PtBorderLeftWidth:
  798. CurRule->PrMinUnit = unit;
  799. CurRule->PrMinAttr = LatestNumberAttr;
  800. CurRule->PrMinValue = LatestNumber;
  801. break;
  802. case PtVertRef:
  803. case PtHorizRef:
  804. case PtVertPos:
  805. case PtHorizPos:
  806. CurRule->PrPosRule.PoDistUnit = unit;
  807. CurRule->PrPosRule.PoDistAttr = LatestNumberAttr;
  808. CurRule->PrPosRule.PoDistance = LatestNumber;
  809. break;
  810. case PtHeight:
  811. case PtWidth:
  812. if (CurRule->PrDimRule.DrPosition)
  813. {
  814. CurRule->PrDimRule.DrPosRule.PoDistUnit = unit;
  815. CurRule->PrDimRule.DrPosRule.PoDistAttr = LatestNumberAttr;
  816. CurRule->PrDimRule.DrPosRule.PoDistance = LatestNumber;
  817. }
  818. else
  819. {
  820. CurRule->PrDimRule.DrUnit = unit;
  821. CurRule->PrDimRule.DrAttr = LatestNumberAttr;
  822. CurRule->PrDimRule.DrValue = LatestNumber;
  823. }
  824. break;
  825. default:
  826. break;
  827. }
  828. }
  829. LatestNumber = 0;
  830. LatestNumberAttr = False;
  831. PrevSign = 1;
  832. CurUnit = FontHeight;
  833. }
  834. /*----------------------------------------------------------------------
  835. NewAttrPRule allocation et initialisation d'une structure
  836. AttributePres en fonction de l'attribut de numero att
  837. ----------------------------------------------------------------------*/
  838. static AttributePres *NewAttrPRule (int att)
  839. {
  840. AttributePres *pPRuleA;
  841. NumAttrCase *pAttrCase;
  842. int j;
  843. GetAttributePres (&pPRuleA);
  844. if (pPRuleA)
  845. {
  846. /* selon le type de l'attribut */
  847. switch (pSSchema->SsAttribute->TtAttr[att - 1]->AttrType)
  848. {
  849. case AtNumAttr:
  850. pPRuleA->ApNCases = 0;
  851. for (j = 0; j < MAX_PRES_ATTR_CASE; j++)
  852. {
  853. pAttrCase = &pPRuleA->ApCase[j];
  854. pAttrCase->CaComparType = ComparConstant;
  855. pAttrCase->CaLowerBound = -MAX_INT_ATTR_VAL - 1;
  856. pAttrCase->CaUpperBound = MAX_INT_ATTR_VAL + 1;
  857. pAttrCase->CaFirstPRule = NULL;
  858. }
  859. break;
  860. case AtTextAttr:
  861. pPRuleA->ApString = NULL;
  862. pPRuleA->ApTextFirstPRule = NULL;
  863. break;
  864. case AtReferenceAttr:
  865. pPRuleA->ApRefFirstPRule = NULL;
  866. break;
  867. case AtEnumAttr:
  868. for (j = 0; j <= MAX_ATTR_VAL; j++)
  869. pPRuleA->ApEnumFirstPRule[j] = NULL;
  870. break;
  871. default:
  872. break;
  873. }
  874. }
  875. else
  876. /* memoire insuffisante */
  877. CompilerMessage (0, PRS, FATAL, NO_MORE_MEM_LEFT, inputLine, LineNum);
  878. pPSchema->PsNAttrPRule->Num[att - 1] += 1;
  879. return (pPRuleA);
  880. }
  881. /*----------------------------------------------------------------------
  882. GenerateRPresAttribute alloue eventuellement une nouvelle
  883. structure AttributePres et initialise la regle concernee
  884. ----------------------------------------------------------------------*/
  885. static void GenerateRPresAttribute (indLine wi)
  886. {
  887. AttributePres *pPRuleA;
  888. NumAttrCase *pAttrCase;
  889. int l;
  890. PtrPRule pPRule;
  891. /* s'il n'y a pas de structure AttributePres, on en alloue une */
  892. if (pPSchema->PsNAttrPRule->Num[CurAttrNum - 1] == 0)
  893. {
  894. pPRuleA = pPSchema->PsAttrPRule->AttrPres[CurAttrNum - 1]
  895. = NewAttrPRule (CurAttrNum);
  896. if (CurElemHeritAttr)
  897. {
  898. pPSchema->PsNInheritedAttrs->Num[CurElemHeritAttr - 1] += 1;
  899. pPSchema->PsNHeirElems->Num[CurAttrNum - 1] += 1;
  900. }
  901. }
  902. else
  903. /* sinon on cherche s'il y en a une qui traite deja certaines regles
  904. de l'element CurElemHeritAttr */
  905. {
  906. pPRuleA = pPSchema->PsAttrPRule->AttrPres[CurAttrNum - 1];
  907. for (l = pPSchema->PsNAttrPRule->Num[CurAttrNum - 1]; --l > 0;
  908. pPRuleA = pPRuleA->ApNextAttrPres)
  909. if (!CurTextDefined)
  910. if (pPRuleA->ApElemType == CurElemHeritAttr)
  911. break;
  912. /* si on n'a pas touve, on alloue un paquet suivant */
  913. if (pPRuleA->ApElemType != CurElemHeritAttr || CurTextDefined)
  914. {
  915. pPRuleA->ApNextAttrPres = NewAttrPRule (CurAttrNum);
  916. pPRuleA = pPRuleA->ApNextAttrPres;
  917. if (CurElemHeritAttr)
  918. {
  919. pPSchema->PsNInheritedAttrs->Num[CurElemHeritAttr - 1] += 1;
  920. pPSchema->PsNHeirElems->Num[CurAttrNum - 1] += 1;
  921. }
  922. }
  923. }
  924. CurAttrPRule = pPRuleA;
  925. /* maintenant on remplit les champs dans pPRuleA */
  926. pPRuleA->ApElemType = CurElemHeritAttr;
  927. pPRuleA->ApElemInherits = CurElemHeritAttrSelf;
  928. switch (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType)
  929. {
  930. case AtNumAttr:
  931. /* c'est un attribut a valeur numerique */
  932. if (pPRuleA->ApNCases >= MAX_PRES_ATTR_CASE)
  933. /* trop de cas pour cet attribut */
  934. CompilerMessage (wi, PRS, FATAL, MAX_CASES_IN_ATTR_OVERFLOW,
  935. inputLine, LineNum);
  936. else
  937. {
  938. pAttrCase = &pPRuleA->ApCase[pPRuleA->ApNCases++];
  939. if (CurComparAttr == 0)
  940. /* on utilise des constantes pour comparer */
  941. {
  942. pAttrCase->CaComparType = ComparConstant;
  943. pAttrCase->CaLowerBound = CurAttrLowerBound;
  944. pAttrCase->CaUpperBound = CurAttrUpperBound;
  945. }
  946. else
  947. /* on utilise un numero d'attribut */
  948. {
  949. if (CurElemHeritAttr == 0)
  950. pPSchema->PsNComparAttrs->Num[CurComparAttr - 1] += 1;
  951. /* ATTENTION ce n'est donc pas le vrai nombre
  952. d'attributs se comparant a CurComparAttr
  953. puisqu'on fait +1 a chaque fois */
  954. pAttrCase->CaComparType = ComparAttr;
  955. if (VCondGreater)
  956. /* attr GREATER MinValAttrName */
  957. {
  958. pAttrCase->CaLowerBound = CurComparAttr;
  959. pAttrCase->CaUpperBound = -1;
  960. }
  961. else if (VCondLess)
  962. /* attr LESS MaxValAttrName */
  963. {
  964. pAttrCase->CaLowerBound = -1;
  965. pAttrCase->CaUpperBound = CurComparAttr;
  966. }
  967. else
  968. /* attr EQUAL EqValAttrName */
  969. {
  970. pAttrCase->CaLowerBound = CurComparAttr;
  971. pAttrCase->CaUpperBound = CurComparAttr;
  972. }
  973. }
  974. pAttrCase->CaFirstPRule = NextRule;
  975. FirstRule = NextRule;
  976. }
  977. break;
  978. case AtTextAttr:
  979. if (CurTextDefined)
  980. pPRuleA->ApString = TtaStrdup ((char *)CurTextEqual);
  981. else
  982. pPRuleA->ApString = NULL;
  983. CurTextDefined = False;
  984. CurTextEqual[0] = EOS;
  985. pPRuleA->ApTextFirstPRule = NextRule;
  986. FirstRule = NextRule;
  987. break;
  988. case AtReferenceAttr:
  989. if (pPRuleA->ApRefFirstPRule != NULL)
  990. /* ce bloc a deja des regles */
  991. {
  992. pPRule = pPRuleA->ApRefFirstPRule;
  993. do
  994. {
  995. if (!pPRule->PrDuplicate)
  996. /* ce bloc a une regle non dupliquee. C'est une erreur */
  997. {
  998. CompilerMessage (wi, PRS, FATAL, CANT_REDEFINE, inputLine,
  999. LineNum);
  1000. pPRule = NULL;
  1001. }
  1002. else
  1003. {
  1004. /* cherche la derniere regle du bloc */
  1005. if (pPRule->PrNextPRule)
  1006. pPRule = pPRule->PrNextPRule;
  1007. else
  1008. {
  1009. /* c'est la derniere regle, ajoute la nouvelle apres */
  1010. pPRule->PrNextPRule = NextRule;
  1011. pPRule = NULL;
  1012. }
  1013. }
  1014. }
  1015. while (pPRule);
  1016. }
  1017. else
  1018. {
  1019. pPRuleA->ApRefFirstPRule = NextRule;
  1020. FirstRule = NextRule;
  1021. }
  1022. break;
  1023. case AtEnumAttr:
  1024. if (pPRuleA->ApEnumFirstPRule[CurAttrVal] != NULL)
  1025. /* ce bloc a deja des regles */
  1026. {
  1027. pPRule = pPRuleA->ApEnumFirstPRule[CurAttrVal];
  1028. do
  1029. {
  1030. if (!pPRule->PrDuplicate)
  1031. /* ce bloc a une regle non dupliquee. C'est une erreur */
  1032. {
  1033. CompilerMessage (wi, PRS, FATAL, CANT_REDEFINE, inputLine,
  1034. LineNum);
  1035. pPRule = NULL;
  1036. }
  1037. else
  1038. {
  1039. /* cherche la derniere regle du bloc */
  1040. if (pPRule->PrNextPRule)
  1041. pPRule = pPRule->PrNextPRule;
  1042. else
  1043. {
  1044. /* c'est la derniere regle, ajoute la nouvelle apres */
  1045. pPRule->PrNextPRule = NextRule;
  1046. pPRule = NULL;
  1047. }
  1048. }
  1049. }
  1050. while (pPRule);
  1051. }
  1052. else
  1053. {
  1054. pPRuleA->ApEnumFirstPRule[CurAttrVal] = NextRule;
  1055. FirstRule = NextRule;
  1056. }
  1057. break;
  1058. default:
  1059. break;
  1060. }
  1061. NewAttributeDef = False;
  1062. }
  1063. /*----------------------------------------------------------------------
  1064. PageCounterChangeBox Cherche les compteurs de page pour la vue
  1065. pageView et indique dans ces compteurs que la boite de numero
  1066. boxNum peut etre modifiee par ces compteurs.
  1067. ----------------------------------------------------------------------*/
  1068. static void PageCounterChangeBox (int boxNum, int pageView)
  1069. {
  1070. int counter;
  1071. int item;
  1072. Counter *pCntr;
  1073. /* parcourt tous les compteurs du schema de presentation */
  1074. for (counter = 0; counter < pPSchema->PsNCounters; counter++)
  1075. {
  1076. pCntr = &pPSchema->PsCounter[counter];
  1077. for (item = 0; item < pCntr->CnNItems; item++)
  1078. if (pCntr->CnItem[item].CiElemType == PageBreak + 1)
  1079. if (pCntr->CnItem[item].CiViewNum == pageView)
  1080. /* C'est un compteur de pages pour la vue voulue */
  1081. if (pCntr->CnNPresBoxes < MAX_PRES_COUNT_USER)
  1082. {
  1083. pCntr->CnNPresBoxes++;
  1084. pCntr->CnPresBox[pCntr->CnNPresBoxes - 1] = boxNum;
  1085. }
  1086. }
  1087. }
  1088. /*----------------------------------------------------------------------
  1089. DuplicateAttrCondRule
  1090. If the current presentation rule has a condition involving an attribute,
  1091. create a copy of that rule for that attribute.
  1092. When the ATTRIBUTES section of a P schema contains:
  1093. attrA (elem) = valA
  1094. BEGIN
  1095. ...
  1096. if attrB = valB Rule;
  1097. ...
  1098. END;
  1099. this function generates in addition the equivalent of:
  1100. attrB = valB
  1101. if elem and inherited attrA = valA Rule;
  1102. This will allow the user to change either attrA or AttrB and have the
  1103. editor to apply and unapply the Rule correctly.
  1104. ----------------------------------------------------------------------*/
  1105. static void DuplicateAttrCondRule (PtrPRule pRule)
  1106. {
  1107. PtrCondition pCond, pCond2;
  1108. AttributePres *pPRuleAttr;
  1109. PtrPRule pRule2, *PtrPtrPRule, prevPRule;
  1110. ThotBool found;
  1111. pCond = pRule->PrCond;
  1112. PtrPtrPRule = NULL;
  1113. if (pCond)
  1114. {
  1115. if (pCond->CoCondition == PcAttribute && !pCond->CoTarget &&
  1116. pCond->CoNotNegative && !pCond->CoNextCondition)
  1117. {
  1118. if (pPSchema->PsNAttrPRule->Num[pCond->CoTypeAttr - 1] == 0)
  1119. pPRuleAttr = pPSchema->PsAttrPRule->AttrPres[pCond->CoTypeAttr - 1] =
  1120. NewAttrPRule (pCond->CoTypeAttr);
  1121. else
  1122. {
  1123. found = FALSE;
  1124. pPRuleAttr = pPSchema->PsAttrPRule->AttrPres[pCond->CoTypeAttr - 1];
  1125. while (pPRuleAttr && !found)
  1126. {
  1127. if (pPRuleAttr->ApElemType == 0)
  1128. {
  1129. if (pSSchema->SsAttribute->TtAttr[pCond->CoTypeAttr - 1]->AttrType != AtTextAttr)
  1130. found = TRUE;
  1131. else
  1132. {
  1133. if (!pCond->CoTestAttrValue && pPRuleAttr->ApString == NULL)
  1134. found = TRUE;
  1135. else if (!strcmp(pPRuleAttr->ApString, pCond->CoAttrTextValue))
  1136. found = TRUE;
  1137. }
  1138. }
  1139. if (!found)
  1140. pPRuleAttr = pPRuleAttr->ApNextAttrPres;
  1141. }
  1142. /* si on n'a pas touve, on alloue un paquet suivant */
  1143. if (!found)
  1144. {
  1145. pPRuleAttr->ApNextAttrPres = NewAttrPRule (pCond->CoTypeAttr);
  1146. pPRuleAttr = pPRuleAttr->ApNextAttrPres;
  1147. }
  1148. }
  1149. switch (pSSchema->SsAttribute->TtAttr[pCond->CoTypeAttr - 1]->AttrType)
  1150. {
  1151. case AtNumAttr:
  1152. pPRuleAttr->ApNCases++;
  1153. pPRuleAttr->ApCase[pPRuleAttr->ApNCases -1].CaComparType =
  1154. ComparConstant;
  1155. if (!pCond->CoTestAttrValue)
  1156. {
  1157. pPRuleAttr->ApCase[pPRuleAttr->ApNCases -1].CaLowerBound =
  1158. -MAX_INT_ATTR_VAL - 1;
  1159. pPRuleAttr->ApCase[pPRuleAttr->ApNCases -1].CaUpperBound =
  1160. MAX_INT_ATTR_VAL + 1;
  1161. }
  1162. else
  1163. {
  1164. pPRuleAttr->ApCase[pPRuleAttr->ApNCases -1].CaLowerBound =
  1165. pCond->CoAttrValue;
  1166. pPRuleAttr->ApCase[pPRuleAttr->ApNCases -1].CaUpperBound =
  1167. pCond->CoAttrValue;
  1168. }
  1169. PtrPtrPRule = &pPRuleAttr->ApCase[pPRuleAttr->ApNCases -1].CaFirstPRule;
  1170. break;
  1171. case AtTextAttr:
  1172. if (pCond->CoTestAttrValue)
  1173. pPRuleAttr->ApString = TtaStrdup ((char *)pCond->CoAttrTextValue);
  1174. else
  1175. pPRuleAttr->ApString = NULL;
  1176. PtrPtrPRule = &pPRuleAttr->ApTextFirstPRule;
  1177. break;
  1178. case AtReferenceAttr:
  1179. PtrPtrPRule = &pPRuleAttr->ApRefFirstPRule;
  1180. break;
  1181. case AtEnumAttr:
  1182. if (!pCond->CoTestAttrValue)
  1183. PtrPtrPRule = &pPRuleAttr->ApEnumFirstPRule[0];
  1184. else
  1185. PtrPtrPRule = &pPRuleAttr->ApEnumFirstPRule[pCond->CoAttrValue];
  1186. break;
  1187. }
  1188. GetPresentRule (&pRule2);
  1189. *pRule2 = *pRule;
  1190. prevPRule = *PtrPtrPRule;
  1191. *PtrPtrPRule = pRule2;
  1192. pRule2->PrNextPRule = prevPRule;
  1193. pRule2->PrDuplicate = TRUE;
  1194. GetPresentRuleCond (&pCond2);
  1195. pRule2->PrCond = pCond2;
  1196. pCond2->CoNextCondition = NULL;
  1197. if (CurAttrPRule->ApElemType > 0)
  1198. pCond2->CoCondition = PcInheritAttribute;
  1199. else
  1200. pCond2->CoCondition = PcAttribute;
  1201. pCond2->CoNotNegative = TRUE;
  1202. pCond2->CoTarget = FALSE;
  1203. pCond2->CoTypeAttr = CurAttrNum;
  1204. switch (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType)
  1205. {
  1206. case AtNumAttr:
  1207. pCond2->CoTestAttrValue = FALSE;
  1208. if (CurAttrPRule->ApCase[0].CaComparType == ComparConstant)
  1209. if (CurAttrPRule->ApCase[0].CaLowerBound ==
  1210. CurAttrPRule->ApCase[0].CaUpperBound)
  1211. {
  1212. pCond2->CoTestAttrValue = TRUE;
  1213. pCond2->CoAttrValue = CurAttrPRule->ApCase[0].CaUpperBound;
  1214. }
  1215. PtrPtrPRule = &pPRuleAttr->ApCase[pPRuleAttr->ApNCases -1].CaFirstPRule;
  1216. pCond2->CoTestAttrValue = TRUE;
  1217. break;
  1218. case AtTextAttr:
  1219. if (CurAttrPRule->ApString == NULL)
  1220. pCond2->CoTestAttrValue = FALSE;
  1221. else
  1222. {
  1223. pCond2->CoTestAttrValue = TRUE;
  1224. pCond->CoAttrTextValue = TtaStrdup ((char *)CurAttrPRule->ApString);
  1225. }
  1226. break;
  1227. case AtReferenceAttr:
  1228. break;
  1229. case AtEnumAttr:
  1230. if (CurAttrPRule->ApEnumFirstPRule[0] == pRule)
  1231. pCond2->CoTestAttrValue = FALSE;
  1232. else
  1233. {
  1234. pCond2->CoTestAttrValue = TRUE;
  1235. pCond2->CoAttrValue = CurAttrVal;
  1236. }
  1237. break;
  1238. }
  1239. if (CurAttrPRule->ApElemType > 0)
  1240. {
  1241. GetPresentRuleCond (&pCond2->CoNextCondition);
  1242. pCond2 = pCond2->CoNextCondition;
  1243. pCond2->CoNextCondition = NULL;
  1244. pCond2->CoCondition = PcElemType;
  1245. pCond2->CoNotNegative = TRUE;
  1246. pCond2->CoTarget = FALSE;
  1247. pCond2->CoTypeElem = CurAttrPRule->ApElemType;
  1248. }
  1249. }
  1250. }
  1251. }
  1252. /*----------------------------------------------------------------------
  1253. ProcessShortKeyWord
  1254. ----------------------------------------------------------------------*/
  1255. static void ProcessShortKeyWord (int x, indLine wi, SyntacticCode gCode)
  1256. {
  1257. PresVariable *pPresVar;
  1258. /* traitement selon le code du mot-cle court */
  1259. switch (x)
  1260. {
  1261. case CHR_59:
  1262. /* ; */
  1263. if (gCode == RULE_Rule)
  1264. /* fin d'une regle */
  1265. {
  1266. if (CurRule != NULL)
  1267. if (CurRule->PrType == PtBreak1 ||
  1268. CurRule->PrType == PtBreak2 ||
  1269. CurRule->PrType == PtIndent ||
  1270. CurRule->PrType == PtVertRef ||
  1271. CurRule->PrType == PtHorizRef ||
  1272. CurRule->PrType == PtVertPos ||
  1273. CurRule->PrType == PtHorizPos ||
  1274. CurRule->PrType == PtHeight ||
  1275. CurRule->PrType == PtWidth ||
  1276. CurRule->PrType == PtLineSpacing ||
  1277. CurRule->PrType == PtLineWeight ||
  1278. CurRule->PrType == PtMarginTop ||
  1279. CurRule->PrType == PtMarginRight ||
  1280. CurRule->PrType == PtMarginBottom ||
  1281. CurRule->PrType == PtMarginLeft ||
  1282. CurRule->PrType == PtPaddingTop ||
  1283. CurRule->PrType == PtPaddingRight ||
  1284. CurRule->PrType == PtPaddingBottom ||
  1285. CurRule->PrType == PtPaddingLeft ||
  1286. CurRule->PrType == PtBorderTopWidth ||
  1287. CurRule->PrType == PtBorderRightWidth ||
  1288. CurRule->PrType == PtBorderBottomWidth ||
  1289. CurRule->PrType == PtBorderLeftWidth)
  1290. EndOfNumber ();
  1291. InInLineRule = False;
  1292. /* verifie la validite des regles de dimensionnement relatif */
  1293. /* au contenu */
  1294. if (CurRule != NULL)
  1295. if (CurRule->PrType == PtHeight || CurRule->PrType == PtWidth)
  1296. if (!CurRule->PrDimRule.DrPosition)
  1297. if (!CurRule->PrDimRule.DrAbsolute)
  1298. if (CurRule->PrDimRule.DrRelation == RlEnclosed)
  1299. if (CurRule->PrDimRule.DrRefIdent != 0 ||
  1300. CurRule->PrDimRule.DrValue != 0)
  1301. CompilerMessage (wi, PRS, FATAL, BAD_DIM_RULE,
  1302. inputLine, LineNum);
  1303. InRule = False;
  1304. if (RulesForView && !RuleBlock && !CondBlock)
  1305. {
  1306. RulesForView = False;
  1307. CurView = 1;
  1308. }
  1309. if (!ViewBlock)
  1310. CheckBoxEnd ();
  1311. if (!RuleBlock)
  1312. Conditions = NULL;
  1313. if (AttributeDef && CurAttrNum > 0)
  1314. DuplicateAttrCondRule (CurRule);
  1315. }
  1316. else if (gCode == RULE_Transmit)
  1317. /* fin d'une regle transmit */
  1318. {
  1319. TransmittedCounter = 0;
  1320. TransmittedElem = 0;
  1321. }
  1322. break;
  1323. case CHR_44:
  1324. /* , */
  1325. if (gCode == RULE_Function)
  1326. {
  1327. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  1328. if (pPresVar->PvItem[pPresVar->PvNItems -1].ViType == VarPageNumber)
  1329. /* c'est la fin d'un PageNumber dans une variable. On connait */
  1330. /* la vue concernee */
  1331. {
  1332. if (NewVariableDef)
  1333. /* definition de variable dans une regle Content */
  1334. /* Cherche les compteurs de page pour la vue concernee */
  1335. /* et indique dans ces compteurs que la boite courante */
  1336. /* peut etre modifiee par ces compteurs */
  1337. PageCounterChangeBox (CurPresBox,
  1338. pPresVar->PvItem[pPresVar->PvNItems - 1].ViView);
  1339. }
  1340. }
  1341. break;
  1342. case CHR_58:
  1343. /* : */
  1344. if (gCode == RULE_Rule1 || gCode == RULE_Rule2 ||
  1345. gCode == RULE_Rule3 || gCode == RULE_Rule4 ||
  1346. gCode == RULE_Rule5)
  1347. InRule = True;
  1348. if (gCode == RULE_Attr && NewAttributeDef)
  1349. GenerateRPresAttribute (wi);
  1350. break;
  1351. case CHR_40:
  1352. /* ( */
  1353. if (gCode == RULE_VarConst)
  1354. /* dans une regle VarConst */
  1355. if (PresBoxDef)
  1356. /* dans la regle Content d'une boite de presentation */
  1357. {
  1358. NewVar (wi); /* cree une nouvelle variable */
  1359. pPSchema->PsPresentBox->PresBox[CurPresBox - 1]->PbContent =
  1360. ContVariable;
  1361. pPSchema->PsPresentBox->PresBox[CurPresBox - 1]->PbContVariable =
  1362. pPSchema->PsNVariables;
  1363. NewVariableDef = True;
  1364. }
  1365. else
  1366. /* dans une regle Content d'une paire ou d'une reference,
  1367. on refuse: seules les constantes sont acceptees dans
  1368. cette regle */
  1369. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_A_REF, inputLine,
  1370. LineNum);
  1371. else if (gCode == RULE_Rule3)
  1372. /* dans Rule3 */
  1373. InRule = True;
  1374. else if (gCode == RULE_ElemCondition && !InCondPage)
  1375. /* on s'occupe de la construction ``if compteur < cste''
  1376. (resp >, =, IN [*..*] et pas des construction ``if One (compteur)''
  1377. (resp Even, Odd) */
  1378. {
  1379. Conditions->CoCondition = PcInterval;
  1380. Conditions->CoCounter = 0;
  1381. Conditions->CoMinCounter = MIN_COUNTER_VAL;
  1382. Conditions->CoMaxCounter = MAX_COUNTER_VAL;
  1383. Conditions->CoValCounter = CntCurVal;
  1384. }
  1385. break;
  1386. case CHR_41:
  1387. /* ) */
  1388. if (gCode == RULE_VarConst)
  1389. /* dans une regle VarConst */
  1390. NewVariableDef = False; /* fin de definition de variable */
  1391. if (gCode == RULE_Rule3)
  1392. if (CurRule->PrType == PtFunction &&
  1393. CurRule->PrPresFunction == FnCopy)
  1394. /* fin d'une regle Copy */
  1395. if (CopyType[0] != EOS)
  1396. /* on n'a pas encore traite' le nom de type a copier */
  1397. /* ce nom de type est donc erronne' */
  1398. {
  1399. CompilerMessage (BeginCopyType, PRS, FATAL,
  1400. UNDECLARED_IDENTIFIER, inputLine, LineNum);
  1401. CopyType[0] = EOS;
  1402. BeginCopyType = 0;
  1403. }
  1404. break;
  1405. case CHR_61:
  1406. /* = */
  1407. if (gCode == RULE_InheritVal || gCode == RULE_NameInherit ||
  1408. gCode == RULE_Color ||
  1409. gCode == RULE_BoolInherit || gCode == RULE_InheritDist ||
  1410. gCode == RULE_InheritSize || gCode == RULE_AdjustInherit ||
  1411. gCode == RULE_DirInherit || gCode == RULE_BidiInherit ||
  1412. gCode == RULE_LineStyleInherit || gCode == RULE_StyleInherit ||
  1413. gCode == RULE_FloatInherit || gCode == RULE_ClearInherit ||
  1414. gCode == RULE_InheritParent || gCode == RULE_DisplayVal ||
  1415. gCode == RULE_ListStyleType || gCode == RULE_ListStyleImage ||
  1416. gCode == RULE_ListStylePosition)
  1417. /* PresInherit */
  1418. {
  1419. CurRule->PrInhPercent = False;
  1420. CurRule->PrInhAttr = False;
  1421. CurRule->PrInhDelta = 0;
  1422. CurRule->PrInhUnit = UnRelative;
  1423. }
  1424. else if (gCode == RULE_InheritDist)
  1425. {
  1426. PrevSign = 1;
  1427. LatestNumberAttr = False;
  1428. LatestNumber = 0;
  1429. CurUnit = FontHeight;
  1430. }
  1431. else if (gCode == RULE_ElemCondition)
  1432. {
  1433. if (Conditions->CoCondition != PcAttribute &&
  1434. Conditions->CoCondition != PcInheritAttribute)
  1435. CompilerMessage (wi, PRS, FATAL, VALID_ONLY_FOR_ATTRIBUTES,
  1436. inputLine, LineNum);
  1437. else
  1438. {
  1439. Conditions->CoTestAttrValue = TRUE;
  1440. Conditions->CoAttrTextValue = NULL;
  1441. AttrValSign = 1;
  1442. }
  1443. }
  1444. break;
  1445. case CHR_46:
  1446. /* . */
  1447. if (gCode == RULE_Dimension) /* dimension relative */
  1448. {
  1449. if (!CurRule->PrDimRule.DrPosition)
  1450. CurRule->PrDimRule.DrAbsolute = False;
  1451. }
  1452. else if (gCode == RULE_AbsDist) /* introduit une partie decimale */
  1453. if (LatestNumberAttr) /* interdit apres un attribut */
  1454. CompilerMessage (wi, PRS, FATAL, NO_DECIMAL_PART_AFTER_AN_ATTR,
  1455. inputLine, LineNum);
  1456. break;
  1457. case CHR_42:
  1458. /* * */
  1459. if (gCode == RULE_TypeOrPage || gCode == RULE_RefVPosition ||
  1460. gCode == RULE_RefHPosition || gCode == RULE_Present ||
  1461. gCode == RULE_BoxType)
  1462. InclusionRefName = True;
  1463. else if (gCode == RULE_Reference)
  1464. SetLevel (RlSelf, wi);
  1465. else if (gCode == RULE_FSTypeName)
  1466. /* c'est un heritage d'attribut des ascendants mais aussi de
  1467. l'element meme */
  1468. CurElemHeritAttrSelf = TRUE;
  1469. break;
  1470. case CHR_43:
  1471. /* + */
  1472. if (gCode == RULE_Sign || gCode == RULE_InheritDist)
  1473. /* dans une distance */
  1474. PrevSign = 1;
  1475. break;
  1476. case CHR_45:
  1477. /* - */
  1478. if (gCode == RULE_Sign || gCode == RULE_InheritDist)
  1479. /* dans une distance */
  1480. PrevSign = -1;
  1481. else if (gCode == RULE_AttrRelat || gCode == RULE_AttrValue)
  1482. /* devant une valeur d'attribut numerique, dans une condition */
  1483. /* d'application de regles associees a un attribut */
  1484. AttrValSign = -1;
  1485. else if (gCode == RULE_ElemCondition)
  1486. CurCondCntSign = -1;
  1487. else if (gCode == RULE_RelAncestorLevel)
  1488. AncestorSign = -1;
  1489. break;
  1490. case CHR_62:
  1491. /* > */
  1492. if (gCode == RULE_GreaterLess)
  1493. {
  1494. Conditions->CoAncestorRel = CondGreater;
  1495. SignGreaterOrLess = True;
  1496. }
  1497. break;
  1498. case CHR_60:
  1499. /* < */
  1500. if (gCode == RULE_GreaterLess)
  1501. {
  1502. Conditions->CoAncestorRel = CondLess;
  1503. SignGreaterOrLess = True;
  1504. }
  1505. break;
  1506. case CHR_37:
  1507. /* % */
  1508. if (gCode == RULE_Unit)
  1509. CurUnit = Percent;
  1510. break;
  1511. default:
  1512. break;
  1513. }
  1514. }
  1515. /*----------------------------------------------------------------------
  1516. ProcessAxis
  1517. ----------------------------------------------------------------------*/
  1518. static void ProcessAxis (BoxEdge axis, indLine wi)
  1519. {
  1520. switch (CurRule->PrType)
  1521. {
  1522. case PtVertRef:
  1523. case PtHorizRef:
  1524. CurRule->PrPosRule.PoPosRef = axis;
  1525. break;
  1526. case PtVertPos:
  1527. case PtHorizPos:
  1528. if (AxisDef)
  1529. {
  1530. AxisDef = False;
  1531. CurRule->PrPosRule.PoPosDef = axis;
  1532. }
  1533. else
  1534. CurRule->PrPosRule.PoPosRef = axis;
  1535. break;
  1536. case PtHeight:
  1537. case PtWidth:
  1538. if (!CurRule->PrDimRule.DrPosition)
  1539. if ((CurRule->PrType == PtHeight &&
  1540. !(axis == Top || axis == Bottom)) ||
  1541. (CurRule->PrType == PtWidth &&
  1542. !(axis == Left || axis == Right)))
  1543. CompilerMessage (wi, PRS, FATAL, BROKEN_RULE, inputLine, LineNum);
  1544. else
  1545. {
  1546. CurRule->PrDimRule.DrPosition = True;
  1547. CurRule->PrDimRule.DrPosRule.PoPosDef = axis;
  1548. CurRule->PrDimRule.DrPosRule.PoPosRef = NoEdge;
  1549. CurRule->PrDimRule.DrPosRule.PoDistUnit = UnRelative;
  1550. CurRule->PrDimRule.DrPosRule.PoDeltaUnit = UnRelative;
  1551. CurRule->PrDimRule.DrPosRule.PoDistAttr = False;
  1552. CurRule->PrDimRule.DrPosRule.PoDistance = 0;
  1553. CurRule->PrDimRule.DrPosRule.PoDistDelta = 0;
  1554. CurRule->PrDimRule.DrPosRule.PoRelation = RlSameLevel;
  1555. CurRule->PrDimRule.DrPosRule.PoNotRel = False;
  1556. CurRule->PrDimRule.DrPosRule.PoRefKind = RkAnyBox;
  1557. CurRule->PrDimRule.DrPosRule.PoRefIdent = 0;
  1558. AxisDef = False;
  1559. }
  1560. else
  1561. /* 2eme repere d'un dimensionnement elastique */
  1562. CurRule->PrDimRule.DrPosRule.PoPosRef = axis;
  1563. break;
  1564. default:
  1565. break;
  1566. }
  1567. }
  1568. /*----------------------------------------------------------------------
  1569. CreateConstant
  1570. ----------------------------------------------------------------------*/
  1571. static void CreateConstant (BasicType constType, indLine wi)
  1572. {
  1573. PresVariable *pPresVar;
  1574. if (!ConstantDef)
  1575. {
  1576. NewConst (wi);
  1577. if (NewVariableDef || VariableDef)
  1578. /* dans une definition de variable */
  1579. {
  1580. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  1581. NewVarListItem (pPresVar, wi);
  1582. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarText;
  1583. pPresVar->PvItem[pPresVar->PvNItems - 1].ViConstant =
  1584. pPSchema->PsNConstants;
  1585. }
  1586. else
  1587. /* on ne peut etre que dans une regle 'Content' */
  1588. if (PresBoxDef)
  1589. /* definition dans une regle Content d'une boite de presentation */
  1590. {
  1591. pPSchema->PsPresentBox->PresBox[CurPresBox - 1]->PbContent =
  1592. ContConst;
  1593. pPSchema->PsPresentBox->PresBox[CurPresBox - 1]->PbContConstant =
  1594. pPSchema->PsNConstants;
  1595. }
  1596. else if (RuleDef && CurRule->PrPresMode == PresFunction
  1597. && CurRule->PrPresFunction == FnContentRef)
  1598. /* dans une regle Content d'un element reference ou paire */
  1599. {
  1600. CurRule->PrNPresBoxes = 1;
  1601. CurRule->PrPresBox[0] = pPSchema->PsNConstants;
  1602. }
  1603. }
  1604. pPSchema->PsConstant[pPSchema->PsNConstants - 1].PdType = constType;
  1605. }
  1606. /*----------------------------------------------------------------------
  1607. NewCounterOper
  1608. ----------------------------------------------------------------------*/
  1609. static void NewCounterOper (CounterOp oper, indLine wi)
  1610. {
  1611. Counter *pCntr;
  1612. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  1613. if (pCntr->CnNItems >= MAX_PRES_COUNT_ITEM)
  1614. CompilerMessage (wi, PRS, FATAL, MAX_OPS_ON_A_COUNTER_OVERFLOW,
  1615. inputLine, LineNum);
  1616. else
  1617. {
  1618. pCntr->CnItem[pCntr->CnNItems].CiCntrOp = oper;
  1619. pCntr->CnItem[pCntr->CnNItems].CiElemType = 0;
  1620. pCntr->CnItem[pCntr->CnNItems].CiAscendLevel = 0;
  1621. pCntr->CnItem[pCntr->CnNItems].CiViewNum = 0;
  1622. pCntr->CnItem[pCntr->CnNItems].CiParamValue = 0;
  1623. pCntr->CnItem[pCntr->CnNItems].CiInitAttr = 0;
  1624. pCntr->CnItem[pCntr->CnNItems].CiReinitAttr = 0;
  1625. pCntr->CnItem[pCntr->CnNItems].CiCondAttr = 0;
  1626. pCntr->CnItem[pCntr->CnNItems].CiCondAttrPresent = FALSE;
  1627. pCntr->CnNItems++;
  1628. }
  1629. }
  1630. /*----------------------------------------------------------------------
  1631. GetTypedRule cherche la regle de type ruleType pour la vue 1
  1632. dans la liste de regles qui commence par la regle firstR.
  1633. ----------------------------------------------------------------------*/
  1634. static PtrPRule GetTypedRule (PRuleType ruleType, PtrPRule firstR)
  1635. {
  1636. PtrPRule pRule;
  1637. ThotBool stop;
  1638. pRule = firstR;
  1639. stop = False;
  1640. do
  1641. if (pRule == NULL)
  1642. stop = True;
  1643. else if (pRule->PrType == ruleType && pRule->PrViewNum == 1)
  1644. stop = True;
  1645. else
  1646. pRule = pRule->PrNextPRule;
  1647. while (!stop);
  1648. return pRule;
  1649. }
  1650. /*----------------------------------------------------------------------
  1651. CreateDefaultRule cree une nouvelle regle de presentation par
  1652. defaut.
  1653. ----------------------------------------------------------------------*/
  1654. static void CreateDefaultRule ()
  1655. {
  1656. if (CurRule != NULL)
  1657. CurRule->PrNextPRule = NextRule;
  1658. CurRule = NextRule;
  1659. GetPresentRule (&NextRule);
  1660. if (NextRule == NULL)
  1661. /* memoire insuffisante */
  1662. CompilerMessage (0, PRS, FATAL, NO_MORE_MEM_LEFT, inputLine, LineNum);
  1663. if (pPSchema->PsFirstDefaultPRule == NULL)
  1664. pPSchema->PsFirstDefaultPRule = CurRule;
  1665. CurRule->PrNextPRule = NULL;
  1666. CurRule->PrCond = NULL;
  1667. CurRule->PrViewNum = 1;
  1668. CurRule->PrPresMode = PresImmediate;
  1669. }
  1670. /*----------------------------------------------------------------------
  1671. InheritRule transforme la regle de presentation courante en
  1672. une regle d'heritage de type inheritType.
  1673. ----------------------------------------------------------------------*/
  1674. static void InheritRule (InheritMode inheritType)
  1675. {
  1676. CurRule->PrPresMode = PresInherit;
  1677. CurRule->PrInheritMode = inheritType;
  1678. CurRule->PrInhPercent = False;
  1679. CurRule->PrInhAttr = False;
  1680. CurRule->PrInhDelta = 0;
  1681. CurRule->PrMinMaxAttr = False;
  1682. CurRule->PrInhMinOrMax = 0;
  1683. CurRule->PrInhUnit = UnRelative;
  1684. }
  1685. /*----------------------------------------------------------------------
  1686. CheckDefaultRules verifie que toutes les regles par defaut
  1687. sont presentes pour la vue 1 et si certaines sont absentes, on
  1688. les ajoute.
  1689. ----------------------------------------------------------------------*/
  1690. static void CheckDefaultRules ()
  1691. {
  1692. if (pPSchema->PsFirstDefaultPRule == NextRule)
  1693. pPSchema->PsFirstDefaultPRule = NULL;
  1694. if (GetTypedRule (PtVisibility, pPSchema->PsFirstDefaultPRule) == NULL)
  1695. /* pas de regle Visibility par defaut, on en cree une : */
  1696. /* Visibility: Enclosing =; */
  1697. {
  1698. CreateDefaultRule ();
  1699. CurRule->PrType = PtVisibility;
  1700. InheritRule (InheritParent);
  1701. }
  1702. if (GetTypedRule (PtListStyleType, pPSchema->PsFirstDefaultPRule) == NULL)
  1703. /* pas de regle PtListStyleType par defaut, on en cree une : */
  1704. /* ListStyleType: disc; */
  1705. {
  1706. CreateDefaultRule ();
  1707. CurRule->PrType = PtListStyleType;
  1708. InheritRule (InheritParent);
  1709. }
  1710. if (GetTypedRule (PtListStyleImage, pPSchema->PsFirstDefaultPRule) == NULL)
  1711. /* pas de regle PtListStyleImage par defaut, on en cree une : */
  1712. /* ListStyleImage: Enclosing =; */
  1713. {
  1714. CreateDefaultRule ();
  1715. CurRule->PrType = PtListStyleImage;
  1716. InheritRule (InheritParent);
  1717. }
  1718. if (GetTypedRule (PtListStylePosition, pPSchema->PsFirstDefaultPRule) == NULL)
  1719. /* pas de regle PtListStylePosition par defaut, on en cree une : */
  1720. /* ListStylePosition: outside; */
  1721. {
  1722. CreateDefaultRule ();
  1723. CurRule->PrType = PtListStylePosition;
  1724. InheritRule (InheritParent);
  1725. }
  1726. if (GetTypedRule (PtVertOverflow, pPSchema->PsFirstDefaultPRule) == NULL)
  1727. /* pas de regle VertOverflow par defaut, on en cree une : */
  1728. /* VertOverflow: False; */
  1729. {
  1730. CreateDefaultRule ();
  1731. CurRule->PrType = PtVertOverflow;
  1732. CurRule->PrPresMode = PresImmediate;
  1733. CurRule->PrBoolValue = FALSE;
  1734. }
  1735. if (GetTypedRule (PtHorizOverflow, pPSchema->PsFirstDefaultPRule) == NULL)
  1736. /* pas de regle HorizOverflow par defaut, on en cree une : */
  1737. /* HorizOverflow: False; */
  1738. {
  1739. CreateDefaultRule ();
  1740. CurRule->PrType = PtHorizOverflow;
  1741. CurRule->PrPresMode = PresImmediate;
  1742. CurRule->PrBoolValue = FALSE;
  1743. }
  1744. if (GetTypedRule (PtVertRef, pPSchema->PsFirstDefaultPRule) == NULL)
  1745. /* pas de regle VertRef par defaut, on en cree une : */
  1746. /* VertRef: * . Left; */
  1747. {
  1748. CreateDefaultRule ();
  1749. CurRule->PrType = PtVertRef;
  1750. CurRule->PrPosRule.PoPosDef = VertRef;
  1751. CurRule->PrPosRule.PoPosRef = Left;
  1752. CurRule->PrPosRule.PoDistUnit = UnRelative;
  1753. CurRule->PrPosRule.PoDeltaUnit = UnRelative;
  1754. CurRule->PrPosRule.PoDistAttr = False;
  1755. CurRule->PrPosRule.PoDistance = 0;
  1756. CurRule->PrPosRule.PoDistDelta = 0;
  1757. CurRule->PrPosRule.PoRelation = RlSelf;
  1758. CurRule->PrPosRule.PoNotRel = False;
  1759. CurRule->PrPosRule.PoUserSpecified = False;
  1760. CurRule->PrPosRule.PoRefKind = RkAnyBox;
  1761. CurRule->PrPosRule.PoRefIdent = 0;
  1762. }
  1763. if (GetTypedRule (PtHorizRef, pPSchema->PsFirstDefaultPRule) == NULL)
  1764. /* pas de regle HorizRef par defaut, on en cree une : */
  1765. /* HorizRef: Enclosed . HRef; */
  1766. {
  1767. CreateDefaultRule ();
  1768. CurRule->PrType = PtHorizRef;
  1769. CurRule->PrPosRule.PoPosDef = HorizRef;
  1770. CurRule->PrPosRule.PoPosRef = HorizRef;
  1771. CurRule->PrPosRule.PoDistUnit = UnRelative;
  1772. CurRule->PrPosRule.PoDeltaUnit = UnRelative;
  1773. CurRule->PrPosRule.PoDistAttr = False;
  1774. CurRule->PrPosRule.PoDistance = 0;
  1775. CurRule->PrPosRule.PoDistDelta = 0;
  1776. CurRule->PrPosRule.PoRelation = RlEnclosed;
  1777. CurRule->PrPosRule.PoNotRel = False;
  1778. CurRule->PrPosRule.PoUserSpecified = False;
  1779. CurRule->PrPosRule.PoRefKind = RkAnyBox;
  1780. CurRule->PrPosRule.PoRefIdent = 0;
  1781. }
  1782. if (GetTypedRule (PtHeight, pPSchema->PsFirstDefaultPRule) == NULL)
  1783. /* pas de regle Height par defaut, on en cree une : */
  1784. /* Height: Enclosed . Height; */
  1785. {
  1786. CreateDefaultRule ();
  1787. CurRule->PrType = PtHeight;
  1788. CurRule->PrDimRule.DrPosition = False;
  1789. CurRule->PrDimRule.DrAbsolute = False;
  1790. CurRule->PrDimRule.DrSameDimens = True;
  1791. CurRule->PrDimRule.DrUnit = UnRelative;
  1792. CurRule->PrDimRule.DrAttr = False;
  1793. CurRule->PrDimRule.DrMin = False;
  1794. CurRule->PrDimRule.DrUserSpecified = False;
  1795. CurRule->PrDimRule.DrValue = 0;
  1796. CurRule->PrDimRule.DrRelation = RlEnclosed;
  1797. CurRule->PrDimRule.DrNotRelat = False;
  1798. CurRule->PrDimRule.DrRefKind = RkElType;
  1799. CurRule->PrDimRule.DrRefIdent = 0;
  1800. }
  1801. if (GetTypedRule (PtWidth, pPSchema->PsFirstDefaultPRule) == NULL)
  1802. /* pas de regle Width par defaut, on en cree une : */
  1803. /* Width: Enclosed . Width; */
  1804. {
  1805. CreateDefaultRule ();
  1806. CurRule->PrType = PtWidth;
  1807. CurRule->PrDimRule.DrPosition = False;
  1808. CurRule->PrDimRule.DrAbsolute = False;
  1809. CurRule->PrDimRule.DrSameDimens = True;
  1810. CurRule->PrDimRule.DrUnit = UnRelative;
  1811. CurRule->PrDimRule.DrAttr = False;
  1812. CurRule->PrDimRule.DrMin = False;
  1813. CurRule->PrDimRule.DrUserSpecified = False;
  1814. CurRule->PrDimRule.DrValue = 0;
  1815. CurRule->PrDimRule.DrRelation = RlEnclosed;
  1816. CurRule->PrDimRule.DrNotRelat = False;
  1817. CurRule->PrDimRule.DrRefKind = RkElType;
  1818. CurRule->PrDimRule.DrRefIdent= 0;
  1819. }
  1820. if (GetTypedRule (PtVertPos, pPSchema->PsFirstDefaultPRule) == NULL)
  1821. /* pas de regle VertPos par defaut, on en cree une : */
  1822. /* VertPos: Top = Previous . Bottom; */
  1823. {
  1824. CreateDefaultRule ();
  1825. CurRule->PrType = PtVertPos;
  1826. CurRule->PrPosRule.PoPosDef = Top;
  1827. CurRule->PrPosRule.PoPosRef = Bottom;
  1828. CurRule->PrPosRule.PoDistUnit = UnRelative;
  1829. CurRule->PrPosRule.PoDeltaUnit = UnRelative;
  1830. CurRule->PrPosRule.PoDistAttr = False;
  1831. CurRule->PrPosRule.PoDistance = 0;
  1832. CurRule->PrPosRule.PoDistDelta = 0;
  1833. CurRule->PrPosRule.PoRelation = RlPrevious;
  1834. CurRule->PrPosRule.PoNotRel = False;
  1835. CurRule->PrPosRule.PoUserSpecified = False;
  1836. CurRule->PrPosRule.PoRefKind = RkAnyBox;
  1837. CurRule->PrPosRule.PoRefIdent = 0;
  1838. }
  1839. if (GetTypedRule (PtHorizPos, pPSchema->PsFirstDefaultPRule) == NULL)
  1840. /* pas de regle HorizPos par defaut, on en cree une : */
  1841. /* HorizPos: Left = Enclosing . Left; */
  1842. {
  1843. CreateDefaultRule ();
  1844. CurRule->PrType = PtHorizPos;
  1845. CurRule->PrPosRule.PoPosDef = Left;
  1846. CurRule->PrPosRule.PoPosRef = Left;
  1847. CurRule->PrPosRule.PoDistUnit = UnRelative;
  1848. CurRule->PrPosRule.PoDeltaUnit = UnRelative;
  1849. CurRule->PrPosRule.PoDistAttr = False;
  1850. CurRule->PrPosRule.PoDistance = 0;
  1851. CurRule->PrPosRule.PoDistDelta = 0;
  1852. CurRule->PrPosRule.PoRelation = RlEnclosing;
  1853. CurRule->PrPosRule.PoNotRel = False;
  1854. CurRule->PrPosRule.PoUserSpecified = False;
  1855. CurRule->PrPosRule.PoRefKind = RkAnyBox;
  1856. CurRule->PrPosRule.PoRefIdent = 0;
  1857. }
  1858. if (GetTypedRule (PtMarginTop, pPSchema->PsFirstDefaultPRule) == NULL)
  1859. /* pas de regle MarginTop par defaut, on en cree une : */
  1860. /* MarginTop = 0; */
  1861. {
  1862. CreateDefaultRule ();
  1863. CurRule->PrType = PtMarginTop;
  1864. CurRule->PrPresMode = PresImmediate;
  1865. CurRule->PrMinUnit = UnRelative;
  1866. CurRule->PrMinAttr = FALSE;
  1867. CurRule->PrMinValue = 0;
  1868. }
  1869. if (GetTypedRule (PtMarginRight, pPSchema->PsFirstDefaultPRule) == NULL)
  1870. /* pas de regle MarginRight par defaut, on en cree une : */
  1871. /* MarginRight = 0; */
  1872. {
  1873. CreateDefaultRule ();
  1874. CurRule->PrType = PtMarginRight;
  1875. CurRule->PrPresMode = PresImmediate;
  1876. CurRule->PrMinUnit = UnRelative;
  1877. CurRule->PrMinAttr = FALSE;
  1878. CurRule->PrMinValue = 0;
  1879. }
  1880. if (GetTypedRule (PtMarginBottom, pPSchema->PsFirstDefaultPRule) == NULL)
  1881. /* pas de regle MarginBottom par defaut, on en cree une : */
  1882. /* MarginBottom = 0; */
  1883. {
  1884. CreateDefaultRule ();
  1885. CurRule->PrType = PtMarginBottom;
  1886. CurRule->PrPresMode = PresImmediate;
  1887. CurRule->PrMinUnit = UnRelative;
  1888. CurRule->PrMinAttr = FALSE;
  1889. CurRule->PrMinValue = 0;
  1890. }
  1891. if (GetTypedRule (PtMarginLeft, pPSchema->PsFirstDefaultPRule) == NULL)
  1892. /* pas de regle MarginLeft par defaut, on en cree une : */
  1893. /* MarginLeft = 0; */
  1894. {
  1895. CreateDefaultRule ();
  1896. CurRule->PrType = PtMarginLeft;
  1897. CurRule->PrPresMode = PresImmediate;
  1898. CurRule->PrMinUnit = UnRelative;
  1899. CurRule->PrMinAttr = FALSE;
  1900. CurRule->PrMinValue = 0;
  1901. }
  1902. if (GetTypedRule (PtPaddingTop, pPSchema->PsFirstDefaultPRule) == NULL)
  1903. /* pas de regle PaddingTop par defaut, on en cree une : */
  1904. /* PaddingTop = 0; */
  1905. {
  1906. CreateDefaultRule ();
  1907. CurRule->PrType = PtPaddingTop;
  1908. CurRule->PrPresMode = PresImmediate;
  1909. CurRule->PrMinUnit = UnRelative;
  1910. CurRule->PrMinAttr = FALSE;
  1911. CurRule->PrMinValue = 0;
  1912. }
  1913. if (GetTypedRule (PtPaddingRight, pPSchema->PsFirstDefaultPRule) == NULL)
  1914. /* pas de regle PaddingRight par defaut, on en cree une : */
  1915. /* PaddingRight = 0; */
  1916. {
  1917. CreateDefaultRule ();
  1918. CurRule->PrType = PtPaddingRight;
  1919. CurRule->PrPresMode = PresImmediate;
  1920. CurRule->PrMinUnit = UnRelative;
  1921. CurRule->PrMinAttr = FALSE;
  1922. CurRule->PrMinValue = 0;
  1923. }
  1924. if (GetTypedRule (PtPaddingBottom, pPSchema->PsFirstDefaultPRule) == NULL)
  1925. /* pas de regle PaddingBottom par defaut, on en cree une : */
  1926. /* PaddingBottom = 0; */
  1927. {
  1928. CreateDefaultRule ();
  1929. CurRule->PrType = PtPaddingBottom;
  1930. CurRule->PrPresMode = PresImmediate;
  1931. CurRule->PrMinUnit = UnRelative;
  1932. CurRule->PrMinAttr = FALSE;
  1933. CurRule->PrMinValue = 0;
  1934. }
  1935. if (GetTypedRule (PtPaddingLeft, pPSchema->PsFirstDefaultPRule) == NULL)
  1936. /* pas de regle PaddingLeft par defaut, on en cree une : */
  1937. /* PaddingLeft = 0; */
  1938. {
  1939. CreateDefaultRule ();
  1940. CurRule->PrType = PtPaddingLeft;
  1941. CurRule->PrPresMode = PresImmediate;
  1942. CurRule->PrMinUnit = UnRelative;
  1943. CurRule->PrMinAttr = FALSE;
  1944. CurRule->PrMinValue = 0;
  1945. }
  1946. if (GetTypedRule (PtBorderTopWidth, pPSchema->PsFirstDefaultPRule) == NULL)
  1947. /* pas de regle BorderTopWidth par defaut, on en cree une : */
  1948. /* BorderTopWidth = 0; */
  1949. {
  1950. CreateDefaultRule ();
  1951. CurRule->PrType = PtBorderTopWidth;
  1952. CurRule->PrPresMode = PresImmediate;
  1953. CurRule->PrMinUnit = UnRelative;
  1954. CurRule->PrMinAttr = FALSE;
  1955. CurRule->PrMinValue = 0;
  1956. }
  1957. if (GetTypedRule (PtBorderRightWidth, pPSchema->PsFirstDefaultPRule) == NULL)
  1958. /* pas de regle BorderRightWidth par defaut, on en cree une : */
  1959. /* BorderRightWidth = 0; */
  1960. {
  1961. CreateDefaultRule ();
  1962. CurRule->PrType = PtBorderRightWidth;
  1963. CurRule->PrPresMode = PresImmediate;
  1964. CurRule->PrMinUnit = UnRelative;
  1965. CurRule->PrMinAttr = FALSE;
  1966. CurRule->PrMinValue = 0;
  1967. }
  1968. if (GetTypedRule (PtBorderBottomWidth, pPSchema->PsFirstDefaultPRule) == NULL)
  1969. /* pas de regle BorderBottomWidth par defaut, on en cree une : */
  1970. /* BorderBottomWidth = 0; */
  1971. {
  1972. CreateDefaultRule ();
  1973. CurRule->PrType = PtBorderBottomWidth;
  1974. CurRule->PrPresMode = PresImmediate;
  1975. CurRule->PrMinUnit = UnRelative;
  1976. CurRule->PrMinAttr = FALSE;
  1977. CurRule->PrMinValue = 0;
  1978. }
  1979. if (GetTypedRule (PtBorderLeftWidth, pPSchema->PsFirstDefaultPRule) == NULL)
  1980. /* pas de regle BorderLeftWidth par defaut, on en cree une : */
  1981. /* BorderLeftWidth = 0; */
  1982. {
  1983. CreateDefaultRule ();
  1984. CurRule->PrType = PtBorderLeftWidth;
  1985. CurRule->PrPresMode = PresImmediate;
  1986. CurRule->PrMinUnit = UnRelative;
  1987. CurRule->PrMinAttr = FALSE;
  1988. CurRule->PrMinValue = 0;
  1989. }
  1990. if (GetTypedRule (PtBorderTopColor, pPSchema->PsFirstDefaultPRule) == NULL)
  1991. /* pas de regle BorderTopColor par defaut, on en cree une : */
  1992. /* BorderTopColor: Enclosing =; */
  1993. {
  1994. CreateDefaultRule ();
  1995. CurRule->PrType = PtBorderTopColor;
  1996. InheritRule (InheritParent);
  1997. }
  1998. if (GetTypedRule (PtBorderRightColor, pPSchema->PsFirstDefaultPRule) == NULL)
  1999. /* pas de regle BorderRightColor par defaut, on en cree une : */
  2000. /* BorderRightColor: same as foreground; */
  2001. {
  2002. CreateDefaultRule ();
  2003. CurRule->PrType = PtBorderRightColor;
  2004. InheritRule (InheritParent);
  2005. }
  2006. if (GetTypedRule (PtBorderBottomColor, pPSchema->PsFirstDefaultPRule) == NULL)
  2007. /* pas de regle BorderBottomColor par defaut, on en cree une : */
  2008. /* BorderBottomColor: same as foreground; */
  2009. {
  2010. CreateDefaultRule ();
  2011. CurRule->PrType = PtBorderBottomColor;
  2012. InheritRule (InheritParent);
  2013. }
  2014. if (GetTypedRule (PtBorderLeftColor, pPSchema->PsFirstDefaultPRule) == NULL)
  2015. /* pas de regle BorderLeftColor par defaut, on en cree une : */
  2016. /* BorderLeftColor: same as foreground; */
  2017. {
  2018. CreateDefaultRule ();
  2019. CurRule->PrType = PtBorderLeftColor;
  2020. InheritRule (InheritParent);
  2021. }
  2022. if (GetTypedRule (PtBorderTopStyle, pPSchema->PsFirstDefaultPRule) == NULL)
  2023. /* pas de regle BorderTopStyle par defaut, on en cree une : */
  2024. /* BorderTopStyle: none; */
  2025. {
  2026. CreateDefaultRule ();
  2027. CurRule->PrType = PtBorderTopStyle;
  2028. CurRule->PrPresMode = PresImmediate;
  2029. CurRule->PrChrValue = '0'; /* none */
  2030. }
  2031. if (GetTypedRule (PtBorderRightStyle, pPSchema->PsFirstDefaultPRule) == NULL)
  2032. /* pas de regle BorderRightStyle par defaut, on en cree une : */
  2033. /* BorderRightStyle: none; */
  2034. {
  2035. CreateDefaultRule ();
  2036. CurRule->PrType = PtBorderRightStyle;
  2037. CurRule->PrPresMode = PresImmediate;
  2038. CurRule->PrChrValue = '0'; /* none */
  2039. }
  2040. if (GetTypedRule (PtBorderBottomStyle, pPSchema->PsFirstDefaultPRule) == NULL)
  2041. /* pas de regle BorderBottomStyle par defaut, on en cree une : */
  2042. /* BorderBottomStyle: none; */
  2043. {
  2044. CreateDefaultRule ();
  2045. CurRule->PrType = PtBorderBottomStyle;
  2046. CurRule->PrPresMode = PresImmediate;
  2047. CurRule->PrChrValue = '0'; /* none */
  2048. }
  2049. if (GetTypedRule (PtBorderLeftStyle, pPSchema->PsFirstDefaultPRule) == NULL)
  2050. /* pas de regle BorderLeftStyle par defaut, on en cree une : */
  2051. /* BorderLeftStyle: none; */
  2052. {
  2053. CreateDefaultRule ();
  2054. CurRule->PrType = PtBorderLeftStyle;
  2055. CurRule->PrPresMode = PresImmediate;
  2056. CurRule->PrChrValue = '0'; /* none */
  2057. }
  2058. if (GetTypedRule (PtSize, pPSchema->PsFirstDefaultPRule) == NULL)
  2059. /* pas de regle Size par defaut, on en cree une : */
  2060. /* Size: Enclosing =; */
  2061. {
  2062. CreateDefaultRule ();
  2063. CurRule->PrType = PtSize;
  2064. InheritRule (InheritParent);
  2065. }
  2066. if (GetTypedRule (PtStyle, pPSchema->PsFirstDefaultPRule) == NULL)
  2067. /* pas de regle Style par defaut, on en cree une : */
  2068. /* Style: Enclosing =; */
  2069. {
  2070. CreateDefaultRule ();
  2071. CurRule->PrType = PtStyle;
  2072. InheritRule (InheritParent);
  2073. }
  2074. if (GetTypedRule (PtWeight, pPSchema->PsFirstDefaultPRule) == NULL)
  2075. /* pas de regle Weight par defaut, on en cree une : */
  2076. /* Weight: Enclosing =; */
  2077. {
  2078. CreateDefaultRule ();
  2079. CurRule->PrType = PtWeight;
  2080. InheritRule (InheritParent);
  2081. }
  2082. if (GetTypedRule (PtVariant, pPSchema->PsFirstDefaultPRule) == NULL)
  2083. /* pas de regle Variant par defaut, on en cree une : */
  2084. /* Variant: Enclosing =; */
  2085. {
  2086. CreateDefaultRule ();
  2087. CurRule->PrType = PtVariant;
  2088. InheritRule (InheritParent);
  2089. }
  2090. if (GetTypedRule (PtFont, pPSchema->PsFirstDefaultPRule) == NULL)
  2091. /* pas de regle Font par defaut, on en cree une : */
  2092. /* Font: Enclosing =; */
  2093. {
  2094. CreateDefaultRule ();
  2095. CurRule->PrType = PtFont;
  2096. InheritRule (InheritParent);
  2097. }
  2098. if (GetTypedRule (PtUnderline, pPSchema->PsFirstDefaultPRule) == NULL)
  2099. /* pas de regle Underline par defaut, on en cree une : */
  2100. /* Underline: Enclosing =; */
  2101. {
  2102. CreateDefaultRule ();
  2103. CurRule->PrType = PtUnderline;
  2104. InheritRule (InheritParent);
  2105. }
  2106. if (GetTypedRule (PtThickness, pPSchema->PsFirstDefaultPRule) == NULL)
  2107. /* pas de regle Thickness par defaut, on en cree une : */
  2108. /* Thickness: Enclosing =; */
  2109. {
  2110. CreateDefaultRule ();
  2111. CurRule->PrType = PtThickness;
  2112. InheritRule (InheritParent);
  2113. }
  2114. if (GetTypedRule (PtIndent, pPSchema->PsFirstDefaultPRule) == NULL)
  2115. /* pas de regle Indent par defaut, on en cree une : */
  2116. /* Indent: Enclosing =; */
  2117. {
  2118. CreateDefaultRule ();
  2119. CurRule->PrType = PtIndent;
  2120. InheritRule (InheritParent);
  2121. }
  2122. if (GetTypedRule (PtLineSpacing, pPSchema->PsFirstDefaultPRule) == NULL)
  2123. /* pas de regle LineSpacing par defaut, on en cree une : */
  2124. /* LineSpacing: Enclosing =; */
  2125. {
  2126. CreateDefaultRule ();
  2127. CurRule->PrType = PtLineSpacing;
  2128. InheritRule (InheritParent);
  2129. }
  2130. if (GetTypedRule (PtDepth, pPSchema->PsFirstDefaultPRule) == NULL)
  2131. /* pas de regle Depth par defaut, on en cree une : */
  2132. /* Depth: 0; */
  2133. {
  2134. CreateDefaultRule ();
  2135. CurRule->PrType = PtDepth;
  2136. CurRule->PrPresMode = PresImmediate;
  2137. CurRule->PrValueType = PrNumValue;
  2138. CurRule->PrIntValue = 0;
  2139. }
  2140. if (GetTypedRule (PtAdjust, pPSchema->PsFirstDefaultPRule) == NULL)
  2141. /* pas de regle Adjust par defaut, on en cree une : */
  2142. /* Adjust: Enclosing =; */
  2143. {
  2144. CreateDefaultRule ();
  2145. CurRule->PrType = PtAdjust;
  2146. InheritRule (InheritParent);
  2147. }
  2148. if (GetTypedRule (PtDirection, pPSchema->PsFirstDefaultPRule) == NULL)
  2149. /* pas de regle Direction par defaut, on en cree une : */
  2150. /* Direction: Enclosing =; */
  2151. {
  2152. CreateDefaultRule ();
  2153. CurRule->PrType = PtDirection;
  2154. InheritRule (InheritParent);
  2155. }
  2156. if (GetTypedRule (PtUnicodeBidi, pPSchema->PsFirstDefaultPRule) == NULL)
  2157. /* pas de regle UnicodeBidi par defaut, on en cree une : */
  2158. /* UnicodeBidi: Enclosing =; */
  2159. {
  2160. CreateDefaultRule ();
  2161. CurRule->PrType = PtUnicodeBidi;
  2162. InheritRule (InheritParent);
  2163. }
  2164. if (GetTypedRule (PtLineStyle, pPSchema->PsFirstDefaultPRule) == NULL)
  2165. /* pas de regle LineStyle par defaut, on en cree une : */
  2166. /* LineStyle: Enclosing =; */
  2167. {
  2168. CreateDefaultRule ();
  2169. CurRule->PrType = PtLineStyle;
  2170. InheritRule (InheritParent);
  2171. }
  2172. if (GetTypedRule (PtFloat, pPSchema->PsFirstDefaultPRule) == NULL)
  2173. /* pas de regle Float par defaut, on en cree une : */
  2174. /* Float: None; */
  2175. {
  2176. CreateDefaultRule ();
  2177. CurRule->PrType = PtFloat;
  2178. CurRule->PrPresMode = PresImmediate;
  2179. CurRule->PrChrValue = 'N';
  2180. }
  2181. if (GetTypedRule (PtClear, pPSchema->PsFirstDefaultPRule) == NULL)
  2182. /* pas de regle Clear par defaut, on en cree une : */
  2183. /* Clear: None; */
  2184. {
  2185. CreateDefaultRule ();
  2186. CurRule->PrType = PtClear;
  2187. CurRule->PrPresMode = PresImmediate;
  2188. CurRule->PrChrValue = 'N';
  2189. }
  2190. if (GetTypedRule (PtLineWeight, pPSchema->PsFirstDefaultPRule) == NULL)
  2191. /* pas de regle LineWeight par defaut, on en cree une : */
  2192. /* LineWeight: Enclosing =; */
  2193. {
  2194. CreateDefaultRule ();
  2195. CurRule->PrType = PtLineWeight;
  2196. InheritRule (InheritParent);
  2197. }
  2198. if (GetTypedRule (PtFillPattern, pPSchema->PsFirstDefaultPRule) == NULL)
  2199. /* pas de regle FillPattern par defaut, on en cree une : */
  2200. /* FillPattern: Enclosing =; */
  2201. {
  2202. CreateDefaultRule ();
  2203. CurRule->PrType = PtFillPattern;
  2204. InheritRule (InheritParent);
  2205. }
  2206. if (GetTypedRule (PtOpacity, pPSchema->PsFirstDefaultPRule) == NULL)
  2207. /* pas de regle Opacity par defaut, on en cree une : */
  2208. /* Opacity: 100%; */
  2209. {
  2210. CreateDefaultRule ();
  2211. CurRule->PrType = PtOpacity;
  2212. CurRule->PrValueType = PrNumValue;
  2213. InheritRule (InheritParent);
  2214. }
  2215. if (GetTypedRule (PtFillOpacity, pPSchema->PsFirstDefaultPRule) == NULL)
  2216. /* pas de regle Opacity par defaut, on en cree une : */
  2217. /* FillOpacity: Enclosing =; */
  2218. {
  2219. CreateDefaultRule ();
  2220. CurRule->PrType = PtFillOpacity;
  2221. InheritRule (InheritParent);
  2222. }
  2223. if (GetTypedRule (PtStrokeOpacity, pPSchema->PsFirstDefaultPRule) == NULL)
  2224. /* pas de regle Opacity par defaut, on en cree une : */
  2225. /* StrokeOpacity: Enclosing =; */
  2226. {
  2227. CreateDefaultRule ();
  2228. CurRule->PrType = PtStrokeOpacity;
  2229. InheritRule (InheritParent);
  2230. }
  2231. if (GetTypedRule (PtOpacity, pPSchema->PsFirstDefaultPRule) == NULL)
  2232. /* pas de regle Opacity par defaut, on en cree une : */
  2233. /* Opacity: 100%; */
  2234. {
  2235. CreateDefaultRule ();
  2236. CurRule->PrType = PtOpacity;
  2237. CurRule->PrValueType = PrNumValue;
  2238. CurRule->PrIntValue = 1000;
  2239. }
  2240. if (GetTypedRule (PtBackground, pPSchema->PsFirstDefaultPRule) == NULL)
  2241. /* pas de regle Background par defaut, on en cree une : */
  2242. /* Background: Enclosing =; */
  2243. {
  2244. CreateDefaultRule ();
  2245. CurRule->PrType = PtBackground;
  2246. InheritRule (InheritParent);
  2247. }
  2248. if (GetTypedRule (PtForeground, pPSchema->PsFirstDefaultPRule) == NULL)
  2249. /* pas de regle Foreground par defaut, on en cree une : */
  2250. /* Foreground: Enclosing =; */
  2251. {
  2252. CreateDefaultRule ();
  2253. CurRule->PrType = PtForeground;
  2254. InheritRule (InheritParent);
  2255. }
  2256. if (GetTypedRule (PtColor, pPSchema->PsFirstDefaultPRule) == NULL)
  2257. /* pas de regle Color par defaut, on en cree une : */
  2258. /* Color: Enclosing =; */
  2259. {
  2260. CreateDefaultRule ();
  2261. CurRule->PrType = PtColor;
  2262. InheritRule (InheritParent);
  2263. }
  2264. if (GetTypedRule (PtStopColor, pPSchema->PsFirstDefaultPRule) == NULL)
  2265. /* pas de regle StopColor par defaut, on en cree une : */
  2266. /* StopColor: Black; */
  2267. {
  2268. CreateDefaultRule ();
  2269. CurRule->PrType = PtStopColor;
  2270. CurRule->PrPresMode = PresImmediate;
  2271. CurRule->PrValueType = PrNumValue;
  2272. CurRule->PrIntValue = 1;
  2273. }
  2274. if (GetTypedRule (PtStopOpacity, pPSchema->PsFirstDefaultPRule) == NULL)
  2275. /* pas de regle StopOpacity par defaut, on en cree une : */
  2276. /* StopOpacity: 100%; */
  2277. {
  2278. CreateDefaultRule ();
  2279. CurRule->PrType = PtStopOpacity;
  2280. CurRule->PrPresMode = PresImmediate;
  2281. CurRule->PrValueType = PrNumValue;
  2282. CurRule->PrIntValue = 1000;
  2283. }
  2284. if (GetTypedRule (PtMarker, pPSchema->PsFirstDefaultPRule) == NULL)
  2285. /* pas de regle Marker par defaut, on en cree une : */
  2286. /* Marker: Enclosing =; */
  2287. {
  2288. CreateDefaultRule ();
  2289. CurRule->PrType = PtMarker;
  2290. InheritRule (InheritParent);
  2291. }
  2292. if (GetTypedRule (PtMarkerStart, pPSchema->PsFirstDefaultPRule) == NULL)
  2293. /* pas de regle MarkerStart par defaut, on en cree une : */
  2294. /* MarkerStart: Enclosing =; */
  2295. {
  2296. CreateDefaultRule ();
  2297. CurRule->PrType = PtMarkerStart;
  2298. InheritRule (InheritParent);
  2299. }
  2300. if (GetTypedRule (PtMarkerMid, pPSchema->PsFirstDefaultPRule) == NULL)
  2301. /* pas de regle MarkerMid par defaut, on en cree une : */
  2302. /* MarkerMid: Enclosing =; */
  2303. {
  2304. CreateDefaultRule ();
  2305. CurRule->PrType = PtMarkerMid;
  2306. InheritRule (InheritParent);
  2307. }
  2308. if (GetTypedRule (PtMarkerEnd, pPSchema->PsFirstDefaultPRule) == NULL)
  2309. /* pas de regle MarkerEnd par defaut, on en cree une : */
  2310. /* MarkerEnd: Enclosing =; */
  2311. {
  2312. CreateDefaultRule ();
  2313. CurRule->PrType = PtMarkerEnd;
  2314. InheritRule (InheritParent);
  2315. }
  2316. if (GetTypedRule (PtHyphenate, pPSchema->PsFirstDefaultPRule) == NULL)
  2317. /* pas de regle Hyphenate par defaut, on en cree une : */
  2318. /* Hyphenate: Enclosing =; */
  2319. {
  2320. CreateDefaultRule ();
  2321. CurRule->PrType = PtHyphenate;
  2322. InheritRule (InheritParent);
  2323. }
  2324. if (GetTypedRule (PtPageBreak, pPSchema->PsFirstDefaultPRule) == NULL)
  2325. /* pas de regle PageBreak par defaut, on en cree une : */
  2326. /* PageBreak: True; */
  2327. {
  2328. CreateDefaultRule ();
  2329. CurRule->PrType = PtPageBreak;
  2330. CurRule->PrPresMode = PresImmediate;
  2331. CurRule->PrBoolValue = True;
  2332. }
  2333. if (GetTypedRule (PtLineBreak, pPSchema->PsFirstDefaultPRule) == NULL)
  2334. /* pas de regle LineBreak par defaut, on en cree une : */
  2335. /* LineBreak: True; */
  2336. {
  2337. CreateDefaultRule ();
  2338. CurRule->PrType = PtLineBreak;
  2339. CurRule->PrPresMode = PresImmediate;
  2340. CurRule->PrBoolValue = True;
  2341. }
  2342. if (GetTypedRule (PtGather, pPSchema->PsFirstDefaultPRule) == NULL)
  2343. /* pas de regle Gather par defaut, on en cree une : */
  2344. /* PtGather: False; */
  2345. {
  2346. CreateDefaultRule ();
  2347. CurRule->PrType = PtGather;
  2348. CurRule->PrPresMode = PresImmediate;
  2349. CurRule->PrBoolValue = False;
  2350. }
  2351. if (GetTypedRule (PtDisplay, pPSchema->PsFirstDefaultPRule) == NULL)
  2352. /* pas de regle Display par defaut, on en cree une : */
  2353. /* Display: undefined; */
  2354. {
  2355. CreateDefaultRule ();
  2356. CurRule->PrType = PtDisplay;
  2357. CurRule->PrPresMode = PresImmediate;
  2358. CurRule->PrChrValue = 'U'; /* undefined */
  2359. }
  2360. CurRule->PrNextPRule = NULL;
  2361. }
  2362. /*----------------------------------------------------------------------
  2363. CheckForwardRef verifie que toutes les references de boites
  2364. en avant sont resolues.
  2365. ----------------------------------------------------------------------*/
  2366. static void CheckForwardRef (indLine wi)
  2367. {
  2368. int box;
  2369. int i, j;
  2370. ThotBool stop;
  2371. for (box = 0; box < pPSchema->PsNPresentBoxes; box++)
  2372. if (pPSchema->PsPresentBox->PresBox[box]->PbName[0] == ' ')
  2373. {
  2374. i = 0;
  2375. stop = False;
  2376. do
  2377. {
  2378. if (i + 1 > MAX_IDENTIFIERS)
  2379. stop = True;
  2380. else if (Identifier[i].SrcIdentCode == RULE_ViewName)
  2381. /* identificateur de boite */
  2382. if (Identifier[i].SrcIdentDefRule == box + 1)
  2383. {
  2384. stop = True;
  2385. /* affiche le nom de l'identificateur */
  2386. printf ("\n");
  2387. for (j = 0; j < Identifier[i].SrcIdentLen; j++)
  2388. putchar (Identifier[i].SrcIdentifier[j]);
  2389. printf ("\n");
  2390. }
  2391. i++;
  2392. }
  2393. while (!stop);
  2394. if (i > MAX_IDENTIFIERS)
  2395. /*erreur dans la declaration FORWARD */
  2396. CompilerMessage (wi, PRS, FATAL, BAD_USE_OF_KEYWORD_FORWARD, inputLine, LineNum);
  2397. }
  2398. }
  2399. /*----------------------------------------------------------------------
  2400. LayoutRule
  2401. ----------------------------------------------------------------------*/
  2402. static void LayoutRule (FunctionType layoutFonct, indLine wi)
  2403. {
  2404. PtrPRule pPRule;
  2405. ConditionEnd ();
  2406. if (DefaultRuleDef)
  2407. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_DEFAULT_RULES, inputLine,
  2408. LineNum);
  2409. else if (RuleDef && CurType <= MAX_BASIC_TYPE)
  2410. CompilerMessage (wi, PRS, FATAL, BAD_RULE_FOR_A_TERMINAL_ELEM,
  2411. inputLine, LineNum);
  2412. else if (layoutFonct != FnLine &&
  2413. layoutFonct != FnNoLine &&
  2414. layoutFonct != FnShowBox &&
  2415. pSSchema->SsRule->SrElem[CurType - 1]->SrConstruct == CsChoice)
  2416. CompilerMessage (wi, PRS, FATAL, CANT_USE_RULE_FOR_A_CHOICE, inputLine,
  2417. LineNum);
  2418. else
  2419. {
  2420. /* verifie qu'il n'y a que des conditions Within parmi les
  2421. conditions courantes */
  2422. CheckConditions (wi);
  2423. CreatePRule (PtFunction, wi);
  2424. CurRule->PrPresMode = PresFunction;
  2425. CurRule->PrPresFunction = layoutFonct;
  2426. CurRule->PrPresBoxRepeat = False;
  2427. CurRule->PrElement = False;
  2428. CurRule->PrExternal = False;
  2429. CurRule->PrNPresBoxes = 0;
  2430. CurRule->PrPresBoxName[0] = EOS;
  2431. /* verifie que cette regle n'est pas deja presente pour cette */
  2432. /* vue uniquement pour layoutFonct = FnLine ou FnPage ou FnColumn */
  2433. if (layoutFonct == FnLine || layoutFonct == FnPage ||
  2434. layoutFonct == FnColumn || layoutFonct == FnSubColumn ||
  2435. layoutFonct == FnNoLine)
  2436. {
  2437. pPRule = FirstRule;
  2438. while (pPRule != CurRule)
  2439. {
  2440. if (pPRule->PrViewNum == CurView)
  2441. if (pPRule->PrType == PtFunction)
  2442. if (pPRule->PrPresFunction == FnLine
  2443. || pPRule->PrPresFunction == FnNoLine
  2444. || pPRule->PrPresFunction == FnPage
  2445. || pPRule->PrPresFunction == FnColumn
  2446. || pPRule->PrPresFunction == FnSubColumn)
  2447. CompilerMessage (wi, PRS, FATAL, ONLY_ONE_PAGE_RULE,
  2448. inputLine, LineNum);
  2449. pPRule = pPRule->PrNextPRule;
  2450. }
  2451. }
  2452. }
  2453. }
  2454. /*----------------------------------------------------------------------
  2455. BooleanValue affecte la valeur bool a la regle de presentation courante
  2456. ----------------------------------------------------------------------*/
  2457. static void BooleanValue (ThotBool b, indLine wi)
  2458. {
  2459. if (InInLineRule)
  2460. /* on est dans une regle InLine */
  2461. {
  2462. if (!b)
  2463. LayoutRule (FnNotInLine, wi);
  2464. }
  2465. else
  2466. /* on est dans une regle Hyphenate, VertOverflow, HorizOverflow,
  2467. PtGather, PtPageBreak, PtLineBreak */
  2468. {
  2469. CurRule->PrPresMode = PresImmediate;
  2470. CurRule->PrBoolValue = b;
  2471. }
  2472. }
  2473. /*----------------------------------------------------------------------
  2474. CreationRule
  2475. ----------------------------------------------------------------------*/
  2476. static void CreationRule (FunctionType creatFonct, indLine wi)
  2477. {
  2478. if (DefaultRuleDef)
  2479. /* pas de creation dans les regles par defaut */
  2480. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_DEFAULT_RULES, inputLine,
  2481. LineNum);
  2482. else if (CurView != 1)
  2483. /* regles de creation seulement dans la vue principale */
  2484. CompilerMessage (wi, PRS, FATAL, RULE_FORBIDDEN_IN_A_VIEW, inputLine,
  2485. LineNum);
  2486. /* pas de creation avant, apres ou au-dessus de la racine */
  2487. /****
  2488. else if ((creatFonct == FnCreateBefore || creatFonct == FnCreateAfter ||
  2489. creatFonct == FnCreateWith || creatFonct == FnCreateEnclosing) &&
  2490. CurType == pSSchema->SsRootElem)
  2491. CompilerMessage (wi, PRS, FATAL, PRS_INVALID_RULE_FOR_ROOT_ELEM,
  2492. inputLine, LineNum);
  2493. ****/
  2494. else
  2495. {
  2496. CreatePRule (PtFunction, wi);
  2497. CurRule->PrPresMode = PresFunction;
  2498. CurRule->PrPresFunction = creatFonct;
  2499. CurRule->PrPresBoxRepeat = False;
  2500. CurRule->PrElement = False;
  2501. CurRule->PrExternal = False;
  2502. CurRule->PrNPresBoxes = 0;
  2503. CurRule->PrPresBoxName[0] = EOS;
  2504. }
  2505. }
  2506. /*----------------------------------------------------------------------
  2507. GenerateCopyRule
  2508. ----------------------------------------------------------------------*/
  2509. static void GenerateCopyRule (FunctionType fonctType, indLine wi)
  2510. {
  2511. PtrPRule R;
  2512. /* verifie qu'il n'y a que des conditions Within parmi les
  2513. conditions courantes */
  2514. CheckConditions (wi);
  2515. CreatePRule (PtFunction, wi);
  2516. CurRule->PrPresMode = PresFunction;
  2517. CurRule->PrPresFunction = fonctType;
  2518. CurRule->PrPresBoxRepeat = False;
  2519. CurRule->PrElement = False;
  2520. CurRule->PrExternal = False;
  2521. CurRule->PrNPresBoxes = 0;
  2522. CurRule->PrPresBoxName[0] = EOS;
  2523. /* S'il n'y a pas de condition courante, verifie qu'il n'y a pas */
  2524. /* deja une regle Copy ou Content sans condition pour cette vue */
  2525. if (Conditions != NULL)
  2526. {
  2527. R = FirstRule;
  2528. while (R != CurRule)
  2529. {
  2530. if (R->PrViewNum == CurView)
  2531. if (R->PrType == PtFunction)
  2532. if (R->PrPresFunction == FnContentRef ||
  2533. R->PrPresFunction == FnCopy)
  2534. if (R->PrCond == NULL)
  2535. CompilerMessage (wi, PRS, FATAL, ONLY_ONE_COPY_CONTENT_RULE,
  2536. inputLine, LineNum);
  2537. R = R->PrNextPRule;
  2538. }
  2539. }
  2540. }
  2541. /*----------------------------------------------------------------------
  2542. SameConditions compare deux chaines de conditions et retourne
  2543. True si elles sont egales.
  2544. ----------------------------------------------------------------------*/
  2545. static ThotBool SameConditions (PtrCondition pCond1, PtrCondition pCond2)
  2546. {
  2547. ThotBool different, sameRules, oneRule;
  2548. PtrCondition curCond1;
  2549. PtrCondition curCond2;
  2550. curCond1 = pCond1;
  2551. curCond2 = pCond2;
  2552. different = False;
  2553. /* les deux chaines de conditions ont-elles la meme longueur ? */
  2554. while (curCond1 != NULL && curCond2 != NULL)
  2555. {
  2556. curCond1 = curCond1->CoNextCondition;
  2557. curCond2 = curCond2->CoNextCondition;
  2558. }
  2559. if (curCond1 != NULL || curCond2 != NULL)
  2560. /* une chaine est plus longue que l'autre */
  2561. different = True;
  2562. else
  2563. /* les deux chaines de conditions ont la meme longueur */
  2564. /* on compare chaque regle d'une chaine avec toutes celles */
  2565. /* de l'autre, jusqu'a trouver une regle de la 1ere chaine qui */
  2566. /* n'aie pas d'egale dans le deuxieme */
  2567. {
  2568. curCond1 = pCond1;
  2569. while (curCond1 != NULL && !different)
  2570. {
  2571. curCond2 = pCond2;
  2572. oneRule = False;
  2573. while (curCond2 != NULL && !oneRule)
  2574. {
  2575. sameRules = True;
  2576. if (curCond1->CoNotNegative != curCond2->CoNotNegative)
  2577. sameRules = False;
  2578. else if (curCond1->CoCondition != curCond2->CoCondition)
  2579. sameRules = False;
  2580. else if (curCond1->CoTarget != curCond2->CoTarget)
  2581. sameRules = False;
  2582. else if (curCond1->CoCondition == PcInterval ||
  2583. curCond1->CoCondition == PcEven ||
  2584. curCond1->CoCondition == PcOdd ||
  2585. curCond1->CoCondition == PcOne)
  2586. {
  2587. if (curCond1->CoCounter != curCond2->CoCounter)
  2588. sameRules = False;
  2589. else if (curCond1->CoCondition == PcInterval)
  2590. {
  2591. if (curCond1->CoMinCounter != curCond2->CoMinCounter)
  2592. sameRules = False;
  2593. else
  2594. if (curCond1->CoMaxCounter != curCond2->CoMaxCounter)
  2595. sameRules = False;
  2596. }
  2597. }
  2598. else if (curCond1->CoCondition == PcElemType)
  2599. {
  2600. if (curCond1->CoTypeElem != curCond2->CoTypeElem)
  2601. sameRules = False;
  2602. }
  2603. else if (curCond1->CoCondition == PcAttribute ||
  2604. curCond1->CoCondition == PcInheritAttribute)
  2605. {
  2606. if (curCond1->CoTypeAttr != curCond2->CoTypeAttr)
  2607. sameRules = False;
  2608. else if (curCond1->CoTestAttrValue != curCond2->CoTestAttrValue)
  2609. sameRules = False;
  2610. else if (curCond1->CoTestAttrValue)
  2611. {
  2612. if (pSSchema->SsAttribute->TtAttr[curCond1->CoTypeAttr - 1]->AttrType == AtTextAttr)
  2613. {
  2614. if ((curCond1->CoAttrTextValue && !curCond2->CoAttrTextValue) ||
  2615. (curCond2->CoAttrTextValue && !curCond1->CoAttrTextValue))
  2616. sameRules = False;
  2617. else if (curCond1->CoAttrTextValue &&
  2618. curCond2->CoAttrTextValue &&
  2619. strcmp (curCond1->CoAttrTextValue,
  2620. curCond2->CoAttrTextValue))
  2621. sameRules = False;
  2622. }
  2623. else if (curCond1->CoAttrValue != curCond2->CoAttrValue)
  2624. sameRules = False;
  2625. }
  2626. }
  2627. else if (curCond1->CoCondition == PcWithin)
  2628. {
  2629. if (curCond1->CoRelation != curCond2->CoRelation)
  2630. sameRules = False;
  2631. else if (curCond1->CoTypeAncestor != curCond2->CoTypeAncestor)
  2632. sameRules = False;
  2633. else if (curCond1->CoImmediate != curCond2->CoImmediate)
  2634. sameRules = False;
  2635. else if (curCond1->CoAncestorRel != curCond2->CoAncestorRel)
  2636. sameRules = False;
  2637. else if ((curCond1->CoAncestorName && !curCond2->CoAncestorName) ||
  2638. (curCond2->CoAncestorName && !curCond1->CoAncestorName))
  2639. sameRules = False;
  2640. else if (strcmp (curCond1->CoAncestorName,
  2641. curCond2->CoAncestorName) != 0)
  2642. sameRules = False;
  2643. else if (curCond1->CoAncestorName &&
  2644. curCond2->CoAncestorName &&
  2645. strcmp (curCond1->CoSSchemaName,
  2646. curCond2->CoSSchemaName) != 0)
  2647. sameRules = False;
  2648. }
  2649. if (sameRules)
  2650. oneRule = True;
  2651. else
  2652. curCond2 = curCond2->CoNextCondition;
  2653. }
  2654. if (!oneRule)
  2655. different = True;
  2656. else
  2657. curCond1 = curCond1->CoNextCondition;
  2658. }
  2659. }
  2660. return !different;
  2661. }
  2662. /*----------------------------------------------------------------------
  2663. ProcessLongKeyWord
  2664. ----------------------------------------------------------------------*/
  2665. static void ProcessLongKeyWord (int x, SyntacticCode gCode, indLine wi)
  2666. {
  2667. int i;
  2668. Counter *pCntr;
  2669. PresVariable *pPresVar;
  2670. switch (x)
  2671. {
  2672. /* traitement selon le code du mot-cle */
  2673. case KWD_PRESENTATION:
  2674. /* PRESENTATION */
  2675. break;
  2676. case KWD_VIEWS:
  2677. /* VIEWS */
  2678. ViewDef = True;
  2679. break;
  2680. case KWD_PRINT:
  2681. /* PRINT */
  2682. ViewDef = False;
  2683. break;
  2684. case KWD_COUNTERS:
  2685. /* COUNTERS */
  2686. ViewDef = False;
  2687. CounterDef = True;
  2688. break;
  2689. case KWD_CONST:
  2690. /* CONST */
  2691. ViewDef = False;
  2692. CounterDef = False;
  2693. ConstantDef = True;
  2694. break;
  2695. case KWD_VAR:
  2696. /* VAR */
  2697. ViewDef = False;
  2698. CounterDef = False;
  2699. ConstantDef = False;
  2700. VariableDef = True;
  2701. break;
  2702. case KWD_DEFAULT:
  2703. /* DEFAULT */
  2704. ViewDef = False;
  2705. CounterDef = False;
  2706. ConstantDef = False;
  2707. VariableDef = False;
  2708. DefaultRuleDef = True;
  2709. pPSchema->PsFirstDefaultPRule = NextRule;
  2710. FirstRule = NextRule;
  2711. break;
  2712. case KWD_BOXES:
  2713. /* BOXES */
  2714. /* verifie que toutes les regles par defaut sont presentes pour la */
  2715. /* vue 1. */
  2716. CheckDefaultRules ();
  2717. ViewDef = False;
  2718. CounterDef = False;
  2719. ConstantDef = False;
  2720. VariableDef = False;
  2721. DefaultRuleDef = False;
  2722. PresBoxDef = True;
  2723. break;
  2724. case KWD_RULES:
  2725. /* RULES */
  2726. ViewDef = False;
  2727. CounterDef = False;
  2728. ConstantDef = False;
  2729. VariableDef = False;
  2730. DefaultRuleDef = False;
  2731. CheckForwardRef (wi);
  2732. if (PresBoxDef)
  2733. {
  2734. CheckForwardRef (wi);
  2735. /* verifie les references en avant de boites */
  2736. PresBoxDef = False;
  2737. }
  2738. else
  2739. /* verifie que toutes les regles par defaut sont presentes pour */
  2740. /* la vue 1 */
  2741. CheckDefaultRules ();
  2742. CurRule->PrNextPRule = NULL;
  2743. RuleDef = True;
  2744. break;
  2745. case KWD_ATTRIBUTES:
  2746. /* ATTRIBUTES */
  2747. CheckDefaultRules ();
  2748. ViewDef = False;
  2749. CounterDef = False;
  2750. ConstantDef = False;
  2751. VariableDef = False;
  2752. DefaultRuleDef = False;
  2753. PresBoxDef = False;
  2754. RuleDef = False;
  2755. AttributeDef = True;
  2756. break;
  2757. case KWD_TRANSMIT:
  2758. /* TRANSMIT */
  2759. CheckDefaultRules ();
  2760. ViewDef = False;
  2761. CounterDef = False;
  2762. ConstantDef = False;
  2763. VariableDef = False;
  2764. DefaultRuleDef = False;
  2765. PresBoxDef = False;
  2766. RuleDef = False;
  2767. AttributeDef = False;
  2768. TransmittedCounter = 0;
  2769. TransmittedElem = 0;
  2770. EndOfRulesForType ();
  2771. CurAttrNum = 0;
  2772. CurRule->PrNextPRule = NULL;
  2773. if (NextRule != NULL)
  2774. free (NextRule);
  2775. NextRule = NULL;
  2776. break;
  2777. case KWD_END:
  2778. /* END */
  2779. switch (gCode)
  2780. {
  2781. /* r= numero de la regle ou apparait END */
  2782. case RULE_PresentModel:
  2783. /* fin du progamme */
  2784. EndOfRulesForType ();
  2785. CurRule->PrNextPRule = NULL;
  2786. if (NextRule != NULL)
  2787. free (NextRule);
  2788. NextRule = NULL;
  2789. break;
  2790. case RULE_ViewRuleList:
  2791. /* fin ViewRuleList */
  2792. ViewBlock = False;
  2793. CheckBoxEnd ();
  2794. EndOfRulesForType ();
  2795. break;
  2796. case RULE_CondRuleList:
  2797. /* fin CondRuleList */
  2798. /* la vue par defaut est la premiere */
  2799. CurView = 1;
  2800. RulesForView = False;
  2801. CondBlock = False;
  2802. if (!ViewBlock)
  2803. {
  2804. CheckBoxEnd ();
  2805. EndOfRulesForType ();
  2806. }
  2807. break;
  2808. case RULE_RuleList:
  2809. RuleBlock = False;
  2810. Conditions = NULL;
  2811. if (!ViewBlock && !CondBlock)
  2812. {
  2813. CheckBoxEnd ();
  2814. EndOfRulesForType ();
  2815. }
  2816. break;
  2817. }
  2818. break;
  2819. case KWD_EXPORT /* THOT_EXPORT */ :
  2820. /* verifie qu'il n'y a pas deja une vue THOT_EXPORT */
  2821. i = 1;
  2822. while (i < pPSchema->PsNViews && !pPSchema->PsExportView[i - 1])
  2823. i++;
  2824. if (pPSchema->PsExportView[i - 1])
  2825. CompilerMessage (wi, PRS, FATAL,
  2826. ONLY_ONE_EXPORT_VIEW_ALLOWED, inputLine,
  2827. LineNum); /* deja une vue THOT_EXPORT */
  2828. else
  2829. pPSchema->PsExportView[pPSchema->PsNViews - 1] = True;
  2830. break;
  2831. case KWD_MERGE:
  2832. break;
  2833. case KWD_RANK:
  2834. /* RANK */
  2835. NewCounterOper (CntrRank, wi);
  2836. AncestorSign = 1;
  2837. AttrInitCounter = False;
  2838. break;
  2839. case KWD_RLevel:
  2840. /* CntrRLevel */
  2841. NewCounterOper (CntrRLevel, wi);
  2842. break;
  2843. case KWD_INIT /* INIT */ :
  2844. AttrInitCounter = True;
  2845. break;
  2846. case KWD_REINIT /* REINIT */ :
  2847. AttrInitCounter = False;
  2848. break;
  2849. case KWD_SET:
  2850. /* SET */
  2851. NewCounterOper (CntrSet, wi);
  2852. break;
  2853. case KWD_ADD:
  2854. /* ADD */
  2855. NewCounterOper (CntrAdd, wi);
  2856. break;
  2857. case KWD_Page:
  2858. if (gCode == RULE_TypeOrPage) /* dans un compteur */
  2859. {
  2860. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  2861. pCntr->CnItem[pCntr->CnNItems - 1].CiElemType = PageBreak + 1;
  2862. pCntr->CnItem[pCntr->CnNItems - 1].CiViewNum = 0;
  2863. }
  2864. else
  2865. /* regle de mise en pages */
  2866. {
  2867. if (x == KWD_Page)
  2868. LayoutRule (FnPage, wi);
  2869. pPSchema->PsPaginatedView[CurView - 1] = True;
  2870. }
  2871. break;
  2872. case KWD_With:
  2873. /* With */
  2874. if (gCode == RULE_CondAttr)
  2875. {
  2876. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  2877. pCntr->CnItem[pCntr->CnNItems - 1].CiCondAttrPresent = TRUE;
  2878. }
  2879. break;
  2880. case KWD_Without:
  2881. /* Without */
  2882. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  2883. pCntr->CnItem[pCntr->CnNItems - 1].CiCondAttrPresent = FALSE;
  2884. break;
  2885. case KWD_TEXT:
  2886. /* TEXT */
  2887. CreateConstant (CharString, wi);
  2888. break;
  2889. case KWD_SYMBOL:
  2890. /* SYMBOL */
  2891. CreateConstant (Symbol, wi);
  2892. break;
  2893. case KWD_GRAPHICS:
  2894. /* GRAPHICS */
  2895. CreateConstant (GraphicElem, wi);
  2896. break;
  2897. case KWD_PICTURE:
  2898. /* PICTURE */
  2899. CreateConstant (tt_Picture, wi);
  2900. break;
  2901. case KWD_DATE:
  2902. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2903. NewVarListItem (pPresVar, wi);
  2904. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarDate;
  2905. break;
  2906. case KWD_FDATE:
  2907. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2908. NewVarListItem (pPresVar, wi);
  2909. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarFDate;
  2910. break;
  2911. case KWD_DocName:
  2912. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2913. NewVarListItem (pPresVar, wi);
  2914. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarDocName;
  2915. break;
  2916. case KWD_DirName:
  2917. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2918. NewVarListItem (pPresVar, wi);
  2919. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarDirName;
  2920. break;
  2921. case KWD_ElemName:
  2922. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2923. NewVarListItem (pPresVar, wi);
  2924. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarElemName;
  2925. break;
  2926. case KWD_AttributeName:
  2927. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2928. NewVarListItem (pPresVar, wi);
  2929. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarAttrName;
  2930. break;
  2931. case KWD_AttributeValue:
  2932. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2933. NewVarListItem (pPresVar, wi);
  2934. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarAttrValue;
  2935. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntDecimal;
  2936. pPresVar->PvItem[pPresVar->PvNItems - 1].ViAttr = 0;
  2937. break;
  2938. case KWD_VALUE:
  2939. break;
  2940. case KWD_PageNumber:
  2941. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2942. NewVarListItem (pPresVar, wi);
  2943. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarPageNumber;
  2944. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntDecimal;
  2945. pPresVar->PvItem[pPresVar->PvNItems - 1].ViView = 1;
  2946. break;
  2947. case KWD_Arabic:
  2948. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2949. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntDecimal;
  2950. break;
  2951. case KWD_Decimal:
  2952. if (gCode == RULE_CounterStyle)
  2953. {
  2954. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2955. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntDecimal;
  2956. }
  2957. else if (gCode == RULE_ListStyleType)
  2958. CurRule->PrChrValue = '1';
  2959. break;
  2960. case KWD_DecimalLeadingZero:
  2961. if (gCode == RULE_CounterStyle)
  2962. {
  2963. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2964. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntZLDecimal;
  2965. }
  2966. else if (gCode == RULE_ListStyleType)
  2967. CurRule->PrChrValue = 'Z';
  2968. break;
  2969. case KWD_URoman:
  2970. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2971. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntURoman;
  2972. break;
  2973. case KWD_UpperRoman:
  2974. if (gCode == RULE_CounterStyle)
  2975. {
  2976. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2977. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntURoman;
  2978. }
  2979. else if (gCode == RULE_ListStyleType)
  2980. CurRule->PrChrValue = 'I';
  2981. break;
  2982. case KWD_LRoman:
  2983. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2984. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntLRoman;
  2985. break;
  2986. case KWD_LowerRoman:
  2987. if (gCode == RULE_CounterStyle)
  2988. {
  2989. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2990. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntLRoman;
  2991. }
  2992. else if (gCode == RULE_ListStyleType)
  2993. CurRule->PrChrValue = 'i';
  2994. break;
  2995. case KWD_Uppercase:
  2996. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  2997. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntUppercase;
  2998. break;
  2999. case KWD_UpperLatin:
  3000. if (gCode == RULE_CounterStyle)
  3001. {
  3002. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  3003. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntUppercase;
  3004. }
  3005. else if (gCode == RULE_ListStyleType)
  3006. CurRule->PrChrValue = 'A';
  3007. break;
  3008. case KWD_Lowercase:
  3009. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  3010. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntLowercase;
  3011. break;
  3012. case KWD_LowerLatin:
  3013. if (gCode == RULE_CounterStyle)
  3014. {
  3015. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  3016. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntLowercase;
  3017. }
  3018. else if (gCode == RULE_ListStyleType)
  3019. CurRule->PrChrValue = 'a';
  3020. break;
  3021. case KWD_LowerGreek:
  3022. if (gCode == RULE_CounterStyle)
  3023. {
  3024. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  3025. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntLGreek;
  3026. }
  3027. else if (gCode == RULE_ListStyleType)
  3028. CurRule->PrChrValue = 'g';
  3029. break;
  3030. case KWD_UpperGreek:
  3031. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  3032. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntUGreek;
  3033. break;
  3034. case KWD_FORWARD:
  3035. /* forward */
  3036. Forward = True;
  3037. break;
  3038. case KWD_BEGIN /* BEGIN */ :
  3039. if (gCode == RULE_ViewRuleList)
  3040. ViewBlock = True;
  3041. if (gCode == RULE_RuleList)
  3042. {
  3043. RuleBlock = True;
  3044. ConditionEnd ();
  3045. }
  3046. if (gCode == RULE_CondRuleList)
  3047. CondBlock = True;
  3048. break;
  3049. case KWD_Otherwise:
  3050. /* Otherwise */
  3051. Conditions = NULL;
  3052. NewCondition (wi);
  3053. Conditions->CoCondition = PcDefaultCond;
  3054. break;
  3055. case KWD_VertRef:
  3056. /* VertRef */
  3057. CreatePRule (PtVertRef, wi);
  3058. CurRule->PrPosRule.PoPosDef = VertRef;
  3059. break;
  3060. case KWD_HorizRef:
  3061. /* HorizRef */
  3062. CreatePRule (PtHorizRef, wi);
  3063. CurRule->PrPosRule.PoPosDef = HorizRef;
  3064. break;
  3065. case KWD_Height /* Height */ :
  3066. if (InRule)
  3067. if (CurRule->PrType == PtHeight)
  3068. CurRule->PrDimRule.DrSameDimens = True;
  3069. else
  3070. CurRule->PrDimRule.DrSameDimens = False;
  3071. else
  3072. CreatePRule (PtHeight, wi);
  3073. break;
  3074. case KWD_Width /* Width */ :
  3075. if (InRule)
  3076. if (CurRule->PrType == PtWidth)
  3077. CurRule->PrDimRule.DrSameDimens = True;
  3078. else
  3079. CurRule->PrDimRule.DrSameDimens = False;
  3080. else
  3081. CreatePRule (PtWidth, wi);
  3082. break;
  3083. case KWD_VertPos:
  3084. /* VertPos */
  3085. CreatePRule (PtVertPos, wi);
  3086. AxisDef = True; /* le prochain repere boite est une definition */
  3087. break;
  3088. case KWD_HorizPos:
  3089. /* HorizPos */
  3090. CreatePRule (PtHorizPos, wi);
  3091. AxisDef = True; /* le prochain repere boite est une definition */
  3092. break;
  3093. case KWD_Hyphenate:
  3094. /* Hyphenate */
  3095. CreatePRule (PtHyphenate, wi);
  3096. break;
  3097. case KWD_VertOverflow:
  3098. /* VertOverflow */
  3099. CreatePRule (PtVertOverflow, wi);
  3100. break;
  3101. case KWD_HorizOverflow:
  3102. /* HorizOverflow */
  3103. CreatePRule (PtHorizOverflow, wi);
  3104. break;
  3105. case KWD_LineSpacing:
  3106. /* LineSpacing */
  3107. CreatePRule (PtLineSpacing, wi);
  3108. break;
  3109. case KWD_PageBreak:
  3110. /* PageBreak */
  3111. CreatePRule (PtPageBreak, wi);
  3112. break;
  3113. case KWD_LineBreak:
  3114. /* LineBreak */
  3115. CreatePRule (PtLineBreak, wi);
  3116. break;
  3117. case KWD_InLine:
  3118. if (DefaultRuleDef)
  3119. /* pas de regle InLine dans les regles par defaut */
  3120. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_DEFAULT_RULES,
  3121. inputLine, LineNum);
  3122. else
  3123. InInLineRule = True;
  3124. break;
  3125. case KWD_Size:
  3126. /* Size */
  3127. CreatePRule (PtSize, wi);
  3128. break;
  3129. case KWD_Visibility:
  3130. /* Visibility */
  3131. CreatePRule (PtVisibility, wi);
  3132. break;
  3133. case KWD_Font:
  3134. /* Font */
  3135. CreatePRule (PtFont, wi);
  3136. break;
  3137. case KWD_Roman:
  3138. /* Style roman */
  3139. CurRule->PrChrValue = 'R';
  3140. break;
  3141. case KWD_Italics:
  3142. /* Style Italics */
  3143. CurRule->PrChrValue = 'I';
  3144. break;
  3145. case KWD_Oblique:
  3146. /* Style Oblique */
  3147. CurRule->PrChrValue = 'O';
  3148. break;
  3149. case KWD_Bold:
  3150. /* Weight Bold */
  3151. CurRule->PrChrValue = 'B';
  3152. if (CurRule->PrType == PtStyle)
  3153. /* OBSOLETE rule "Style: Bold"
  3154. turn it into "Weight: Bold" */
  3155. CurRule->PrType = PtWeight;
  3156. break;
  3157. case KWD_BoldItalics:
  3158. /* Style BoldItalics -- OBSOLETE -- */
  3159. CurRule->PrChrValue = 'I'; /* Style: Italics; */
  3160. CreatePRule (PtWeight, wi);
  3161. CurRule->PrChrValue = 'B'; /* Weight; Bold */
  3162. break;
  3163. case KWD_BoldOblique:
  3164. /* Style BoldOblique -- OBSOLETE -- */
  3165. CurRule->PrChrValue = 'O'; /* Style: Oblique; */
  3166. CreatePRule (PtWeight, wi);
  3167. CurRule->PrChrValue = 'B'; /* Weight; Bold */
  3168. break;
  3169. case KWD_SmallCaps:
  3170. /* Variant = SmallCaps */
  3171. CurRule->PrChrValue = 'C';
  3172. break;
  3173. case KWD_DoubleStruck:
  3174. /* Variant = DoubleStruck */
  3175. CurRule->PrChrValue = 'D';
  3176. break;
  3177. case KWD_Script:
  3178. /* Variant = Script */
  3179. CurRule->PrChrValue = 'S';
  3180. break;
  3181. case KWD_Fraktur:
  3182. /* Variant = Fraktur */
  3183. CurRule->PrChrValue = 'F';
  3184. break;
  3185. case KWD_Underline:
  3186. /* Souligne */
  3187. CreatePRule (PtUnderline, wi);
  3188. break;
  3189. case KWD_NoUnderline:
  3190. /* pas de soulignement */
  3191. CurRule->PrChrValue = 'N';
  3192. break;
  3193. case KWD_Underlined:
  3194. /* soulignement */
  3195. CurRule->PrChrValue = 'U';
  3196. break;
  3197. case KWD_Overlined:
  3198. /* surlignement */
  3199. CurRule->PrChrValue = 'O';
  3200. break;
  3201. case KWD_CrossedOut:
  3202. CurRule->PrChrValue = 'C';
  3203. break;
  3204. case KWD_Thickness:
  3205. /* epaisseur du soulignement */
  3206. CreatePRule (PtThickness, wi);
  3207. break;
  3208. case KWD_Style:
  3209. /* Style */
  3210. CreatePRule (PtStyle, wi);
  3211. break;
  3212. case KWD_Weight:
  3213. /* Weight */
  3214. CreatePRule (PtWeight, wi);
  3215. break;
  3216. case KWD_Variant:
  3217. /* Variant */
  3218. CreatePRule (PtVariant, wi);
  3219. break;
  3220. case KWD_Indent:
  3221. /* Indent */
  3222. CreatePRule (PtIndent, wi);
  3223. break;
  3224. case KWD_Adjust:
  3225. /* Adjust */
  3226. CreatePRule (PtAdjust, wi);
  3227. break;
  3228. case KWD_NoBreak1 /* NoBreak1 */ :
  3229. if (DefaultRuleDef)
  3230. /* pas de regle NoBreak1 dans les regles par defaut */
  3231. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_DEFAULT_RULES,
  3232. inputLine, LineNum);
  3233. else
  3234. CreatePRule (PtBreak1, wi);
  3235. break;
  3236. case KWD_NoBreak2 /* NoBreak2 */ :
  3237. if (DefaultRuleDef)
  3238. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_DEFAULT_RULES,
  3239. inputLine, LineNum); /* pas de regle NoBreak2
  3240. * dans les regles par
  3241. * defaut */
  3242. else
  3243. CreatePRule (PtBreak2, wi);
  3244. break;
  3245. case KWD_Content /* Content */ :
  3246. /* autorise' seulement pour les boites de presentation et les */
  3247. /* elements reference ou paire */
  3248. if (PresBoxDef)
  3249. {
  3250. if (Conditions != NULL)
  3251. /* un IF precede la regle Content d'une boite de presentation */
  3252. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_CONDITION,
  3253. inputLine, LineNum);
  3254. }
  3255. else
  3256. /* on n'est pas dans une boite de presentation */
  3257. if (!(RuleDef &&
  3258. (pSSchema->SsRule->SrElem[CurType -1]->SrConstruct == CsReference ||
  3259. pSSchema->SsRule->SrElem[CurType -1]->SrConstruct == CsPairedElement)))
  3260. /* on n'est pas dans les regles d'un element reference */
  3261. /* ni dans celles d'un element CsPairedElement */
  3262. CompilerMessage (wi, PRS, FATAL,
  3263. AUTHORIZED_ONLY_FOR_BOXES_AND_REFS, inputLine,
  3264. LineNum);
  3265. else
  3266. /* cree une regle "Content" pour le type courant */
  3267. {
  3268. GenerateCopyRule (FnContentRef, wi);
  3269. ConditionEnd ();
  3270. }
  3271. break;
  3272. case KWD_Gather /* Gather */ :
  3273. CreatePRule (PtGather, wi);
  3274. break;
  3275. case KWD_Line:
  3276. /* Line */
  3277. LayoutRule (FnLine, wi);
  3278. break;
  3279. case KWD_NoLine:
  3280. /* NoLine */
  3281. LayoutRule (FnNoLine, wi);
  3282. break;
  3283. case KWD_Display:
  3284. /* Display */
  3285. CreatePRule (PtDisplay, wi);
  3286. break;
  3287. case KWD_ListStyleType:
  3288. /* ListStyleType */
  3289. CreatePRule (PtListStyleType, wi);
  3290. break;
  3291. case KWD_ListStyleImage:
  3292. /* ListStyleImage */
  3293. CreatePRule (PtListStyleImage, wi);
  3294. break;
  3295. case KWD_ListStylePosition:
  3296. /* ListStylePosition */
  3297. CreatePRule (PtListStylePosition, wi);
  3298. break;
  3299. case KWD_Included:
  3300. IncludedColumn = True;
  3301. break;
  3302. case KWD_Column:
  3303. /* Column */
  3304. if (IncludedColumn)
  3305. LayoutRule (FnSubColumn, wi);
  3306. else
  3307. LayoutRule (FnColumn, wi);
  3308. IncludedColumn = False;
  3309. break;
  3310. case KWD_Copy /* Copy */ :
  3311. if (DefaultRuleDef)
  3312. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_DEFAULT_RULES,
  3313. inputLine, LineNum);
  3314. else if (CurView != 1)
  3315. /* regle autorisee seulement dans la vue principale */
  3316. CompilerMessage (wi, PRS, FATAL, RULE_FORBIDDEN_IN_A_VIEW,
  3317. inputLine, LineNum);
  3318. else if (RuleDef &&
  3319. pSSchema->SsRule->SrElem[CurType - 1]->SrConstruct != CsReference)
  3320. /* reserve' aux references */
  3321. CompilerMessage (wi, PRS, FATAL, VALID_ONLY_FOR_REFS, inputLine,
  3322. LineNum);
  3323. else
  3324. {
  3325. GenerateCopyRule (FnCopy, wi);
  3326. ConditionEnd ();
  3327. }
  3328. break;
  3329. case KWD_Depth:
  3330. /* Depth */
  3331. CreatePRule (PtDepth, wi);
  3332. break;
  3333. case KWD_Direction:
  3334. /* Direction */
  3335. CreatePRule (PtDirection, wi);
  3336. break;
  3337. case KWD_UnicodeBidi:
  3338. /* UnicodeBidi */
  3339. CreatePRule (PtUnicodeBidi, wi);
  3340. break;
  3341. case KWD_LineStyle:
  3342. CreatePRule (PtLineStyle, wi);
  3343. break;
  3344. case KWD_LineWeight:
  3345. CreatePRule (PtLineWeight, wi);
  3346. break;
  3347. case KWD_Float:
  3348. CreatePRule (PtFloat, wi);
  3349. break;
  3350. case KWD_Clear:
  3351. CreatePRule (PtClear, wi);
  3352. break;
  3353. case KWD_FillPattern:
  3354. CreatePRule (PtFillPattern, wi);
  3355. break;
  3356. case KWD_Background:
  3357. CreatePRule (PtBackground, wi);
  3358. break;
  3359. case KWD_Foreground:
  3360. if (gCode == RULE_Rule4)
  3361. CreatePRule (PtForeground, wi);
  3362. else if (gCode == RULE_BorderColor)
  3363. {
  3364. CurRule->PrPresMode = PresImmediate;
  3365. CurRule->PrValueType = PrNumValue;
  3366. CurRule->PrIntValue = -1; /* -1 means Foreground color */
  3367. }
  3368. break;
  3369. case KWD_Opacity:
  3370. CreatePRule (PtOpacity, wi);
  3371. break;
  3372. case KWD_FillOpacity:
  3373. CreatePRule (PtFillOpacity, wi);
  3374. break;
  3375. case KWD_StrokeOpacity:
  3376. CreatePRule (PtStrokeOpacity, wi);
  3377. break;
  3378. case KWD_ShowBox:
  3379. LayoutRule (FnShowBox, wi);
  3380. break;
  3381. case KWD_BackgroundPicture:
  3382. /* create a new constant */
  3383. NewConst (wi);
  3384. LayoutRule (FnBackgroundPicture, wi);
  3385. CurRule->PrNPresBoxes = 1;
  3386. CurRule->PrPresBox[0] = pPSchema->PsNConstants;
  3387. break;
  3388. case KWD_PictureMode:
  3389. LayoutRule (FnBackgroundRepeat, wi);
  3390. CurRule->PrNPresBoxes = 1;
  3391. CurRule->PrPresBox[0] = RealSize;
  3392. break;
  3393. case KWD_MarginTop:
  3394. CreatePRule (PtMarginTop, wi);
  3395. break;
  3396. case KWD_MarginRight:
  3397. CreatePRule (PtMarginRight, wi);
  3398. break;
  3399. case KWD_MarginBottom:
  3400. CreatePRule (PtMarginBottom, wi);
  3401. break;
  3402. case KWD_MarginLeft:
  3403. CreatePRule (PtMarginLeft, wi);
  3404. break;
  3405. case KWD_PaddingTop:
  3406. CreatePRule (PtPaddingTop, wi);
  3407. break;
  3408. case KWD_PaddingRight:
  3409. CreatePRule (PtPaddingRight, wi);
  3410. break;
  3411. case KWD_PaddingBottom:
  3412. CreatePRule (PtPaddingBottom, wi);
  3413. break;
  3414. case KWD_PaddingLeft:
  3415. CreatePRule (PtPaddingLeft, wi);
  3416. break;
  3417. case KWD_BorderTopWidth:
  3418. CreatePRule (PtBorderTopWidth, wi);
  3419. break;
  3420. case KWD_BorderRightWidth:
  3421. CreatePRule (PtBorderRightWidth, wi);
  3422. break;
  3423. case KWD_BorderBottomWidth:
  3424. CreatePRule (PtBorderBottomWidth, wi);
  3425. break;
  3426. case KWD_BorderLeftWidth:
  3427. CreatePRule (PtBorderLeftWidth, wi);
  3428. break;
  3429. case KWD_BorderTopColor:
  3430. CreatePRule (PtBorderTopColor, wi);
  3431. break;
  3432. case KWD_BorderRightColor:
  3433. CreatePRule (PtBorderRightColor, wi);
  3434. break;
  3435. case KWD_BorderBottomColor:
  3436. CreatePRule (PtBorderBottomColor, wi);
  3437. break;
  3438. case KWD_BorderLeftColor:
  3439. CreatePRule (PtBorderLeftColor, wi);
  3440. break;
  3441. case KWD_BorderTopStyle:
  3442. CreatePRule (PtBorderTopStyle, wi);
  3443. break;
  3444. case KWD_BorderRightStyle:
  3445. CreatePRule (PtBorderRightStyle, wi);
  3446. break;
  3447. case KWD_BorderBottomStyle:
  3448. CreatePRule (PtBorderBottomStyle, wi);
  3449. break;
  3450. case KWD_BorderLeftStyle:
  3451. CreatePRule (PtBorderLeftStyle, wi);
  3452. break;
  3453. case KWD_Auto:
  3454. if (gCode == RULE_MarginWidth)
  3455. {
  3456. CurRule->PrMinUnit = UnAuto;
  3457. CurRule->PrMinAttr = FALSE;
  3458. CurRule->PrMinValue = 0;
  3459. }
  3460. else if (gCode == RULE_Dimension)
  3461. {
  3462. CurRule->PrDimRule.DrUnit = UnAuto;
  3463. CurRule->PrDimRule.DrRelation = RlEnclosed;
  3464. CurRule->PrDimRule.DrRefKind = RkElType;
  3465. CurRule->PrDimRule.DrAbsolute = FALSE;
  3466. }
  3467. break;
  3468. case KWD_Thin:
  3469. /* underline or border */
  3470. if (CurRule->PrType == PtThickness)
  3471. CurRule->PrChrValue = 'N';
  3472. else
  3473. /* border */
  3474. {
  3475. CurRule->PrMinAttr = FALSE;
  3476. CurRule->PrMinUnit = UnPoint;
  3477. CurRule->PrMinValue = 1;
  3478. }
  3479. break;
  3480. case KWD_Medium:
  3481. /* border */
  3482. CurRule->PrMinAttr = FALSE;
  3483. CurRule->PrMinUnit = UnPoint;
  3484. CurRule->PrMinValue = 2;
  3485. break;
  3486. case KWD_Thick:
  3487. /* underline or border */
  3488. if (CurRule->PrType == PtThickness)
  3489. CurRule->PrChrValue = 'T';
  3490. else
  3491. /* border */
  3492. {
  3493. CurRule->PrMinAttr = FALSE;
  3494. CurRule->PrMinUnit = UnPoint;
  3495. CurRule->PrMinValue = 3;
  3496. }
  3497. break;
  3498. case KWD_Transparent:
  3499. CurRule->PrPresMode = PresImmediate;
  3500. CurRule->PrValueType = PrNumValue;
  3501. CurRule->PrIntValue = -2; /* -2 means Transparent */
  3502. break;
  3503. case KWD_None:
  3504. if (gCode == RULE_FloatInherit)
  3505. /* floating side */
  3506. CurRule->PrChrValue = 'N';
  3507. else if (gCode == RULE_ClearInherit)
  3508. /* clear side */
  3509. CurRule->PrChrValue = 'N';
  3510. else if (gCode == RULE_DisplayVal)
  3511. /* display = none */
  3512. CurRule->PrChrValue = 'N';
  3513. else if (gCode == RULE_ListStyleType)
  3514. /* list style type = none */
  3515. CurRule->PrChrValue = 'N';
  3516. else if (gCode == RULE_ListStyleImage)
  3517. /* list style image = none */
  3518. {
  3519. CurRule->PrPresMode = PresImmediate;
  3520. CurRule->PrValueType = PrNumValue;
  3521. CurRule->PrIntValue = 0;
  3522. }
  3523. else
  3524. /* border style */
  3525. CurRule->PrChrValue = '0';
  3526. break;
  3527. case KWD_Hidden:
  3528. /* border style */
  3529. CurRule->PrChrValue = 'H';
  3530. break;
  3531. case KWD_Dotted:
  3532. /* border style or line style */
  3533. CurRule->PrChrValue = '.';
  3534. break;
  3535. case KWD_Dashed:
  3536. /* border style or line style */
  3537. CurRule->PrChrValue = '-';
  3538. break;
  3539. case KWD_Solid:
  3540. /* border style or line style */
  3541. CurRule->PrChrValue = 'S';
  3542. break;
  3543. case KWD_Double:
  3544. /* border style */
  3545. CurRule->PrChrValue = 'D';
  3546. break;
  3547. case KWD_Groove:
  3548. /* border style */
  3549. CurRule->PrChrValue = 'G';
  3550. break;
  3551. case KWD_Ridge:
  3552. /* border style */
  3553. CurRule->PrChrValue = 'R';
  3554. break;
  3555. case KWD_Inset:
  3556. /* border style */
  3557. CurRule->PrChrValue = 'I';
  3558. break;
  3559. case KWD_Outset:
  3560. /* border style */
  3561. CurRule->PrChrValue = 'O';
  3562. break;
  3563. case KWD_NormalSize:
  3564. CurRule->PrPresBox[0] = RealSize;
  3565. break;
  3566. case KWD_Scale:
  3567. CurRule->PrPresBox[0] = ReScale;
  3568. break;
  3569. case KWD_RepeatXY:
  3570. CurRule->PrPresBox[0] = FillFrame;
  3571. break;
  3572. case KWD_RepeatX:
  3573. CurRule->PrPresBox[0] = XRepeat;
  3574. break;
  3575. case KWD_RepeatY:
  3576. CurRule->PrPresBox[0] = YRepeat;
  3577. break;
  3578. case KWD_CSSInline:
  3579. CurRule->PrChrValue = 'I';
  3580. break;
  3581. case KWD_Block:
  3582. CurRule->PrChrValue = 'B';
  3583. break;
  3584. case KWD_ListItem:
  3585. if (!(RuleDef || AttributeDef))
  3586. /* interdit pour les boites de presentation */
  3587. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_A_PRES_BOX, inputLine,
  3588. LineNum);
  3589. else
  3590. CurRule->PrChrValue = 'L';
  3591. break;
  3592. case KWD_RunIn:
  3593. CurRule->PrChrValue = 'R';
  3594. break;
  3595. case KWD_InlineBlock:
  3596. CurRule->PrChrValue = 'b';
  3597. break;
  3598. case KWD_Disc:
  3599. CurRule->PrChrValue = 'D';
  3600. break;
  3601. case KWD_Circle:
  3602. CurRule->PrChrValue = 'C';
  3603. break;
  3604. case KWD_Square:
  3605. CurRule->PrChrValue = 'S';
  3606. break;
  3607. case KWD_Inside:
  3608. CurRule->PrChrValue = 'I';
  3609. break;
  3610. case KWD_Outside:
  3611. CurRule->PrChrValue = 'O';
  3612. break;
  3613. case KWD_ltr:
  3614. /* writing direction */
  3615. CurRule->PrChrValue = 'L';
  3616. break;
  3617. case KWD_rtl:
  3618. /* writing direction */
  3619. CurRule->PrChrValue = 'R';
  3620. break;
  3621. case KWD_Normal:
  3622. if (CurRule->PrType == PtUnicodeBidi)
  3623. /* UnicodeBidi = Normal */
  3624. CurRule->PrChrValue = 'N';
  3625. else if (CurRule->PrType == PtVariant)
  3626. /* Variant = Normal */
  3627. CurRule->PrChrValue = 'N';
  3628. else
  3629. /* Weight = Normal */
  3630. CurRule->PrChrValue = 'N';
  3631. break;
  3632. case KWD_Embed:
  3633. CurRule->PrChrValue = 'E';
  3634. break;
  3635. case KWD_Override:
  3636. CurRule->PrChrValue = 'O';
  3637. break;
  3638. case KWD_Left /* Left */ :
  3639. if (gCode == RULE_FloatInherit)
  3640. /* floating side */
  3641. CurRule->PrChrValue = 'L';
  3642. else if (gCode == RULE_ClearInherit)
  3643. /* clear side */
  3644. CurRule->PrChrValue = 'L';
  3645. else if (gCode == RULE_Adjustment)
  3646. /* mode d'alignement des lignes */
  3647. CurRule->PrAdjust = AlignLeft;
  3648. else
  3649. ProcessAxis (Left, wi);
  3650. break;
  3651. case KWD_Right /* Right */ :
  3652. if (gCode == RULE_FloatInherit)
  3653. /* floating side */
  3654. CurRule->PrChrValue = 'R';
  3655. else if (gCode == RULE_ClearInherit)
  3656. /* clear side */
  3657. CurRule->PrChrValue = 'R';
  3658. else if (gCode == RULE_Adjustment)
  3659. /* mode d'alignement des lignes */
  3660. CurRule->PrAdjust = AlignRight;
  3661. else
  3662. ProcessAxis (Right, wi);
  3663. break;
  3664. case KWD_Both:
  3665. /* clear side */
  3666. CurRule->PrChrValue = 'B';
  3667. break;
  3668. case KWD_nil /* NULL */ :
  3669. if (CurRule->PrType == PtHeight || CurRule->PrType == PtWidth)
  3670. CompilerMessage (wi, PRS, FATAL, FORDBIDDEN_IN_HEIGHT_AND_WIDTH,
  3671. inputLine, LineNum);
  3672. else
  3673. {
  3674. CurRule->PrPosRule.PoPosDef = NoEdge;
  3675. AxisDef = True;
  3676. }
  3677. break;
  3678. case KWD_UserSpecified:
  3679. if (!(RuleDef || AttributeDef))
  3680. /* interdit pour les boites de presentation */
  3681. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_A_PRES_BOX, inputLine,
  3682. LineNum);
  3683. else if (CurRule->PrType == PtHeight || CurRule->PrType == PtWidth)
  3684. CurRule->PrDimRule.DrUserSpecified = True;
  3685. else if (CurRule->PrType == PtVertPos || CurRule->PrType == PtHorizPos)
  3686. CurRule->PrPosRule.PoUserSpecified = True;
  3687. break;
  3688. case KWD_Refering:
  3689. /* Refering */
  3690. SetLevel (RlContainsRef, wi);
  3691. break;
  3692. case KWD_Enclosing /* Enclosing */ :
  3693. if (gCode == RULE_Reference)
  3694. SetLevel (RlEnclosing, wi);
  3695. else
  3696. InheritRule (InheritParent);
  3697. break;
  3698. case KWD_Enclosed /* Enclosed */ :
  3699. if (gCode == RULE_Reference)
  3700. SetLevel (RlEnclosed, wi);
  3701. else if (CurRule->PrType == PtVisibility ||
  3702. CurRule->PrType == PtVariant ||
  3703. CurRule->PrType == PtDirection ||
  3704. CurRule->PrType == PtUnicodeBidi)
  3705. CompilerMessage (wi, PRS, FATAL, CANT_INHERIT_FROM_ENCLOSED,
  3706. inputLine, LineNum);
  3707. else
  3708. InheritRule (InheritChild);
  3709. break;
  3710. case KWD_Creator:
  3711. if (!PresBoxDef)
  3712. /* on n'est pas dans une boite de presentation, erreur */
  3713. CompilerMessage (BeginCopyType, PRS, FATAL, VALID_ONLY_FOR_PRES_BOX,
  3714. inputLine, LineNum);
  3715. else if (gCode == RULE_Reference)
  3716. SetLevel (RlCreator, wi);
  3717. else
  3718. InheritRule (InheritCreator);
  3719. break;
  3720. case KWD_Previous /* Previous */ :
  3721. if (gCode == RULE_Reference)
  3722. SetLevel (RlPrevious, wi);
  3723. else if (CurRule->PrType == PtVisibility ||
  3724. CurRule->PrType == PtDirection ||
  3725. CurRule->PrType == PtUnicodeBidi)
  3726. CompilerMessage (wi, PRS, FATAL, CANT_INHERIT_FROM_PREVIOUS,
  3727. inputLine, LineNum);
  3728. else
  3729. InheritRule (InheritPrevious);
  3730. break;
  3731. case KWD_GrandFather:
  3732. InheritRule (InheritGrandFather);
  3733. break;
  3734. case KWD_Next:
  3735. /* Next */
  3736. SetLevel (RlNext, wi);
  3737. break;
  3738. case KWD_Root:
  3739. /* Root */
  3740. if (gCode == RULE_Reference)
  3741. /* in a Reference */
  3742. SetLevel (RlRoot, wi);
  3743. else
  3744. /* in a ElemCondition */
  3745. Conditions->CoCondition = PcRoot;
  3746. break;
  3747. case KWD_LastSibling :
  3748. SetLevel (RlLastSibling, wi);
  3749. break;
  3750. case KWD_Refered /* Refered */ :
  3751. case KWD_Referred /* Referred */ :
  3752. if (gCode == RULE_ElemCondition)
  3753. /* dans une condition "IF Referred" */
  3754. Conditions->CoCondition = PcReferred;
  3755. else if (!AttributeDef && !PresBoxDef)
  3756. /* autorise' seulement pour les attributs */
  3757. CompilerMessage (wi, PRS, FATAL, CANT_USE_IF_NOT_A_REF_ATTR,
  3758. inputLine, LineNum);
  3759. else if (AttributeDef &&
  3760. pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtReferenceAttr)
  3761. /* seulement pour les attributs reference */
  3762. CompilerMessage (wi, PRS, FATAL, CANT_USE_IF_NOT_A_REF_ATTR,
  3763. inputLine, LineNum);
  3764. else
  3765. SetLevel (RlReferred, wi);
  3766. break;
  3767. case KWD_AnyElem:
  3768. CurRule->PrPosRule.PoRefKind = RkAnyElem;
  3769. CurRule->PrPosRule.PoRefIdent = 1; /* must not be 0 see presrules.c */
  3770. break;
  3771. case KWD_AnyBox:
  3772. CurRule->PrPosRule.PoRefKind = RkAnyBox;
  3773. CurRule->PrPosRule.PoRefIdent = 1; /* must not be 0 see presrules.c */
  3774. break;
  3775. case KWD_ElemWithAttr:
  3776. break;
  3777. case KWD_NOT /* NOT */ :
  3778. if (gCode == RULE_Condition)
  3779. /* dans une Condition */
  3780. Conditions->CoNotNegative = False;
  3781. else
  3782. /* Not dans NBoxType */
  3783. {
  3784. switch (CurRule->PrType)
  3785. {
  3786. case PtVertRef:
  3787. case PtHorizRef:
  3788. case PtVertPos:
  3789. case PtHorizPos:
  3790. CurRule->PrPosRule.PoNotRel = True;
  3791. break;
  3792. case PtHeight:
  3793. case PtWidth:
  3794. if (CurRule->PrDimRule.DrPosition)
  3795. CurRule->PrDimRule.DrPosRule.PoNotRel = True;
  3796. else
  3797. CurRule->PrDimRule.DrNotRelat = True;
  3798. break;
  3799. default:
  3800. break;
  3801. }
  3802. }
  3803. break;
  3804. case KWD_VMiddle /* VMiddle */ :
  3805. if (gCode == RULE_Adjustment)
  3806. /* mode d'alignement des lignes */
  3807. CurRule->PrAdjust = AlignCenter;
  3808. else
  3809. ProcessAxis (VertMiddle, wi);
  3810. break;
  3811. case KWD_VRef:
  3812. /* VRef */
  3813. ProcessAxis (VertRef, wi);
  3814. break;
  3815. case KWD_Top:
  3816. /* Top */
  3817. ProcessAxis (Top, wi);
  3818. break;
  3819. case KWD_HMiddle:
  3820. /* HMiddle */
  3821. ProcessAxis (HorizMiddle, wi);
  3822. break;
  3823. case KWD_HRef:
  3824. /* HRef */
  3825. ProcessAxis (HorizRef, wi);
  3826. break;
  3827. case KWD_Bottom:
  3828. /* Bottom */
  3829. ProcessAxis (Bottom, wi);
  3830. break;
  3831. case KWD_CM /* cm */ :
  3832. if (LatestNumberAttr)
  3833. CompilerMessage (wi, PRS, FATAL, BAD_UNIT_FOR_AN_ATTR,
  3834. inputLine, LineNum);
  3835. else
  3836. CurUnit = Centimeter;
  3837. break;
  3838. case KWD_MM /* mm */ :
  3839. if (LatestNumberAttr)
  3840. CompilerMessage (wi, PRS, FATAL, BAD_UNIT_FOR_AN_ATTR,
  3841. inputLine, LineNum);
  3842. else
  3843. CurUnit = Millimeter;
  3844. break;
  3845. case KWD_PT /* pt */ :
  3846. if (gCode == RULE_Unit)
  3847. CurUnit = Point;
  3848. else if (gCode == RULE_SizeInherit)
  3849. CurRule->PrMinUnit = UnPoint;
  3850. else if (gCode == RULE_InheritSize)
  3851. CurRule->PrInhUnit = UnPoint;
  3852. break;
  3853. case KWD_PC /* pc */ :
  3854. if (LatestNumberAttr)
  3855. CompilerMessage (wi, PRS, FATAL, BAD_UNIT_FOR_AN_ATTR,
  3856. inputLine, LineNum);
  3857. else
  3858. CurUnit = Pica;
  3859. break;
  3860. case KWD_IN /* in */ :
  3861. if (gCode == RULE_Unit)
  3862. {
  3863. if (LatestNumberAttr)
  3864. CompilerMessage (wi, PRS, FATAL, BAD_UNIT_FOR_AN_ATTR,
  3865. inputLine, LineNum);
  3866. else
  3867. CurUnit = Inch;
  3868. }
  3869. break;
  3870. case KWD_PX /* px */ :
  3871. CurUnit = ScreenPixel;
  3872. break;
  3873. case KWD_EM /* em */ :
  3874. CurUnit = FontHeight;
  3875. break;
  3876. case KWD_EX /* ex */ :
  3877. CurUnit = XHeight;
  3878. break;
  3879. case KWD_Min:
  3880. if (gCode == RULE_Dimension)
  3881. CurRule->PrDimRule.DrMin = True;
  3882. break;
  3883. case KWD_Yes:
  3884. /* Yes */
  3885. BooleanValue (True, wi);
  3886. break;
  3887. case KWD_No:
  3888. /* No */
  3889. BooleanValue (False, wi);
  3890. break;
  3891. case KWD_LeftWithDots:
  3892. /* LeftWithDots */
  3893. CurRule->PrAdjust = AlignLeftDots;
  3894. break;
  3895. case KWD_Justify:
  3896. /* Justify */
  3897. CurRule->PrAdjust = AlignJustify;
  3898. break;
  3899. case KWD_IF:
  3900. /* IF */
  3901. CondInheritedAttr = FALSE;
  3902. if (DefaultRuleDef)
  3903. /* pas de condition dans les regles par defaut */
  3904. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_DEFAULT_RULES,
  3905. inputLine, LineNum);
  3906. else
  3907. {
  3908. Conditions = NULL;
  3909. NewCondition (wi);
  3910. }
  3911. break;
  3912. case KWD_AND /* AND */ :
  3913. ConditionEnd ();
  3914. CondInheritedAttr = FALSE;
  3915. NewCondition (wi);
  3916. break;
  3917. case KWD_Target:
  3918. /* Target */
  3919. if (RuleDef &&
  3920. pSSchema->SsRule->SrElem[CurType - 1]->SrConstruct != CsReference)
  3921. /* reserve' aux elements references */
  3922. CompilerMessage (wi, PRS, FATAL, VALID_ONLY_FOR_REFS, inputLine,
  3923. LineNum);
  3924. else if (AttributeDef &&
  3925. pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtReferenceAttr)
  3926. /* seulement pour les attributs reference */
  3927. CompilerMessage (wi, PRS, FATAL, CANT_USE_IF_NOT_A_REF_ATTR,
  3928. inputLine, LineNum);
  3929. else
  3930. Conditions->CoTarget = True;
  3931. break;
  3932. case KWD_First:
  3933. /* First */
  3934. if (gCode == RULE_FirstSec)
  3935. FirstInPair = True;
  3936. else
  3937. Conditions->CoCondition = PcFirst;
  3938. break;
  3939. case KWD_Second:
  3940. /* Second */
  3941. SecondInPair = True;
  3942. break;
  3943. case KWD_Last:
  3944. /* Last */
  3945. Conditions->CoCondition = PcLast;
  3946. break;
  3947. case KWD_FirstRef:
  3948. /* FirstRef */
  3949. Conditions->CoCondition = PcFirstRef;
  3950. break;
  3951. case KWD_LastRef:
  3952. /* LastRef */
  3953. Conditions->CoCondition = PcLastRef;
  3954. break;
  3955. case KWD_ExternalRef:
  3956. /* ExternalRef */
  3957. Conditions->CoCondition = PcExternalRef;
  3958. break;
  3959. case KWD_InternalRef:
  3960. /* InternalRef */
  3961. Conditions->CoCondition = PcInternalRef;
  3962. break;
  3963. case KWD_CopyRef:
  3964. /* PcCopyRef */
  3965. Conditions->CoCondition = PcCopyRef;
  3966. break;
  3967. case KWD_AnyAttributes:
  3968. /* AnyAttributs */
  3969. Conditions->CoCondition = PcAnyAttributes;
  3970. break;
  3971. case KWD_FirstAttr:
  3972. /* FirstAttr */
  3973. Conditions->CoCondition = PcFirstAttr;
  3974. break;
  3975. case KWD_LastAttr:
  3976. /* LastAttr */
  3977. Conditions->CoCondition = PcLastAttr;
  3978. break;
  3979. case KWD_UserPage:
  3980. /* UserPage */
  3981. Conditions->CoCondition = PcUserPage;
  3982. break;
  3983. case KWD_StartPage:
  3984. /* StartPage */
  3985. Conditions->CoCondition = PcStartPage;
  3986. break;
  3987. case KWD_ComputedPage:
  3988. /* ComputedPage */
  3989. Conditions->CoCondition = PcComputedPage;
  3990. break;
  3991. case KWD_Empty:
  3992. /* PcEmpty */
  3993. Conditions->CoCondition = PcEmpty;
  3994. break;
  3995. case KWD_MaxRangeVal:
  3996. /* MaxRangeVal */
  3997. if (Conditions != NULL)
  3998. Conditions->CoValCounter = CntMaxVal;
  3999. CurMinMax = CntMaxVal;
  4000. break;
  4001. case KWD_MinRangeVal:
  4002. /* MinRangeVal */
  4003. if (Conditions != NULL)
  4004. Conditions->CoValCounter = CntMinVal;
  4005. CurMinMax = CntMinVal;
  4006. break;
  4007. case KWD_Even:
  4008. /* Even */
  4009. Conditions->CoCondition = PcEven;
  4010. Conditions->CoCounter = 0;
  4011. InCondPage = True;
  4012. break;
  4013. case KWD_Odd:
  4014. /* Odd */
  4015. Conditions->CoCondition = PcOdd;
  4016. Conditions->CoCounter = 0;
  4017. InCondPage = True;
  4018. break;
  4019. case KWD_One:
  4020. /* One */
  4021. Conditions->CoCondition = PcOne;
  4022. Conditions->CoCounter = 0;
  4023. InCondPage = True;
  4024. break;
  4025. case KWD_Immediately:
  4026. Immediately = True;
  4027. break;
  4028. case KWD_Within:
  4029. Conditions->CoCondition = PcWithin;
  4030. Conditions->CoImmediate = Immediately;
  4031. SignGreaterOrLess = False;
  4032. /* a priori, il n'y a pas de nombre d'ancetres indique' */
  4033. /* On considere "If Within Type" comme "If Within >0 Type" */
  4034. Conditions->CoAncestorRel = CondGreater;
  4035. Conditions->CoRelation = 0;
  4036. Conditions->CoTypeAncestor = 0;
  4037. Conditions->CoAncestorName = NULL;
  4038. Conditions->CoSSchemaName[0] = EOS;
  4039. InWithinCond = True;
  4040. break;
  4041. case KWD_Inherited:
  4042. CondInheritedAttr = TRUE;
  4043. break;
  4044. case KWD_Create:
  4045. /* Create */
  4046. CreationRule (FnCreateFirst, wi);
  4047. CompilerMessage (wi, PRS, INFO, USE_CREATEFIRST, inputLine, LineNum);
  4048. break;
  4049. case KWD_CreateBefore:
  4050. /* CreateBefore */
  4051. CreationRule (FnCreateBefore, wi);
  4052. break;
  4053. case KWD_CreateAfter:
  4054. /* CreateAfter */
  4055. CreationRule (FnCreateAfter, wi);
  4056. break;
  4057. case KWD_CreateLast:
  4058. /* CreateLast */
  4059. CreationRule (FnCreateLast, wi);
  4060. break;
  4061. case KWD_CreateFirst:
  4062. /* CreateFirst */
  4063. CreationRule (FnCreateFirst, wi);
  4064. break;
  4065. case KWD_CreateWith:
  4066. /* CreateWith */
  4067. CreationRule (FnCreateWith, wi);
  4068. break;
  4069. case KWD_CreateEnclosing:
  4070. /* CreateEnclosing */
  4071. CreationRule (FnCreateEnclosing, wi);
  4072. break;
  4073. case KWD_Repeated:
  4074. /* Repeated */
  4075. CurRule->PrPresBoxRepeat = True;
  4076. break;
  4077. case KWD_LESS:
  4078. VCondLess = True;
  4079. break;
  4080. case KWD_GREATER:
  4081. VCondGreater = True;
  4082. break;
  4083. case KWD_EQUAL:
  4084. CondEqual = True;
  4085. break;
  4086. default:
  4087. break;
  4088. }
  4089. }
  4090. /*----------------------------------------------------------------------
  4091. GetTypeNumber retourne le numero du type d'element dont
  4092. le nom est typeName.
  4093. ----------------------------------------------------------------------*/
  4094. static int GetTypeNumber (indLine wl, indLine wi, Name typeName)
  4095. {
  4096. int i;
  4097. CopyName (typeName, wi, wl);
  4098. /* verifie si le type est declare' dans le schema de structure */
  4099. i = 1;
  4100. while (strcmp (typeName, pSSchema->SsRule->SrElem[i - 1]->SrName)
  4101. && i < pSSchema->SsNRules)
  4102. i++;
  4103. if (strcmp (typeName, pSSchema->SsRule->SrElem[i - 1]->SrName))
  4104. i = 0;
  4105. else if (InclusionRefName)
  4106. /* on cherche une reference a un document importe' */
  4107. {
  4108. while (i <= pSSchema->SsNRules &&
  4109. (pSSchema->SsRule->SrElem[i - 1]->SrConstruct != CsReference ||
  4110. !pSSchema->SsRule->SrElem[i - 1]->SrRefImportedDoc))
  4111. /* ce n'est pas ce que l'on cherche, on continue */
  4112. {
  4113. i++;
  4114. while (strcmp (typeName, pSSchema->SsRule->SrElem[i - 1]->SrName) &&
  4115. i < pSSchema->SsNRules)
  4116. i++;
  4117. }
  4118. if (i > pSSchema->SsNRules)
  4119. i = 0;
  4120. }
  4121. return i;
  4122. }
  4123. /*----------------------------------------------------------------------
  4124. ProcessTypeName traite un nom de type d'element
  4125. ----------------------------------------------------------------------*/
  4126. static void ProcessTypeName (SyntacticCode prevRule, Name typeName,
  4127. indLine wi, indLine wl)
  4128. {
  4129. int i;
  4130. Counter *pCntr;
  4131. i = GetTypeNumber (wl, wi, typeName);
  4132. if (i == 0)
  4133. CompilerMessage (wi, PRS, FATAL, UNKNOWN_TYPE, inputLine, LineNum);
  4134. /* type inconnu */
  4135. else
  4136. {
  4137. if (pSSchema->SsRule->SrElem[i - 1]->SrConstruct == CsPairedElement)
  4138. /* c'est un element CsPairedElement */
  4139. {
  4140. if (!SecondInPair && !FirstInPair)
  4141. /* le nom du type n'etait pas precede' de First ou Second */
  4142. CompilerMessage (wi, PRS, FATAL, MISSING_FIRST_SECOND,
  4143. inputLine, LineNum);
  4144. else if (SecondInPair)
  4145. /* il s'agit du type suivant */
  4146. i++;
  4147. }
  4148. else
  4149. /* ce n'est pas un element CsPairedElement */
  4150. if (SecondInPair || FirstInPair)
  4151. /* le nom du type etait precede' de First ou Second, erreur */
  4152. CompilerMessage (wi, PRS, FATAL, NOT_A_PAIR,
  4153. inputLine, LineNum);
  4154. if (prevRule == RULE_FSTypeName)
  4155. /* un nom de type d'element, avant les regles */
  4156. /* de presentation d'un attribut */
  4157. CurElemHeritAttr = i;
  4158. else if (prevRule == RULE_TypeOrCounter)
  4159. /* un nom de type au debut d'une regle Transmit */
  4160. {
  4161. TransmittedElem = i;
  4162. if (pPSchema->PsNTransmElems >= MAX_TRANSM_ELEM)
  4163. CompilerMessage (wi, PRS, FATAL, MAX_MANY_TRANSMIT_RULES_FOR_ELEMS_OVERFLOW, inputLine, LineNum); /* table PsTransmElem saturee */
  4164. else if (pPSchema->PsElemTransmit->Num[i - 1] > 0)
  4165. /* deja une regle transmit pout l'element */
  4166. CompilerMessage (wi, PRS, FATAL, ELEM_HAS_A_TRANSMIT_RULE,
  4167. inputLine, LineNum);
  4168. else
  4169. {
  4170. pPSchema->PsNTransmElems++;
  4171. pPSchema->PsElemTransmit->Num[i - 1] = pPSchema->PsNTransmElems;
  4172. }
  4173. }
  4174. else if (prevRule == RULE_Transmit)
  4175. {
  4176. /* un nom de type a la fin d'une regle Transmit */
  4177. if (!pSSchema->SsRule->SrElem[i - 1]->SrRefImportedDoc)
  4178. CompilerMessage (wi, PRS, FATAL, NOT_AN_INCLUDED_DOC,
  4179. inputLine, LineNum);
  4180. else if (TransmittedCounter > 0)
  4181. /* c'est une regle Transmit pour un compteur */
  4182. {
  4183. pCntr = &pPSchema->PsCounter[TransmittedCounter - 1];
  4184. pCntr->CnTransmSSchemaAttr[pCntr->CnNTransmAttrs - 1] = i;
  4185. }
  4186. else if (TransmittedElem > 0)
  4187. /* un nom de type a la fin d'une regle Transmit pour un */
  4188. /* contenu d'element */
  4189. pPSchema->PsTransmElem[pPSchema->PsNTransmElems - 1].TeTargetDoc = i;
  4190. }
  4191. else if (CounterDef)
  4192. /* dans une definition de compteur */
  4193. {
  4194. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  4195. pCntr->CnItem[pCntr->CnNItems - 1].CiElemType = i;
  4196. pCntr->CnItem[pCntr->CnNItems - 1].CiViewNum = 0;
  4197. }
  4198. else if (!InRule)
  4199. /* debut des regles d'un type */
  4200. {
  4201. if (pPSchema->PsElemPRule->ElemPres[i - 1])
  4202. CompilerMessage (wi, PRS, FATAL, CANT_REDEFINE,
  4203. inputLine, LineNum); /* deja traite' */
  4204. else
  4205. {
  4206. pPSchema->PsElemPRule->ElemPres[i - 1] = NextRule;
  4207. FirstRule = NextRule;
  4208. CurType = i;
  4209. }
  4210. }
  4211. else
  4212. /* utilisation d'un type dans un positionnement, un */
  4213. /* dimensionnement, une copie ou un contenu de boite */
  4214. {
  4215. if ((CurRule->PrType == PtVertRef
  4216. || CurRule->PrType == PtHorizRef)
  4217. && CurRule->PrPosRule.PoRelation != RlEnclosed)
  4218. CompilerMessage (wi, PRS, FATAL, ONLY_ENCLOSED_AND_ARE_ALLOWED,
  4219. inputLine, LineNum);
  4220. else
  4221. switch (CurRule->PrType)
  4222. {
  4223. case PtVertRef:
  4224. case PtHorizRef:
  4225. case PtVertPos:
  4226. case PtHorizPos:
  4227. CurRule->PrPosRule.PoRefKind = RkElType;
  4228. CurRule->PrPosRule.PoRefIdent = i;
  4229. break;
  4230. case PtHeight:
  4231. case PtWidth:
  4232. if (CurRule->PrDimRule.DrPosition)
  4233. {
  4234. CurRule->PrDimRule.DrPosRule.PoRefKind = RkElType;
  4235. CurRule->PrDimRule.DrPosRule.PoRefIdent = i;
  4236. }
  4237. else
  4238. {
  4239. CurRule->PrDimRule.DrRefKind = RkElType;
  4240. CurRule->PrDimRule.DrRefIdent = i;
  4241. }
  4242. break;
  4243. case PtFunction:
  4244. if (CurRule->PrPresFunction == FnCopy)
  4245. {
  4246. CurRule->PrElement = True;
  4247. CurRule->PrExternal = False;
  4248. CurRule->PrNPresBoxes = 1;
  4249. CurRule->PrPresBox[0] = i;
  4250. }
  4251. break;
  4252. default:
  4253. break;
  4254. }
  4255. }
  4256. }
  4257. FirstInPair = False;
  4258. SecondInPair = False;
  4259. InclusionRefName = False;
  4260. }
  4261. /*----------------------------------------------------------------------
  4262. NewBoxName traite un nouveau nom de boite de presentation
  4263. ----------------------------------------------------------------------*/
  4264. static void NewBoxName (indLine wl, indLine wi, int identnum)
  4265. {
  4266. int size, i;
  4267. PtrPresentationBox pPresBox;
  4268. if (pPSchema->PsNPresentBoxes >= pPSchema->PsPresentBoxTableSize)
  4269. /* the presentation box table is full. Extend it */
  4270. {
  4271. /* add 10 new entries */
  4272. size = pPSchema->PsNPresentBoxes + 10;
  4273. i = size * sizeof (PtrPresentationBox);
  4274. if (!pPSchema->PsPresentBox)
  4275. pPSchema->PsPresentBox = (PresBoxTable*) malloc (i);
  4276. else
  4277. pPSchema->PsPresentBox = (PresBoxTable*) realloc (pPSchema->PsPresentBox, i);
  4278. if (!pPSchema->PsPresentBox)
  4279. CompilerMessage (0, PRS, FATAL, NO_MORE_MEM_LEFT, inputLine, LineNum);
  4280. else
  4281. {
  4282. pPSchema->PsPresentBoxTableSize = size;
  4283. for (i = pPSchema->PsNPresentBoxes; i < size; i++)
  4284. pPSchema->PsPresentBox->PresBox[i] = NULL;
  4285. }
  4286. }
  4287. /* create a new presentation box descriptor */
  4288. pPresBox = (PtrPresentationBox) malloc (sizeof (PresentationBox));
  4289. if (pPresBox == NULL)
  4290. CompilerMessage (0, PRS, FATAL, NO_MORE_MEM_LEFT, inputLine, LineNum);
  4291. else
  4292. pPSchema->PsPresentBox->PresBox[pPSchema->PsNPresentBoxes++] = pPresBox;
  4293. memset (pPresBox, 0, sizeof (PresentationBox));
  4294. Identifier[identnum].SrcIdentDefRule = pPSchema->PsNPresentBoxes;
  4295. if (Forward)
  4296. {
  4297. pPresBox->PbName[0] = ' ';
  4298. Forward = False;
  4299. }
  4300. else
  4301. {
  4302. CopyName (pPresBox->PbName, wi, wl);
  4303. pPresBox->PbFirstPRule = NextRule;
  4304. FirstRule = NextRule;
  4305. CurPresBox = pPSchema->PsNPresentBoxes;
  4306. }
  4307. /* a priori la boite a un contenu libre */
  4308. pPresBox->PbContent = FreeContent;
  4309. }
  4310. /*----------------------------------------------------------------------
  4311. IntAttribute traite un nom d'attribut qui apparait a la place d'une
  4312. valeur numerique entiere.
  4313. ----------------------------------------------------------------------*/
  4314. static void IntAttribute (int attr, SyntacticCode prevRule, indLine wi)
  4315. {
  4316. if (pSSchema->SsAttribute->TtAttr[attr - 1]->AttrType != AtNumAttr)
  4317. /* not an attribute of type Integer, error */
  4318. CompilerMessage (wi, PRS, FATAL, BAD_ATTR_TYPE, inputLine, LineNum);
  4319. else
  4320. switch (prevRule)
  4321. /* prevRule = number of the rule where the attribute name appears*/
  4322. {
  4323. case RULE_NbInherit:
  4324. case RULE_OpacityInherit:
  4325. /* Integer or OpacityInherit */
  4326. CurRule->PrIntValue = attr;
  4327. CurRule->PrValueType = PrAttrValue;
  4328. break;
  4329. case RULE_DimRatioA:
  4330. /* DimRatioA */
  4331. CurUnit = Percent;
  4332. LatestNumber = attr;
  4333. LatestNumberAttr = True;
  4334. PrevSign = 1; /* sign = "+" */
  4335. CurRule->PrDimRule.DrUnit = UnPercent;
  4336. break;
  4337. case RULE_IntPartA:
  4338. /* IntPartA */
  4339. LatestNumber = attr;
  4340. LatestNumberAttr = True;
  4341. break;
  4342. case RULE_PosIntegerA:
  4343. /* PosIntegerA */
  4344. CurRule->PrInhDelta = attr;
  4345. CurRule->PrInhAttr = True;
  4346. CurRule->PrInhUnit = UnRelative;
  4347. break;
  4348. case RULE_maximumA:
  4349. /* maximumA */
  4350. CurRule->PrInhMinOrMax = attr;
  4351. CurRule->PrMinMaxAttr = True;
  4352. break;
  4353. case RULE_NegIntegerA:
  4354. /* NegIntegerA */
  4355. CurRule->PrInhDelta = -attr;
  4356. CurRule->PrInhAttr = True;
  4357. CurRule->PrInhUnit = UnRelative;
  4358. break;
  4359. case RULE_minimumA:
  4360. /* minimumA */
  4361. CurRule->PrInhMinOrMax = attr;
  4362. CurRule->PrMinMaxAttr = True;
  4363. break;
  4364. case RULE_SizeA:
  4365. /* SizeA */
  4366. CurRule->PrMinValue = attr;
  4367. CurRule->PrMinUnit = UnRelative;
  4368. CurRule->PrMinAttr = True;
  4369. break;
  4370. case RULE_PosSizeA:
  4371. /* PosSizeA */
  4372. CurRule->PrInhDelta = attr;
  4373. CurRule->PrInhUnit = UnRelative;
  4374. CurRule->PrInhAttr = True;
  4375. break;
  4376. case RULE_MaxSizeA:
  4377. /* MaxSizeA */
  4378. CurRule->PrInhMinOrMax = attr;
  4379. CurRule->PrMinMaxAttr = True;
  4380. break;
  4381. case RULE_NegSizeA:
  4382. /* NegSizeA */
  4383. CurRule->PrInhDelta = -attr;
  4384. CurRule->PrInhUnit = UnRelative;
  4385. CurRule->PrInhAttr = True;
  4386. break;
  4387. case RULE_MinSizeA:
  4388. /* MinSizeA */
  4389. CurRule->PrInhMinOrMax = attr;
  4390. CurRule->PrMinMaxAttr = True;
  4391. break;
  4392. case RULE_PercentSizeA:
  4393. /* PercentSizeA */
  4394. CurRule->PrInhPercent = True;
  4395. CurRule->PrInhAttr = True;
  4396. CurRule->PrInhDelta = attr;
  4397. CurRule->PrInhUnit = UnRelative;
  4398. break;
  4399. default:
  4400. break;
  4401. }
  4402. }
  4403. /*----------------------------------------------------------------------
  4404. ColorName
  4405. ----------------------------------------------------------------------*/
  4406. static void ColorName (indLine wi, indLine wl)
  4407. {
  4408. Name n;
  4409. int i;
  4410. i = 0;
  4411. CopyName (n, wi, wl);
  4412. while (i < MAX_COLOR && strcmp (Name_colors[i], n))
  4413. i++;
  4414. if (i == MAX_COLOR)
  4415. CompilerMessage (wi, PRS, FATAL, MISSING_COLOR, inputLine, LineNum);
  4416. else
  4417. {
  4418. CurRule->PrValueType = PrNumValue;
  4419. CurRule->PrIntValue = i;
  4420. }
  4421. }
  4422. /*----------------------------------------------------------------------
  4423. ProcessName traite un nom.
  4424. ----------------------------------------------------------------------*/
  4425. static void ProcessName (SyntacticCode gCode, int identnum, SyntacticCode prevRule,
  4426. indLine wl, indLine wi)
  4427. {
  4428. Name n;
  4429. int i, j;
  4430. ThotBool ok, new_;
  4431. Counter *pCntr;
  4432. PresVariable *pPresVar;
  4433. PtrPresentationBox pPresBox;
  4434. PresVarItem *pVarElem;
  4435. PtrPRule pPRule;
  4436. PtrCondition pCond;
  4437. PtrTtAttribute pAttr;
  4438. PtrHostView pHostView, prevHostView;
  4439. /* gCode = numero de la regle ou apparait le nom */
  4440. switch (gCode)
  4441. {
  4442. case RULE_TypeName /* TypeName */ :
  4443. if (prevRule == RULE_PresentModel)
  4444. /* nom de la structure generique */
  4445. {
  4446. CopyName (n, wi, wl);
  4447. /* lit le schema de structure compile' */
  4448. GetSchStruct (&pSSchema);
  4449. if (pSSchema == NULL)
  4450. /* memoire insuffisante */
  4451. TtaDisplaySimpleMessage (FATAL, PRS, NO_MORE_MEM_LEFT);
  4452. if (!ReadStructureSchema (n, pSSchema))
  4453. TtaDisplaySimpleMessage (FATAL, PRS, MISSING_STRUCT_SCHEM);
  4454. /* echec lecture du schema de structure */
  4455. else if (strcmp (n, pSSchema->SsName))
  4456. CompilerMessage (wi, PRS, FATAL, STRUCT_SCHEM_DOES_NOT_MATCH,
  4457. inputLine, LineNum);
  4458. else
  4459. {
  4460. Initialize ();
  4461. if (pPSchema->PsStructName)
  4462. TtaFreeMemory (pPSchema->PsStructName);
  4463. pPSchema->PsStructName = TtaStrdup ((char *)n);
  4464. }
  4465. }
  4466. else if (prevRule == RULE_ExtStruct)
  4467. {
  4468. /* verifier que ce schema de structure externe existe et qu'il
  4469. contient bien le type CopyType */
  4470. CopyName (n, wi, wl);
  4471. if (!ReadStructureSchema (n, pExternalSS))
  4472. /* echec lecture du schema de structure */
  4473. CompilerMessage (wi, PRS, FATAL, CANT_LOAD_SCHEMA, inputLine,
  4474. LineNum);
  4475. else
  4476. /* le schema de structure externe a ete charge' */
  4477. {
  4478. i = 1;
  4479. while (strcmp (CopyType, pExternalSS->SsRule->SrElem[i - 1]->SrName) != 0
  4480. && i < pExternalSS->SsNRules)
  4481. i++;
  4482. if (strcmp (CopyType, pExternalSS->SsRule->SrElem[i - 1]->SrName) != 0)
  4483. /* type inconnu */
  4484. if (PresBoxDef || InWithinCond)
  4485. /* on est dans une boite de presentation, erreur */
  4486. CompilerMessage (BeginCopyType, PRS, FATAL,
  4487. NOT_FOR_PRES_BOX, inputLine, LineNum);
  4488. else
  4489. {
  4490. /* on suppose que c'est un nom de boite de presentation
  4491. definie dans un autre schema de presentation (pour
  4492. la presentation des references externes) */
  4493. if ((RuleDef && pSSchema->SsRule->SrElem[CurType - 1]->SrRefTypeNat[0] == EOS) ||
  4494. (AttributeDef && pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrTypeRefNature[0] == EOS))
  4495. /* la regle ne s'applique pas a` une reference externe */
  4496. CompilerMessage (BeginCopyType, PRS, FATAL,
  4497. AUTHORIZED_ONLY_FOR_EXT_REFS,
  4498. inputLine, LineNum);
  4499. else
  4500. /* la regle s'applique a` une reference externe */
  4501. if (CurRule->PrNPresBoxes != 0)
  4502. /* deja une boite dans la regle, on refuse */
  4503. CompilerMessage (wi, PRS, FATAL,
  4504. REDEFINITION_OF_CONTENT,
  4505. inputLine, LineNum);
  4506. else
  4507. {
  4508. strncpy (CurRule->PrPresBoxName, CopyType,
  4509. MAX_NAME_LENGTH);
  4510. /* indique qu'on copie une boite de presentation
  4511. et non un element */
  4512. CurRule->PrElement = False;
  4513. }
  4514. }
  4515. else if (InWithinCond)
  4516. {
  4517. strncpy (Conditions->CoAncestorName, CopyType,
  4518. MAX_NAME_LENGTH);
  4519. CopyName (Conditions->CoSSchemaName, wi, wl);
  4520. Conditions->CoTypeAncestor = 0;
  4521. }
  4522. else
  4523. /* le type a copier existe, il a le numero i */
  4524. {
  4525. /* indique qu'on copie un element et non une boite de
  4526. presentation */
  4527. CurRule->PrElement = True;
  4528. /* nom du type d'element a copier */
  4529. strncpy (CurRule->PrPresBoxName, CopyType, MAX_NAME_LENGTH);
  4530. /* indique que PrPresBoxName est un nom de type defini */
  4531. /* dans un autre schema */
  4532. CurRule->PrExternal = True;
  4533. }
  4534. /* marque que ce nom externe est traite' */
  4535. CopyType[0] = EOS;
  4536. BeginCopyType = 0;
  4537. }
  4538. }
  4539. else if (prevRule == RULE_ElemCondition)
  4540. {
  4541. /* On est dans une condition */
  4542. CopyName (n, wi, wl);
  4543. /* verifie si le type existe dans le schema de structure */
  4544. i = 1;
  4545. while (strcmp (n, pSSchema->SsRule->SrElem[i - 1]->SrName) &&
  4546. i < pSSchema->SsNRules)
  4547. i++;
  4548. if (InWithinCond)
  4549. /* un nom de type d'element dans une condition Within */
  4550. {
  4551. if (strcmp (n, pSSchema->SsRule->SrElem[i - 1]->SrName))
  4552. /* type inconnu */
  4553. {
  4554. /* c'est peut-etre un type defini dans un autre schema */
  4555. CopyName (CopyType, wi, wl);
  4556. BeginCopyType = wi;
  4557. }
  4558. else
  4559. /* le type existe, il a le numero i */
  4560. Conditions->CoTypeAncestor = i;
  4561. /* On remet Immediately a faux seulement ici */
  4562. Immediately = False;
  4563. }
  4564. else
  4565. /* on est dans une condition, mais pas apres Within */
  4566. {
  4567. if (!strcmp (n, pSSchema->SsRule->SrElem[i - 1]->SrName))
  4568. /* c'est bien un nom de type d'element */
  4569. {
  4570. /* la regle est-elle bien pour un attribut ? */
  4571. if (!AttributeDef)
  4572. CompilerMessage (wi, PRS, FATAL, VALID_ONLY_FOR_ATTRIBUTES,
  4573. inputLine, LineNum);
  4574. else
  4575. {
  4576. Conditions->CoCondition = PcElemType;
  4577. Conditions->CoTypeElem = i;
  4578. }
  4579. }
  4580. else
  4581. /* peut-etre est-ce un nom d'attribut */
  4582. {
  4583. /* cherche ce nom parmi les attributs du schema de structure */
  4584. i = 1;
  4585. while (strcmp (n, pSSchema->SsAttribute->TtAttr[i - 1]->AttrName) &&
  4586. i < pSSchema->SsNAttributes)
  4587. i++;
  4588. if (strcmp (n, pSSchema->SsAttribute->TtAttr[i - 1]->AttrName))
  4589. /* on ne l'a pas trouve, erreur */
  4590. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  4591. inputLine, LineNum);
  4592. else
  4593. /* c'est un nom d'attribut dans une condition "if attr..."*/
  4594. {
  4595. /* change le type de ce nom qui devient un nom d'attribut */
  4596. Identifier[identnum].SrcIdentCode = RULE_AttrName;
  4597. /* traite ce nom d'attribut */
  4598. if (CondInheritedAttr)
  4599. {
  4600. Conditions->CoCondition = PcInheritAttribute;
  4601. CondInheritedAttr = FALSE;
  4602. }
  4603. else
  4604. Conditions->CoCondition = PcAttribute;
  4605. Conditions->CoTypeAttr = i;
  4606. Conditions->CoTestAttrValue = FALSE;
  4607. }
  4608. }
  4609. }
  4610. }
  4611. else if (prevRule == RULE_CountFunction)
  4612. {
  4613. /* On est dans un CntrRLevel */
  4614. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  4615. CopyName (n, wi, wl);
  4616. /* verifie si le type existe dans le schema de structure */
  4617. i = 1;
  4618. while (strcmp (n, pSSchema->SsRule->SrElem[i - 1]->SrName) &&
  4619. i < pSSchema->SsNRules)
  4620. i++;
  4621. if (strcmp (n, pSSchema->SsRule->SrElem[i - 1]->SrName))
  4622. /* type inconnu */
  4623. CompilerMessage (wi, PRS, FATAL, UNKNOWN_TYPE, inputLine,LineNum);
  4624. else
  4625. /* le type existe, il a le numero i */
  4626. pCntr->CnItem[0].CiElemType = i;
  4627. }
  4628. else
  4629. ProcessTypeName (prevRule, n, wi, wl);
  4630. break;
  4631. case RULE_ViewName:
  4632. /* ViewName */
  4633. if (ViewDef)
  4634. {
  4635. if (prevRule == RULE_DclView)
  4636. /* declaration de vue */
  4637. {
  4638. if (pPSchema->PsNViews >= MAX_VIEW)
  4639. /* Trop de vues */
  4640. CompilerMessage (wi, PRS, FATAL, MAX_VIEWS_OVERFLOW,
  4641. inputLine, LineNum);
  4642. else if (Identifier[identnum].SrcIdentDefRule != 0)
  4643. /* Vue deja declaree */
  4644. CompilerMessage (wi, PRS, FATAL, CANT_REDECLARE_NAME,
  4645. inputLine, LineNum);
  4646. else
  4647. /* ajoute une vue dans la table des vues */
  4648. {
  4649. CopyName (pPSchema->PsView[pPSchema->PsNViews], wi, wl);
  4650. pPSchema->PsHostViewList[pPSchema->PsNViews] = NULL;
  4651. pPSchema->PsNViews++;
  4652. Identifier[identnum].SrcIdentDefRule = pPSchema->PsNViews;
  4653. }
  4654. }
  4655. else if (prevRule == RULE_MergeViews)
  4656. /* a view name after "merge with" in the VIEWS section.
  4657. Add this name to the host view list of the current view */
  4658. {
  4659. pHostView = (PtrHostView) TtaGetMemory (sizeof (HostView));
  4660. CopyName (pHostView->HostViewName, wi, wl);
  4661. pHostView->NextHostView = NULL;
  4662. if (!pPSchema->PsHostViewList[pPSchema->PsNViews - 1])
  4663. pPSchema->PsHostViewList[pPSchema->PsNViews - 1] = pHostView;
  4664. else
  4665. {
  4666. prevHostView = pPSchema->PsHostViewList[pPSchema->PsNViews-1];
  4667. while (prevHostView->NextHostView)
  4668. prevHostView = prevHostView->NextHostView;
  4669. prevHostView->NextHostView = pHostView;
  4670. }
  4671. }
  4672. }
  4673. else if (prevRule == RULE_PrintView)
  4674. /* dans la liste des vues a imprimer */
  4675. if (Identifier[identnum].SrcIdentDefRule == 0)
  4676. /* ce nom n'a pas ete declare comme nom de vue */
  4677. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  4678. inputLine, LineNum);
  4679. else
  4680. /* ce nom a ete declare comme nom de vue */
  4681. {
  4682. if (pPSchema->PsNPrintedViews >= MAX_PRINT_VIEW)
  4683. /* table des vues a imprimee saturee */
  4684. CompilerMessage (wi, PRS, FATAL,
  4685. MAX_VIEWS_TO_BE_PRINTED_OVERFLOW,
  4686. inputLine, LineNum);
  4687. else
  4688. {
  4689. pPSchema->PsPrintedView[pPSchema->PsNPrintedViews].VpNumber =
  4690. Identifier[identnum].SrcIdentDefRule;
  4691. pPSchema->PsNPrintedViews++;
  4692. }
  4693. }
  4694. else if (CounterDef)
  4695. {
  4696. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  4697. pCntr->CnItem[pCntr->CnNItems - 1].CiViewNum =
  4698. Identifier[identnum].SrcIdentDefRule;
  4699. }
  4700. else if (prevRule == RULE_CounterAttrPage)
  4701. if (Identifier[identnum].SrcIdentDefRule == 0)
  4702. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  4703. inputLine, LineNum);
  4704. else
  4705. {
  4706. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  4707. pPresVar->PvItem[pPresVar->PvNItems - 1].ViView =
  4708. Identifier[identnum].SrcIdentDefRule;
  4709. }
  4710. else if (prevRule == RULE_ViewRules)
  4711. /* dans une instruction 'in ViewName ...' */
  4712. {
  4713. if (Identifier[identnum].SrcIdentDefRule == 0)
  4714. /* Vue non declaree */
  4715. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  4716. inputLine, LineNum);
  4717. else if (Identifier[identnum].SrcIdentDefRule == 1)
  4718. /* C'est la vue* principale, erreur */
  4719. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_THE_MAIN_VIEW,
  4720. inputLine, LineNum);
  4721. else
  4722. {
  4723. CurView = Identifier[identnum].SrcIdentDefRule;
  4724. RulesForView = True;
  4725. }
  4726. }
  4727. break;
  4728. case RULE_CounterName:
  4729. /* CounterName */
  4730. if (CounterDef)
  4731. /* declaration de compteur */
  4732. {
  4733. if (pPSchema->PsNCounters >= MAX_PRES_COUNTER)
  4734. CompilerMessage (wi, PRS, FATAL, MAX_COUNTERS_OVERFLOW,
  4735. inputLine, LineNum);
  4736. else if (Identifier[identnum].SrcIdentDefRule != 0)
  4737. CompilerMessage (wi, PRS, FATAL, CANT_REDECLARE_NAME,
  4738. inputLine, LineNum);
  4739. else
  4740. {
  4741. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters];
  4742. pPSchema->PsNCounters++;
  4743. pCntr->CnNameIndx = 0;
  4744. pCntr->CnNItems = 0;
  4745. pCntr->CnNTransmAttrs = 0;
  4746. pCntr->CnNPresBoxes = 0;
  4747. pCntr->CnNCreators = 0;
  4748. pCntr->CnNCreatedBoxes = 0;
  4749. Identifier[identnum].SrcIdentDefRule = pPSchema->PsNCounters;
  4750. }
  4751. }
  4752. else if (Identifier[identnum].SrcIdentDefRule == 0)
  4753. /* on n'a pas encore rencontre' ce nom */
  4754. if (prevRule != RULE_CounterAttrPage)
  4755. /* compteur non declare' */
  4756. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  4757. inputLine, LineNum);
  4758. else
  4759. /* on vient de la regle CounterAttrPage; peut-etre est-ce
  4760. un nom d'attribut */
  4761. {
  4762. /* cherche ce nom parmi les attributs du schema de structure */
  4763. CopyName (n, wi, wl);
  4764. i = 1;
  4765. while (strcmp (n, pSSchema->SsAttribute->TtAttr[i -1]->AttrName) &&
  4766. i < pSSchema->SsNAttributes)
  4767. i++;
  4768. if (strcmp (n, pSSchema->SsAttribute->TtAttr[i - 1]->AttrName))
  4769. /* on ne l'a pas trouve, erreur */
  4770. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  4771. inputLine, LineNum);
  4772. else
  4773. /* c'est un nom d'attribut apres VALUE */
  4774. {
  4775. /* change le type de ce nom qui devient un nom d'attribut */
  4776. Identifier[identnum].SrcIdentCode = RULE_AttrName;
  4777. /* traite ce nom d'attribut */
  4778. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  4779. NewVarListItem (pPresVar, wi);
  4780. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarAttrValue;
  4781. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntDecimal;
  4782. pPresVar->PvItem[pPresVar->PvNItems - 1].ViAttr = i;
  4783. }
  4784. }
  4785. else if (prevRule == RULE_CounterAttrPage)
  4786. /* un compteur dans une definition de variable */
  4787. {
  4788. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  4789. pPresVar->PvItem[pPresVar->PvNItems].ViType = VarCounter;
  4790. pPresVar->PvItem[pPresVar->PvNItems].ViCounter =
  4791. Identifier[identnum].SrcIdentDefRule;
  4792. pPresVar->PvItem[pPresVar->PvNItems].ViCounterVal = CurMinMax;
  4793. pPresVar->PvNItems++;
  4794. if (NewVariableDef)
  4795. /* definition de var. dans une regle Content */
  4796. {
  4797. pCntr = &pPSchema->PsCounter[Identifier[identnum].SrcIdentDefRule - 1];
  4798. /* ce compteur est utilise' dans la boite de presentation */
  4799. if (pCntr->CnNPresBoxes < MAX_PRES_COUNT_USER)
  4800. {
  4801. pCntr->CnPresBox[pCntr->CnNPresBoxes] = CurPresBox;
  4802. if (CurMinMax == CntMaxVal || CurMinMax == CntMinVal)
  4803. pCntr->CnMinMaxPresBox[pCntr->CnNPresBoxes] = True;
  4804. else
  4805. pCntr->CnMinMaxPresBox[pCntr->CnNPresBoxes] = False;
  4806. pCntr->CnNPresBoxes++;
  4807. }
  4808. }
  4809. CurMinMax = CntCurVal;
  4810. }
  4811. else if (prevRule == RULE_ElemCondition)
  4812. /* dans une condition */
  4813. {
  4814. Conditions->CoCounter = Identifier[identnum].SrcIdentDefRule;
  4815. pCntr = &pPSchema->PsCounter[Identifier[identnum].SrcIdentDefRule-1];
  4816. /* ce compteur est-il deja utilise' par la boite courante */
  4817. /* comme condition de creation ? */
  4818. if (PresBoxDef)
  4819. j = CurPresBox;
  4820. else
  4821. j = CurType;
  4822. new_ = True;
  4823. for (i = 0; i < pCntr->CnNCreators; i++)
  4824. if (pCntr->CnCreator[i] == j &&
  4825. pCntr->CnPresBoxCreator[i] == PresBoxDef)
  4826. new_ = False;
  4827. if (new_)
  4828. /* ce compteur n'est pas encore utilise' par la boite */
  4829. /* courante dans ses regles de creation, on le marque. */
  4830. {
  4831. pCntr->CnCreator[pCntr->CnNCreators] = j;
  4832. pCntr->CnPresBoxCreator[pCntr->CnNCreators] = PresBoxDef;
  4833. if (CurMinMax == CntMaxVal || CurMinMax == CntMinVal)
  4834. pCntr->CnMinMaxCreator[pCntr->CnNCreators] = True;
  4835. else
  4836. pCntr->CnMinMaxCreator[pCntr->CnNCreators] = False;
  4837. CurMinMax = CntCurVal;
  4838. pCntr->CnNCreators++;
  4839. }
  4840. }
  4841. else if (prevRule == RULE_TypeOrCounter)
  4842. /* un compteur au debut d'une regle Transmit */
  4843. {
  4844. TransmittedCounter = Identifier[identnum].SrcIdentDefRule;
  4845. pCntr = &pPSchema->PsCounter[TransmittedCounter - 1];
  4846. if (pCntr->CnNTransmAttrs >= MAX_TRANSM_ATTR)
  4847. {
  4848. /* trop de regles transmit pour ce compteur */
  4849. CompilerMessage (wi, PRS, FATAL,
  4850. MAX_TRANSMIT_RULES_FOR_COUNTER_OVERFLOW,
  4851. inputLine, LineNum);
  4852. TransmittedCounter = 0;
  4853. }
  4854. else
  4855. pCntr->CnNTransmAttrs++;
  4856. }
  4857. break;
  4858. case RULE_AttrName:
  4859. /* AttrName */
  4860. /* cherche ce nom d'attribut dans le schema de structure */
  4861. CopyName (n, wi, wl);
  4862. i = 1;
  4863. while (strcmp (n, pSSchema->SsAttribute->TtAttr[i - 1]->AttrName) &&
  4864. i < pSSchema->SsNAttributes)
  4865. i++;
  4866. if (strcmp (n, pSSchema->SsAttribute->TtAttr[i - 1]->AttrName))
  4867. /* on ne l'a pas trouve */
  4868. {
  4869. if (prevRule == RULE_ElemCondition)
  4870. /* c'est peut-etre un nom d'element */
  4871. {
  4872. /* cherche ce type d'element dans le schema de structure */
  4873. i = 1;
  4874. while (strcmp (n, pSSchema->SsRule->SrElem[i - 1]->SrName) &&
  4875. i < pSSchema->SsNRules)
  4876. i++;
  4877. if (!strcmp (n, pSSchema->SsRule->SrElem[i - 1]->SrName))
  4878. /* c'est bien un nom de type d'element */
  4879. {
  4880. /* la regle est-elle bien pour un attribut ? */
  4881. if (!AttributeDef)
  4882. CompilerMessage (wi, PRS, FATAL, VALID_ONLY_FOR_ATTRIBUTES,
  4883. inputLine, LineNum);
  4884. else
  4885. {
  4886. Conditions->CoCondition = PcElemType;
  4887. Conditions->CoTypeElem = i;
  4888. }
  4889. }
  4890. }
  4891. else
  4892. /* erreur */
  4893. CompilerMessage (wi, PRS, FATAL, NO_SUCH__ATTR, inputLine, LineNum);
  4894. }
  4895. else if (!(prevRule == RULE_Attr
  4896. || prevRule == RULE_CountFunction
  4897. || prevRule == RULE_CondAttr
  4898. || prevRule == RULE_Function
  4899. || prevRule == RULE_AttrValue
  4900. || prevRule == RULE_AttrRelat
  4901. || prevRule == RULE_ElemCondition
  4902. || prevRule == RULE_CounterAttrPage
  4903. || prevRule == RULE_BoxType))
  4904. /* c'est un nom d'attribut a la place d'une valeur numerique */
  4905. IntAttribute (i, prevRule, wi);
  4906. else if (prevRule == RULE_Function || prevRule == RULE_CounterAttrPage)
  4907. /* c'est un nom d'attribut dans une variable */
  4908. {
  4909. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  4910. NewVarListItem (pPresVar, wi);
  4911. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarAttrValue;
  4912. pPresVar->PvItem[pPresVar->PvNItems - 1].ViStyle = CntDecimal;
  4913. pPresVar->PvItem[pPresVar->PvNItems - 1].ViAttr = i;
  4914. }
  4915. else if (prevRule == RULE_Attr)
  4916. /* c'est un nom d'attribut auquel on va associer des regles de */
  4917. /* presentation */
  4918. {
  4919. /* on se souvient de son numero */
  4920. CurAttrNum = i;
  4921. /* on effectue un certain nombre d'initialisations */
  4922. NewAttributeDef = True;
  4923. VCondLess = False;
  4924. VCondGreater = False;
  4925. CondEqual = False;
  4926. CurAttrVal = 0;
  4927. /* on n'a pas encore rencontre' de valeur */
  4928. CurComparAttr = 0;
  4929. /* a priori on ne compare pas avec un attribut */
  4930. CurElemHeritAttr = 0;
  4931. /* a priori ce n'est pas de l'heritage */
  4932. CurElemHeritAttrSelf = FALSE;
  4933. /* a priori c'est un heritage des ascendants seulement */
  4934. CurAttrLowerBound = -MAX_INT_ATTR_VAL - 1;
  4935. /* - infini */
  4936. CurAttrUpperBound = MAX_INT_ATTR_VAL + 1;
  4937. /* + infini */
  4938. CurTextDefined = FALSE;
  4939. /* pas de valeur d'attribut textuel specifiee */
  4940. CurTextEqual[0] = EOS;
  4941. /* string vide */
  4942. }
  4943. else if (prevRule == RULE_CountFunction)
  4944. {
  4945. /* c'est un nom d'attribut apres le mot INIT ou REINIT dans */
  4946. /* une definition de compteur */
  4947. /* seuls les attributs numeriques sont accepte's */
  4948. if (pSSchema->SsAttribute->TtAttr[i - 1]->AttrType != AtNumAttr)
  4949. /* ce n'est pas un attribut numerique, erreur */
  4950. CompilerMessage (wi, PRS, FATAL, BAD_ATTR_TYPE, inputLine,
  4951. LineNum);
  4952. else
  4953. {
  4954. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  4955. if (AttrInitCounter)
  4956. /* le compteur courant prendra cet attribut comme */
  4957. /* valeur initiale */
  4958. pCntr->CnItem[0].CiInitAttr = i;
  4959. else
  4960. pCntr->CnItem[0].CiReinitAttr = i;
  4961. }
  4962. }
  4963. else if (prevRule == RULE_CondAttr)
  4964. {
  4965. /* c'est un nom d'attribut apres le mot WITH ou WITHOUT
  4966. dans une definition de compteur */
  4967. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  4968. pCntr->CnItem[pCntr->CnNItems - 1].CiCondAttr = i;
  4969. }
  4970. else if (prevRule == RULE_AttrRelat)
  4971. {
  4972. /* c'est un nom d'attribut a la place d'une valeur numerique */
  4973. /* pour comparer la valeur de l'attribut a un attribut pose */
  4974. /* sur un element englobant */
  4975. if (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtNumAttr)
  4976. /* interdit pour un attribut non numerique */
  4977. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_FOR_THIS_TYPE_OF_ATTR,
  4978. inputLine, LineNum);
  4979. else if (pSSchema->SsAttribute->TtAttr[i - 1]->AttrType != AtNumAttr)
  4980. /* l'attribut n'est pas un attribut numerique */
  4981. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_FOR_THIS_TYPE_OF_ATTR,
  4982. inputLine, LineNum);
  4983. else
  4984. CurComparAttr = i;
  4985. }
  4986. else if (prevRule == RULE_ElemCondition)
  4987. /* c'est un nom d'attribut dans une condition "if attr..." */
  4988. {
  4989. if (CondInheritedAttr)
  4990. {
  4991. Conditions->CoCondition = PcInheritAttribute;
  4992. CondInheritedAttr = FALSE;
  4993. }
  4994. else
  4995. Conditions->CoCondition = PcAttribute;
  4996. Conditions->CoTypeAttr = i;
  4997. Conditions->CoTestAttrValue = FALSE;
  4998. }
  4999. else if (prevRule == RULE_BoxType)
  5000. /* c'est un nom d'attribut dans une regle BoxType */
  5001. {
  5002. if ((CurRule->PrType == PtVertRef ||
  5003. CurRule->PrType == PtHorizRef) &&
  5004. CurRule->PrPosRule.PoRelation != RlEnclosed)
  5005. CompilerMessage (wi, PRS, FATAL, ONLY_ENCLOSED_AND_ARE_ALLOWED,
  5006. inputLine, LineNum);
  5007. else
  5008. switch (CurRule->PrType)
  5009. {
  5010. case PtVertRef:
  5011. case PtHorizRef:
  5012. case PtVertPos:
  5013. case PtHorizPos:
  5014. CurRule->PrPosRule.PoRefKind = RkAttr;
  5015. CurRule->PrPosRule.PoRefIdent = i;
  5016. break;
  5017. case PtWidth:
  5018. case PtHeight:
  5019. if (CurRule->PrDimRule.DrPosition)
  5020. {
  5021. CurRule->PrDimRule.DrPosRule.PoRefKind = RkAttr;
  5022. CurRule->PrDimRule.DrPosRule.PoRefIdent = i;
  5023. }
  5024. else
  5025. {
  5026. CurRule->PrDimRule.DrRefKind = RkAttr;
  5027. CurRule->PrDimRule.DrRefIdent = i;
  5028. }
  5029. break;
  5030. default: break;
  5031. }
  5032. }
  5033. break;
  5034. case RULE_ConstName:
  5035. /* ConstName */
  5036. if (ConstantDef)
  5037. /* definition de constante */
  5038. if (Identifier[identnum].SrcIdentDefRule != 0)
  5039. CompilerMessage (wi, PRS, FATAL, CANT_REDECLARE_NAME, inputLine,
  5040. LineNum);
  5041. else
  5042. {
  5043. NewConst (wi);
  5044. Identifier[identnum].SrcIdentDefRule = pPSchema->PsNConstants;
  5045. }
  5046. else if (Identifier[identnum].SrcIdentDefRule == 0)
  5047. /* utilisation d'une constante */
  5048. /* on n'a pas encore rencontre' ce nom */
  5049. if (prevRule == RULE_Function)
  5050. /* peut-etre est-ce un nom d'attribut */
  5051. /* cherche ce nom parmi les attributs du schema de structure */
  5052. {
  5053. CopyName (n, wi, wl);
  5054. i = 1;
  5055. while (strcmp (n, pSSchema->SsAttribute->TtAttr[i - 1]->AttrName) &&
  5056. i < pSSchema->SsNAttributes)
  5057. i++;
  5058. if (strcmp (n, pSSchema->SsAttribute->TtAttr[i - 1]->AttrName))
  5059. /* on ne l'a pas trouve, erreur */
  5060. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  5061. inputLine, LineNum);
  5062. else
  5063. /* c'est un nom d'attribut dans une variable */
  5064. /* change le type de ce nom qui devient un nom d'attribut */
  5065. {
  5066. Identifier[identnum].SrcIdentCode = RULE_AttrName;
  5067. /* traite ce nom d'attribut */
  5068. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  5069. NewVarListItem (pPresVar, wi);
  5070. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarAttrValue;
  5071. pPresVar->PvItem[pPresVar->PvNItems - 1].ViAttr = i;
  5072. }
  5073. }
  5074. else
  5075. /* nom de constante inconnu */
  5076. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  5077. inputLine, LineNum);
  5078. else
  5079. {
  5080. if (PresBoxDef && !NewVariableDef)
  5081. /* dans une regle 'Content : Nom_Constante;' d'une boite de
  5082. presentation */
  5083. {
  5084. pPresBox = pPSchema->PsPresentBox->PresBox[CurPresBox - 1];
  5085. pPresBox->PbContent = ContConst;
  5086. pPresBox->PbContConstant = Identifier[identnum].SrcIdentDefRule;
  5087. }
  5088. if (VariableDef || NewVariableDef)
  5089. /* dans une definition de variable */
  5090. {
  5091. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsNVariables - 1];
  5092. NewVarListItem (pPresVar, wi);
  5093. pPresVar->PvItem[pPresVar->PvNItems - 1].ViType = VarText;
  5094. pPresVar->PvItem[pPresVar->PvNItems - 1].ViConstant =
  5095. Identifier[identnum].SrcIdentDefRule;
  5096. }
  5097. if (RuleDef)
  5098. if (CurRule->PrPresMode == PresFunction &&
  5099. CurRule->PrPresFunction == FnContentRef)
  5100. /* un nom de constante dans une regle Content d'un element
  5101. reference ou paire */
  5102. {
  5103. CurRule->PrNPresBoxes = 1;
  5104. CurRule->PrPresBox[0] = Identifier[identnum].SrcIdentDefRule;
  5105. }
  5106. }
  5107. break;
  5108. case RULE_ScriptName:
  5109. /* ScriptName */
  5110. /* c'est le script d'une constante, on ne garde que le premier */
  5111. /* caractere */
  5112. pPSchema->PsConstant[pPSchema->PsNConstants - 1].PdScript =
  5113. (char) inputLine[wi - 1];
  5114. break;
  5115. case RULE_VarName /* VarName */ :
  5116. if (VariableDef)
  5117. /* definition de variable */
  5118. if (Identifier[identnum].SrcIdentDefRule != 0)
  5119. CompilerMessage (wi, PRS, FATAL, CANT_REDECLARE_NAME, inputLine,
  5120. LineNum);
  5121. else
  5122. {
  5123. NewVar (wi);
  5124. Identifier[identnum].SrcIdentDefRule = pPSchema->PsNVariables;
  5125. }
  5126. else if (Identifier[identnum].SrcIdentDefRule == 0)
  5127. /* utilisation d'une variable */
  5128. /* ce nom n'a pas ete declare comme identificateur de variable */
  5129. if (prevRule == RULE_VarConst)
  5130. /* s'il vient de la regle VarConst, voyons */
  5131. /* si ce n'est pas un identificateur de type */
  5132. {
  5133. ProcessTypeName (prevRule, n, wi, wl);
  5134. Identifier[identnum].SrcIdentCode = RULE_TypeName;
  5135. /* changement de type, c'est */
  5136. /* maintenant un identificateur de type structure' */
  5137. }
  5138. else
  5139. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  5140. inputLine, LineNum);
  5141. else
  5142. {
  5143. if (PresBoxDef)
  5144. {
  5145. pPresBox = pPSchema->PsPresentBox->PresBox[CurPresBox - 1];
  5146. pPresBox->PbContent = ContVariable;
  5147. pPresBox->PbContVariable = Identifier[identnum].SrcIdentDefRule;
  5148. /* cherche tous les compteurs reference's par cette variable */
  5149. /* et marque que la boite de presentation courante les utilise */
  5150. pPresVar = pPSchema->PsVariable->PresVar[Identifier[identnum].SrcIdentDefRule - 1];
  5151. for (i = 0; i < pPresVar->PvNItems; i++)
  5152. {
  5153. pVarElem = &pPresVar->PvItem[i];
  5154. if (pVarElem->ViType == VarCounter)
  5155. {
  5156. pCntr = &pPSchema->PsCounter[pVarElem->ViCounter - 1];
  5157. if (pCntr->CnNPresBoxes < MAX_PRES_COUNT_USER)
  5158. {
  5159. pCntr->CnPresBox[pCntr->CnNPresBoxes] = CurPresBox;
  5160. if (pPresVar->PvItem[pPresVar->PvNItems - 1].ViCounterVal == CntMinVal ||
  5161. pPresVar->PvItem[pPresVar->PvNItems - 1].ViCounterVal == CntMaxVal)
  5162. pCntr->CnMinMaxPresBox[pCntr->CnNPresBoxes] = True;
  5163. pCntr->CnNPresBoxes++;
  5164. }
  5165. }
  5166. else if (pVarElem->ViType == VarPageNumber)
  5167. PageCounterChangeBox (CurPresBox, pVarElem->ViView);
  5168. }
  5169. }
  5170. else
  5171. /* on est dans une regle Content d'un element reference ou */
  5172. /* paire, on refuse: seules les constantes sont acceptees dans */
  5173. /* cette regle */
  5174. CompilerMessage (wi, PRS, FATAL, FORBIDDEN_IN_A_REF, inputLine,
  5175. LineNum);
  5176. }
  5177. break;
  5178. case RULE_BoxName:
  5179. /* BoxName */
  5180. if (PresBoxDef && !InRule)
  5181. /* definition d'une boite de presentation */
  5182. {
  5183. if (GetTypeNumber (wl, wi, n) != 0)
  5184. /* ce nom de boite de presentation est deja un nom de type */
  5185. /* d'element, erreur */
  5186. CompilerMessage (wi, PRS, FATAL, CANT_USE_TYPE_NAME_FOR_A_BOX,
  5187. inputLine, LineNum);
  5188. else if (Identifier[identnum].SrcIdentDefRule == 0)
  5189. NewBoxName (wl, wi, identnum);
  5190. else if (pPSchema->PsPresentBox->PresBox[Identifier[identnum].SrcIdentDefRule - 1]->PbName[0] != ' ')
  5191. /* nom deja rencontre' dans une declaration de vue, de */
  5192. /* compteur ou dans une instruction Forward */
  5193. CompilerMessage (wi, PRS, FATAL, CANT_REDECLARE_NAME, inputLine,
  5194. LineNum);
  5195. else
  5196. {
  5197. pPresBox = pPSchema->PsPresentBox->PresBox[Identifier[identnum].SrcIdentDefRule - 1];
  5198. CopyName (pPresBox->PbName, wi, wl);
  5199. pPresBox->PbFirstPRule = NextRule;
  5200. FirstRule = NextRule;
  5201. CurPresBox = Identifier[identnum].SrcIdentDefRule;
  5202. }
  5203. }
  5204. else
  5205. /* utilisation d'une boite */
  5206. {
  5207. if (Identifier[identnum].SrcIdentDefRule == 0)
  5208. /* ce nom n'a pas ete declare comme identificateur de boite */
  5209. {
  5210. i = 1;
  5211. if (CurRule->PrType == PtFunction &&
  5212. CurRule->PrPresFunction == FnCopy)
  5213. /* on est dans une regle Copy */
  5214. {
  5215. i = GetTypeNumber (wl, wi, n);
  5216. if (i == 0)
  5217. /* ce n'est pas un identificateur de type d'element */
  5218. /* defini dans le schema de structure */
  5219. {
  5220. /* il s'agit peut-etre d'un type externe, ou d'une */
  5221. /* boite de presentation externe; on garde ce nom */
  5222. /* en attendant le nom de la structure externe */
  5223. CopyName (CopyType, wi, wl);
  5224. BeginCopyType = wi;
  5225. }
  5226. }
  5227. if ((prevRule == RULE_BoxType ||
  5228. prevRule == RULE_BoxTypeCopied) && i != 0)
  5229. /* si on vient de la regle BoxType ou BoxTypeCopied, */
  5230. /* voyons si ce n'est pas un identificateur de type */
  5231. {
  5232. ProcessTypeName (prevRule, n, wi, wl);
  5233. /* changement de type, c'est maintenant un
  5234. identificateur de type d'element */
  5235. Identifier[identnum].SrcIdentCode = RULE_TypeName;
  5236. }
  5237. else if (i != 0)
  5238. CompilerMessage (wi, PRS, FATAL, UNDECLARED_IDENTIFIER,
  5239. inputLine, LineNum);
  5240. }
  5241. else
  5242. /* c'est une boite declaree */
  5243. if ((CurRule->PrType == PtVertRef ||
  5244. CurRule->PrType == PtHorizRef) &&
  5245. CurRule->PrPosRule.PoRelation != RlEnclosed)
  5246. CompilerMessage (wi, PRS, FATAL, ONLY_ENCLOSED_AND_ARE_ALLOWED,
  5247. inputLine, LineNum);
  5248. else
  5249. switch (CurRule->PrType)
  5250. {
  5251. case PtVertRef:
  5252. case PtHorizRef:
  5253. case PtVertPos:
  5254. case PtHorizPos:
  5255. CurRule->PrPosRule.PoRefKind = RkPresBox;
  5256. CurRule->PrPosRule.PoRefIdent = Identifier[identnum].SrcIdentDefRule;
  5257. break;
  5258. case PtWidth:
  5259. case PtHeight:
  5260. if (CurRule->PrDimRule.DrPosition)
  5261. {
  5262. CurRule->PrDimRule.DrPosRule.PoRefKind = RkPresBox;
  5263. CurRule->PrDimRule.DrPosRule.PoRefIdent =
  5264. Identifier[identnum].SrcIdentDefRule;
  5265. }
  5266. else
  5267. {
  5268. CurRule->PrDimRule.DrRefKind = RkPresBox;
  5269. CurRule->PrDimRule.DrRefIdent =
  5270. Identifier[identnum].SrcIdentDefRule;
  5271. }
  5272. break;
  5273. case PtFunction:
  5274. if (CurRule->PrNPresBoxes >= MAX_COLUMN_PAGE)
  5275. CompilerMessage (wi, PRS, FATAL, MAX_COLUMNS_OVERFLOW,
  5276. inputLine, LineNum);
  5277. else if (CurRule->PrPresFunction == FnCopy &&
  5278. pSSchema->SsRule->SrElem[CurType - 1]->SrConstruct ==
  5279. CsReference)
  5280. /* on est dans une regle FnCopy pour une reference */
  5281. if (CurRule->PrNPresBoxes != 0)
  5282. /* deja une boite dans la regle, on refuse */
  5283. CompilerMessage (wi, PRS, FATAL,
  5284. UNDECLARED_IDENTIFIER, inputLine,
  5285. LineNum);
  5286. else
  5287. {
  5288. CurRule->PrNPresBoxes = 1;
  5289. CurRule->PrPresBox[0] =
  5290. Identifier[identnum].SrcIdentDefRule;
  5291. }
  5292. else
  5293. {
  5294. CurRule->PrPresBox[CurRule->PrNPresBoxes] =
  5295. Identifier[identnum].SrcIdentDefRule;
  5296. CurRule->PrNPresBoxes++;
  5297. if (CurRule->PrPresFunction == FnCreateFirst
  5298. || CurRule->PrPresFunction == FnCreateLast
  5299. || CurRule->PrPresFunction == FnCreateBefore
  5300. || CurRule->PrPresFunction == FnCreateWith
  5301. || CurRule->PrPresFunction == FnCreateAfter)
  5302. {
  5303. /* on est dans une regle de creation */
  5304. /******@@@ si la regle de creation n'est pas appelee par un attribut, verifie
  5305. que la boite creee ne contient pas AttrName ou AttrValue @@@@*****/
  5306. /* teste si on a deja cette regle de creation dans */
  5307. /* la chaine de regles courante */
  5308. pPRule = FirstRule;
  5309. while (pPRule != NULL && pPRule != CurRule)
  5310. {
  5311. if (pPRule->PrViewNum == CurRule->PrViewNum)
  5312. /* la regle concerne la meme vue */
  5313. if (pPRule->PrType == PtFunction)
  5314. if (pPRule->PrPresFunction == CurRule->PrPresFunction)
  5315. /* meme operation de creation */
  5316. if (pPRule->PrPresBox[0] == CurRule->PrPresBox[0])
  5317. /* meme boite creee */
  5318. if (SameConditions (pPRule->PrCond, CurRule->PrCond))
  5319. CompilerMessage (wi, PRS, FATAL,
  5320. RULE_ALREADY_DEFINED, inputLine,
  5321. LineNum);
  5322. /* regle suivante dans la chaine */
  5323. pPRule = pPRule->PrNextPRule;
  5324. }
  5325. /* cherche les compteurs qui controlent la */
  5326. /* creation de cette boite */
  5327. pCond = CurRule->PrCond;
  5328. while (pCond != NULL)
  5329. /* teste toutes les conditions de creation */
  5330. {
  5331. if (pCond->CoCondition == PcEven
  5332. || pCond->CoCondition == PcOdd
  5333. || pCond->CoCondition == PcOne
  5334. || pCond->CoCondition == PcInterval)
  5335. /* c'est une condition sur un compteur, */
  5336. /* indique dans le compteur qu'il controle la */
  5337. /* creation de ce type de boite, si ce n'est */
  5338. /* deja fait. */
  5339. {
  5340. pCntr = &pPSchema->PsCounter[pCond->CoCounter - 1];
  5341. new_ = True;
  5342. for (j = 0; j < pCntr->CnNCreatedBoxes; j++)
  5343. if (pCntr->CnCreatedBox[j] ==
  5344. Identifier[identnum].SrcIdentDefRule)
  5345. new_ = False;
  5346. if (new_)
  5347. {
  5348. /* Si la boite est creee sur une condition
  5349. de min ou de max, on le note */
  5350. if (pCond->CoValCounter == CntMinVal ||
  5351. pCond->CoValCounter == CntMaxVal)
  5352. pCntr->CnMinMaxCreatedBox[pCntr->CnNCreatedBoxes] = True;
  5353. else
  5354. pCntr->CnMinMaxCreatedBox[pCntr->CnNCreatedBoxes] = False;
  5355. pCntr->CnCreatedBox[pCntr->CnNCreatedBoxes] =
  5356. Identifier[identnum].SrcIdentDefRule;
  5357. pCntr->CnNCreatedBoxes++;
  5358. }
  5359. }
  5360. pCond = pCond->CoNextCondition;
  5361. }
  5362. }
  5363. }
  5364. break;
  5365. default:
  5366. break;
  5367. }
  5368. }
  5369. break;
  5370. case RULE_FontColorName:
  5371. if (CurRule->PrType == PtFillPattern)
  5372. /* Pattern name */
  5373. {
  5374. /* cherche le nom dans le tableau des trames Thot */
  5375. CopyName (n, wi, wl);
  5376. i = 0;
  5377. ok = False;
  5378. do
  5379. if (strcmp (n, Name_patterns[i]) == 0)
  5380. ok = True;
  5381. else
  5382. i++;
  5383. while (!ok &&
  5384. (unsigned int)i < sizeof (Name_patterns) / sizeof (char *));
  5385. if (!ok)
  5386. CompilerMessage (wi, PRS, FATAL, MISSING_PATTERN, inputLine,
  5387. LineNum);
  5388. else
  5389. /* on met le rang du pattern dans la regle */
  5390. {
  5391. CurRule->PrValueType = PrNumValue;;
  5392. CurRule->PrIntValue = i;
  5393. }
  5394. }
  5395. else if (CurRule->PrType == PtBackground ||
  5396. CurRule->PrType == PtForeground ||
  5397. CurRule->PrType == PtBorderTopColor ||
  5398. CurRule->PrType == PtBorderRightColor ||
  5399. CurRule->PrType == PtBorderBottomColor ||
  5400. CurRule->PrType == PtBorderLeftColor)
  5401. /* color name */
  5402. ColorName (wi, wl);
  5403. else
  5404. /* font name */
  5405. CurRule->PrChrValue = (char) inputLine[wi - 1];
  5406. break;
  5407. case RULE_AttrVal:
  5408. /* AttrVal */
  5409. if (Conditions)
  5410. /* an attribute value in a condition "if attr = nnn" */
  5411. pAttr = pSSchema->SsAttribute->TtAttr[Conditions->CoTypeAttr - 1];
  5412. else
  5413. pAttr = pSSchema->SsAttribute->TtAttr[CurAttrNum - 1];
  5414. if (pAttr->AttrType != AtEnumAttr)
  5415. /* ce n'est pas un attribut a valeur enumerees */
  5416. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5417. LineNum);
  5418. else
  5419. {
  5420. CopyName (n, wi, wl);
  5421. /* cherche cette valeur parmi celles de l'attribut concerne' */
  5422. i = 1;
  5423. while (strcmp (n, pAttr->AttrEnumValue[i - 1]) &&
  5424. i < pAttr->AttrNEnumValues)
  5425. i++;
  5426. if (strcmp (n, pAttr->AttrEnumValue[i - 1]))
  5427. /* on ne trouve pas cette valeur, erreur */
  5428. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5429. LineNum);
  5430. else
  5431. {
  5432. if (Conditions)
  5433. /* an attribute value in a condition "if attr = nnn" */
  5434. Conditions->CoAttrValue = i;
  5435. else
  5436. CurAttrVal = i; /* on garde le numero de cette valeur */
  5437. }
  5438. }
  5439. break;
  5440. case RULE_ExternalAttr:
  5441. /* un nom d'attribut externe dans une regle Transmit */
  5442. if (TransmittedCounter > 0)
  5443. /* c'est une regle transmit pour un compteur */
  5444. {
  5445. pCntr = &pPSchema->PsCounter[TransmittedCounter - 1];
  5446. CopyName (pCntr->CnTransmAttr[pCntr->CnNTransmAttrs - 1], wi, wl);
  5447. }
  5448. else if (TransmittedElem > 0)
  5449. /* c'est une regle transmit pour un contenu d'element */
  5450. CopyName (pPSchema->PsTransmElem[pPSchema->PsNTransmElems - 1].TeTargetAttr, wi, wl);
  5451. break;
  5452. default:
  5453. break;
  5454. }
  5455. }
  5456. /*----------------------------------------------------------------------
  5457. ProcessInteger traite un nombre.
  5458. ----------------------------------------------------------------------*/
  5459. static void ProcessInteger (SyntacticCode gCode, indLine wl, indLine wi)
  5460. {
  5461. int n;
  5462. Counter *pCntr;
  5463. n = AsciiToInt (wi, wl);
  5464. switch (gCode)
  5465. {
  5466. /* r= numero de la regle ou apparait le nombre */
  5467. case RULE_RelLevel:
  5468. Conditions->CoRelation = n;
  5469. if (!SignGreaterOrLess)
  5470. /* le nombre d'ancetres n'est pas precede' du signe > ou < */
  5471. Conditions->CoAncestorRel = CondEquals;
  5472. break;
  5473. case RULE_CountValue:
  5474. /* CountValue */
  5475. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  5476. pCntr->CnItem[pCntr->CnNItems - 1].CiParamValue = n;
  5477. break;
  5478. case RULE_AncestorLevel:
  5479. /* AncestorLevel */
  5480. pCntr = &pPSchema->PsCounter[pPSchema->PsNCounters - 1];
  5481. pCntr->CnItem[pCntr->CnNItems - 1].CiAscendLevel = n * AncestorSign;
  5482. break;
  5483. case RULE_DimRatio:
  5484. /* DimRatio */
  5485. CurUnit = Percent;
  5486. LatestNumber = n * 1000;
  5487. LatestNumberAttr = False;
  5488. PrevSign = 1; /* signe positif */
  5489. CurRule->PrDimRule.DrUnit = UnPercent;
  5490. break;
  5491. case RULE_IntPart:
  5492. /* IntPart */
  5493. LatestNumber = n * 1000;
  5494. /* LatestNumber est exprime' en 1/1000 */
  5495. LatestNumberAttr = False;
  5496. break;
  5497. case RULE_DecimPart:
  5498. /* DecimPart */
  5499. /* on convertit la partie apres la virgule en milliemes */
  5500. switch (wl) /* selon le nombre de chiffres apres la virgule */
  5501. {
  5502. case 1:
  5503. n = n * 100;
  5504. break;
  5505. case 2:
  5506. n = n * 10;
  5507. break;
  5508. case 3:
  5509. n = n * 1;
  5510. break;
  5511. case 4:
  5512. n = n / 10;
  5513. break;
  5514. default:
  5515. /* trop de decimales */
  5516. CompilerMessage (wi, PRS, FATAL, MAX_AFTER_DIGITS_OVERFLOW,
  5517. inputLine, LineNum);
  5518. break;
  5519. }
  5520. /* ajoute cette partie a la partie entiere deja convertie en milliemes */
  5521. LatestNumber += n;
  5522. break;
  5523. case RULE_PosInteger:
  5524. /* PosInteger */
  5525. if (CurRule->PrType == PtOpacity || CurRule->PrType == PtFillOpacity ||
  5526. CurRule->PrType == PtStrokeOpacity)
  5527. /* opacity is expressed in percentage in the P language source, but
  5528. in thousandths in the internal representation */
  5529. n = n * 10;
  5530. CurRule->PrInhDelta = n;
  5531. CurRule->PrInhUnit = UnRelative;
  5532. CurRule->PrInhAttr = False;
  5533. break;
  5534. case RULE_NegInteger:
  5535. /* NegInteger */
  5536. if (CurRule->PrType == PtOpacity || CurRule->PrType == PtFillOpacity ||
  5537. CurRule->PrType == PtStrokeOpacity)
  5538. /* opacity is expressed in percentage in the P language source, but
  5539. in thousandths in the internal representation */
  5540. n = n * 10;
  5541. CurRule->PrInhDelta = -n;
  5542. CurRule->PrInhUnit = UnRelative;
  5543. CurRule->PrInhAttr = False;
  5544. break;
  5545. case RULE_maximum:
  5546. /* maximum */
  5547. if (CurRule->PrType == PtOpacity || CurRule->PrType == PtFillOpacity ||
  5548. CurRule->PrType == PtStrokeOpacity)
  5549. /* opacity is expressed in percentage in the P language source, but
  5550. in thousandths in the internal representation */
  5551. n = n * 10;
  5552. CurRule->PrInhMinOrMax = n;
  5553. CurRule->PrMinMaxAttr = False;
  5554. break;
  5555. case RULE_minimum:
  5556. /* minimum */
  5557. if (CurRule->PrType == PtOpacity || CurRule->PrType == PtFillOpacity ||
  5558. CurRule->PrType == PtStrokeOpacity)
  5559. /* opacity is expressed in percentage in the P language source, but
  5560. in thousandths in the internal representation */
  5561. n = n * 10;
  5562. CurRule->PrInhMinOrMax = n;
  5563. CurRule->PrMinMaxAttr = False;
  5564. break;
  5565. case RULE_Integer:
  5566. /* Integer */
  5567. CurRule->PrIntValue = n;
  5568. CurRule->PrValueType = PrNumValue;
  5569. break;
  5570. case RULE_OpPercent:
  5571. /* OpPercent */
  5572. /* opacity values in the source P file are in percent, while the
  5573. internal values are in permil */
  5574. if (n < 0 || n > 100)
  5575. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5576. LineNum); /**** should be INVALID_OPACITY_VALUE ***/
  5577. else
  5578. {
  5579. CurRule->PrIntValue = n * 10;
  5580. CurRule->PrValueType = PrNumValue;
  5581. }
  5582. break;
  5583. case RULE_Size:
  5584. /* Size */
  5585. CurRule->PrMinValue = n;
  5586. CurRule->PrMinAttr = False;
  5587. CurRule->PrMinUnit = UnRelative;
  5588. break;
  5589. case RULE_PosSize:
  5590. /* PosSize */
  5591. CurRule->PrInhDelta = n;
  5592. CurRule->PrInhUnit = UnRelative;
  5593. CurRule->PrInhAttr = False;
  5594. break;
  5595. case RULE_NegSize:
  5596. /* NegSize */
  5597. CurRule->PrInhDelta = -n;
  5598. CurRule->PrInhUnit = UnRelative;
  5599. CurRule->PrInhAttr = False;
  5600. break;
  5601. case RULE_MaxSize:
  5602. /* MaxSize */
  5603. CurRule->PrInhMinOrMax = n;
  5604. CurRule->PrMinMaxAttr = False;
  5605. break;
  5606. case RULE_MinSize:
  5607. /* MinSize */
  5608. CurRule->PrInhMinOrMax = n;
  5609. CurRule->PrMinMaxAttr = False;
  5610. break;
  5611. case RULE_PercentSize:
  5612. /* PercentSize */
  5613. CurRule->PrInhAttr = False;
  5614. CurRule->PrInhPercent = True;
  5615. CurRule->PrInhDelta = n;
  5616. CurRule->PrInhUnit = UnRelative;
  5617. break;
  5618. case RULE_MinVal:
  5619. /* MinVal */
  5620. if (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtNumAttr
  5621. || n >= MAX_INT_ATTR_VAL)
  5622. /* ce n'est pas un attribut a valeur numerique */
  5623. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5624. LineNum);
  5625. else
  5626. {
  5627. CurAttrLowerBound = n * AttrValSign + 1;
  5628. /* a priori, la prochaine valeur */
  5629. /* d'attribut numerique sera positive */
  5630. AttrValSign = 1;
  5631. }
  5632. break;
  5633. case RULE_MaxVal:
  5634. /* MaxVal */
  5635. if (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtNumAttr
  5636. || n >= MAX_INT_ATTR_VAL)
  5637. /* ce n'est pas un attribut a valeur numerique */
  5638. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5639. LineNum);
  5640. else
  5641. {
  5642. CurAttrUpperBound = n * AttrValSign - 1;
  5643. /* a priori, la prochaine valeur */
  5644. /* d'attribut numerique sera positive */
  5645. AttrValSign = 1;
  5646. }
  5647. break;
  5648. case RULE_MinInterval:
  5649. /* MinInterval */
  5650. if (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtNumAttr
  5651. || n >= MAX_INT_ATTR_VAL)
  5652. /* ce n'est pas un attribut a valeur numerique */
  5653. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5654. LineNum);
  5655. else
  5656. {
  5657. CurAttrLowerBound = n * AttrValSign;
  5658. /* a priori, la prochaine valeur */
  5659. /* d'attribut numerique sera positive */
  5660. AttrValSign = 1;
  5661. }
  5662. break;
  5663. case RULE_MaxInterval:
  5664. /* MaxInterval */
  5665. if (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtNumAttr
  5666. || n >= MAX_INT_ATTR_VAL)
  5667. /* ce n'est pas un attribut a valeur numerique */
  5668. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5669. LineNum);
  5670. else
  5671. {
  5672. if (CurAttrLowerBound > n * AttrValSign)
  5673. CompilerMessage (wi, PRS, FATAL, INVALID_LOWER_BOUND, inputLine,
  5674. LineNum);
  5675. else
  5676. CurAttrUpperBound = n * AttrValSign;
  5677. /* a priori, la prochaine valeur */
  5678. /* d'attribut numerique sera positive */
  5679. AttrValSign = 1;
  5680. }
  5681. break;
  5682. case RULE_ValEqual:
  5683. /* ValEqual */
  5684. if (Conditions)
  5685. /* an attribute value in a condition "if attr = nnn" */
  5686. {
  5687. if (pSSchema->SsAttribute->TtAttr[Conditions->CoTypeAttr - 1]->AttrType != AtNumAttr
  5688. || n >= MAX_INT_ATTR_VAL)
  5689. /* ce n'est pas un attribut a valeur numerique */
  5690. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5691. LineNum);
  5692. else
  5693. Conditions->CoAttrValue = n * AttrValSign;
  5694. }
  5695. else
  5696. {
  5697. if (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtNumAttr
  5698. || n >= MAX_INT_ATTR_VAL)
  5699. /* ce n'est pas un attribut a valeur numerique */
  5700. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5701. LineNum);
  5702. else
  5703. CurAttrUpperBound = CurAttrLowerBound = n * AttrValSign;
  5704. }
  5705. /* a priori, la prochaine valeur d'attribut numerique sera positive */
  5706. AttrValSign = 1;
  5707. break;
  5708. case RULE_MinCounterVal:
  5709. if (n >= MAX_COUNTER_VAL)
  5710. CompilerMessage (wi, PRS, FATAL, BAD_COUNTER_VALUE, inputLine,LineNum);
  5711. else
  5712. {
  5713. Conditions->CoMinCounter = n * CurCondCntSign + 1;
  5714. /* a priori, la prochaine borne sera positive */
  5715. CurCondCntSign = 1;
  5716. }
  5717. break;
  5718. case RULE_MaxCounterVal:
  5719. if (n >= MAX_COUNTER_VAL)
  5720. CompilerMessage (wi, PRS, FATAL, BAD_COUNTER_VALUE, inputLine,LineNum);
  5721. else
  5722. {
  5723. Conditions->CoMaxCounter = n * CurCondCntSign - 1;
  5724. /* a priori, la prochaine borne sera positive */
  5725. CurCondCntSign = 1;
  5726. }
  5727. break;
  5728. case RULE_MinCounterInter:
  5729. if (n >= MAX_COUNTER_VAL)
  5730. CompilerMessage (wi, PRS, FATAL, BAD_COUNTER_VALUE, inputLine,LineNum);
  5731. else
  5732. {
  5733. Conditions->CoMinCounter = n * CurCondCntSign;
  5734. /* a priori, la prochaine borne sera positive */
  5735. CurCondCntSign = 1;
  5736. }
  5737. break;
  5738. case RULE_MaxCounterInter:
  5739. if (n >= MAX_COUNTER_VAL)
  5740. CompilerMessage (wi, PRS, FATAL, BAD_COUNTER_VALUE, inputLine,LineNum);
  5741. else if (Conditions->CoMinCounter > n * CurCondCntSign)
  5742. CompilerMessage (wi, PRS, FATAL, INVALID_LOWER_BOUND, inputLine,
  5743. LineNum);
  5744. else
  5745. {
  5746. Conditions->CoMaxCounter = n * CurCondCntSign;
  5747. /* a priori, la prochaine borne sera positive */
  5748. CurCondCntSign = 1;
  5749. }
  5750. break;
  5751. case RULE_CounterValEqual:
  5752. if (n >= MAX_COUNTER_VAL)
  5753. CompilerMessage (wi, PRS, FATAL, BAD_COUNTER_VALUE, inputLine,LineNum);
  5754. else
  5755. {
  5756. Conditions->CoMaxCounter = Conditions->CoMinCounter =
  5757. n * CurCondCntSign;
  5758. /* a priori, la prochaine borne sera positive */
  5759. CurCondCntSign = 1;
  5760. }
  5761. break;
  5762. case RULE_ImageType:
  5763. /* c'est le type d'une image */
  5764. pPSchema->PsConstant[pPSchema->PsNConstants - 1].PdScript = n;
  5765. break;
  5766. default:
  5767. break;
  5768. }
  5769. }
  5770. /*----------------------------------------------------------------------
  5771. ProcessString traitee une chaine de caracteres.
  5772. ----------------------------------------------------------------------*/
  5773. static void ProcessString (SyntacticCode gCode, indLine wl, indLine wi)
  5774. {
  5775. int i;
  5776. PresConstant *pPresConst;
  5777. char *ptr;
  5778. if (gCode == RULE_ConstValue || gCode == RULE_FileName ||
  5779. gCode == RULE_ListStyleImageURI)
  5780. /* c'est une valeur de constante ou le nom de fichier d'une image de fond
  5781. ou l'URI d'une image de liste */
  5782. if (wl > MAX_PRES_CONST_LEN)
  5783. CompilerMessage (wi, PRS, FATAL, MAX_CHAR_STRING_SIZE_OVERFLOW,
  5784. inputLine, LineNum);
  5785. else
  5786. {
  5787. if (gCode == RULE_ListStyleImageURI)
  5788. {
  5789. NewConst (wi);
  5790. CurRule->PrValueType = PrNumValue;
  5791. CurRule->PrIntValue = pPSchema->PsNConstants;
  5792. }
  5793. pPresConst = &pPSchema->PsConstant[pPSchema->PsNConstants - 1];
  5794. if (inputLine[wi - 1] == EOS)
  5795. pPresConst->PdString = NULL;
  5796. else
  5797. {
  5798. ptr = (char *) TtaGetMemory (wl);
  5799. pPresConst->PdString = ptr;
  5800. for (i = 0; i < wl - 1; i++)
  5801. ptr[i] = inputLine[wi + i - 1];
  5802. ptr[wl - 1] = EOS;
  5803. }
  5804. }
  5805. else if (gCode == RULE_TextEqual)
  5806. /* TextEqual c'est une valeur d'attribut */
  5807. {
  5808. if (wl >= MAX_NAME_LENGTH)
  5809. CompilerMessage (wi, PRS, FATAL, MAX_CHAR_STRING_SIZE_OVERFLOW,
  5810. inputLine, LineNum);
  5811. else if (Conditions)
  5812. /* an attribute value in a condition such as if attr = "some text" */
  5813. {
  5814. if (pSSchema->SsAttribute->TtAttr[Conditions->CoTypeAttr - 1]->AttrType != AtTextAttr)
  5815. /* ce n'est pas un attribut a valeur textuelle */
  5816. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5817. LineNum);
  5818. else
  5819. Conditions->CoAttrTextValue = TtaStrdup ((char *)inputLine);
  5820. }
  5821. else
  5822. {
  5823. if (pSSchema->SsAttribute->TtAttr[CurAttrNum - 1]->AttrType != AtTextAttr)
  5824. /* ce n'est pas un attribut a valeur textuelle */
  5825. CompilerMessage (wi, PRS, FATAL, INVALID_ATTR_VALUE, inputLine,
  5826. LineNum);
  5827. else
  5828. {
  5829. CurTextDefined = TRUE;
  5830. for (i = 0; i < wl - 1; i++)
  5831. CurTextEqual[i] = inputLine[wi + i - 1];
  5832. CurTextEqual[wl - 1] = EOS;
  5833. }
  5834. }
  5835. }
  5836. }
  5837. /*----------------------------------------------------------------------
  5838. ProcessToken traite le token commencant a la position wi dans
  5839. la ligne courante, de longueur wl et de code grammatical c.
  5840. Si c'est un identificateur, nb contient son rang dans la table
  5841. des identificateurs. r est le numero de la regle dans laquelle
  5842. apparait ce mot, pr est le numero de la regle precedente, celle
  5843. qui a appele la regle r.
  5844. ----------------------------------------------------------------------*/
  5845. static void ProcessToken (indLine wi, indLine wl, SyntacticCode c,
  5846. SyntacticCode r, int identnum, SyntacticCode pr)
  5847. {
  5848. if (c < 1000)
  5849. /* symbole intermediaire de la grammaire, erreur */
  5850. CompilerMessage (wi, PRS, FATAL, INTERMEDIATE_SYMBOL, inputLine, LineNum);
  5851. else if (c < 1100)
  5852. /* mot-cle court */
  5853. ProcessShortKeyWord (c, wi, r);
  5854. else if (c < 2000)
  5855. /* mot-cle long */
  5856. ProcessLongKeyWord (c, r, wi);
  5857. else
  5858. /* type de base */
  5859. switch (c)
  5860. {
  5861. case 3001:
  5862. /* un nom */
  5863. ProcessName (r, identnum, pr, wl, wi);
  5864. break;
  5865. case 3002:
  5866. /* un nombre */
  5867. ProcessInteger (r, wl, wi);
  5868. break;
  5869. case 3003:
  5870. /* une chaine de caracteres */
  5871. ProcessString (r, wl, wi);
  5872. break;
  5873. }
  5874. }
  5875. /*----------------------------------------------------------------------
  5876. RuleBefore
  5877. Return TRUE if pPRule1 must occur before pPRule2 in a sequence of
  5878. presentation rules.
  5879. ----------------------------------------------------------------------*/
  5880. static ThotBool RuleBefore (PtrPRule pPRule1, PtrPRule pPRule2)
  5881. {
  5882. ThotBool ret;
  5883. /* first criterion is the rule type */
  5884. if (pPRule1->PrType != pPRule2->PrType)
  5885. ret = pPRule1->PrType < pPRule2->PrType;
  5886. else
  5887. /* same type */
  5888. if (pPRule1->PrType == PtFunction)
  5889. {
  5890. /* both rules are presentation functions, next criterion is */
  5891. /* the function code. */
  5892. if (pPRule1->PrPresFunction != pPRule2->PrPresFunction)
  5893. /* same presentation function */
  5894. ret = pPRule1->PrPresFunction < pPRule2->PrPresFunction;
  5895. else
  5896. /* same presentation function, the next criterion is the view
  5897. number */
  5898. ret = pPRule1->PrViewNum < pPRule2->PrViewNum;
  5899. }
  5900. else
  5901. {
  5902. /* It's not a presentation function, the next criterion is the
  5903. view number */
  5904. if (pPRule1->PrViewNum != pPRule2->PrViewNum)
  5905. ret = pPRule1->PrViewNum < pPRule2->PrViewNum;
  5906. else
  5907. /* same type and same view: rule with no condition or with
  5908. the default condition ("otherwise") must occur first */
  5909. ret = (!pPRule1->PrCond ||
  5910. pPRule1->PrCond->CoCondition == PcDefaultCond);
  5911. }
  5912. return ret;
  5913. }
  5914. /*----------------------------------------------------------------------
  5915. SortPresRules
  5916. ----------------------------------------------------------------------*/
  5917. static void SortPresRules (PtrPRule * firstPRule)
  5918. {
  5919. PtrPRule oldPRule, curOldPRule, newPRule, curNewPRule, newAnchor;
  5920. ThotBool done, stop;
  5921. if (*firstPRule != NULL)
  5922. {
  5923. oldPRule = *firstPRule;
  5924. newAnchor = NULL;
  5925. /* parcourt l'ancienne chaine des regles pointee par firstPRule */
  5926. while (oldPRule != NULL)
  5927. {
  5928. curOldPRule = oldPRule;
  5929. /* regle courante de l'ancienne chaine */
  5930. oldPRule = oldPRule->PrNextPRule;
  5931. if (newAnchor == NULL)
  5932. {
  5933. newAnchor = curOldPRule;
  5934. curOldPRule->PrNextPRule = NULL;
  5935. }
  5936. else
  5937. {
  5938. newPRule = NULL;
  5939. curNewPRule = newAnchor;
  5940. done = False;
  5941. stop = False;
  5942. /* parcourt la nouvelle chaine */
  5943. while (!stop)
  5944. if (RuleBefore (curOldPRule, curNewPRule))
  5945. {
  5946. if (newPRule == NULL)
  5947. /* insere curOldPRule en tete */
  5948. {
  5949. curOldPRule->PrNextPRule = newAnchor;
  5950. newAnchor = curOldPRule;
  5951. }
  5952. else
  5953. /* insere curOldPRule apres newPRule */
  5954. {
  5955. curOldPRule->PrNextPRule = newPRule->PrNextPRule;
  5956. newPRule->PrNextPRule = curOldPRule;
  5957. }
  5958. done = True;
  5959. stop = True;
  5960. }
  5961. else
  5962. {
  5963. newPRule = curNewPRule;
  5964. curNewPRule = curNewPRule->PrNextPRule;
  5965. if (curNewPRule == NULL)
  5966. stop = True;
  5967. }
  5968. if (!done)
  5969. /* ajoute curOldPRule a la fin de la nouvelle chaine, */
  5970. /* apres newPRule */
  5971. {
  5972. if (newPRule != NULL)
  5973. newPRule->PrNextPRule = curOldPRule;
  5974. else
  5975. newAnchor = oldPRule;
  5976. curOldPRule->PrNextPRule = NULL;
  5977. }
  5978. }
  5979. }
  5980. *firstPRule = newAnchor;
  5981. }
  5982. }
  5983. /*----------------------------------------------------------------------
  5984. SortAllPRules met les regles de presentation dans le bon ordre
  5985. pour l'application des regles lors de la production des images
  5986. abstraites.
  5987. ----------------------------------------------------------------------*/
  5988. void SortAllPRules ()
  5989. {
  5990. int j, l;
  5991. int k;
  5992. AttributePres *pPRuleA;
  5993. /* ordonne les regles par defaut */
  5994. SortPresRules (&pPSchema->PsFirstDefaultPRule);
  5995. /* ordonne les regles des boites de presentation */
  5996. for (j = 0; j < pPSchema->PsNPresentBoxes; j++)
  5997. SortPresRules (&pPSchema->PsPresentBox->PresBox[j]->PbFirstPRule);
  5998. /* ordonne les regles des valeurs d'attribut */
  5999. for (j = 0; j < pSSchema->SsNAttributes; j++)
  6000. {
  6001. /* pour chaque paquet de regles */
  6002. pPRuleA = pPSchema->PsAttrPRule->AttrPres[j];
  6003. for (l = pPSchema->PsNAttrPRule->Num[j]; l-- > 0;
  6004. pPRuleA = pPRuleA->ApNextAttrPres)
  6005. {
  6006. /* selon le type de l'attribut */
  6007. switch (pSSchema->SsAttribute->TtAttr[j]->AttrType)
  6008. {
  6009. case AtNumAttr:
  6010. for (k = 0; k < pPRuleA->ApNCases; k++)
  6011. SortPresRules (&pPRuleA->ApCase[k].CaFirstPRule);
  6012. break;
  6013. case AtTextAttr:
  6014. SortPresRules (&pPRuleA->ApTextFirstPRule);
  6015. break;
  6016. case AtReferenceAttr:
  6017. SortPresRules (&pPRuleA->ApRefFirstPRule);
  6018. break;
  6019. case AtEnumAttr:
  6020. for (k = 0; k <= pSSchema->SsAttribute->TtAttr[j]->AttrNEnumValues; k++)
  6021. SortPresRules (&pPRuleA->ApEnumFirstPRule[k]);
  6022. break;
  6023. default:
  6024. break;
  6025. }
  6026. }
  6027. }
  6028. /* ordonne les regles des elements structures */
  6029. for (j = 0; j < pSSchema->SsNRules; j++)
  6030. SortPresRules (&pPSchema->PsElemPRule->ElemPres[j]);
  6031. }
  6032. /*----------------------------------------------------------------------
  6033. PageCounter determine si le compteur de numero counter est
  6034. un compteur de page. Retourne Vrai si c'est un compteur de
  6035. pages, Faux sinon.
  6036. ----------------------------------------------------------------------*/
  6037. static ThotBool PageCounter (int counter)
  6038. {
  6039. Counter *pCntr;
  6040. ThotBool ret;
  6041. pCntr = &pPSchema->PsCounter[counter - 1];
  6042. ret = ((pCntr->CnItem[0].CiCntrOp == CntrRank
  6043. && pCntr->CnItem[0].CiElemType == PageBreak + 1)
  6044. || (pCntr->CnItem[0].CiCntrOp == CntrSet
  6045. && pCntr->CnItem[1].CiElemType == PageBreak + 1));
  6046. return ret;
  6047. }
  6048. /*----------------------------------------------------------------------
  6049. SearchPRule cherche pour la vue view une regle de type ruleType
  6050. dans la chaine de regles dont l'ancre est firstRule. Retourne
  6051. un pointeur sur cette regle si elle existe ou insere une regle
  6052. de ce type dans la chaine et retourne un pointeur sur la
  6053. regle creee.
  6054. ----------------------------------------------------------------------*/
  6055. static PtrPRule SearchPRule (PtrPRule *firstRule, PRuleType ruleType, int view,
  6056. ThotBool *newRule)
  6057. {
  6058. PtrPRule pR, pPRule;
  6059. ThotBool stop, cree;
  6060. *newRule = False;
  6061. pR = *firstRule;
  6062. pPRule = NULL;
  6063. stop = False;
  6064. do
  6065. {
  6066. if (pR == NULL)
  6067. stop = True;
  6068. else if (pR->PrType >= ruleType)
  6069. stop = True;
  6070. if (!stop)
  6071. {
  6072. pPRule = pR;
  6073. pR = pR->PrNextPRule;
  6074. }
  6075. }
  6076. while (!stop);
  6077. stop = False;
  6078. do
  6079. {
  6080. if (pR == NULL)
  6081. stop = True;
  6082. else if (pR->PrType != ruleType || pR->PrViewNum >= view)
  6083. stop = True;
  6084. if (!stop)
  6085. {
  6086. pPRule = pR;
  6087. pR = pR->PrNextPRule;
  6088. }
  6089. }
  6090. while (!stop);
  6091. if (pR == NULL)
  6092. cree = True;
  6093. else if (pR->PrType > ruleType || pR->PrViewNum > view)
  6094. cree = True;
  6095. else
  6096. cree = False;
  6097. if (cree)
  6098. /* il n'y a pas de regle de ce type, on en cree une */
  6099. {
  6100. GetPresentRule (&pR);
  6101. if (pR == NULL)
  6102. TtaDisplaySimpleMessage (FATAL, PRS, NO_MORE_MEM_LEFT);
  6103. else
  6104. {
  6105. *newRule = True;
  6106. pR->PrType = ruleType;
  6107. /* on insere la regle cree */
  6108. if (pPRule == NULL)
  6109. {
  6110. pR->PrNextPRule = *firstRule;
  6111. *firstRule = pR;
  6112. }
  6113. else
  6114. {
  6115. pR->PrNextPRule = pPRule->PrNextPRule;
  6116. pPRule->PrNextPRule = pR;
  6117. }
  6118. pR->PrCond = NULL;
  6119. pR->PrViewNum = view;
  6120. pR->PrSpecifAttr = 0;
  6121. pR->PrSpecifAttrSSchema = NULL;
  6122. }
  6123. }
  6124. return pR;
  6125. }
  6126. /*----------------------------------------------------------------------
  6127. CheckPageBoxes verifie que toutes les boites de presentation
  6128. declarees pour les pages sont bien utilisees et adapte les
  6129. regles des boites pages.
  6130. ----------------------------------------------------------------------*/
  6131. static void CheckPageBoxes ()
  6132. {
  6133. PtrPRule pR, pHeadR, pPRule, pRule;
  6134. int b, hfB, el, view, footHeight, headHeight, h, i, counter;
  6135. ThotBool stop, stop1, exist, newRule;
  6136. PtrPresentationBox pPresBox;
  6137. PresVariable *pPresVar;
  6138. PtrCondition pCond;
  6139. NumberTable *viewOfBox;
  6140. viewOfBox = (NumberTable*) malloc (pPSchema->PsNPresentBoxes * sizeof (int));
  6141. memset (viewOfBox, 0, pPSchema->PsNPresentBoxes * sizeof (int));
  6142. /* a priori les boites de presentation ne sont pas des boites pages */
  6143. for (b = 0; b < pPSchema->PsNPresentBoxes; b++)
  6144. {
  6145. viewOfBox->Num[b] = 0;
  6146. pPresBox = pPSchema->PsPresentBox->PresBox[b];
  6147. pPresBox->PbPageBox = False;
  6148. pPresBox->PbPageFooter = False;
  6149. pPresBox->PbPageHeader = False;
  6150. }
  6151. /* a priori les compteurs ne sont pas utilise's en bas de page */
  6152. for (b = 0; b < pPSchema->PsNCounters; b++)
  6153. pPSchema->PsCounter[b].CnPageFooter = False;
  6154. /* recherche toutes les regles PAGE dans le schema de presentation */
  6155. /* et marque les boites pages utilisees par ces regles. */
  6156. for (el = 0; el < pSSchema->SsNRules; el++)
  6157. /* cherche dans les regles de */
  6158. /* presentation de chaque type d'element */
  6159. {
  6160. pR = pPSchema->PsElemPRule->ElemPres[el];
  6161. /* 1ere regle de pres. du type */
  6162. stop = False;
  6163. do
  6164. {
  6165. if (pR == NULL)
  6166. stop = True;
  6167. else if (pR->PrType > PtFunction)
  6168. stop = True;
  6169. if (!stop)
  6170. {
  6171. if (pR->PrType == PtFunction
  6172. && pR->PrPresFunction == FnPage)
  6173. /* c'est une regle Page */
  6174. /* marque la boite page */
  6175. {
  6176. b = pR->PrPresBox[0];
  6177. /* b: numero de la boite page */
  6178. /* note la vue concernee par cette boite page, si */
  6179. /* elle n'est pas deja notee */
  6180. if (viewOfBox->Num[b - 1] == 0)
  6181. viewOfBox->Num[b - 1] = pR->PrViewNum;
  6182. pPSchema->PsPresentBox->PresBox[b - 1]->PbPageBox =True;
  6183. pPSchema->PsPresentBox->PresBox[b - 1]->PbPageCounter = 0;
  6184. /* verifie que la boite page a une largeur et une hauteur */
  6185. /* absolues */
  6186. /* cherche la regle de hauteur d'abord */
  6187. pRule = pPSchema->PsPresentBox->PresBox[b - 1]->PbFirstPRule;
  6188. stop1 = False;
  6189. exist = False;
  6190. do
  6191. {
  6192. if (pRule == NULL)
  6193. stop1 = True;
  6194. else if (pRule->PrType > PtHeight)
  6195. stop1 = True;
  6196. else if (pRule->PrType == PtHeight)
  6197. {
  6198. stop1 = True;
  6199. exist = True;
  6200. }
  6201. if (!stop1)
  6202. pRule = pRule->PrNextPRule;
  6203. }
  6204. while (!stop1);
  6205. if (!exist)
  6206. /* il n'y a pas de regle de hauteur, erreur */
  6207. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, BAD_HEIGHT_RULE), pPSchema->PsPresentBox->PresBox[b - 1]->PbName);
  6208. else if (!pRule->PrDimRule.DrAbsolute
  6209. || pRule->PrDimRule.DrUnit == UnRelative
  6210. || pRule->PrDimRule.DrPosition)
  6211. /* ce n'est pas une hauteur absolue fixe, erreur */
  6212. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, BAD_HEIGHT_RULE), pPSchema->PsPresentBox->PresBox[b - 1]->PbName);
  6213. /* cherche la regle de largeur */
  6214. pRule = pPSchema->PsPresentBox->PresBox[b - 1]->PbFirstPRule;
  6215. stop1 = False;
  6216. exist = False;
  6217. do
  6218. {
  6219. if (pRule == NULL)
  6220. stop1 = True;
  6221. else if (pRule->PrType > PtWidth)
  6222. stop1 = True;
  6223. else if (pRule->PrType == PtWidth)
  6224. {
  6225. stop1 = True;
  6226. exist = True;
  6227. }
  6228. if (!stop1)
  6229. pRule = pRule->PrNextPRule;
  6230. }
  6231. while (!stop1);
  6232. if (!exist)
  6233. /* il n'y a pas de regle de largeur, erreur */
  6234. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, BAD_WIDTH_RULE), pPSchema->PsPresentBox->PresBox[b - 1]->PbName);
  6235. else if (!pRule->PrDimRule.DrAbsolute
  6236. || pRule->PrDimRule.DrUnit == UnRelative
  6237. || pRule->PrDimRule.DrPosition)
  6238. /* ce n'est pas une largeur absolue fixe, erreur */
  6239. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, BAD_WIDTH_RULE), pPSchema->PsPresentBox->PresBox[b - 1]->PbName);
  6240. /* cherche la regle de position verticale */
  6241. /* de la boite page */
  6242. pRule = pPSchema->PsPresentBox->PresBox[b - 1]->PbFirstPRule;
  6243. stop1 = False;
  6244. exist = False;
  6245. do
  6246. {
  6247. if (pRule == NULL)
  6248. stop1 = True;
  6249. else if (pRule->PrType > PtVertPos)
  6250. stop1 = True;
  6251. else if (pRule->PrType == PtVertPos)
  6252. {
  6253. stop1 = True;
  6254. exist = True;
  6255. }
  6256. if (!stop1)
  6257. pRule = pRule->PrNextPRule;
  6258. }
  6259. while (!stop1);
  6260. if (!exist)
  6261. /* il n'y a pas de regle de position verticale, erreur */
  6262. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, BAD_VERTPOS_RULE), pPSchema->PsPresentBox->PresBox[b - 1]->PbName);
  6263. else
  6264. {
  6265. if (pRule->PrPosRule.PoPosDef != Top
  6266. /* position du cote superieur */
  6267. || pRule->PrPosRule.PoPosRef != Top
  6268. /* par rapport au cote sup. */
  6269. || pRule->PrPosRule.PoRelation != RlEnclosing
  6270. /* de l'englobant */
  6271. || (pRule->PrPosRule.PoDistUnit == UnRelative && pRule->PrPosRule.PoDistance != 0))
  6272. /* et distance absolue */
  6273. /* ce n'est pas un positionnement correct, erreur */
  6274. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, BAD_VERTPOS_RULE), pPSchema->PsPresentBox->PresBox[b - 1]->PbName);
  6275. }
  6276. /* cherche la regle de position horizontale */
  6277. pRule = pPSchema->PsPresentBox->PresBox[b - 1]->PbFirstPRule;
  6278. stop1 = False;
  6279. exist = False;
  6280. do
  6281. {
  6282. if (pRule == NULL)
  6283. stop1 = True;
  6284. else if (pRule->PrType > PtHorizPos)
  6285. stop1 = True;
  6286. else if (pRule->PrType == PtHorizPos)
  6287. {
  6288. stop1 = True;
  6289. exist = True;
  6290. }
  6291. if (!stop1)
  6292. pRule = pRule->PrNextPRule;
  6293. }
  6294. while (!stop1);
  6295. if (!exist)
  6296. /* il n'y a pas de regle de position horiz., erreur */
  6297. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, BAD_HORIZPOS_RULE), pPSchema->PsPresentBox->PresBox[b - 1]->PbName);
  6298. else
  6299. {
  6300. if (pRule->PrPosRule.PoPosDef != Left
  6301. /* position du cote gauche */
  6302. || pRule->PrPosRule.PoPosRef != Left
  6303. /* par rapport au cote gauche */
  6304. || pRule->PrPosRule.PoRelation != RlEnclosing
  6305. /* de l'englobant */
  6306. || (pRule->PrPosRule.PoDistUnit == UnRelative && pRule->PrPosRule.PoDistance != 0))
  6307. /* et distance absolue */
  6308. /* ce n'est pas un positionnement correct, erreur */
  6309. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, BAD_HORIZPOS_RULE), pPSchema->PsPresentBox->PresBox[b - 1]->PbName);
  6310. }
  6311. }
  6312. pR = pR->PrNextPRule;
  6313. /* passe a la regle suivante */
  6314. }
  6315. }
  6316. while (!stop);
  6317. }
  6318. /* Toutes les boites pages sont maintenant marquees */
  6319. /* Cherche les boites creees par les boites pages (ce sont les */
  6320. /* boites de haut et de bas de page) et marque ces boites. Calcule la */
  6321. /* hauteur minimum des bas de page. */
  6322. for (b = 0; b < pPSchema->PsNPresentBoxes; b++)
  6323. /* examine chaque boite */
  6324. if (pPSchema->PsPresentBox->PresBox[b]->PbPageBox)
  6325. /* c'est une boite page */
  6326. {
  6327. footHeight = 0;
  6328. headHeight = 0;
  6329. /* cherche les regles de creation de la boite page */
  6330. pR = pPSchema->PsPresentBox->PresBox[b]->PbFirstPRule;
  6331. /* 1ere regle de presentation */
  6332. /* parcourt les premieres regles de la boite page */
  6333. stop = False;
  6334. do
  6335. {
  6336. if (pR == NULL)
  6337. stop = True;
  6338. else if (pR->PrType > PtFunction)
  6339. stop = True;
  6340. if (!stop)
  6341. {
  6342. if (pR->PrType == PtFunction &&
  6343. (pR->PrPresFunction == FnCreateBefore ||
  6344. pR->PrPresFunction == FnCreateWith ||
  6345. pR->PrPresFunction == FnCreateFirst ||
  6346. pR->PrPresFunction == FnCreateLast ||
  6347. pR->PrPresFunction == FnCreateAfter))
  6348. /* c'est une regle de creation */
  6349. {
  6350. if (!(pR->PrPresFunction == FnCreateBefore ||
  6351. pR->PrPresFunction == FnCreateAfter))
  6352. /* ce n'est pas une regle de creation autorisee, erreur */
  6353. TtaDisplayMessage (FATAL,
  6354. TtaGetMessage (PRS, FORBIDDEN_CREA_RULE),
  6355. pPSchema->PsPresentBox->PresBox[b]->PbName);
  6356. else
  6357. /* la regle pR est une regle CreateAfter ou */
  6358. /* a CreateBefore */
  6359. {
  6360. hfB = pR->PrPresBox[0] - 1;
  6361. /* numero de la boite de haut ou de bas de page */
  6362. /* la boite de haut ou de bas de page appartient */
  6363. /* la meme vue que la boite page qui la cree */
  6364. viewOfBox->Num[hfB] = viewOfBox->Num[b];
  6365. /* cherche la regle de positionnement vertical de */
  6366. /* la boite creee par la boite page */
  6367. pPRule = pPSchema->PsPresentBox->PresBox[hfB]->PbFirstPRule;
  6368. stop1 = False;
  6369. exist = False;
  6370. do
  6371. {
  6372. if (pPRule == NULL)
  6373. stop1 = True;
  6374. else if (pPRule->PrType > PtVertPos)
  6375. stop1 = True;
  6376. else if (pPRule->PrType == PtVertPos)
  6377. {
  6378. stop1 = True;
  6379. exist = True;
  6380. }
  6381. if (!stop1)
  6382. pPRule = pPRule->PrNextPRule;
  6383. }
  6384. while (!stop1);
  6385. if (!exist)
  6386. /* pas de regle de positionnement vertical, erreur */
  6387. TtaDisplayMessage (FATAL,
  6388. TtaGetMessage (PRS, MISSING_VERTIC_POS_IN_THE_PAGE),
  6389. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6390. else
  6391. {
  6392. if (!(pPRule->PrPosRule.PoPosDef == Top ||
  6393. pPRule->PrPosRule.PoPosDef == Bottom ||
  6394. pPRule->PrPosRule.PoPosDef == HorizMiddle) ||
  6395. pPRule->PrPosRule.PoNotRel ||
  6396. pPRule->PrPosRule.PoRefKind != RkElType ||
  6397. pPRule->PrPosRule.PoRefIdent != PageBreak + 1)
  6398. TtaDisplayMessage (FATAL,
  6399. TtaGetMessage (PRS, INVALID_VERTIC_POS_IN_PAGE),
  6400. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6401. if (pPRule->PrPosRule.PoDistance != 0)
  6402. if (pPRule->PrPosRule.PoDistUnit == UnRelative)
  6403. TtaDisplayMessage (FATAL,
  6404. TtaGetMessage (PRS, VERTIC_DIST_ISNT_CONSTANT),
  6405. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6406. if (pPRule->PrPosRule.PoRelation == RlPrevious)
  6407. /* la boite creee est positionnee par rapport */
  6408. /* au haut de la page */
  6409. {
  6410. pPSchema->PsPresentBox->PresBox[hfB]->PbPageHeader = True;
  6411. /* cherche la regle de hauteur de la boite de */
  6412. /* haut de page */
  6413. pHeadR = pPSchema->PsPresentBox->PresBox[hfB]->PbFirstPRule;
  6414. stop1 = False;
  6415. exist = False;
  6416. do
  6417. {
  6418. if (pHeadR == NULL)
  6419. stop1 = True;
  6420. else if (pHeadR->PrType > PtHeight)
  6421. stop1 = True;
  6422. else if (pHeadR->PrType == PtHeight)
  6423. {
  6424. stop1 = True;
  6425. exist = True;
  6426. }
  6427. if (!stop1)
  6428. pHeadR = pHeadR->PrNextPRule;
  6429. }
  6430. while (!stop1);
  6431. /* si pas de regle de hauteur, pas d'erreur */
  6432. if (exist)
  6433. {
  6434. if (pHeadR->PrDimRule.DrPosition)
  6435. /* c'est une hauteur elastique, erreur */
  6436. TtaDisplayMessage (FATAL,
  6437. TtaGetMessage (PRS, BAD_HEIGHT_RULE),
  6438. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6439. else if (!pHeadR->PrDimRule.DrAbsolute)
  6440. /* c'est une hauteur relative, on n'accepte */
  6441. /* que la hauteur du contenu */
  6442. {
  6443. if (pHeadR->PrDimRule.DrRelation != RlEnclosed)
  6444. TtaDisplayMessage (FATAL,
  6445. TtaGetMessage (PRS, BAD_HEIGHT_RULE),
  6446. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6447. }
  6448. else
  6449. /* regle de hauteur absolue */
  6450. if (pHeadR->PrDimRule.DrUnit == UnRelative)
  6451. /* la hauteur n'est pas en unites fixes */
  6452. TtaDisplayMessage (FATAL,
  6453. TtaGetMessage (PRS, BAD_HEIGHT_RULE),
  6454. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6455. else
  6456. /* calcule la distance entre le bas de la */
  6457. /* boite de haut de page et le haut de la page */
  6458. /* calcule la distance entre le bas de la */
  6459. /* boite de precedente et le bas de la */
  6460. /* boite creee (haut ou bas) */
  6461. /* ce code n'a plus vraiment de sens car */
  6462. /* le plus souvent, la hauteur des hauts et */
  6463. /* et bas de page est donnee par leur contenu */
  6464. /* (plusieurs boites filles) */
  6465. /* donc, c'est le mediateur qui peut calculer */
  6466. /* ces valeurs (cf. code de page.c) */
  6467. {
  6468. switch (pPRule->PrPosRule.PoPosDef)
  6469. {
  6470. case Bottom:
  6471. h = pPRule->PrPosRule.PoDistance;
  6472. break;
  6473. case Top:
  6474. h = pPRule->PrPosRule.PoDistance +
  6475. pHeadR->PrDimRule.DrValue;
  6476. break;
  6477. case HorizMiddle:
  6478. h = pPRule->PrPosRule.PoDistance +
  6479. pHeadR->PrDimRule.DrValue / 2;
  6480. break;
  6481. default:
  6482. h = 0;
  6483. break;
  6484. }
  6485. if (h > headHeight)
  6486. headHeight = h;
  6487. }
  6488. }
  6489. } /* fin boite haut de page */
  6490. else if (pPRule->PrPosRule.PoRelation == RlNext)
  6491. /* la boite creee est positionnee par rapport */
  6492. /* au bas de la page, c'est une boite de bas de page */
  6493. {
  6494. pPSchema->PsPresentBox->PresBox[hfB]->PbPageFooter = True;
  6495. /* cherche la regle de hauteur de la boite de */
  6496. /* bas de page */
  6497. pHeadR = pPSchema->PsPresentBox->PresBox[hfB]->PbFirstPRule;
  6498. stop1 = False;
  6499. exist = False;
  6500. do
  6501. {
  6502. if (pHeadR == NULL)
  6503. stop1 = True;
  6504. else if (pHeadR->PrType > PtHeight)
  6505. stop1 = True;
  6506. else if (pHeadR->PrType == PtHeight)
  6507. {
  6508. stop1 = True;
  6509. exist = True;
  6510. }
  6511. if (!stop1)
  6512. pHeadR = pHeadR->PrNextPRule;
  6513. }
  6514. while (!stop1);
  6515. if (!exist)
  6516. /* il n'y a pas de regle de hauteur, erreur */
  6517. TtaDisplayMessage (FATAL,
  6518. TtaGetMessage (PRS, BAD_HEIGHT_RULE),
  6519. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6520. else
  6521. if (pHeadR->PrDimRule.DrPosition)
  6522. /* c'est une hauteur elastique, erreur */
  6523. TtaDisplayMessage (FATAL,
  6524. TtaGetMessage (PRS, BAD_HEIGHT_RULE),
  6525. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6526. else if (!pHeadR->PrDimRule.DrAbsolute)
  6527. /* c'est une hauteur relative, on n'accepte */
  6528. /* que la hauteur du contenu */
  6529. {
  6530. if (pHeadR->PrDimRule.DrRelation != RlEnclosed)
  6531. TtaDisplayMessage (FATAL,
  6532. TtaGetMessage (PRS, BAD_HEIGHT_RULE),
  6533. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6534. }
  6535. else
  6536. /* regle de hauteur absolue */
  6537. if (pHeadR->PrDimRule.DrUnit == UnRelative)
  6538. /* la hauteur n'est pas en unites fixes */
  6539. TtaDisplayMessage (FATAL,
  6540. TtaGetMessage (PRS, BAD_HEIGHT_RULE),
  6541. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6542. else
  6543. /* calcule la distance entre le haut de la */
  6544. /* boite de bas de page et le bas de la page */
  6545. /* calcule la distance entre le bas de la */
  6546. /* boite de precedente et le bas de la */
  6547. /* boite creee (haut ou bas) */
  6548. /* ce code n'a plus vraiment de sens car */
  6549. /* le plus souvent, la hauteur des hauts et */
  6550. /* et bas de page est donnee par leur contenu */
  6551. /* (plusieurs boites filles) */
  6552. /* donc, c'est le mediateur qui peut calculer */
  6553. /* ces valeurs (cf. code de page.c) */
  6554. {
  6555. switch (pPRule->PrPosRule.PoPosDef)
  6556. {
  6557. case Top:
  6558. h = pPRule->PrPosRule.PoDistance;
  6559. break;
  6560. case Bottom:
  6561. h = pPRule->PrPosRule.PoDistance +
  6562. pHeadR->PrDimRule.DrValue;
  6563. break;
  6564. case HorizMiddle:
  6565. h = pPRule->PrPosRule.PoDistance +
  6566. pHeadR->PrDimRule.DrValue / 2;
  6567. break;
  6568. default:
  6569. h = 0;
  6570. break;
  6571. }
  6572. if (h > footHeight)
  6573. footHeight = h;
  6574. }
  6575. }
  6576. else
  6577. /* la boite creee n'est pas positionnee par */
  6578. /* rapport a la page, erreur */
  6579. TtaDisplayMessage (FATAL,
  6580. TtaGetMessage (PRS, INVALID_VERTIC_POS_IN_PAGE),
  6581. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6582. /* examine les conditions de creation de la boite de */
  6583. /* haut ou de bas de page, a la recherche d'un */
  6584. /* compteur de page qui determine la creation de la */
  6585. /* boite de haut ou de bas de page. */
  6586. pCond = pR->PrCond;
  6587. while (pCond != NULL)
  6588. {
  6589. if (pCond->CoCondition == PcInterval ||
  6590. pCond->CoCondition == PcEven ||
  6591. pCond->CoCondition == PcOdd ||
  6592. pCond->CoCondition == PcOne)
  6593. {
  6594. counter = pCond->CoCounter;
  6595. if (PageCounter (counter))
  6596. {
  6597. /* c'est un compteur de pages */
  6598. if (pPSchema->PsPresentBox->PresBox[b]->PbPageCounter > 0)
  6599. /* il y a deja un compteur de page */
  6600. {
  6601. if (pPSchema->PsPresentBox->PresBox[b]->PbPageCounter != counter)
  6602. /* ce n'est pas le meme compteur */
  6603. TtaDisplayMessage (FATAL,
  6604. TtaGetMessage (PRS, USES_DIFFERENT_PAGE_COUNTERS),
  6605. pPSchema->PsPresentBox->PresBox[b]->PbName);
  6606. }
  6607. else
  6608. /* on a trouve' le compteur de pages associe' */
  6609. /* a ce type de page */
  6610. pPSchema->PsPresentBox->PresBox[b]->PbPageCounter = counter;
  6611. }
  6612. }
  6613. pCond = pCond->CoNextCondition;
  6614. }
  6615. /* la boite de haut ou de bas de page contient-elle */
  6616. /* le numero de page ? */
  6617. if (pPSchema->PsPresentBox->PresBox[hfB]->PbContent == ContVariable)
  6618. /* la boite contient une variable */
  6619. {
  6620. pPresVar = pPSchema->PsVariable->PresVar[pPSchema->PsPresentBox->PresBox[hfB]->PbContVariable - 1];
  6621. for (i = 0; i < pPresVar->PvNItems; i++)
  6622. if (pPresVar->PvItem[i].ViType == VarCounter)
  6623. /* la variable contient une valeur de */
  6624. /* compteur, on examine ce compteur */
  6625. {
  6626. counter = pPresVar->PvItem[i].ViCounter;
  6627. if (PageCounter (counter))
  6628. /* c'est un compteur de pages */
  6629. {
  6630. if (pPSchema->PsPresentBox->PresBox[b]->PbPageCounter > 0)
  6631. /* il y a deja un compteur de page */
  6632. {
  6633. if (pPSchema->PsPresentBox->PresBox[b]->PbPageCounter !=
  6634. counter)
  6635. /* ce n'est pas le meme compteur */
  6636. TtaDisplayMessage (FATAL,
  6637. TtaGetMessage (PRS, TWO_DIFFERENT_PAGE_NUMBERS),
  6638. pPSchema->PsPresentBox->PresBox[hfB]->PbName);
  6639. }
  6640. else
  6641. /* on trouve' le compteur de pages */
  6642. pPSchema->PsPresentBox->PresBox[b]->PbPageCounter = counter;
  6643. pPSchema->PsCounter[counter - 1].CnPageFooter =
  6644. pPSchema->PsPresentBox->PresBox[hfB]->PbPageFooter;
  6645. }
  6646. }
  6647. }
  6648. } /* fin regle de position verticale OK */
  6649. }
  6650. }
  6651. /* passe a la regle suivante de b */
  6652. pR = pR->PrNextPRule;
  6653. }
  6654. }
  6655. while (!stop);
  6656. /* on a traite' toutes les boites de haut et de bas de page de */
  6657. /* cette boite page */
  6658. pPSchema->PsPresentBox->PresBox[b]->PbFooterHeight = footHeight;
  6659. pPSchema->PsPresentBox->PresBox[b]->PbHeaderHeight = headHeight;
  6660. /* prevoir d'ajouter le positionnement de RPDimMin du corps */
  6661. /* de page */
  6662. }
  6663. /* les boites de haut et de bas de page sont maintenant marquees */
  6664. /* verifie que seules les boites pages et les boites de haut et de */
  6665. /* bas de page creent d'autres boites */
  6666. for (b = 0; b < pPSchema->PsNPresentBoxes; b++)
  6667. {
  6668. /* examine chaque boite */
  6669. pPresBox = pPSchema->PsPresentBox->PresBox[b];
  6670. /* cherche les regles de creation de la boite */
  6671. pR = pPresBox->PbFirstPRule;
  6672. /* 1ere regle de presentation */
  6673. /* parcourt les premieres regles de la boite */
  6674. stop = False;
  6675. do
  6676. {
  6677. if (pR == NULL)
  6678. stop = True;
  6679. else if (pR->PrType > PtFunction)
  6680. stop = True;
  6681. if (!stop)
  6682. {
  6683. if (pR->PrType == PtFunction
  6684. && (pR->PrPresFunction == FnCreateBefore
  6685. || pR->PrPresFunction == FnCreateAfter))
  6686. /* ce n'est pas une regle de creation autorisee */
  6687. if (!pPresBox->PbPageBox)
  6688. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, FORBIDDEN_CREA_RULE),
  6689. pPSchema->PsPresentBox->PresBox[b]->PbName);
  6690. pR = pR->PrNextPRule;
  6691. /* passe a la regle suivante */
  6692. }
  6693. }
  6694. while (!stop);
  6695. }
  6696. /* verifie les regles de l'element PAGE_UNIT */
  6697. for (view = 1; view <= pPSchema->PsNViews; view++)
  6698. /* cherche la regle de positionnement vertical */
  6699. {
  6700. pR = SearchPRule (&pPSchema->PsElemPRule->ElemPres[PageBreak],
  6701. PtVertPos, view, &newRule);
  6702. /* modifie la regle: positionnement au-dessous de l'element */
  6703. /* precedent */
  6704. pR->PrPresMode = PresImmediate;
  6705. pR->PrPosRule.PoPosDef = Top;
  6706. pR->PrPosRule.PoPosRef = Bottom;
  6707. pR->PrPosRule.PoDistUnit = UnPoint;
  6708. pR->PrPosRule.PoDeltaUnit = UnPoint;
  6709. pR->PrPosRule.PoDistance = 0;
  6710. pR->PrPosRule.PoDistDelta = 0;
  6711. pR->PrPosRule.PoRelation = RlPrevious;
  6712. pR->PrPosRule.PoNotRel = False;
  6713. pR->PrPosRule.PoRefKind = RkElType;
  6714. pR->PrPosRule.PoUserSpecified = False;
  6715. pR->PrPosRule.PoRefIdent = 0;
  6716. /* cherche la regle de positionnement horizontal */
  6717. pR = SearchPRule (&pPSchema->PsElemPRule->ElemPres[PageBreak],
  6718. PtHorizPos, view, &newRule);
  6719. /* modifie la regle: positionnement sur le bord gauche de la */
  6720. /* boite racine */
  6721. pR->PrPresMode = PresImmediate;
  6722. pR->PrPosRule.PoPosDef = Left;
  6723. pR->PrPosRule.PoPosRef = Left;
  6724. pR->PrPosRule.PoDistUnit = UnPoint;
  6725. pR->PrPosRule.PoDistDelta = UnPoint;
  6726. pR->PrPosRule.PoDistance = 0;
  6727. pR->PrPosRule.PoDistDelta = 0;
  6728. pR->PrPosRule.PoRelation = RlRoot;
  6729. pR->PrPosRule.PoNotRel = False;
  6730. pR->PrPosRule.PoRefKind = RkElType;
  6731. pR->PrPosRule.PoUserSpecified = False;
  6732. pR->PrPosRule.PoRefIdent = 0;
  6733. /* cherche la regle de largeur */
  6734. pR = SearchPRule (&pPSchema->PsElemPRule->ElemPres[PageBreak],
  6735. PtWidth, view, &newRule);
  6736. /* modifie la regle: largeur du contenu */
  6737. pR->PrPresMode = PresImmediate;
  6738. pR->PrDimRule.DrPosition = False;
  6739. pR->PrDimRule.DrAbsolute = False;
  6740. pR->PrDimRule.DrSameDimens = True;
  6741. pR->PrDimRule.DrUnit = UnRelative;
  6742. pR->PrDimRule.DrValue = 0;
  6743. pR->PrDimRule.DrRelation = RlEnclosed;
  6744. pR->PrDimRule.DrNotRelat = False;
  6745. pR->PrDimRule.DrRefKind = RkElType;
  6746. pR->PrDimRule.DrUserSpecified = False;
  6747. pR->PrDimRule.DrRefIdent = 0;
  6748. /* cherche la regle de hauteur */
  6749. pR = SearchPRule (&pPSchema->PsElemPRule->ElemPres[PageBreak],
  6750. PtHeight, view, &newRule);
  6751. /* modifie la regle: hauteur du contenu */
  6752. pR->PrPresMode = PresImmediate;
  6753. pR->PrDimRule.DrPosition = False;
  6754. pR->PrDimRule.DrAbsolute = False;
  6755. pR->PrDimRule.DrSameDimens = True;
  6756. pR->PrDimRule.DrUnit = UnRelative;
  6757. pR->PrDimRule.DrValue = 0;
  6758. pR->PrDimRule.DrRelation = RlEnclosed;
  6759. pR->PrDimRule.DrNotRelat = False;
  6760. pR->PrDimRule.DrRefKind = RkElType;
  6761. pR->PrDimRule.DrUserSpecified = False;
  6762. pR->PrDimRule.DrRefIdent = 0;
  6763. /* modifie la regle: HorizOverflow: True; */
  6764. pR = SearchPRule (&pPSchema->PsElemPRule->ElemPres[PageBreak],
  6765. PtHorizOverflow, view, &newRule);
  6766. pR->PrType = PtHorizOverflow;
  6767. pR->PrPresMode = PresImmediate;
  6768. pR->PrBoolValue = True;
  6769. }
  6770. free (viewOfBox);
  6771. }
  6772. /*----------------------------------------------------------------------
  6773. CheckUsedBoxes parcourt la chaine de regles de presentation
  6774. commencant par la regle pointee par pRule et cherche toutes les
  6775. regles de creation ou de mise en page. Marque utilisee la
  6776. boite de presentation utilisee dans ces regles
  6777. ----------------------------------------------------------------------*/
  6778. static void CheckUsedBoxes (PtrPRule pRule, BoolTable *usedBox)
  6779. {
  6780. int i;
  6781. ThotBool stop;
  6782. stop = False;
  6783. do
  6784. {
  6785. if (pRule == NULL)
  6786. stop = True;
  6787. /* derniere regle de la chaine */
  6788. else if (pRule->PrType > PtFunction)
  6789. stop = True;
  6790. /* on a vu la partie interessante de la chaine */
  6791. if (!stop)
  6792. {
  6793. if (pRule->PrType == PtFunction
  6794. && (pRule->PrPresFunction == FnPage
  6795. || pRule->PrPresFunction == FnCreateEnclosing
  6796. || pRule->PrPresFunction == FnCreateBefore
  6797. || pRule->PrPresFunction == FnCreateWith
  6798. || pRule->PrPresFunction == FnCreateFirst
  6799. || pRule->PrPresFunction == FnCreateLast
  6800. || pRule->PrPresFunction == FnCreateAfter))
  6801. /* c'est une regle de creation ou une regle Page */
  6802. /* marque la boite utilisee */
  6803. usedBox->Bln[pRule->PrPresBox[0] - 1] = True;
  6804. else if (pRule->PrType == PtFunction
  6805. && (pRule->PrPresFunction == FnColumn || pRule->PrPresFunction == FnSubColumn))
  6806. /* c'est une regle de colonnage */
  6807. for (i = 0; i < pRule->PrNPresBoxes; i++)
  6808. usedBox->Bln[pRule->PrPresBox[i] - 1] = True;
  6809. pRule = pRule->PrNextPRule;
  6810. /* passe a la regle suivante */
  6811. }
  6812. }
  6813. while (!stop);
  6814. }
  6815. /*----------------------------------------------------------------------
  6816. CheckAllBoxesUsed verifie que toutes les boites de presentation
  6817. declarees dans le schema sont bien utilisees dans une regle de
  6818. creation ou une regle Page
  6819. ----------------------------------------------------------------------*/
  6820. static void CheckAllBoxesUsed ()
  6821. {
  6822. int b, el, att, k, l;
  6823. BoolTable *usedBox;
  6824. AttributePres *pPRuleA;
  6825. usedBox = (BoolTable*) malloc (pPSchema->PsNPresentBoxes * sizeof(ThotBool));
  6826. memset (usedBox, 0, pPSchema->PsNPresentBoxes * sizeof (ThotBool));
  6827. /* marque d'abord qu'aucune boite de presentation n'est utilisee */
  6828. for (b = 0; b < pPSchema->PsNPresentBoxes; b++)
  6829. usedBox->Bln[b] = False;
  6830. /* recherche toutes les regles de creation associees aux boites de */
  6831. /* presentation et marque les boites utilisees par ces regles. */
  6832. for (b = 0; b < pPSchema->PsNPresentBoxes; b++)
  6833. CheckUsedBoxes (pPSchema->PsPresentBox->PresBox[b]->PbFirstPRule,
  6834. usedBox);
  6835. /* recherche toutes les regles de creation et les regles PAGE associees aux */
  6836. /* types d'elements et marque les boites utilisees par ces regles. */
  6837. for (el = 0; el < pSSchema->SsNRules; el++)
  6838. /* cherche dans les regles de */
  6839. /* presentation de chaque type d'element */
  6840. CheckUsedBoxes (pPSchema->PsElemPRule->ElemPres[el], usedBox);
  6841. /* recherche toutes les regles de creation associees aux attributs et */
  6842. /* marque les boites utilisees par ces regles. */
  6843. for (att = 0; att < pSSchema->SsNAttributes; att++)
  6844. /* cherche dans les regles de presentation des attributs */
  6845. {
  6846. pPRuleA = pPSchema->PsAttrPRule->AttrPres[att];
  6847. for (l = pPSchema->PsNAttrPRule->Num[att]; l-- > 0; pPRuleA = pPRuleA->ApNextAttrPres)
  6848. {
  6849. /* selon le type de l'attribut */
  6850. switch (pSSchema->SsAttribute->TtAttr[att]->AttrType)
  6851. {
  6852. case AtNumAttr:
  6853. for (k = 0; k < pPRuleA->ApNCases; k++)
  6854. CheckUsedBoxes (pPRuleA->ApCase[k].CaFirstPRule, usedBox);
  6855. break;
  6856. case AtTextAttr:
  6857. CheckUsedBoxes (pPRuleA->ApTextFirstPRule, usedBox);
  6858. break;
  6859. case AtReferenceAttr:
  6860. CheckUsedBoxes (pPRuleA->ApRefFirstPRule, usedBox);
  6861. break;
  6862. case AtEnumAttr:
  6863. for (k = 0; k <= pSSchema->SsAttribute->TtAttr[att]->AttrNEnumValues; k++)
  6864. CheckUsedBoxes (pPRuleA->ApEnumFirstPRule[k], usedBox);
  6865. break;
  6866. default:
  6867. break;
  6868. }
  6869. }
  6870. }
  6871. /* sort un message pour chaque boite inutilisee */
  6872. for (b = 0; b < pPSchema->PsNPresentBoxes; b++)
  6873. if (!usedBox->Bln[b])
  6874. TtaDisplayMessage (INFO, TtaGetMessage (PRS, UNUSED_BOX), pPSchema->PsPresentBox->PresBox[b]->PbName);
  6875. free (usedBox);
  6876. }
  6877. /*----------------------------------------------------------------------
  6878. main
  6879. ----------------------------------------------------------------------*/
  6880. #ifdef _WINGUI
  6881. int PRSmain (HWND hwnd, HWND statusBar, int argc, char **argv, int *Y)
  6882. #else /* !_WINGUI */
  6883. int main (int argc, char **argv)
  6884. #endif /* _WINGUI */
  6885. {
  6886. FILE *infile;
  6887. Name srceFileName; /* nom du fichier a compiler */
  6888. indLine wi; /* position du debut du mot courant dans la
  6889. ligne en cours */
  6890. indLine wl; /* longueur du mot courant */
  6891. SyntacticType wn; /* SyntacticType grammaticale du mot courant */
  6892. SyntRuleNum r; /* numero de regle de grammaire */
  6893. SyntRuleNum pr; /* numero de la regle de grammaire precedente*/
  6894. SyntacticCode c; /* code grammatical du mot trouve */
  6895. char *pwd, *ptr;
  6896. char fname[200], buffer[200];
  6897. int nb; /* indice dans Identifier du mot trouve', si
  6898. identificateur */
  6899. int i;
  6900. int param;
  6901. PtrPRule pR;
  6902. #ifdef _WINGUI
  6903. char *CMD;
  6904. char *cmd[100];
  6905. int ndx, pIndex = 0;
  6906. char msg[800];
  6907. HANDLE cppLib;
  6908. /* FARPROC ptrMainProc; */
  6909. typedef int (*MYPROC) (HWND, int, char **, int *);
  6910. MYPROC ptrMainProc;
  6911. #else /* !_WINGUI */
  6912. char cmd[800];
  6913. #endif /* _WINGUI */
  6914. ThotBool fileOK, newRule;
  6915. #ifdef _WINGUI
  6916. COMPWnd = hwnd;
  6917. compilersDC = GetDC (hwnd);
  6918. _CY_ = *Y;
  6919. strcpy (msg, "Executing prs ");
  6920. for (ndx = 1; ndx < argc; ndx++)
  6921. {
  6922. strcat (msg, argv [ndx]);
  6923. strcat (msg, " ");
  6924. }
  6925. TtaDisplayMessage (INFO, msg);
  6926. SendMessage (statusBar, SB_SETTEXT, (WPARAM) 0, (LPARAM) &msg[0]);
  6927. SendMessage (statusBar, WM_PAINT, (WPARAM) 0, (LPARAM) 0);
  6928. #endif /* _WINGUI */
  6929. TtaInitializeAppRegistry (argv[0]);
  6930. i = TtaGetMessageTable ("libdialogue", TMSG_LIB_MSG_MAX);
  6931. COMPIL = TtaGetMessageTable ("compildialogue", COMP_MSG_MAX);
  6932. PRS = TtaGetMessageTable ("prsdialogue", PRS_MSG_MAX);
  6933. error = False;
  6934. /* initialize the parser */
  6935. InitParser ();
  6936. /* load the compiler grammar */
  6937. InitSyntax ("PRESEN.GRM");
  6938. if (!error)
  6939. {
  6940. /* prepare the cpp command */
  6941. #ifdef _WINGUI
  6942. cmd [pIndex] = (char *) TtaGetMemory (4);
  6943. strcpy (cmd [pIndex++], "cpp");
  6944. #else /* !_WINGUI */
  6945. strcpy (cmd, CPP " ");
  6946. #endif /* _WINGUI */
  6947. param = 1;
  6948. while (param < argc && argv[param][0] == '-')
  6949. {
  6950. /* keep cpp params */
  6951. #ifdef _WINGUI
  6952. cmd [pIndex] = (char *) TtaGetMemory (strlen (argv[param]) + 1);
  6953. strcpy (cmd [pIndex++], argv[param]);
  6954. #else /* !_WINGUI */
  6955. strcat (cmd, argv[param]);
  6956. strcat (cmd, " ");
  6957. #endif /* _WINGUI */
  6958. param++;
  6959. }
  6960. /* recupere d'abord le nom du schema a compiler */
  6961. if (param >= argc)
  6962. {
  6963. TtaDisplaySimpleMessage (FATAL, PRS, UNKNOWN_FILE);
  6964. #ifdef _WINGUI
  6965. ReleaseDC (hwnd, compilersDC);
  6966. return FATAL_EXIT_CODE;
  6967. #else /* _WINGUI */
  6968. exit (1);
  6969. #endif /* _WINGUI */
  6970. }
  6971. strncpy (srceFileName, argv[param], MAX_NAME_LENGTH - 1);
  6972. srceFileName[MAX_NAME_LENGTH - 1] = EOS;
  6973. param++;
  6974. strcpy (fname, srceFileName);
  6975. /* check if the name contains a suffix */
  6976. ptr = strrchr(fname, '.');
  6977. nb = strlen (srceFileName);
  6978. if (!ptr) /* there is no suffix */
  6979. strcat (srceFileName, ".P");
  6980. else if (strcmp(ptr, ".P"))
  6981. {
  6982. /* it's not the valid suffix */
  6983. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, INVALID_FILE), srceFileName);
  6984. #ifdef _WINGUI
  6985. ReleaseDC (hwnd, compilersDC);
  6986. return FATAL_EXIT_CODE;
  6987. #else /* _WINGUI */
  6988. exit (1);
  6989. #endif /* _WINGUI */
  6990. }
  6991. else
  6992. {
  6993. /* it's the valid suffix, cut the srcFileName here */
  6994. ptr[0] = EOS;
  6995. nb -= 2; /* length without the suffix */
  6996. }
  6997. /* add the suffix .SCH in srceFileName */
  6998. strcat (fname, ".SCH");
  6999. /* does the file to compile exist */
  7000. if (!TtaFileExist(srceFileName))
  7001. TtaDisplaySimpleMessage (FATAL, PRS, UNKNOWN_FILE);
  7002. else
  7003. {
  7004. /* provide the real source file */
  7005. TtaFileUnlink (fname);
  7006. pwd = TtaGetEnvString ("PWD");
  7007. #ifndef _WINGUI
  7008. i = strlen (cmd);
  7009. #endif /* _WINGUI */
  7010. if (pwd != NULL)
  7011. {
  7012. #ifdef _WINGUI
  7013. CMD = (char *) TtaGetMemory (3 + strlen (pwd));
  7014. sprintf (CMD, "-I%s", pwd);
  7015. cmd [pIndex] = (char *) TtaGetMemory (3 + strlen (pwd));
  7016. strcpy (cmd [pIndex++], CMD);
  7017. cmd [pIndex] = (char *) TtaGetMemory (3);
  7018. strcpy (cmd [pIndex++], "-C");
  7019. cmd [pIndex] = (char *) TtaGetMemory (strlen (srceFileName) + 1);
  7020. strcpy (cmd [pIndex++], srceFileName);
  7021. cmd [pIndex] = (char *) TtaGetMemory (strlen (fname) + 1);
  7022. strcpy (cmd [pIndex++], fname);
  7023. #else /* !_WINGUI */
  7024. sprintf (&cmd[i], "-I%s -C %s > %s", pwd, srceFileName, fname);
  7025. #endif /* _WINGUI */
  7026. }
  7027. else
  7028. {
  7029. #ifdef _WINGUI
  7030. cmd [pIndex] = (char *) TtaGetMemory (3);
  7031. strcpy (cmd [pIndex++], "-C");
  7032. cmd [pIndex] = (char *) TtaGetMemory (strlen (srceFileName) + 1);
  7033. strcpy (cmd [pIndex++], srceFileName);
  7034. cmd [pIndex] = (char *) TtaGetMemory (strlen (fname) + 1);
  7035. strcpy (cmd [pIndex++], fname);
  7036. #else /* !_WINGUI */
  7037. sprintf (&cmd[i], "-C %s > %s", srceFileName, fname);
  7038. #endif /* _WINGUI */
  7039. }
  7040. #ifdef _WINGUI
  7041. cppLib = LoadLibrary ("cpp");
  7042. ptrMainProc = (MYPROC) GetProcAddress ((HMODULE)cppLib, "CPPmain");
  7043. i = ptrMainProc (hwnd, pIndex, cmd, &_CY_);
  7044. FreeLibrary ((HMODULE)cppLib);
  7045. for (ndx = 0; ndx < pIndex; ndx++)
  7046. {
  7047. free (cmd [ndx]);
  7048. cmd [ndx] = (char*) 0;
  7049. }
  7050. #else /* _WINGUI */
  7051. i = system (cmd);
  7052. #endif /* _WINGUI */
  7053. if (i == FATAL_EXIT_CODE)
  7054. {
  7055. /* cpp is not available, copy directely the file */
  7056. TtaDisplaySimpleMessage (INFO, PRS, CPP_NOT_FOUND);
  7057. TtaFileCopy (srceFileName, fname);
  7058. }
  7059. infile = TtaReadOpen (fname);
  7060. if (param == argc)
  7061. /* the output name is equal to the input name */
  7062. /*suppress the suffix ".SCH" */
  7063. srceFileName[nb] = EOS;
  7064. else
  7065. /* read the output name */
  7066. strncpy (srceFileName, argv[param], MAX_NAME_LENGTH - 1);
  7067. /* le fichier a compiler est ouvert */
  7068. NIdentifiers = 0; /* table des identificateurs vide */
  7069. LineNum = 0; /* encore aucune ligne lue */
  7070. pSSchema = NULL; /* pas (encore) de schema de structure */
  7071. /* lit tout le fichier et fait l'analyse */
  7072. fileOK = True;
  7073. while (fileOK && !error)
  7074. {
  7075. /* lit une ligne */
  7076. LineNum++; /* incremente le compteur de lignes lues */
  7077. i = 0;
  7078. do
  7079. {
  7080. fileOK = TtaReadByte (infile, &inputLine[i]);
  7081. i++;
  7082. }
  7083. while (i < LINE_LENGTH && inputLine[i - 1] != '\n' && fileOK);
  7084. /* marque la fin reelle de la ligne */
  7085. inputLine[i - 1] = EOS;
  7086. if (i >= LINE_LENGTH) /* ligne trop longue */
  7087. CompilerMessage (1, PRS, FATAL, MAX_LINE_SIZE_OVERFLOW, inputLine, LineNum);
  7088. else if (inputLine[0] == '#')
  7089. {
  7090. /* cette ligne contient une directive du preprocesseur cpp */
  7091. sscanf ((char *)inputLine, "# %d %s", &LineNum, buffer);
  7092. LineNum--;
  7093. }
  7094. else
  7095. {
  7096. /* traduit tous les caracteres de la ligne */
  7097. OctalToChar ();
  7098. /* analyse la ligne */
  7099. wi = 1;
  7100. wl = 0;
  7101. /* analyse tous les mots de la ligne courante */
  7102. do
  7103. {
  7104. i = wi + wl;
  7105. GetNextToken (i, &wi, &wl, &wn);
  7106. /* mot suivant */
  7107. if (wi > 0)
  7108. {
  7109. /* word found */
  7110. AnalyzeToken (wi, wl, wn, &c, &r, &nb, &pr);
  7111. /* analyze the word */
  7112. if (!error)
  7113. ProcessToken (wi, wl, c, r, nb - 1, pr); /* on le traite */
  7114. }
  7115. }
  7116. while (wi != 0 && !error);
  7117. /* il n'y a plus de mots a analyser dans la ligne */
  7118. }
  7119. }
  7120. /* end of file */
  7121. TtaReadClose (infile);
  7122. if (!error)
  7123. ParserEnd ();
  7124. /* fin d'analyse */
  7125. if (!error)
  7126. {
  7127. /* met les regles de presentation dans le bon ordre. */
  7128. SortAllPRules ();
  7129. /* si aucune vue n'est definie, cree la vue par defaut avec */
  7130. /* un nom standard */
  7131. if (pPSchema->PsNViews == 0)
  7132. {
  7133. pPSchema->PsNViews = 1;
  7134. strcpy (pPSchema->PsView[0],
  7135. TtaGetMessage (PRS, SINGLE_VIEW));
  7136. pPSchema->PsHostViewList[0] = NULL;
  7137. }
  7138. /* check that there exists a FillRule rule in the default
  7139. presentation rules */
  7140. pR = SearchPRule (&pPSchema->PsFirstDefaultPRule, PtFillRule,
  7141. 1, &newRule);
  7142. if (newRule)
  7143. /* there was no FillRule in the default presentation rules.
  7144. Make an inheritance rule. */
  7145. pR->PrPresMode = PresInherit;
  7146. /* verifie que toutes les boites de presentation declarees */
  7147. /* pour les pages sont bien utilisees et adapte les regles. */
  7148. /* cela ne peut se faire qu'apres avoir ajoute' la vue par */
  7149. /* defaut */
  7150. CheckPageBoxes ();
  7151. /* verifie que toutes les boites de presentation sont bien */
  7152. /* utilisees */
  7153. CheckAllBoxesUsed ();
  7154. /* write the compiled schema into the output file */
  7155. /* remove temporary file */
  7156. TtaFileUnlink (fname);
  7157. strcat (srceFileName, ".PRS");
  7158. fileOK = WritePresentationSchema (srceFileName, pPSchema,
  7159. pSSchema);
  7160. if (!fileOK)
  7161. TtaDisplayMessage (FATAL, TtaGetMessage (PRS, WRITE_ERROR),
  7162. srceFileName);
  7163. }
  7164. }
  7165. }
  7166. // fflush (stdout);
  7167. TtaSaveAppRegistry ();
  7168. #ifdef _WINGUI
  7169. *Y = _CY_ ;
  7170. ReleaseDC (hwnd, compilersDC);
  7171. if (error)
  7172. return FATAL_EXIT_CODE ;
  7173. return COMP_SUCCESS;
  7174. #else /* _WINGUI */
  7175. exit (0);
  7176. #endif /* _WINGUI */
  7177. }