Skip to main content

Module grid

Module grid 

Source
Expand description

Format-neutral logical grid derivation for tables.

A table’s cells carry only spans (col_span/row_span); their absolute grid positions are implicit in row/cell order. This module derives the pre-merge logical grid — the same coordinate system used by document formats on the wire — from Core data alone, using a row-major greedy placement scan (cursor per row, skipping positions occupied by spans from previous rows).

Two surfaces share one placement algorithm:

  • TableGrid::from_tablestrict: fails on any tiling violation (overlap, hole, bottom overhang, oversized grid). Addressing surfaces (export, cell editing) use this so addresses are only ever derived from well-formed grids.
  • grid_placementslenient: mirrors the historical encoder behaviour exactly, performing no validation. Format encoders use this so byte output for existing documents (including malformed tables) never changes.

The grid validates only what Core can see. Wire-level addresses that a source format may have carried are not compared here (decoders normalize into Core before this module runs).

Structs§

GridCell
An anchor cell placed on the logical grid.
GridCoord
Absolute position on the pre-merge logical grid, zero-based.
GridPlacements
Result of the lenient placement scan (see grid_placements).
PlacedCell
One placement produced by the lenient scan: where a cell landed.
TableGrid
The derived logical grid of a table (strict; see module docs).

Enums§

GridError
Why a table’s cells do not tile a well-formed logical grid.

Constants§

MAX_GRID_POSITIONS
Maximum number of logical grid positions (rows × cols) a grid may have.

Functions§

grid_placements
Places every cell on the logical grid without validating the result.