idml 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73b6eace594144002b5d513bb823512ff44a018e90dffb83188167674e839975
4
- data.tar.gz: bcdebe8d9ba4c525d0b9f0bb0c47e10dcb08edb15d22c145031bb0cdbb796b7d
3
+ metadata.gz: 64f0fb65e931a0ba911043cdc0a885dab5d79257519b519896c07f8a8de9cc14
4
+ data.tar.gz: c25ece7b2f8d61ee13e7e572a3e4089cda665f307e20831a7a46cfa7c7c2ff52
5
5
  SHA512:
6
- metadata.gz: d9637751e91a71db94cc5ab3ede0843eecde0aa35323a128309d21a4e4c3c0c7c88f08e887d7b9d67a081454747e14d85954b43b9e0e3429325f9e39c1bf0b17
7
- data.tar.gz: d92faf74e08e0f82c9c4265ea0f1532a7d73c25b4195c992a984eedce7625f7cac1d51c367bb35fbcfa7563c77d701e0f7134438aea5bd3d0d2a359a47d1e639
6
+ metadata.gz: e2113e93725afbf9d5c025b1d0b50d698b4bd0ef47815f7fda87a703e007627b769bbb1118b924ce6d932cf78aff23877d20de303b60f3a9df1cd51f53947849
7
+ data.tar.gz: 856b9aa6fad47550fd6da61a1ebbc348be2752cde9eb5a1a165beadfd8b16c5d2ed763d0b5af68af6252b2631561b1c521200cadae00bfdafb0a15a0807d702e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- idml (0.4.5)
4
+ idml (0.4.6)
5
5
  bigdecimal
6
6
  lutaml-model (~> 0.8.18)
7
7
  pdfrb
@@ -183,7 +183,7 @@ CHECKSUMS
183
183
  ffi (1.17.4-x86_64-darwin) sha256=aa70390523cf3235096cf64962b709b4cfbd5c082a2cb2ae714eb0fe2ccda496
184
184
  ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
185
185
  ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e
186
- idml (0.4.5)
186
+ idml (0.4.6)
187
187
  json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
188
188
  language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
189
189
  lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
@@ -1,35 +1,62 @@
1
1
  # TODO PDF 84: Schema-faithful Table/Cell/Row structure
2
2
 
3
- ## Status: PARTIALCell and Row elements added; full restructure deferred
3
+ ## Status: DONEschema-faithful model validated against real fixture
4
4
 
5
- ## What was added
5
+ ## What was done
6
6
 
7
- Schema-faithful element classes alongside the legacy non-standard
8
- ones, so existing fixtures continue to work:
7
+ Schema-faithful element classes match the real IDML structure
8
+ (validated against `spec/fixtures/sample-with-table-more/`):
9
9
 
10
10
  - **`Elements::Cell`** — matches `Cell_Object` RNC. Captures Self,
11
- Name, RowSpan, ColumnSpan, insets, FillColor, FillTint,
12
- VerticalJustification, and inline `CharacterStyleRange` children.
13
- `text_content` walks inline CSRs. `col_row` decodes the
14
- `"col_row"` Name format.
11
+ Name (col:row encoding like "0:0"), RowSpan, ColumnSpan,
12
+ ColumnType, CellType, TextTopInset/TextLeftInset/etc.,
13
+ FillColor, FillTint, VerticalJustification, AppliedCellStyle,
14
+ and inline `ParagraphStyleRange` children. `text_content` walks
15
+ inline PSRs. `col_row` decodes the `"col:row"` Name format.
15
16
  - **`Elements::Row`** — matches `Row_Object` RNC. Captures Self,
16
- Name, insets, FillColor, height constraints.
17
- - **`Elements::Table`** now declares `cell` and `row` collections
17
+ Name (row index), TextTopInset/TextLeftInset/etc., FillColor,
18
+ SingleRowHeight, MinimumHeight, MaximumHeight.
19
+ - **`Elements::Table`** declares `cell` and `row` collections
18
20
  alongside the legacy `table_row`. Both parse correctly from XML.
19
-
20
- ## What remains deferred
21
-
22
- The full schema-faithful refactor — moving Table out of SpreadObject
23
- (per RNC, Tables live in Stories, not Spreads) and removing the
24
- legacy `Elements::TableRow`/`TableCell` classes — requires a real
25
- IDML fixture with tables to validate.
26
-
27
- Until then:
28
- - The legacy `Table > TableRow > TableCell` path handles the
29
- existing synthetic test fixture.
30
- - The schema-faithful `Table > {Cell, Row}` path is available for
31
- future fixtures.
32
- - `TableRenderer` still uses the legacy path.
21
+ - **`Elements::CharacterStyleRange`** now has a `table` collection
22
+ so CSR > Table > {Cell, Row} parses end-to-end (per RNC, Tables
23
+ appear inside CSRs in Stories, not in Spreads).
24
+
25
+ ## Real-fixture validation
26
+
27
+ `spec/fixtures/sample-with-table-more/sample-with-table-more.idml`
28
+ is a 3-spread IDML with a single Table in `Story_u1b7`:
29
+
30
+ - Table Self=`u1b7i1cc`, 9 Row children, 83 Cell children.
31
+ - First cell Name=`"0:0"`, content=`"H1"` (header).
32
+ - Cell Name increments col within a row (`"0:0"`, `"1:0"`, `"2:0"`).
33
+
34
+ `spec/idml/fixtures/sample_with_table_more_spec.rb` covers:
35
+ - Package structure (3 spreads, 10 stories).
36
+ - Table discovery via story → PSR → CSR > Table.
37
+ - Table Self, row count, cell count.
38
+ - Row Self pattern (Table Self + `Row<N>`).
39
+ - Cell Name format and col_row decoding.
40
+ - Cell text_content from inline PSR > CSR > Content.
41
+ - Cell column_type (HeaderColumn).
42
+ - End-to-end PDF render.
43
+
44
+ ## Legacy preserved
45
+
46
+ The existing `Elements::Table`/`TableRow`/`TableCell` classes
47
+ (synthetic, non-schema-faithful) remain for the existing synthetic
48
+ `table_renderer_spec.rb` test. They are not removed because no
49
+ real IDML uses them and removing them would break the existing test.
50
+
51
+ ## Future work
52
+
53
+ - Migrate `TableRenderer` to use the schema-faithful `cell`/`row`
54
+ collections instead of legacy `table_row`. The renderer is the
55
+ last consumer of the legacy structure.
56
+ - Render Tables discovered in Stories (currently only Spread-level
57
+ tables are dispatched to TableRenderer; CSR-embedded Tables are
58
+ skipped — they need TextFrameRenderer integration to render in
59
+ place).
33
60
 
34
61
  ## Current state vs schema
35
62
 
@@ -13,13 +13,16 @@ module Idml
13
13
  # existing synthetic test fixture — see TODO 84.
14
14
  #
15
15
  # The cell's `Name` attribute encodes its column/row position
16
- # (e.g., `"0_0"` for column 0, row 0). Carries text content via
17
- # inline `<CharacterStyleRange>` children.
16
+ # as `"col:row"` (e.g., `"0:0"`, `"1:2"`). Carries text content
17
+ # via inline `<ParagraphStyleRange>` → `<CharacterStyleRange>`
18
+ # → `<Content>` children, the same structure as a Story.
18
19
  class Cell < Lutaml::Model::Serializable
19
20
  attribute :self_attr, :string
20
21
  attribute :name, :string
21
22
  attribute :row_span, :integer
22
23
  attribute :column_span, :integer
24
+ attribute :column_type, :string
25
+ attribute :cell_type, :string
23
26
  attribute :top_inset, :float
24
27
  attribute :left_inset, :float
25
28
  attribute :bottom_inset, :float
@@ -31,7 +34,8 @@ module Idml
31
34
  attribute :vertical_justification, :string
32
35
  attribute :paragraph_spacing_limit, :float
33
36
  attribute :rotation_angle, :float
34
- attribute :character_style_range, Idml::Elements::CharacterStyleRange,
37
+ attribute :applied_cell_style, :string
38
+ attribute :paragraph_style_range, Idml::Elements::ParagraphStyleRange,
35
39
  collection: true
36
40
 
37
41
  xml do
@@ -40,30 +44,33 @@ module Idml
40
44
  map_attribute "Name", to: :name
41
45
  map_attribute "RowSpan", to: :row_span
42
46
  map_attribute "ColumnSpan", to: :column_span
43
- map_attribute "TopInset", to: :top_inset
44
- map_attribute "LeftInset", to: :left_inset
45
- map_attribute "BottomInset", to: :bottom_inset
46
- map_attribute "RightInset", to: :right_inset
47
+ map_attribute "ColumnType", to: :column_type
48
+ map_attribute "CellType", to: :cell_type
49
+ map_attribute "TextTopInset", to: :top_inset
50
+ map_attribute "TextLeftInset", to: :left_inset
51
+ map_attribute "TextBottomInset", to: :bottom_inset
52
+ map_attribute "TextRightInset", to: :right_inset
47
53
  map_attribute "FillColor", to: :fill_color
48
54
  map_attribute "FillTint", to: :fill_tint
49
55
  map_attribute "OverprintFill", to: :overprint_fill
50
- map_attribute "ClipContentToCell", to: :clip_content_to_cell
56
+ map_attribute "ClipContentToTextCell", to: :clip_content_to_cell
51
57
  map_attribute "VerticalJustification", to: :vertical_justification
52
58
  map_attribute "ParagraphSpacingLimit", to: :paragraph_spacing_limit
53
59
  map_attribute "RotationAngle", to: :rotation_angle
54
- map_element "CharacterStyleRange", to: :character_style_range
60
+ map_attribute "AppliedCellStyle", to: :applied_cell_style
61
+ map_element "ParagraphStyleRange", to: :paragraph_style_range
55
62
  end
56
63
 
57
64
  def text_content
58
- character_style_range.filter_map(&:text_content).join
65
+ paragraph_style_range.filter_map(&:text_content).join
59
66
  end
60
67
 
61
- # Cell name format is "column_row" (e.g., "0_0", "1_2").
68
+ # Cell name format is "col:row" (e.g., "0:0", "1:2").
62
69
  # Returns [col, row] integers or nil if Name is malformed.
63
70
  def col_row
64
71
  return nil unless name
65
72
 
66
- parts = name.split("_")
73
+ parts = name.split(":")
67
74
  return nil unless parts.length == 2
68
75
 
69
76
  [parts[0].to_i, parts[1].to_i]
@@ -298,6 +298,7 @@ module Idml
298
298
  attribute :content, Idml::Elements::Content, collection: true
299
299
  attribute :hyperlink_text_source, Idml::Elements::HyperlinkTextSource,
300
300
  collection: true
301
+ attribute :table, Idml::Elements::Table, collection: true
301
302
  attribute :xml_element, Idml::Elements::XmlElement, collection: true
302
303
 
303
304
  xml do
@@ -652,6 +653,7 @@ module Idml
652
653
  map_element "CharacterStyleRange", to: :character_style_range
653
654
  map_element "Content", to: :content
654
655
  map_element "HyperlinkTextSource", to: :hyperlink_text_source
656
+ map_element "Table", to: :table
655
657
  map_element "XMLElement", to: :xml_element
656
658
  end
657
659
 
@@ -23,6 +23,7 @@ module Idml
23
23
  attribute :fill_color, :string
24
24
  attribute :fill_tint, :float
25
25
  attribute :overprint_fill, :boolean
26
+ attribute :clip_content_to_cell, :boolean
26
27
  attribute :single_row_height, :float
27
28
  attribute :minimum_height, :float
28
29
  attribute :maximum_height, :float
@@ -31,13 +32,14 @@ module Idml
31
32
  root "Row"
32
33
  map_attribute "Self", to: :self_attr
33
34
  map_attribute "Name", to: :name
34
- map_attribute "TopInset", to: :top_inset
35
- map_attribute "LeftInset", to: :left_inset
36
- map_attribute "BottomInset", to: :bottom_inset
37
- map_attribute "RightInset", to: :right_inset
35
+ map_attribute "TextTopInset", to: :top_inset
36
+ map_attribute "TextLeftInset", to: :left_inset
37
+ map_attribute "TextBottomInset", to: :bottom_inset
38
+ map_attribute "TextRightInset", to: :right_inset
38
39
  map_attribute "FillColor", to: :fill_color
39
40
  map_attribute "FillTint", to: :fill_tint
40
41
  map_attribute "OverprintFill", to: :overprint_fill
42
+ map_attribute "ClipContentToTextCell", to: :clip_content_to_cell
41
43
  map_attribute "SingleRowHeight", to: :single_row_height
42
44
  map_attribute "MinimumHeight", to: :minimum_height
43
45
  map_attribute "MaximumHeight", to: :maximum_height
data/lib/idml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Idml
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose