Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

365 lines
12 KiB

  1. /*****************************************************************************
  2. emact.h
  3. Owner: DaleG
  4. Copyright (c) 1997 Microsoft Corporation
  5. Delayed Action Interpreter mechanism, shared header file.
  6. *****************************************************************************/
  7. #ifndef _EMACT_H
  8. #define _EMACT_H
  9. #include "emrultk.h"
  10. MSOEXTERN_C_BEGIN // ***************** Begin extern "C" ********************
  11. #define iactAllocMax 256
  12. /* M S O A C T */
  13. /*----------------------------------------------------------------------------
  14. %%Structure: MSOACT
  15. %%Contact: daleg
  16. Delayed-Action structure. Used to pass argument values to functions
  17. delay-called from the rulebase.
  18. ----------------------------------------------------------------------------*/
  19. typedef struct _MSOACT
  20. {
  21. union
  22. {
  23. struct
  24. {
  25. short actt; // Action type
  26. MSOBF fComposite : 1; // Composite action?
  27. MSOBF fValidate : 1; // Check if act OK?
  28. MSOBF fAdjust : 1; // Adjusting CA?
  29. MSOBF fDeferred : 1; // Deferred eval?
  30. long rgl[8]; // Arg values, 1st rec
  31. struct _MSOACT *pactSublist; // Child record
  32. } rec1;
  33. struct
  34. {
  35. long hdrCA; // Shared rec1 header
  36. MSOCA ca; // Edit range
  37. } rec1_ca;
  38. long hdr; // Shared header
  39. long rglSublist[10]; // Arg values, 2nd+ rec
  40. char *rszSublist[10]; // Arg values, 2nd+ rec
  41. };
  42. struct _MSOACT *pactNext; // Next record
  43. } MSOACT;
  44. #define msoacttNil (-1) // Out of range actt
  45. #define msopactNULL ((MSOACT *) (-1)) // End of list marker
  46. // Return object pointer of (first record of) a pact
  47. #define PObjectPact(pact) \
  48. ((pact)->rec1_ca.ca.pObject)
  49. // Return cpFirst of (first record of) a pact
  50. #define CpFirstPact(pact) \
  51. ((pact)->rec1_ca.ca.cpFirst)
  52. // Return cpLim of (first record of) a pact
  53. #define CpLimPact(pact) \
  54. ((pact)->rec1_ca.ca.cpLim)
  55. /* M S O A C T B L K */
  56. /*----------------------------------------------------------------------------
  57. %%Function: MSOACTBLK
  58. %%Contact: daleg
  59. Delayed-Action structure allocation block.
  60. ----------------------------------------------------------------------------*/
  61. typedef struct _MSOACTBLK
  62. {
  63. struct _MSOACTBLK *pactblkNext; // Next alloc block
  64. MSOACT rgact[iactAllocMax]; // Array of MSOACTs
  65. } MSOACTBLK;
  66. /* M S O A C T T R E C */
  67. /*----------------------------------------------------------------------------
  68. %%Function: MSOACTTREC
  69. %%Contact: daleg
  70. Action-type table record. Holds flags associated with actt values.
  71. ----------------------------------------------------------------------------*/
  72. typedef struct _MSOACTTREC
  73. {
  74. short cargs; // Num of args to fn
  75. unsigned short actf; // Action flags
  76. } MSOACTTREC;
  77. // Base action flags
  78. #define msoactfExclusiveEdit 0x0001 // Truncates other acts
  79. #define msoactfTruncatable 0x0002 // Trucated by Excl act
  80. #define msoactfNonExclPaired 0x0004 // Trunc unless paired
  81. // "User"-level action flags
  82. #define msoactfNonEdit 0x0000 // Not an edit
  83. #define msoactfEdit 0x0003 // e.g. Edits
  84. #define msoactfProp 0x0002 // e.g. Props
  85. #define msoactfPairedProp 0x0004 // Props paired w/edits
  86. #define msoactfOverlapCalc 0x0007 // Overlap calc necess
  87. #define msoactfCond 0x0010 // Cond exec next act
  88. #define msoactfConposite 0x0020 // Composite action
  89. // Return whether the action is a composite, composed of multiple records
  90. #define MsoFCompositeAct(actt, pacttbl) \
  91. MsoFActfActt(actt, msoactfConposite, pacttbl)
  92. // Return whether ACT record has actf flag set
  93. #define MsoFActfActt(actt, actfMask, pacttbl) \
  94. (MsoActfActt((actt), (pacttbl)) & (actfMask))
  95. // Return whether ACT record has actf flag set
  96. #define MsoFActfIs(actf, actfMask) \
  97. ((actf) & (actfMask))
  98. // Return whether ACT record type has actf flag set
  99. #define MsoFActfActtIs(actt, actfMatch, pacttbl) \
  100. (MsoActfActt((actt), (pacttbl)) == (actfMatch))
  101. // Return whether ACT record type has actf flag set
  102. #define MsoActfActt(actt, pacttbl) \
  103. (MsoPActtrec((actt), (pacttbl))->actf)
  104. // Return action record (MSOACTTREC) associated with ACT record
  105. #define MsoPActtrec(actt, pacttbl) \
  106. (&(pacttbl)->rgacttrec[actt])
  107. /* M S O A C T T B L */
  108. /*----------------------------------------------------------------------------
  109. %%Structure: MSOACTTBL
  110. %%Contact: daleg
  111. Action-type table. Contains MSOACT state and action flags.
  112. ----------------------------------------------------------------------------*/
  113. typedef struct _MSOACTTBL
  114. {
  115. const MSOACTTREC *rgacttrec; // Per-action data
  116. MSOCP cpFirstEditPrev; // 1st CP of last edit
  117. MSOCP dcpEditPrev; // dCP of last edit
  118. MSOCP cpLimEdit; // cpLim, edit so far
  119. MSORULTKH *prultkh; // Text Token cache
  120. MSOACT *pactPending; // Pending actions
  121. MSOACT *pactPendingPrev; // Prev pending acts
  122. MSOACT *pactFree; // Free list
  123. MSOACTBLK *pactblkAlloc; // Allocation list
  124. } MSOACTTBL;
  125. // Start a new MSOACT action list frame
  126. #define MsoPushPactPending() \
  127. MsoBeginActSublist((_pacttbl), &(_pacttbl)->pactPendingPrev)
  128. // End and close a new MSOACT sub-list, and return sublist
  129. #define MsoPopPactPending(ppact) \
  130. (*(ppact) = (_pacttbl)->pactPending, \
  131. MsoEndActSublist((_pacttbl), &(_pacttbl)->pactPendingPrev))
  132. // Start a new MSOACT action list frame
  133. __inline void MsoBeginActSublist(MSOACTTBL *pacttbl, MSOACT **ppactPrev)
  134. {
  135. *ppactPrev = pacttbl->pactPending;
  136. pacttbl->pactPending = (MSOACT *) NULL;
  137. }
  138. // End and close a new MSOACT sub-list
  139. __inline void MsoEndActSublist(MSOACTTBL *pacttbl, MSOACT **ppactPrev)
  140. {
  141. pacttbl->pactPending = *ppactPrev;
  142. *ppactPrev = (MSOACT *) NULL;
  143. }
  144. // Callback to evaluate the MSOACT
  145. typedef long (WIN_CALLBACK * MSOPFNACT)(
  146. MSOACT *pact,
  147. MSOACTTBL *pacttbl,
  148. long *pdcp, // IN, RETURN
  149. MSOCA *pcaAdjusted,
  150. MSOACT **ppactNext, // RETURN
  151. int *pfDiscard // RETURN
  152. );
  153. // Are there pending action records?
  154. #define MsoPendingActions(pacttbl) \
  155. ((pacttbl)->pactPending)
  156. // Return value for args 0-7
  157. #define MsoLPact(pact, iarg) \
  158. ((pact)->rec1.rgl[iarg])
  159. // Return value for args 8-17
  160. #define MsoLPact2(pact, iarg) \
  161. ((pact)->rec1.pactSublist->rglSublist[(iarg) - 8])
  162. // Return value for args 18-27
  163. #define MsoLPact3(pact, iarg) \
  164. ((pact)->rec1.pactSublist-> \
  165. ((pact)->rec1.pactSublist->pactNext->rglSublist[(iarg) - 18])
  166. // Return value for args 28-31
  167. #define MsoLPact4(pact, iarg) \
  168. ((pact)->rec1.pactSublist->pactNext->pactNext \
  169. ->rglSublist[(iarg) - 28])
  170. MSOCDECLAPI_(MSOACT *) MsoPact( // Build new MSOACT rec
  171. MSOACTTBL *pacttbl,
  172. int actt,
  173. ...
  174. );
  175. MSOCDECLAPI_(MSOACT *) MsoPactNq( // As above, not queued
  176. MSOACTTBL *pacttbl,
  177. int actt,
  178. ...
  179. );
  180. MSOCDECLAPI_(MSOACT *) MsoPactDtk( // Bld MSOACT rec w/tks
  181. MSOACTTBL *pacttbl,
  182. int actt,
  183. int dtkStart,
  184. int dtk,
  185. ...
  186. );
  187. MSOCDECLAPI_(MSOACT *) MsoPactDtkNq( // As above, not queued
  188. MSOACTTBL *pacttbl,
  189. int actt,
  190. int dtkStart,
  191. int dtk,
  192. ...
  193. );
  194. MSOCDECLAPI_(MSOACT *) MsoPactPca( // Bld MSOACT rec w/CPs
  195. MSOACTTBL *pacttbl,
  196. int actt,
  197. MSOCA *pca,
  198. ...
  199. );
  200. MSOCDECLAPI_(MSOACT *) MsoPactPcaNq( // As above, not queued
  201. MSOACTTBL *pacttbl,
  202. int actt,
  203. MSOCA *pca,
  204. ...
  205. );
  206. MSOAPI_(MSOACT *) MsoPactCompositeDtk( // Bld Composite action
  207. MSOACTTBL *pacttbl,
  208. int actt,
  209. int dtkStart,
  210. int dtk,
  211. MSOACT **ppactPrev
  212. );
  213. void SetPactCaFromSublist(MSOACT *pact); // Set CA of Comp pact
  214. #define MsoReversePactPending(pacttbl) \
  215. MsoReversePact(&pacttbl->pactPending) // Reverse pending acts
  216. MSOAPI_(void) MsoReversePact(MSOACT **ppact); // Reverse ACT list
  217. MSOAPI_(long) MsoDcpDoActs( // Execute ACT list
  218. MSOACT **ppact,
  219. MSOACTTBL *pacttbl,
  220. long dcp,
  221. int fDiscardActs,
  222. int dactLim,
  223. MSOPFNACT pfnact // MSOACT handler
  224. );
  225. MSOAPI_(MSOACT *) MsoPactDtkAp( // Bld MSOACT tks & ap
  226. MSOACTTBL *pacttbl,
  227. int actt,
  228. int dtkStart,
  229. int dtk,
  230. va_list ap
  231. );
  232. MSOAPI_(MSOACT *) MsoPactPcaAp( // Bld MSOACT CPs & ap
  233. MSOACTTBL *pacttbl,
  234. int actt,
  235. MSOCA *pca,
  236. va_list ap
  237. );
  238. MSOAPI_(MSOACT *) MsoPactAp( // Bld MSOACT rec ap
  239. MSOACTTBL *pacttbl,
  240. int actt,
  241. int cargsOffset,
  242. va_list ap
  243. );
  244. MSOAPI_(void) MsoInsertPact( // Insert ACT by MSOCA
  245. MSOACT *pact,
  246. MSOACT **ppactHead
  247. );
  248. MSOAPI_(int) MsoFEnsurePactFirst( // Sort ACT 1st in rng
  249. MSOACT *pact,
  250. MSOACTTBL *pacttbl
  251. );
  252. MSOAPI_(MSOACT *) MsoFindPactOfActt( // Find rec by actt
  253. short actt,
  254. MSOACT *pact,
  255. MSOCP cpFirst,
  256. MSOCP cpLim
  257. );
  258. MSOAPI_(void) MsoDeletePact( // Remove & free act
  259. MSOACT *pact,
  260. MSOACTTBL *pacttbl
  261. );
  262. MSOAPI_(void) MsoSkipNextPact( // Skip over next ACT
  263. MSOACT **ppactNext,
  264. MSOACTTBL *pacttbl
  265. );
  266. MSOAPI_(MSOACT *) _MsoPactNew(MSOACTTBL *pacttbl); // Create blk of MSOACT
  267. _inline MSOACT *MsoPactNew(MSOACTTBL *pacttbl) // Return new MSOACT
  268. {
  269. MSOACT *pact;
  270. if ((pact = pacttbl->pactFree))
  271. {
  272. pacttbl->pactFree = pact->pactNext;
  273. return pact;
  274. }
  275. return _MsoPactNew(pacttbl);
  276. }
  277. void ClearPactPending(MSOACTTBL *pacttbl); // Free pending acts
  278. MSOAPI_(void) MsoFreePact( // Free MSOACT rec
  279. MSOACT *pact,
  280. MSOACTTBL *pacttbl
  281. );
  282. _inline int MsoFAllocPact(MSOACTTBL *pacttbl) // Pre-alloc ACT list
  283. {
  284. MSOACT *pact;
  285. if ((pact = MsoPactNew(pacttbl)) == NULL)
  286. return FALSE;
  287. MsoFreePact(pact, pacttbl);
  288. return TRUE;
  289. }
  290. MSOAPI_(void) MsoFreeActMem(MSOACTTBL *pacttbl); // Free act mem used
  291. #ifdef DEBUG
  292. MSOAPI_(void) MsoMarkActMem(MSOACTTBL *pacttbl); // Mark act mem used
  293. #endif // DEBUG
  294. MSOEXTERN_C_END // ****************** End extern "C" *********************
  295. #endif /* !_EMACT_H */