TableOpsImpl.Mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Created by Rick Beach, June 6, 1985 2:07:37 pm PDT
=
BEGIN
OPEN TableBase, TableOps;
DeleteRow:
PUBLIC PROCEDURE [table: RefTable, deleteTopGrid, deleteBottomGrid: GridNumber] = {
delete between deleteTopGrid (exclusive) and deleteBottomGrid (inclusive)
Prepare the new tableGrid
EnumerateTableByRows[DeleteBox]
Install new tableGrid
DeleteBox[box]
deltaGrid ← deleteBottomGrid-deleteTopGrid
ASSERT box.top < box.bottom AND deleteTopGrid < deleteBottomGrid
IF box.top >= deleteTopGrid AND box.bottom <= deleteBottomGrid THEN don't copy this box
ELSE {
IF box.top > deleteTopGrid THEN {
IF box.top <= deleteBottomGrid
THEN box.top ← deleteTopGrid
ELSE box.top ← box.top - deltaGrid
}
IF box.bottom > deleteTopGrid THEN {
IF box.bottom <= deleteBottomGrid
THEN box.bottom ← deleteTopGrid
ELSE box.bottom ← box.bottom - deltaGrid
}
insert box in new tableGrid
}
};
DeleteCol:
PUBLIC PROCEDURE [table: RefTable, deleteLeftGrid, deleteRightGrid: GridNumber] = {
analagous to DeleteRowStructure
};
InsertRow:
PUBLIC PROCEDURE [table: RefTable, rowGrid: GridNumber, where: BeforeOrAfter] = {
insert a new row, either before or after rowGrid
Prepare a new tableGrid
EnumerateTable[InsertBox]
Install new tableGrid
worry about
rowGrids ← rowGrids + 1;
rowGridPosition vector changes;
rowConstraints need relabelling
InsertBox[box]
SELECT where FROM
before => {
IF box.top > rowGrid THEN box.top ← box.top + 1
IF box.bottom >= rowGrid THEN box.bottom ← box.bottom + 1
}
after => {
IF box.top >= rowGrid THEN box.top ← box.top + 1
IF box.bottom > rowGrid THEN box.bottom ← box.bottom + 1
}
ENDCASE => ERROR;
insert box in new tableGrid
};
InsertCol:
PUBLIC PROCEDURE [table: RefTable, colGrid: GridNumber, where: BeforeOrAfter] = {
insert a new row, either before or after rowGrid
Prepare a new tableGrid
EnumerateTable[InsertBox]
Install new tableGrid
worry about
rowGrids ← rowGrids + 1;
rowGridPosition vector changes;
rowConstraints need relabelling
InsertBox[box]
SELECT where FROM
before => {
IF box.top > rowGrid THEN box.top ← box.top + 1
IF box.bottom >= rowGrid THEN box.bottom ← box.bottom + 1
}
after => {
IF box.top >= rowGrid THEN box.top ← box.top + 1
IF box.bottom > rowGrid THEN box.bottom ← box.bottom + 1
}
ENDCASE => ERROR;
insert box in new tableGrid
};
TransposeTable:
PUBLIC PROCEDURE [table: RefTable] = {
transpose rows and columns
Prepare a new tableGrid
EnumerateTable[TransposeBox]
Install new tableGrid
worry about
switching rowGrids and colGrids
switching rowGridPosition and colGridPosition vectors
relabel rowConstraints and colConstraints
Transpose[box]
box.top <-> box.left
box.bottom <-> box.right
insert box in new tableGrid
};