Class: Idml::Render::Renderers::TableRenderer
- Inherits:
-
Object
- Object
- Idml::Render::Renderers::TableRenderer
- Defined in:
- lib/idml/render/renderers/table_renderer.rb
Overview
Renders an IDML Table. Draws the cell grid via rectangle ops, then renders inline text in each cell. Cells with no text render as empty rectangles.
Two table layouts are supported:
1. **Schema-faithful** (real IDML): `Table` has `cell`
and `row` sibling collections. Cell `Name` encodes
column and row as `"col:row"`. Row order determines
vertical position; cell Name determines horizontal.
2. **Legacy** (synthetic test fixture): `Table` has a
`table_row` collection, each `TableRow` has a
`table_cell` collection. Nested structure.
The renderer auto-detects which layout is present.
Honors per-cell:
fill_color/fill_tint— background fill before stroke.top_inset/left_inset/bottom_inset/right_inset— text insets (replaces fixedINSET = 4.0).vertical_justification— Top / Center / Bottom / Justify.paragraph_style_range→ typed runs (per-run font + size).
Honors per-table:
single_column_width— overrides the even-division default for column widths.
Constant Summary collapse
- DEFAULT_SIZE =
10.0- DEFAULT_INSET =
4.0
Class Method Summary collapse
- .render(canvas, context) ⇒ Object
-
.render_in_box(canvas, table, box, context, start_row: 0, bottom_limit: nil) ⇒ Object
Renders a Table using caller-supplied bounds (no Placement.box lookup).
Class Method Details
.render(canvas, context) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/idml/render/renderers/table_renderer.rb', line 36 def self.render(canvas, context) table = context.item return if table.visible == false box = Placement.box(table, context.page_height) return unless box render_in_box(canvas, table, box, context) end |
.render_in_box(canvas, table, box, context, start_row: 0, bottom_limit: nil) ⇒ Object
Renders a Table using caller-supplied bounds (no
Placement.box lookup). Used by TextFrameRenderer to
render Tables inlined in a story — real IDML Tables
have no own geometry, so the containing TextFrame's
bounds stand in for the Table's bounds.
Renders the table within box. When bottom_limit is
given, rows stop at the limit and the next unrendered row
index is returned (nil when the table completed) — the
caller threads it into the next frame of the chain via
start_row, which also re-emits HeaderRowCount header
rows above the continuation.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/idml/render/renderers/table_renderer.rb', line 57 def self.render_in_box(canvas, table, box, context, start_row: 0, bottom_limit: nil) return if table.visible == false return nil if schema_faithful?(table) && start_row >= table.row.length next_row = nil canvas.save_graphics_state do next_row = if schema_faithful?(table) render_schema_faithful(canvas, table, box, context, start_row: start_row, bottom_limit: bottom_limit) else render_legacy(canvas, table, box, context) nil end end next_row end |