TableOpsImpl.Mesa
Created by Rick Beach, December 13, 1984 2:56:29 pm PST
DIRECTORY
TableBase,
TableOps;
TableOpsImpl: CEDAR PROGRAM
EXPORTS TableOps = {
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
};
}.