DTPData.Mod 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474
  1. MODULE DTPData; (** AUTHOR "PL"; PURPOSE "Data Model for simple DTP Editor"; *)
  2. IMPORT
  3. Files, XML, WMGraphics, Strings, WMWindowManager; (* , DTPFrame; *)
  4. CONST
  5. TYPE
  6. MetaInformation* = OBJECT
  7. VAR
  8. author*, documentName*, documentTitle* : Strings.String;
  9. END MetaInformation;
  10. StyleObject* = OBJECT
  11. VAR name*: ARRAY 64 OF CHAR; (* unique style name *)
  12. END StyleObject;
  13. ParagraphStyleObject* = OBJECT(StyleObject)
  14. VAR alignment* : LONGINT; (* 0 = left, 1 = center, 2 = right, 3 = justified *)
  15. spaceBefore* : REAL; (* space before paragraph [mm] *)
  16. spaceAfter* : REAL; (* space after paragrapg [mm] *)
  17. leftIndent* : REAL; (* left Indent [mm] *)
  18. rightIndent* : REAL; (* right Indent [mm] *)
  19. firstIndent* : REAL; (* first Line Indent [mm] *)
  20. charStyle* : CharacterStyleObject;
  21. PROCEDURE Clone*(): ParagraphStyleObject;
  22. VAR newPSO: ParagraphStyleObject;
  23. BEGIN
  24. NEW(newPSO);
  25. newPSO.name := name;
  26. newPSO.alignment := alignment;
  27. newPSO.spaceBefore := spaceBefore;
  28. newPSO.spaceAfter := spaceAfter;
  29. newPSO.firstIndent := firstIndent;
  30. newPSO.leftIndent := leftIndent;
  31. newPSO.rightIndent := rightIndent;
  32. newPSO.charStyle := charStyle;
  33. RETURN newPSO;
  34. END Clone;
  35. END ParagraphStyleObject;
  36. CharacterStyleObject* = OBJECT(StyleObject)
  37. VAR family* : ARRAY 32 OF CHAR; (* font family *)
  38. style* : SET; (* font style; 0 = bold, 1 = italic *)
  39. size* : REAL; (* font size [pt]; 1pt == 1/72inch == 0,3527777778mm *)
  40. leading* : REAL; (* baseline distance [pt] - usually 120% of font size *)
  41. baselineShift* : REAL; (* baseline shift up/down [pt] *)
  42. tracking* : REAL; (* character spacing [pt] *)
  43. kerning* : REAL; (* NOT USED - needs appropriate Fonts *)
  44. scaleHorizontal* : REAL; (* horizontal character scale *)
  45. scaleVertical* : REAL; (* vertical character scale *)
  46. color* : LONGINT; (* character color *)
  47. bgColor* : LONGINT; (* character background color *)
  48. PROCEDURE Clone*(): CharacterStyleObject;
  49. VAR newCSO: CharacterStyleObject;
  50. BEGIN
  51. NEW(newCSO);
  52. newCSO.name := name;
  53. newCSO.family := family;
  54. newCSO.style := style;
  55. newCSO.size := size;
  56. newCSO.leading := leading;
  57. newCSO.baselineShift := baselineShift;
  58. newCSO.color := color;
  59. newCSO.bgColor := bgColor;
  60. newCSO.tracking := tracking;
  61. newCSO.kerning := kerning;
  62. newCSO.scaleHorizontal := scaleHorizontal;
  63. newCSO.scaleVertical := scaleVertical;
  64. RETURN newCSO;
  65. END Clone;
  66. END CharacterStyleObject;
  67. GraphicStyleObject* = OBJECT(StyleObject)
  68. VAR (* NOT IMPLEMENTED ;-) do it yourself *)
  69. END GraphicStyleObject;
  70. CustomStyleObject* = OBJECT(StyleObject)
  71. VAR (* NOT IMPLEMENTED ;-) do it yourself *)
  72. END CustomStyleObject;
  73. PStyles* = POINTER TO ARRAY OF ParagraphStyleObject;
  74. CStyles* = POINTER TO ARRAY OF CharacterStyleObject;
  75. GStyles* = POINTER TO ARRAY OF GraphicStyleObject;
  76. CustomStyles* = POINTER TO ARRAY OF CustomStyleObject;
  77. (* root for the data - all units in [mm] *)
  78. Document* = OBJECT
  79. VAR
  80. pageWidth, pageHeight : REAL;
  81. marginTop, marginBottom, marginLeft, marginRight : REAL;
  82. facingPages : BOOLEAN;
  83. meta : MetaInformation;
  84. objectCounter*: LONGINT;
  85. copyCounter*: LONGINT;
  86. nofPStyles*: LONGINT;
  87. pStyles* : PStyles;
  88. nofCStyles*: LONGINT;
  89. cStyles* : CStyles;
  90. nofGStyles*: LONGINT;
  91. gStyles* : GStyles;
  92. nofCustomStyles*: LONGINT;
  93. customStyles* : CustomStyles;
  94. defaultParagraphStyle* : ParagraphStyleObject;
  95. defaultCharacterStyle* : CharacterStyleObject;
  96. defaultGraphicStyle* : GraphicStyleObject;
  97. defaultCustomStyle* : CustomStyleObject;
  98. pages* : ContentPages;
  99. mpages* : MasterPages;
  100. contents* : Contents; nofContents* : LONGINT;
  101. frames* : Frames;
  102. (* dollyFrame* : FrameObject; *)
  103. dollyGuide* : GuideObject;
  104. currentPage*, firstPage*, lastPage* : PageObject;
  105. pageNumber*, nofPages* : LONGINT;
  106. currentMPage*, firstMPage*, lastMPage* : MasterPageObject;
  107. mpageNumber*, nofMPages* : LONGINT;
  108. PROCEDURE &New*(width, height, margintop,marginbottom, marginleft, marginright : REAL; facingpages : BOOLEAN);
  109. VAR
  110. BEGIN
  111. pageWidth := width;
  112. pageHeight := height;
  113. marginTop := margintop;
  114. marginBottom := marginbottom;
  115. marginLeft := marginleft;
  116. marginRight := marginright;
  117. facingPages := facingpages;
  118. currentPage := NIL;
  119. firstPage := NIL;
  120. lastPage := NIL;
  121. pageNumber := 0;
  122. nofPages := 0;
  123. currentMPage := NIL;
  124. firstMPage := NIL;
  125. lastMPage := NIL;
  126. mpageNumber := 0;
  127. nofMPages := 0;
  128. (* dollyFrame := NIL; *)
  129. dollyGuide := NIL;
  130. objectCounter := 0; copyCounter := 0;
  131. NEW(pStyles, 4); nofPStyles := 0;
  132. NEW(cStyles, 4); nofCStyles := 0;
  133. NEW(gStyles, 4); nofGStyles := 0;
  134. NEW(customStyles, 4); nofCustomStyles := 0;
  135. AddDefaultStyles;
  136. NEW(contents, 4); nofContents := 0;
  137. END New;
  138. PROCEDURE AddDefaultStyles;
  139. VAR newPStyle: ParagraphStyleObject;
  140. newCStyle: CharacterStyleObject;
  141. BEGIN
  142. NEW(newCStyle);
  143. newCStyle.name := "defaultCharacterStyle";
  144. newCStyle.family := "Oberon";
  145. newCStyle.style := {};
  146. newCStyle.size := 16;
  147. newCStyle.leading := 19;
  148. newCStyle.baselineShift := 0;
  149. newCStyle.tracking := 0;
  150. newCStyle.kerning := 0;
  151. newCStyle.scaleHorizontal := 100;
  152. newCStyle.scaleVertical := 100;
  153. newCStyle.color := 0000000FFH;
  154. newCStyle.bgColor := LONGINT(0FFFFFF00H);
  155. NEW(newPStyle);
  156. newPStyle.name := "defaultParagraphStyle";
  157. newPStyle.alignment := 0; (* Left Align *)
  158. newPStyle.spaceBefore := 0;
  159. newPStyle.spaceAfter := 0;
  160. newPStyle.leftIndent := 0;
  161. newPStyle.rightIndent := 0;
  162. newPStyle.firstIndent := 0;
  163. newPStyle.charStyle := newCStyle;
  164. defaultCharacterStyle := newCStyle;
  165. defaultParagraphStyle := newPStyle;
  166. AddStyle(newCStyle);
  167. AddStyle(newPStyle);
  168. END AddDefaultStyles;
  169. PROCEDURE AddStyle*(style: StyleObject);
  170. VAR newPStyles: PStyles;
  171. newCStyles: CStyles;
  172. newGStyles: GStyles;
  173. newCustomStyles: CustomStyles;
  174. pStyle: ParagraphStyleObject;
  175. cStyle: CharacterStyleObject;
  176. i : LONGINT;
  177. BEGIN
  178. IF (style IS ParagraphStyleObject) THEN
  179. pStyle := GetParagraphStyleByName(style.name);
  180. IF (pStyle = NIL) THEN (* no style with that name - create one *)
  181. INC(nofPStyles);
  182. IF nofPStyles > LEN(pStyles) THEN
  183. NEW(newPStyles, LEN(pStyles) * 2);
  184. FOR i := 0 TO LEN(pStyles)-1 DO newPStyles[i] := pStyles[i]; END;
  185. pStyles := newPStyles;
  186. END;
  187. pStyles[nofPStyles-1] := style(ParagraphStyleObject);
  188. ELSE (* style with that name already exists - update *)
  189. pStyle.alignment := style(ParagraphStyleObject).alignment;
  190. pStyle.firstIndent := style(ParagraphStyleObject).firstIndent;
  191. pStyle.leftIndent := style(ParagraphStyleObject).leftIndent;
  192. pStyle.rightIndent := style(ParagraphStyleObject).rightIndent;
  193. pStyle.spaceBefore := style(ParagraphStyleObject).spaceBefore;
  194. pStyle.spaceAfter := style(ParagraphStyleObject).spaceAfter;
  195. pStyle.charStyle := style(ParagraphStyleObject).charStyle;
  196. END;
  197. ELSIF (style IS CharacterStyleObject) THEN
  198. cStyle := GetCharacterStyleByName(style.name);
  199. IF (cStyle = NIL) THEN (* no style with that name - create one *)
  200. INC(nofCStyles);
  201. IF nofCStyles > LEN(cStyles) THEN
  202. NEW(newCStyles, LEN(cStyles) * 2);
  203. FOR i := 0 TO LEN(cStyles)-1 DO newCStyles[i] := cStyles[i]; END;
  204. cStyles := newCStyles;
  205. END;
  206. cStyles[nofCStyles-1] := style(CharacterStyleObject);
  207. ELSE (* style with that name already exists - update *)
  208. COPY(style(CharacterStyleObject).family, cStyle.family);
  209. cStyle.size := style(CharacterStyleObject).size;
  210. cStyle.style := style(CharacterStyleObject).style;
  211. cStyle.leading := style(CharacterStyleObject).leading;
  212. cStyle.baselineShift := style(CharacterStyleObject).baselineShift;
  213. cStyle.color := style(CharacterStyleObject).color;
  214. cStyle.bgColor := style(CharacterStyleObject).bgColor;
  215. cStyle.tracking := style(CharacterStyleObject).tracking;
  216. cStyle.kerning := style(CharacterStyleObject).kerning;
  217. cStyle.scaleHorizontal := style(CharacterStyleObject).scaleHorizontal;
  218. cStyle.scaleVertical := style(CharacterStyleObject).scaleVertical;
  219. END;
  220. ELSIF (style IS GraphicStyleObject) THEN
  221. INC(nofGStyles);
  222. IF nofGStyles > LEN(gStyles) THEN
  223. NEW(newGStyles, LEN(gStyles) * 2);
  224. FOR i := 0 TO LEN(gStyles)-1 DO newGStyles[i] := gStyles[i]; END;
  225. gStyles := newGStyles;
  226. END;
  227. gStyles[nofGStyles-1] := style(GraphicStyleObject);
  228. ELSIF (style IS CustomStyleObject) THEN
  229. INC(nofCustomStyles);
  230. IF nofCustomStyles > LEN(customStyles) THEN
  231. NEW(newCustomStyles, LEN(customStyles) * 2);
  232. FOR i := 0 TO LEN(customStyles)-1 DO newCustomStyles[i] := customStyles[i]; END;
  233. customStyles := newCustomStyles;
  234. END;
  235. customStyles[nofCustomStyles-1] := style(CustomStyleObject);
  236. ELSE
  237. END;
  238. END AddStyle;
  239. PROCEDURE RemoveStyle*(style: StyleObject);
  240. VAR i : LONGINT;
  241. BEGIN
  242. IF (style IS ParagraphStyleObject) THEN
  243. IF (style(ParagraphStyleObject).name # "defaultParagraphStyle") THEN
  244. i := 0; WHILE (i < nofPStyles) & (pStyles[i] # style(ParagraphStyleObject)) DO INC(i) END;
  245. IF i < nofPStyles THEN
  246. WHILE (i < nofPStyles-1) DO pStyles[i] := pStyles[i+1]; INC(i); END;
  247. DEC(nofPStyles);
  248. pStyles[nofPStyles] := NIL;
  249. END;
  250. END;
  251. ELSIF (style IS CharacterStyleObject) THEN
  252. IF (style(CharacterStyleObject).name # "defaultCharacterStyle") THEN
  253. i := 0; WHILE (i < nofCStyles) & (cStyles[i] # style(CharacterStyleObject)) DO INC(i) END;
  254. IF i < nofCStyles THEN
  255. WHILE (i < nofCStyles-1) DO cStyles[i] := cStyles[i+1]; INC(i); END;
  256. DEC(nofCStyles);
  257. cStyles[nofCStyles] := NIL;
  258. END;
  259. END;
  260. ELSIF (style IS GraphicStyleObject) THEN
  261. IF (style(GraphicStyleObject) # defaultGraphicStyle) THEN
  262. i := 0; WHILE (i < nofGStyles) & (gStyles[i] # style(GraphicStyleObject)) DO INC(i) END;
  263. IF i < nofGStyles THEN
  264. WHILE (i < nofGStyles-1) DO gStyles[i] := gStyles[i+1]; INC(i); END;
  265. DEC(nofGStyles);
  266. gStyles[nofGStyles] := NIL;
  267. END;
  268. END;
  269. ELSIF (style IS CustomStyleObject) THEN
  270. IF (style(CustomStyleObject) # defaultCustomStyle) THEN
  271. i := 0; WHILE (i < nofCustomStyles) & (customStyles[i] # style(CustomStyleObject)) DO INC(i) END;
  272. IF i < nofCustomStyles THEN
  273. WHILE (i < nofCustomStyles-1) DO customStyles[i] := customStyles[i+1]; INC(i); END;
  274. DEC(nofCustomStyles);
  275. customStyles[nofCustomStyles] := NIL;
  276. END;
  277. END;
  278. ELSE
  279. END;
  280. END RemoveStyle;
  281. PROCEDURE GetCharacterStyleByName*(name: ARRAY OF CHAR): CharacterStyleObject;
  282. VAR styleObject: CharacterStyleObject;
  283. i : LONGINT;
  284. found : BOOLEAN;
  285. match: Strings.String;
  286. BEGIN
  287. styleObject := NIL;
  288. i := 0; found := FALSE;
  289. WHILE ((i < nofCStyles) & ~found) DO
  290. match := Strings.NewString(cStyles[i].name);
  291. IF Strings.Match(match^, name) THEN
  292. styleObject := cStyles[i]; found := TRUE;
  293. END;
  294. INC(i);
  295. END;
  296. RETURN styleObject;
  297. END GetCharacterStyleByName;
  298. PROCEDURE GetParagraphStyleByName*(name: ARRAY OF CHAR): ParagraphStyleObject;
  299. VAR styleObject: ParagraphStyleObject;
  300. i : LONGINT;
  301. found : BOOLEAN;
  302. match: Strings.String;
  303. BEGIN
  304. styleObject := NIL;
  305. i := 0; found := FALSE;
  306. WHILE ((i < nofPStyles) & ~found) DO
  307. match := Strings.NewString(pStyles[i].name);
  308. IF Strings.Match(match^, name) THEN
  309. styleObject := pStyles[i]; found := TRUE;
  310. END;
  311. INC(i);
  312. END;
  313. RETURN styleObject;
  314. END GetParagraphStyleByName;
  315. PROCEDURE AddContent*(content: ContentObject);
  316. VAR newContents: Contents;
  317. i : LONGINT;
  318. BEGIN
  319. INC(nofContents); (* INC(objectCounter); *)
  320. IF nofContents > LEN(contents) THEN
  321. NEW(newContents, LEN(contents) * 2);
  322. FOR i := 0 TO LEN(contents)-1 DO newContents[i] := contents[i]; END;
  323. contents := newContents;
  324. END;
  325. contents[nofContents-1] := content;
  326. END AddContent;
  327. PROCEDURE RemoveContent*(content: ContentObject);
  328. VAR i : LONGINT;
  329. BEGIN
  330. i := 0; WHILE (i < nofContents) & (contents[i] # content) DO INC(i) END;
  331. IF i < nofContents THEN
  332. WHILE (i < nofContents-1) DO contents[i] := contents[i+1]; INC(i); END;
  333. DEC(nofContents);
  334. contents[nofContents] := NIL;
  335. END;
  336. END RemoveContent;
  337. PROCEDURE GetContentByName*(name: ARRAY OF CHAR): ContentObject;
  338. VAR contentObject: ContentObject;
  339. i : LONGINT;
  340. found : BOOLEAN;
  341. match: Strings.String;
  342. BEGIN
  343. contentObject := NIL;
  344. i := 0; found := FALSE;
  345. WHILE ((i < nofContents) & ~found) DO
  346. match := contents[i].contentName;
  347. IF Strings.Match(match^, name) THEN
  348. contentObject := contents[i]; found := TRUE;
  349. END;
  350. INC(i);
  351. END;
  352. RETURN contentObject;
  353. END GetContentByName;
  354. PROCEDURE FixContents*; (* loop over all contents and fix the links *)
  355. VAR contentObject: ContentObject;
  356. i : LONGINT;
  357. BEGIN
  358. i := 0;
  359. WHILE (i < nofContents) DO
  360. contentObject := contents[i];
  361. contentObject.FixLinks;
  362. INC(i);
  363. END;
  364. END FixContents;
  365. PROCEDURE FixName*(name: ARRAY OF CHAR; VAR result: ARRAY OF CHAR);
  366. VAR counterString : ARRAY 64 OF CHAR;
  367. BEGIN
  368. COPY(name, result);
  369. Strings.Append(result, "c");
  370. Strings.IntToStr(copyCounter, counterString);
  371. Strings.Append(result, counterString);
  372. INC(copyCounter);
  373. WHILE (GetContentByName(result) # NIL) DO
  374. Strings.IntToStr(copyCounter, counterString);
  375. Strings.Append(result, counterString);
  376. INC(copyCounter);
  377. END;
  378. END FixName;
  379. PROCEDURE AddPage*(after : BOOLEAN);
  380. VAR newpage : PageObject;
  381. BEGIN
  382. NEW(newpage);
  383. IF lastPage = NIL THEN (* document was empty *)
  384. firstPage := newpage;
  385. lastPage := newpage;
  386. INC(pageNumber);
  387. ELSE (* there were already pages *)
  388. IF after THEN (* add after current page *)
  389. newpage.next := currentPage.next;
  390. currentPage.next := newpage;
  391. newpage.prev := currentPage;
  392. IF newpage.next = NIL THEN (* current was last page *)
  393. lastPage := newpage;
  394. ELSE
  395. newpage.next.prev := newpage; (* current was not last page *)
  396. END;
  397. INC(pageNumber);
  398. ELSE (* add before current page *)
  399. newpage.prev := currentPage.prev;
  400. currentPage.prev := newpage;
  401. newpage.next := currentPage;
  402. IF newpage.prev = NIL THEN (* current was first page *)
  403. firstPage := newpage;
  404. ELSE
  405. newpage.prev.next := newpage; (* current was not first page *)
  406. END;
  407. END;
  408. END;
  409. currentPage := newpage; (* change current page *)
  410. INC(nofPages);
  411. currentPage.SetOwner(SELF);
  412. (* UpdatePageNumber; *)
  413. END AddPage;
  414. PROCEDURE DeletePage*;
  415. VAR
  416. BEGIN
  417. IF currentPage.prev # NIL THEN (* not first *)
  418. IF currentPage.next # NIL THEN (* not last *)
  419. currentPage.prev.next := currentPage.next;
  420. currentPage.next.prev := currentPage.prev;
  421. currentPage := currentPage.next;
  422. IF currentPage.prev = NIL THEN firstPage := currentPage; END;
  423. IF currentPage.next = NIL THEN lastPage := currentPage; END;
  424. DEC(nofPages);
  425. ELSE (* last *)
  426. currentPage.prev.next := currentPage.next;
  427. currentPage := currentPage.prev;
  428. IF currentPage.prev = NIL THEN firstPage := currentPage; END;
  429. lastPage := currentPage;
  430. DEC(nofPages); DEC(pageNumber);
  431. END;
  432. ELSE (* first *)
  433. IF currentPage.next # NIL THEN (* you can only delete if more than 1 page left *)
  434. currentPage.next.prev := currentPage.prev;
  435. currentPage := currentPage.next;
  436. firstPage := currentPage;
  437. IF currentPage.next = NIL THEN lastPage := currentPage; END;
  438. DEC(nofPages);
  439. END;
  440. END;
  441. (* UpdatePageNumber; *)
  442. END DeletePage;
  443. PROCEDURE NextPage*;
  444. BEGIN
  445. IF currentPage.next # NIL THEN
  446. currentPage := currentPage.next;
  447. INC(pageNumber);
  448. END;
  449. (* UpdatePageNumber; *)
  450. END NextPage;
  451. PROCEDURE PrevPage*;
  452. BEGIN
  453. IF currentPage.prev # NIL THEN
  454. currentPage := currentPage.prev;
  455. DEC(pageNumber);
  456. END;
  457. (* UpdatePageNumber; *)
  458. END PrevPage;
  459. PROCEDURE FirstPage*;
  460. BEGIN
  461. currentPage := firstPage;
  462. pageNumber := 1;
  463. (* UpdatePageNumber; *)
  464. END FirstPage;
  465. PROCEDURE LastPage*;
  466. BEGIN
  467. currentPage := lastPage;
  468. pageNumber := nofPages;
  469. (* UpdatePageNumber; *)
  470. END LastPage;
  471. PROCEDURE AddMasterPage*(after: BOOLEAN);
  472. VAR newpage : MasterPageObject;
  473. BEGIN
  474. NEW(newpage);
  475. IF lastMPage = NIL THEN (* document was empty *)
  476. firstMPage := newpage;
  477. lastMPage := newpage;
  478. INC(mpageNumber);
  479. ELSE (* there were already pages *)
  480. IF after THEN (* add after current page *)
  481. newpage.next := currentMPage.next;
  482. currentMPage.next := newpage;
  483. newpage.prev := currentMPage;
  484. IF newpage.next = NIL THEN (* current was last page *)
  485. lastMPage := newpage;
  486. ELSE
  487. newpage.next.prev := newpage; (* current was not last page *)
  488. END;
  489. INC(mpageNumber);
  490. ELSE (* add before current page *)
  491. newpage.prev := currentMPage.prev;
  492. currentMPage.prev := newpage;
  493. newpage.next := currentMPage;
  494. IF newpage.prev = NIL THEN (* current was first page *)
  495. firstMPage := newpage;
  496. ELSE
  497. newpage.prev.next := newpage; (* current was not first page *)
  498. END;
  499. END;
  500. END;
  501. currentMPage := newpage; (* change current page *)
  502. INC(nofMPages);
  503. currentMPage.SetOwner(SELF);
  504. END AddMasterPage;
  505. PROCEDURE DeleteMasterPage*;
  506. BEGIN
  507. IF currentMPage.prev # NIL THEN (* not first *)
  508. IF currentMPage.next # NIL THEN (* not last *)
  509. currentMPage.prev.next := currentMPage.next;
  510. currentMPage.next.prev := currentMPage.prev;
  511. currentMPage := currentMPage.next;
  512. IF currentMPage.prev = NIL THEN firstMPage := currentMPage; END;
  513. IF currentMPage.next = NIL THEN lastMPage := currentMPage; END;
  514. DEC(nofMPages);
  515. ELSE (* last *)
  516. currentMPage.prev.next := currentMPage.next;
  517. currentMPage := currentMPage.prev;
  518. IF currentMPage.prev = NIL THEN firstMPage := currentMPage; END;
  519. lastMPage := currentMPage;
  520. DEC(nofMPages); DEC(mpageNumber);
  521. END;
  522. ELSE (* first *)
  523. IF currentMPage.next # NIL THEN (* you can only delete if more than 1 page left *)
  524. currentMPage.next.prev := currentMPage.prev;
  525. currentMPage := currentMPage.next;
  526. firstMPage := currentMPage;
  527. IF currentMPage.next = NIL THEN lastMPage := currentMPage; END;
  528. DEC(nofMPages);
  529. END;
  530. END;
  531. END DeleteMasterPage;
  532. PROCEDURE NextMasterPage*;
  533. BEGIN
  534. IF currentMPage.next # NIL THEN
  535. currentMPage := currentMPage.next;
  536. INC(mpageNumber);
  537. END;
  538. END NextMasterPage;
  539. PROCEDURE PrevMasterPage*;
  540. BEGIN
  541. IF currentMPage.prev # NIL THEN
  542. currentMPage := currentMPage.prev;
  543. DEC(mpageNumber);
  544. END;
  545. END PrevMasterPage;
  546. PROCEDURE FirstMasterPage*;
  547. BEGIN
  548. currentMPage := firstMPage;
  549. mpageNumber := 1;
  550. END FirstMasterPage;
  551. PROCEDURE LastMasterPage*;
  552. BEGIN
  553. currentMPage := lastMPage;
  554. mpageNumber := nofMPages;
  555. END LastMasterPage;
  556. PROCEDURE SetPageWidth*(pagewidth : REAL);
  557. BEGIN
  558. pageWidth := pagewidth;
  559. END SetPageWidth;
  560. PROCEDURE GetPageWidth*(): REAL;
  561. BEGIN
  562. RETURN pageWidth
  563. END GetPageWidth;
  564. PROCEDURE SetPageHeight*(pageheight : REAL);
  565. BEGIN
  566. pageHeight := pageheight;
  567. END SetPageHeight;
  568. PROCEDURE GetPageHeight*(): REAL;
  569. BEGIN
  570. RETURN pageHeight
  571. END GetPageHeight;
  572. PROCEDURE SetMargins*(top, bottom, left, right : REAL);
  573. BEGIN
  574. marginTop := top;
  575. marginBottom := bottom;
  576. marginLeft := left;
  577. marginRight := right;
  578. END SetMargins;
  579. PROCEDURE GetMarginTop*(): REAL;
  580. BEGIN
  581. RETURN marginTop
  582. END GetMarginTop;
  583. PROCEDURE GetMarginBottom*() : REAL;
  584. BEGIN
  585. RETURN marginBottom
  586. END GetMarginBottom;
  587. PROCEDURE GetMarginLeft*(): REAL;
  588. BEGIN
  589. RETURN marginLeft
  590. END GetMarginLeft;
  591. PROCEDURE GetMarginRight*(): REAL;
  592. BEGIN
  593. RETURN marginRight
  594. END GetMarginRight;
  595. PROCEDURE SetFacingPages*(fpages : BOOLEAN);
  596. BEGIN
  597. facingPages := fpages;
  598. END SetFacingPages;
  599. PROCEDURE GetFacingPages*(): BOOLEAN;
  600. BEGIN
  601. RETURN facingPages
  602. END GetFacingPages;
  603. PROCEDURE GetCurrentPage*(): PageObject;
  604. BEGIN
  605. RETURN currentPage;
  606. END GetCurrentPage;
  607. PROCEDURE GetFirstPage*(): PageObject;
  608. BEGIN
  609. RETURN firstPage;
  610. END GetFirstPage;
  611. PROCEDURE GetLastPage*(): PageObject;
  612. BEGIN
  613. RETURN lastPage;
  614. END GetLastPage;
  615. PROCEDURE GetCurrentMasterPage*(): MasterPageObject;
  616. BEGIN
  617. RETURN currentMPage;
  618. END GetCurrentMasterPage;
  619. PROCEDURE GetFirstMasterPage*(): MasterPageObject;
  620. BEGIN
  621. RETURN firstMPage;
  622. END GetFirstMasterPage;
  623. PROCEDURE GetLastMasterPage*(): MasterPageObject;
  624. BEGIN
  625. RETURN lastMPage;
  626. END GetLastMasterPage;
  627. PROCEDURE GetMasterByName*(name: Strings.String): MasterPageObject;
  628. VAR page, result: MasterPageObject;
  629. match: Strings.String;
  630. BEGIN
  631. result := NIL;
  632. IF name # NIL THEN
  633. page := GetFirstMasterPage();
  634. WHILE page # NIL DO
  635. match := page.GetName();
  636. (* KernelLog.String(match^); *)
  637. IF (match # NIL) & Strings.Match(match^, name^) THEN
  638. result := page;
  639. END;
  640. page := page.next;
  641. END;
  642. END;
  643. RETURN result;
  644. END GetMasterByName;
  645. PROCEDURE GetCurrentPageNumber*(): LONGINT;
  646. BEGIN
  647. RETURN pageNumber;
  648. END GetCurrentPageNumber;
  649. PROCEDURE GetCurrentMasterPageNumber*(): LONGINT;
  650. BEGIN
  651. RETURN mpageNumber;
  652. END GetCurrentMasterPageNumber;
  653. END Document;
  654. PageObject* = OBJECT
  655. VAR
  656. ownerDocument* : Document;
  657. masterpage* : MasterPageObject;
  658. next*, prev* : PageObject;
  659. firstFrame*, lastFrame*, currentFrame* : FrameObject;
  660. firstGuide*, lastGuide*, currentGuide* : GuideObject;
  661. PROCEDURE SetOwner*(doc: Document);
  662. BEGIN
  663. ownerDocument := doc;
  664. END SetOwner;
  665. PROCEDURE &New*;
  666. VAR
  667. BEGIN
  668. firstFrame := NIL; lastFrame := NIL; currentFrame := NIL;
  669. firstGuide := NIL; lastGuide := NIL; currentGuide := NIL;
  670. next := NIL; prev := NIL;
  671. masterpage := NIL;
  672. END New;
  673. PROCEDURE SetMasterPage*(master: MasterPageObject);
  674. BEGIN
  675. masterpage := master;
  676. END SetMasterPage;
  677. PROCEDURE GetMasterPage*(): MasterPageObject;
  678. BEGIN
  679. RETURN masterpage;
  680. END GetMasterPage;
  681. PROCEDURE AddFrame*(x, y, w, h : REAL);
  682. VAR newframe : FrameObject;
  683. BEGIN
  684. (* new Frames are added at last position (top) *)
  685. NEW(newframe); newframe.SetExtent(x,y,w,h);
  686. IF lastFrame = NIL THEN (* First frame added *)
  687. firstFrame := newframe;
  688. lastFrame := newframe;
  689. ELSE (* not first frame added *)
  690. newframe.prev := lastFrame;
  691. lastFrame.next := newframe;
  692. lastFrame := newframe;
  693. END;
  694. currentFrame := newframe; (* change current frame *)
  695. END AddFrame;
  696. PROCEDURE InsertFrame*(frame: FrameObject); (* insert the given frame at front *)
  697. VAR name : Strings.String;
  698. content: ContentObject;
  699. temp: ARRAY 64 OF CHAR;
  700. BEGIN
  701. (* check if name of given frame is in use, add content to list *)
  702. name := frame.GetName();
  703. content := ownerDocument.GetContentByName(name^);
  704. IF content # NIL THEN
  705. ownerDocument.FixName(name^, temp); name := Strings.NewString(temp);
  706. frame.SetName(name);
  707. content := frame.GetContent();
  708. content.contentName := name;
  709. ELSE
  710. content := frame.GetContent();
  711. END;
  712. ownerDocument.AddContent(content);
  713. (* insert frame in page *)
  714. IF lastFrame = NIL THEN (* First frame added *)
  715. firstFrame := frame;
  716. lastFrame := frame;
  717. ELSE (* not first frame added *)
  718. frame.prev := lastFrame;
  719. lastFrame.next := frame;
  720. lastFrame := frame;
  721. END;
  722. currentFrame := frame; (* change current frame *)
  723. END InsertFrame;
  724. PROCEDURE DeleteFrame*;
  725. VAR name: Strings.String;
  726. content: ContentObject;
  727. BEGIN
  728. IF currentFrame # NIL THEN
  729. (* remove content first *)
  730. name := currentFrame.GetName();
  731. content := ownerDocument.GetContentByName(name^);
  732. IF content # NIL THEN
  733. ownerDocument.RemoveContent(content);
  734. END;
  735. (* remove frame *)
  736. IF (currentFrame.prev = NIL) & (currentFrame.next = NIL) THEN (* only this frame left *)
  737. currentFrame := NIL;
  738. firstFrame := NIL;
  739. lastFrame := NIL;
  740. ELSIF currentFrame.prev = NIL THEN (* frame at back *)
  741. currentFrame.next.prev := currentFrame.prev;
  742. currentFrame := currentFrame.next;
  743. firstFrame := currentFrame;
  744. ELSIF currentFrame.next = NIL THEN (* frame at front *)
  745. currentFrame.prev.next := currentFrame.next;
  746. currentFrame := currentFrame.prev;
  747. lastFrame := currentFrame;
  748. ELSE (* frame in between *)
  749. currentFrame.prev.next := currentFrame.next;
  750. currentFrame.next.prev := currentFrame.prev;
  751. currentFrame := currentFrame.prev;
  752. END;
  753. END;
  754. END DeleteFrame;
  755. PROCEDURE NextFrame*;
  756. BEGIN
  757. IF (currentFrame # NIL) & (currentFrame.next # NIL) THEN
  758. currentFrame := currentFrame.next;
  759. END;
  760. END NextFrame;
  761. PROCEDURE PrevFrame*;
  762. BEGIN
  763. IF (currentFrame # NIL) & (currentFrame.prev # NIL) THEN
  764. currentFrame := currentFrame.prev;
  765. END
  766. END PrevFrame;
  767. PROCEDURE AddGuide*(position : REAL; horizontal : BOOLEAN);
  768. VAR newguide : GuideObject;
  769. BEGIN
  770. NEW(newguide, position, horizontal);
  771. IF lastGuide = NIL THEN (* first Guide added *)
  772. firstGuide := newguide;
  773. lastGuide := newguide;
  774. ELSE (* guides are added on top *)
  775. newguide.prev := lastGuide;
  776. lastGuide.next := newguide;
  777. lastGuide := newguide;
  778. END;
  779. currentGuide := newguide; (* change Guide *)
  780. END AddGuide;
  781. PROCEDURE DeleteGuide*;
  782. BEGIN
  783. IF currentGuide # NIL THEN
  784. IF (currentGuide.prev = NIL) & (currentGuide.next = NIL) THEN (* one and only guide *)
  785. firstGuide := NIL;
  786. lastGuide := NIL;
  787. currentGuide := NIL;
  788. ELSIF (currentGuide.prev = NIL) THEN (* first guide *)
  789. currentGuide.next.prev := currentGuide.prev;
  790. firstGuide := currentGuide.next;
  791. currentGuide := currentGuide.next;
  792. ELSIF (currentGuide.next = NIL) THEN (* last guide *)
  793. currentGuide.prev.next := currentGuide.next;
  794. lastGuide := currentGuide.prev;
  795. currentGuide := currentGuide.prev;
  796. ELSE (* between guide *)
  797. currentGuide.prev.next := currentGuide.next;
  798. currentGuide.next.prev := currentGuide.prev;
  799. END;
  800. END;
  801. END DeleteGuide;
  802. PROCEDURE Move2Front*;
  803. BEGIN
  804. IF currentFrame # NIL THEN
  805. IF (currentFrame.prev = NIL) & (currentFrame.next = NIL) THEN (* one and only frame *)
  806. firstFrame := currentFrame;
  807. ELSIF (currentFrame.next = NIL) THEN (* last frame *)
  808. (* do nothing *)
  809. ELSIF (currentFrame.prev = NIL) THEN (* first frame *)
  810. currentFrame.next.prev := currentFrame.prev;
  811. firstFrame := currentFrame.next;
  812. lastFrame.next := currentFrame;
  813. currentFrame.prev := lastFrame;
  814. currentFrame.next := NIL;
  815. ELSE (* between *)
  816. currentFrame.prev.next := currentFrame.next;
  817. currentFrame.next.prev := currentFrame.prev;
  818. lastFrame.next := currentFrame;
  819. currentFrame.prev := lastFrame;
  820. currentFrame.next := NIL;
  821. END;
  822. lastFrame := currentFrame;
  823. END;
  824. END Move2Front;
  825. PROCEDURE Move2Back*;
  826. VAR
  827. BEGIN
  828. IF currentFrame # NIL THEN
  829. IF (currentFrame.prev = NIL) & (currentFrame.next = NIL) THEN (* one and only frame *)
  830. lastFrame := currentFrame;
  831. ELSIF (currentFrame.next = NIL) THEN (* last frame *)
  832. currentFrame.prev.next := currentFrame.next;
  833. lastFrame := currentFrame.prev;
  834. firstFrame.prev := currentFrame;
  835. currentFrame.prev := NIL;
  836. currentFrame.next := firstFrame;
  837. ELSIF (currentFrame.prev = NIL) THEN (* first frame *)
  838. (* do nothing *)
  839. ELSE (* between *)
  840. currentFrame.prev.next := currentFrame.next;
  841. currentFrame.next.prev := currentFrame.prev;
  842. firstFrame.prev := currentFrame;
  843. currentFrame.prev := NIL;
  844. currentFrame.next := firstFrame;
  845. END;
  846. firstFrame := currentFrame;
  847. END;
  848. END Move2Back;
  849. PROCEDURE Move2FrontStep*;
  850. VAR
  851. BEGIN
  852. IF currentFrame # NIL THEN
  853. IF (currentFrame.prev = NIL) & (currentFrame.next = NIL) THEN
  854. firstFrame := currentFrame;
  855. lastFrame := currentFrame;
  856. ELSIF (currentFrame.prev = NIL) THEN (* first frame *)
  857. IF currentFrame.next.next = NIL THEN (* only 2 frames - swap *)
  858. currentFrame.prev := currentFrame.next;
  859. lastFrame.next := currentFrame;
  860. lastFrame.prev := NIL;
  861. currentFrame.next := NIL;
  862. firstFrame := lastFrame;
  863. lastFrame := currentFrame;
  864. ELSE (* more than 2 frames *)
  865. currentFrame.prev := currentFrame.next;
  866. currentFrame.next.next.prev := currentFrame;
  867. currentFrame.next := currentFrame.next.next;
  868. currentFrame.prev.next := currentFrame;
  869. firstFrame := currentFrame.prev;
  870. firstFrame.prev := NIL;
  871. END;
  872. ELSIF (currentFrame.next = NIL) THEN (* last frame *)
  873. (* do nothing *)
  874. ELSE (* between *)
  875. IF currentFrame.next.next = NIL THEN (* 2nd last frame *)
  876. currentFrame.prev.next := currentFrame.next;
  877. currentFrame.next.prev := currentFrame.prev;
  878. currentFrame.prev := currentFrame.next;
  879. currentFrame.next.next := currentFrame;
  880. currentFrame.next := NIL;
  881. lastFrame := currentFrame;
  882. ELSE (* "deep" between *)
  883. currentFrame.prev.next := currentFrame.next;
  884. currentFrame.next.prev := currentFrame.prev;
  885. currentFrame.prev := currentFrame.prev.next;
  886. currentFrame.next := currentFrame.prev.next;
  887. currentFrame.prev.next.prev := currentFrame;
  888. currentFrame.prev.next := currentFrame;
  889. END;
  890. END;
  891. END;
  892. END Move2FrontStep;
  893. PROCEDURE Move2BackStep*;
  894. BEGIN
  895. IF currentFrame # NIL THEN
  896. IF (currentFrame.prev = NIL) & (currentFrame.next = NIL) THEN
  897. firstFrame := currentFrame;
  898. lastFrame := currentFrame;
  899. ELSIF (currentFrame.prev = NIL) THEN (* first frame *)
  900. (* do nothing *)
  901. ELSIF (currentFrame.next = NIL) THEN (* last frame *)
  902. IF currentFrame.prev.prev = NIL THEN (* only 2 frames - swap *)
  903. currentFrame.next := currentFrame.prev;
  904. firstFrame.prev := currentFrame;
  905. firstFrame.next := NIL;
  906. currentFrame.prev := NIL;
  907. lastFrame := firstFrame;
  908. firstFrame := currentFrame;
  909. ELSE (* more than 2 frames *)
  910. currentFrame.next := currentFrame.prev;
  911. currentFrame.prev.prev.next := currentFrame;
  912. currentFrame.prev := currentFrame.prev.prev;
  913. currentFrame.next.prev := currentFrame;
  914. lastFrame := currentFrame.next;
  915. lastFrame.next := NIL;
  916. END;
  917. ELSE (* between *)
  918. IF currentFrame.prev.prev = NIL THEN (* 2nd first frame *)
  919. currentFrame.next.prev := currentFrame.prev;
  920. currentFrame.prev.next := currentFrame.next;
  921. currentFrame.next := currentFrame.prev;
  922. currentFrame.prev.prev := currentFrame;
  923. currentFrame.prev := NIL;
  924. firstFrame := currentFrame;
  925. ELSE (* "deep" between *)
  926. currentFrame.next.prev := currentFrame.prev;
  927. currentFrame.prev.next := currentFrame.next;
  928. currentFrame.next := currentFrame.next.prev;
  929. currentFrame.prev := currentFrame.next.prev;
  930. currentFrame.next.prev.next := currentFrame;
  931. currentFrame.next.prev := currentFrame;
  932. END;
  933. END;
  934. END;
  935. END Move2BackStep;
  936. PROCEDURE SetCurrentFrame*(frame : FrameObject);
  937. BEGIN
  938. currentFrame := frame;
  939. END SetCurrentFrame;
  940. PROCEDURE GetCurrentFrame*(): FrameObject;
  941. BEGIN
  942. RETURN currentFrame;
  943. END GetCurrentFrame;
  944. PROCEDURE GetFirstFrame*(): FrameObject;
  945. BEGIN
  946. RETURN firstFrame;
  947. END GetFirstFrame;
  948. PROCEDURE GetLastFrame*(): FrameObject;
  949. BEGIN
  950. RETURN lastFrame;
  951. END GetLastFrame;
  952. PROCEDURE GetCurrentGuide*(): GuideObject;
  953. BEGIN
  954. RETURN currentGuide;
  955. END GetCurrentGuide;
  956. PROCEDURE GetFirstGuide*(): GuideObject;
  957. BEGIN
  958. RETURN firstGuide;
  959. END GetFirstGuide;
  960. PROCEDURE GetLastGuide*(): GuideObject;
  961. BEGIN
  962. RETURN lastGuide;
  963. END GetLastGuide;
  964. END PageObject;
  965. MasterPageObject* = OBJECT(PageObject)
  966. VAR
  967. mpageName* : Strings.String;
  968. next*, prev* : MasterPageObject;
  969. PROCEDURE &New*;
  970. BEGIN
  971. New^;
  972. mpageName := Strings.NewString("Master");
  973. END New;
  974. PROCEDURE SetName*(name: Strings.String);
  975. BEGIN
  976. mpageName := name;
  977. END SetName;
  978. PROCEDURE GetName*(): Strings.String;
  979. BEGIN
  980. RETURN mpageName;
  981. END GetName;
  982. END MasterPageObject;
  983. GuideObject* = OBJECT
  984. VAR
  985. horizontal : BOOLEAN;
  986. position : REAL;
  987. prev*, next* : GuideObject;
  988. PROCEDURE &New*(posi : REAL; horiz : BOOLEAN);
  989. BEGIN
  990. position := posi; horizontal := horiz;
  991. prev := NIL; next := NIL;
  992. END New;
  993. PROCEDURE SetHorizontal*(isHorizontal : BOOLEAN);
  994. BEGIN
  995. horizontal := isHorizontal;
  996. END SetHorizontal;
  997. PROCEDURE GetHorizontal*() : BOOLEAN;
  998. BEGIN
  999. RETURN horizontal;
  1000. END GetHorizontal;
  1001. PROCEDURE SetPosition*(posi : REAL);
  1002. BEGIN
  1003. position := posi;
  1004. END SetPosition;
  1005. PROCEDURE GetPosition*() : REAL;
  1006. BEGIN
  1007. RETURN position;
  1008. END GetPosition;
  1009. PROCEDURE Clone*(): GuideObject;
  1010. VAR newguide: GuideObject;
  1011. BEGIN
  1012. NEW(newguide, GetPosition(), GetHorizontal());
  1013. RETURN newguide;
  1014. END Clone;
  1015. END GuideObject;
  1016. FrameObject* = OBJECT
  1017. VAR
  1018. frameName : Strings.String;
  1019. frameType : Strings.String;
  1020. x, y, w, h : REAL;
  1021. style : StyleObject;
  1022. content : ContentObject; (* DTPFrame.ContentObject; *)
  1023. textwrapON : BOOLEAN;
  1024. twrapTop, twrapBottom, twrapLeft, twrapRight : REAL;
  1025. next*, prev* : FrameObject;
  1026. PROCEDURE &New*;
  1027. BEGIN
  1028. textwrapON := FALSE;
  1029. twrapTop := 0; twrapBottom := 0; twrapLeft := 0; twrapRight := 0;
  1030. next := NIL; prev := NIL;
  1031. frameName := Strings.NewString("newframe");
  1032. style := NIL;
  1033. content := NIL;
  1034. END New;
  1035. PROCEDURE SetName*(name : Strings.String);
  1036. VAR
  1037. BEGIN
  1038. frameName := name;
  1039. END SetName;
  1040. PROCEDURE GetName*() : Strings.String ;
  1041. VAR
  1042. BEGIN
  1043. RETURN frameName
  1044. END GetName;
  1045. PROCEDURE SetType*(type : Strings.String);
  1046. BEGIN
  1047. frameType := type;
  1048. END SetType;
  1049. PROCEDURE GetType*() : Strings.String;
  1050. VAR
  1051. BEGIN
  1052. RETURN frameType;
  1053. END GetType;
  1054. PROCEDURE FixExtent*;
  1055. VAR cx, cy, cw, ch: REAL;
  1056. BEGIN
  1057. cx := x; cy := y; cw := w; ch := h;
  1058. x := MIN(cx, cx+cw); y := MIN(cy, cy+ch);
  1059. w := MAX(cx, cx+cw)-MIN(cx, cx+cw); h := MAX(cy, cy+ch)-MIN(cy, cy+ch);
  1060. END FixExtent;
  1061. PROCEDURE SetExtent*(x, y, w, h: REAL);
  1062. BEGIN
  1063. SELF.x := x; SELF.y := y; SELF.w := w; SELF.h := h;
  1064. END SetExtent;
  1065. PROCEDURE SetSize*( w, h : REAL);
  1066. VAR
  1067. BEGIN
  1068. SELF.w := w; SELF.h := h;
  1069. END SetSize;
  1070. PROCEDURE SetPosition*(x, y: REAL);
  1071. BEGIN
  1072. SELF.x := x; SELF.y := y;
  1073. END SetPosition;
  1074. PROCEDURE GetX*(): REAL;
  1075. VAR
  1076. BEGIN
  1077. RETURN x;
  1078. END GetX;
  1079. PROCEDURE GetY*(): REAL;
  1080. VAR
  1081. BEGIN
  1082. RETURN y;
  1083. END GetY;
  1084. PROCEDURE GetWidth*(): REAL;
  1085. VAR
  1086. BEGIN
  1087. RETURN w;
  1088. END GetWidth;
  1089. PROCEDURE GetHeight*(): REAL;
  1090. VAR
  1091. BEGIN
  1092. RETURN h;
  1093. END GetHeight;
  1094. PROCEDURE SetStyle*(style : StyleObject);
  1095. BEGIN
  1096. SELF.style := style;
  1097. END SetStyle;
  1098. PROCEDURE GetStyle*() : StyleObject;
  1099. BEGIN
  1100. RETURN style
  1101. END GetStyle;
  1102. PROCEDURE SetContent*(content : ContentObject); (* DTPFrame.ContentObject; *)
  1103. BEGIN
  1104. SELF.content := content;
  1105. END SetContent;
  1106. PROCEDURE GetContent*() : ContentObject; (* DTPFrame.ContentObject; *)
  1107. BEGIN
  1108. RETURN content
  1109. END GetContent;
  1110. PROCEDURE SetWrap*(wrap : BOOLEAN);
  1111. BEGIN
  1112. textwrapON := wrap;
  1113. END SetWrap;
  1114. PROCEDURE GetWrap*() : BOOLEAN;
  1115. BEGIN
  1116. RETURN textwrapON;
  1117. END GetWrap;
  1118. PROCEDURE SetWrapSize*(t, b, l, r : REAL);
  1119. BEGIN
  1120. twrapTop := t; twrapBottom := b;
  1121. twrapLeft := l; twrapRight := r;
  1122. END SetWrapSize;
  1123. PROCEDURE GetWrapTop*(): REAL;
  1124. BEGIN
  1125. RETURN twrapTop
  1126. END GetWrapTop;
  1127. PROCEDURE GetWrapBottom*(): REAL;
  1128. BEGIN
  1129. RETURN twrapBottom
  1130. END GetWrapBottom;
  1131. PROCEDURE GetWrapLeft*(): REAL;
  1132. BEGIN
  1133. RETURN twrapLeft
  1134. END GetWrapLeft;
  1135. PROCEDURE GetWrapRight*(): REAL;
  1136. BEGIN
  1137. RETURN twrapRight
  1138. END GetWrapRight;
  1139. PROCEDURE Clone*(): FrameObject;
  1140. VAR newframe: FrameObject;
  1141. newcontent: ContentObject; (* DTPFrame.ContentObject; *)
  1142. BEGIN
  1143. NEW(newframe);
  1144. newframe.SetName(GetName()); (* maybe change name to avoid conflicts *)
  1145. newframe.SetType(GetType());
  1146. newframe.SetExtent(GetX(), GetY(), GetWidth(), GetHeight());
  1147. newframe.SetStyle(GetStyle());
  1148. newcontent := GetContent();
  1149. newframe.SetContent(newcontent.Clone());
  1150. newframe.SetWrap(GetWrap());
  1151. newframe.SetWrapSize(GetWrapTop(), GetWrapBottom(), GetWrapLeft(), GetWrapRight());
  1152. newframe.prev := NIL; newframe.next := NIL;
  1153. RETURN newframe;
  1154. END Clone;
  1155. END FrameObject;
  1156. ContentObject* = OBJECT
  1157. VAR
  1158. contentName* : Strings.String;
  1159. redrawProc* : PROCEDURE {DELEGATE};
  1160. updatePropsPosition*: PROCEDURE {DELEGATE} (x, y: LONGINT);
  1161. contentWidth*, contentHeight*: LONGINT;
  1162. zoomFactor* : REAL;
  1163. ownerDoc*: Document;
  1164. hasFocus- : BOOLEAN;
  1165. running- : BOOLEAN;
  1166. PROCEDURE &New*;
  1167. BEGIN
  1168. hasFocus := FALSE;
  1169. running := FALSE;
  1170. END New;
  1171. PROCEDURE Clone*(): ContentObject;
  1172. VAR newObj: ContentObject;
  1173. BEGIN
  1174. NEW(newObj); newObj.contentName := Strings.NewString(contentName^);
  1175. newObj.redrawProc := redrawProc; newObj.updatePropsPosition := updatePropsPosition;
  1176. newObj.contentWidth := contentWidth; newObj.contentHeight := contentHeight; newObj.zoomFactor := zoomFactor;
  1177. newObj.ownerDoc := ownerDoc;
  1178. RETURN newObj;
  1179. END Clone;
  1180. PROCEDURE Draw*(canvas : WMGraphics.Canvas; x, y, w, h : LONGINT; zoomFactor: REAL; quality, preview: BOOLEAN);
  1181. VAR color: LONGINT;
  1182. BEGIN
  1183. color := LONGINT(0FF0000FFH);
  1184. canvas.Line(x, y, x+w, y+h, color, WMGraphics.ModeCopy);
  1185. canvas.Line(x+w, y, x, y+h, color, WMGraphics.ModeCopy);
  1186. END Draw;
  1187. PROCEDURE Redraw*;
  1188. BEGIN
  1189. IF redrawProc # NIL THEN
  1190. redrawProc;
  1191. ELSE
  1192. (* KernelLog.String("redraw = NIL");KernelLog.Ln; *)
  1193. END;
  1194. END Redraw;
  1195. PROCEDURE UpdatePosition*(x, y: LONGINT);
  1196. BEGIN
  1197. updatePropsPosition(x, y);
  1198. END UpdatePosition;
  1199. PROCEDURE SetSize*(w, h: LONGINT);
  1200. BEGIN
  1201. contentWidth := w; contentHeight := h;
  1202. END SetSize;
  1203. PROCEDURE Resize*(zoomF: REAL);
  1204. BEGIN
  1205. zoomFactor := zoomF;
  1206. END Resize;
  1207. PROCEDURE Show*(x, y: LONGINT);
  1208. END Show;
  1209. PROCEDURE Hide*;
  1210. END Hide;
  1211. PROCEDURE Close*;
  1212. END Close;
  1213. PROCEDURE SetFocus*(focus: BOOLEAN);
  1214. BEGIN
  1215. hasFocus := focus;
  1216. END SetFocus;
  1217. PROCEDURE FocusLost*;
  1218. BEGIN
  1219. hasFocus := FALSE;
  1220. END FocusLost;
  1221. PROCEDURE FocusReceived*;
  1222. BEGIN
  1223. hasFocus := TRUE;
  1224. END FocusReceived;
  1225. PROCEDURE GetPluginPointer*(): WMWindowManager.PointerInfo;
  1226. VAR manager : WMWindowManager.WindowManager;
  1227. BEGIN
  1228. manager := WMWindowManager.GetDefaultManager();
  1229. RETURN manager.pointerStandard;
  1230. END GetPluginPointer;
  1231. PROCEDURE PointerDown*(x, y: LONGINT; keys: SET);
  1232. END PointerDown;
  1233. PROCEDURE PointerMove*(x, y: LONGINT; keys: SET);
  1234. END PointerMove;
  1235. PROCEDURE PointerUp*(x, y: LONGINT; keys: SET);
  1236. END PointerUp;
  1237. PROCEDURE PointerLeave*;
  1238. END PointerLeave;
  1239. PROCEDURE IsHit*(x, y: LONGINT): BOOLEAN;
  1240. BEGIN
  1241. RETURN TRUE;
  1242. END IsHit;
  1243. PROCEDURE KeyEvent*(ucs: LONGINT; flags: SET; VAR keyCode: LONGINT);
  1244. END KeyEvent;
  1245. PROCEDURE Start*;
  1246. BEGIN
  1247. running := TRUE;
  1248. END Start;
  1249. PROCEDURE Stop*;
  1250. BEGIN
  1251. running := FALSE;
  1252. END Stop;
  1253. PROCEDURE OnPageEnter*;
  1254. END OnPageEnter;
  1255. PROCEDURE OnPageLeave*;
  1256. END OnPageLeave;
  1257. PROCEDURE OnCreate*;
  1258. END OnCreate;
  1259. PROCEDURE OnDelete*;
  1260. END OnDelete;
  1261. PROCEDURE Load*(elem: XML.Element);
  1262. END Load;
  1263. PROCEDURE FixLinks*;
  1264. END FixLinks;
  1265. PROCEDURE Store*(VAR w: Files.Writer);
  1266. BEGIN
  1267. w.String('<node-attribute name="type" value="Frame" />'); w.Ln;
  1268. END Store;
  1269. END ContentObject;
  1270. ContentFactory* = PROCEDURE() : ContentObject;
  1271. ContentPages* = POINTER TO ARRAY OF PageObject;
  1272. MasterPages* = POINTER TO ARRAY OF MasterPageObject;
  1273. Frames* = POINTER TO ARRAY OF FrameObject;
  1274. Contents* = POINTER TO ARRAY OF ContentObject;
  1275. (* ------------------------------------- *)
  1276. VAR
  1277. dollyFrame*: FrameObject;
  1278. PROCEDURE NewObject*(): ContentObject;
  1279. VAR newObject: ContentObject;
  1280. BEGIN
  1281. NEW(newObject);
  1282. RETURN newObject;
  1283. END NewObject;
  1284. END DTPData.