PageRenderTime 60ms CodeModel.GetById 17ms 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

Large files files are truncated, but you can click here to view the full 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 !=

Large files files are truncated, but you can click here to view the full file