ð6%Syntax10.Scn.FntSyntax10i.Scn.Fntöÿÿÿ€‹ðIStampElemsAlloc8 Dec 98~þÿÿÐûqInfoElemsAllocUSyntax10.Scn.FntÐöÿÿÿ`=ðIStampElemsAlloc8 Dec 98\-"Title": WebCellElems "Author": Andreas Helm "Abstract": TableTools is part of the Oberon-Web-Browser "Keywords": Cells, Tablecells, Web, Webbrowser, Tables "Version": no version "From": 25 June 98 "Until":  "Changes": no changes so far "Hints": Useful for anyone, who has to extend the webbrowser. öÿÿÐûqBalloonElemsAlloc_Syntax10.Scn.Fnt Syntax10i.Scn.Fnt „Syntax10m.Scn.Fnt 0-Syntax10b.Scn.Fnt‘ &, |  †   ‰  J& 6 G 4 9 C* D›"TableTools" TableTools is an auxiliaray module for the Oberon-Web-Browser. It is useful for anyone, who must extend the Oberon Web-browser. "CellAction" CellAction* = PROCEDURE (frag: WebCellElems.Elem): BOOLEAN; CellAction is a callback procedure, used in ForAllFragments. frag is the current fragment of a cell The callback procedure must return TRUE to continue enumeration, FALSE to stop it. "CheckProc" CheckProc* = PROCEDURE (e: Texts.Elem): BOOLEAN; CheckProc is a callback procedure, used in FindElem and FindElemTable. e is the text elem The callback procedure must return TRUE to continue enumeration, FALSE to stop it. "ReadElem" PROCEDURE ReadElem*(r: Texts.Reader); ReadElem reads the next elem in r, if in a table, all following cells are also read. This procedure can be used the same way as the procedure Texts.ReadElem. "ReadPrevElem" PROCEDURE ReadPrevElem*(r: Texts.Reader); ReadPrevElem reads the previous elem in r, if in a table, all previous cells are also read. This procedure can be used the same way as the procedure Texts.ReadPrevElem. "FindElem" PROCEDURE FindElem*(VAR t: Texts.Text; pos: LONGINT; check: CheckProc; VAR elem: Texts.Elem); FindElem calls for all text elems in the text t the procedure check and returns the first elem, for which check returns TRUE, or elem is set to NIL. "FindElemTable" PROCEDURE FindElemTable*(t: WebTables.Table; check: FoldElems.CheckProc; VAR elem: Texts.Elem); FindElemTable calls for all text elems in the cells of the table t the procedure check and returns the first elem, for which check returns TRUE, or elem is set to NIL. "ForAllFragments" PROCEDURE ForAllFragments*(text: Texts.Text; beg, end: LONGINT; action: CellAction): BOOLEAN; ForAllFragments calls the callback procedure action for every cell fragment, which occurs in text between beg and end. It returns FALSE, if action has terminated the enumeration by returning FALSE, otherwise TRUE. WbSyntax10b.Scn.Fnt 2 (P  h÷ÿÿ€8ÀÔFoldElemsNewmSyntax10.Scn.FntŠSyntax10i.Scn.Fnt l¯I, VAR myR: Texts.Reader; text, text2: Texts.Text; BEGIN IF r.elem # NIL THEN text := Texts.ElemBase(r.elem) ELSE text := NIL END; r.elem := NIL; Texts.ReadElem(r); IF (r.elem # NIL) & (text = NIL) THEN text := Texts.ElemBase(r.elem) END; IF (r.elem # NIL) & ((r.elem IS WebPanelElems.Elem) OR (r.elem IS WebCellElems.Elem)) THEN WHILE (r.elem # NIL) & (r.elem IS WebPanelElems.Elem) DO (* a table was found *) Texts.OpenReader(r, r.elem(WebPanelElems.Elem).elemTxt, 0); Texts.ReadElem(r) END; IF (r.elem # NIL) & (r.elem IS WebCellElems.Elem) THEN Texts.OpenReader(r, r.elem(WebCellElems.Elem).txt, 0); Texts.ReadElem(r) END ELSIF (text # NIL) & (r.eot) THEN IF text IS WebCellElems.Text THEN IF Texts.ElemBase(text(WebCellElems.Text).elem) = NIL THEN RETURN END; Texts.OpenReader(myR, Texts.ElemBase(text(WebCellElems.Text).elem), Texts.ElemPos(text(WebCellElems.Text).elem) + 1); Texts.ReadElem(myR); IF myR.elem # NIL THEN WHILE (myR.elem # NIL) & (myR.elem IS WebPanelElems.Elem) DO Texts.OpenReader(myR, myR.elem(WebPanelElems.Elem).elemTxt, 0); Texts.ReadElem(myR) END; Texts.OpenReader(r, myR.elem(WebCellElems.Elem).txt, 0); Texts.ReadElem(r) ELSE (* first cell read *) text := Texts.ElemBase(text(WebCellElems.Text).elem); IF text = NIL THEN RETURN END; text2 := Texts.ElemBase(text(PanelElems.Text).base); IF text2 # NIL THEN IF text2 IS PanelElems.Text THEN REPEAT Texts.OpenReader(myR, text2, Texts.ElemPos(text(PanelElems.Text).base) + 1); Texts.ReadElem(myR); IF myR.elem = NIL THEN text := text2; text2 := Texts.ElemBase(text(PanelElems.Text).base) END UNTIL (myR.elem # NIL) OR (text2 = NIL) OR ~ (text2 IS PanelElems.Text); IF text2 # NIL THEN Texts.OpenReader(r, text2, Texts.ElemPos(text(PanelElems.Text).base) + 1); ReadElem(r) END ELSE Texts.OpenReader(r, text2, Texts.ElemPos(text(PanelElems.Text).base) + 1); ReadElem(r) END END END END ELSE END END ReadElem;ÿÿÿÿ€8ÀÔS  &÷ÿÿ€8ÀÔ_Syntax10.Scn.Fnt3Syntax10i.Scn.Fnt_uG| VAR myR: Texts.Reader; text, text2: Texts.Text; BEGIN IF r.elem # NIL THEN text := Texts.ElemBase(r.elem) ELSE text := NIL END; Texts.ReadPrevElem(r); IF (r.elem # NIL) & ((r.elem IS WebPanelElems.Elem) OR (r.elem IS WebCellElems.Elem)) THEN WHILE (r.elem # NIL) & (r.elem IS WebPanelElems.Elem) DO (* a table was found *) Texts.OpenReader(r, r.elem(WebPanelElems.Elem).elemTxt, r.elem(WebPanelElems.Elem).elemTxt.len - 1); Texts.ReadElem(r) END; IF (r.elem # NIL) & (r.elem IS WebCellElems.Elem) THEN Texts.OpenReader(r, r.elem(WebCellElems.Elem).txt, r.elem(WebCellElems.Elem).txt.len); Texts.ReadPrevElem(r) END ELSIF (text # NIL) & (r.eot) THEN IF text IS WebCellElems.Text THEN IF Texts.ElemBase(text(WebCellElems.Text).elem) = NIL THEN RETURN END; Texts.OpenReader(myR, Texts.ElemBase(text(WebCellElems.Text).elem), Texts.ElemPos(text(WebCellElems.Text).elem)); Texts.ReadPrevElem(myR); IF myR.elem # NIL THEN WHILE (myR.elem # NIL) & (myR.elem IS WebPanelElems.Elem) DO Texts.OpenReader(myR, myR.elem(WebPanelElems.Elem).elemTxt, myR.elem(WebPanelElems.Elem).elemTxt.len - 1); Texts.ReadElem(myR) END; Texts.OpenReader(r, myR.elem(WebCellElems.Elem).txt, myR.elem(WebCellElems.Elem).txt.len); Texts.ReadPrevElem(r) ELSE (* first cell read *) text := Texts.ElemBase(text(WebCellElems.Text).elem); IF text = NIL THEN RETURN END; text2 := Texts.ElemBase(text(PanelElems.Text).base); IF text2 # NIL THEN IF text2 IS PanelElems.Text THEN REPEAT Texts.OpenReader(myR, text2, Texts.ElemPos(text(PanelElems.Text).base)); Texts.ReadPrevElem(myR); IF myR.elem = NIL THEN text := text2; text2 := Texts.ElemBase(text(PanelElems.Text).base) END UNTIL (myR.elem # NIL) OR (text2 = NIL) OR ~ (text2 IS PanelElems.Text); IF text2 # NIL THEN Texts.OpenReader(r, text2, Texts.ElemPos(text(PanelElems.Text).base)); ReadPrevElem(r) END ELSE Texts.OpenReader(r, text2, Texts.ElemPos(text(PanelElems.Text).base)); ReadPrevElem(r) END END END END END END ReadPrevElem;ÿÿÿÿ€8ÀÔT  KÆþÿÿ€8ÀÔ#Syntax10.Scn.Fnt VAR r : Texts.Reader; BEGIN IF t # NIL THEN Texts.OpenReader(r, t, pos); ReadElem(r); WHILE (r.elem # NIL) & ~ r.eot & ~ check(r.elem) DO ReadElem(r) END; elem := r.elem; IF elem # NIL THEN t := Texts.ElemBase(elem) ELSE t := NIL END ELSE elem := NIL END END FindElem;ÿÿÿÿ€8ÀÔž H¡ýÿÿ€8ÀÔ#Syntax10.Scn.Fnt== VAR tr: WebTables.TableRow; tc: WebTables.TableCell; tt: WebTables.Table; frag: WebCellElems.Elem; BEGIN elem := NIL; IF t = NIL THEN RETURN END; tr := t.first; WHILE tr # NIL DO tc := tr.first; WHILE tc # NIL DO frag := tc.first; tt := tc.table; WHILE frag # NIL DO FoldElems.FindElem(frag.txt, 0, check, elem); IF elem # NIL THEN RETURN END; IF tt # NIL THEN FindElemTable(tt, check, elem) END; IF elem # NIL THEN RETURN END; frag := frag.next END; tc := tc.next END; tr := tr.next END; elem := NIL END FindElemTable;ÿÿÿÿ€8ÀÔ’ D®ýÿÿ€8ÀÔCSyntax10.Scn.FntÃSyntax10i.Scn.Fnt A VAR r: Texts.Reader; elem: Texts.Elem; continue: BOOLEAN; BEGIN Texts.OpenReader(r, text, beg); continue := TRUE; WHILE continue & (~r.eot) & (Texts.Pos(r) <= end) DO Texts.ReadElem(r); IF Texts.Pos(r) <= end THEN elem := r.elem; IF elem # NIL THEN WITH elem: WebCellElems.Elem DO continue := action(elem) | elem: WebPanelElems.Elem DO continue := ForAllFragments(elem.elemTxt, 0, elem.elemTxt.len, action) ELSE (* ignore *) END END END END; RETURN continue END ForAllFragments;ÿÿÿÿ€8ÀÔMODULE TableTools; (* Andreas Helm,  *)   IMPORT FoldElems, PanelElems, Texts, WebCellElems, WebPanelElems, WebTables; TYPE (** Callback-procedure, to stop enumeration, this procedure should return FALSE, otherwise TRUE *) CellAction* = PROCEDURE (frag: WebCellElems.Elem): BOOLEAN; CheckProc* = PROCEDURE (e: Texts.Elem): BOOLEAN; (* reads the next elem in r, if in a table, all following cells are also read *) PROCEDURE ReadElem*(VAR r: Texts.Reader);  (* reads the previous elem in r, if in a table, all previous cells are also read *) PROCEDURE ReadPrevElem*(VAR r: Texts.Reader);  (* Reads all elems from a text t and calls check for it, until check returns true *) PROCEDURE FindElem*(VAR t: Texts.Text; pos: LONGINT; check: CheckProc; VAR elem: Texts.Elem);  (* calls for all text elems in the cells of the table t the procedure check and returns the first elem, for which check returns TRUE, or elem is set to NIL *) PROCEDURE FindElemTable*(t: WebTables.Table; check: FoldElems.CheckProc; VAR elem: Texts.Elem);  (* Iterate over all WebCellElems.Elem in a text or in a WebPanelElems.Elem; returns FALSE, if enumeration was stopped by action, otherwise TRUE *) PROCEDURE ForAllFragments*(text: Texts.Text; beg, end: LONGINT; action: CellAction): BOOLEAN;  END TableTools.