@@ -25,8 +25,10 @@ import {
25
25
$flushHTML ,
26
26
$getAvailableSpace ,
27
27
$getChildren ,
28
+ $getContainedChildren ,
28
29
$getNextPage ,
29
30
$getParent ,
31
+ $getSubformParent ,
30
32
$hasItem ,
31
33
$hasSettableValue ,
32
34
$ids ,
@@ -106,6 +108,16 @@ function getRoot(node) {
106
108
return parent ;
107
109
}
108
110
111
+ function * getContainedChildren ( node ) {
112
+ for ( const child of node [ $getChildren ] ( ) ) {
113
+ if ( child instanceof SubformSet ) {
114
+ yield * child [ $getContainedChildren ] ( ) ;
115
+ continue ;
116
+ }
117
+ yield child ;
118
+ }
119
+ }
120
+
109
121
function valueToHtml ( value ) {
110
122
return HTMLResult . success ( {
111
123
name : "span" ,
@@ -338,6 +350,12 @@ class Area extends XFAObject {
338
350
this . subformSet = new XFAObjectArray ( ) ;
339
351
}
340
352
353
+ * [ $getContainedChildren ] ( ) {
354
+ // This function is overriden in order to fake that subforms under
355
+ // this set are in fact under parent subform.
356
+ yield * getContainedChildren ( this ) ;
357
+ }
358
+
341
359
[ $isTransparent ] ( ) {
342
360
return true ;
343
361
}
@@ -4079,6 +4097,12 @@ class Subform extends XFAObject {
4079
4097
this . subformSet = new XFAObjectArray ( ) ;
4080
4098
}
4081
4099
4100
+ * [ $getContainedChildren ] ( ) {
4101
+ // This function is overriden in order to fake that subforms under
4102
+ // this set are in fact under parent subform.
4103
+ yield * getContainedChildren ( this ) ;
4104
+ }
4105
+
4082
4106
[ $flushHTML ] ( ) {
4083
4107
return flushHTML ( this ) ;
4084
4108
}
@@ -4163,7 +4187,7 @@ class Subform extends XFAObject {
4163
4187
] ) ;
4164
4188
4165
4189
if ( this . layout . includes ( "row" ) ) {
4166
- const columnWidths = this [ $getParent ] ( ) . columnWidths ;
4190
+ const columnWidths = this [ $getSubformParent ] ( ) . columnWidths ;
4167
4191
if ( Array . isArray ( columnWidths ) && columnWidths . length > 0 ) {
4168
4192
this [ $extra ] . columnWidths = columnWidths ;
4169
4193
this [ $extra ] . currentColumn = 0 ;
@@ -4294,27 +4318,22 @@ class SubformSet extends XFAObject {
4294
4318
this . breakBefore = new XFAObjectArray ( ) ;
4295
4319
this . subform = new XFAObjectArray ( ) ;
4296
4320
this . subformSet = new XFAObjectArray ( ) ;
4297
- }
4298
4321
4299
- [ $toHTML ] ( ) {
4300
- const children = [ ] ;
4301
- if ( ! this [ $extra ] ) {
4302
- this [ $extra ] = Object . create ( null ) ;
4303
- }
4304
- this [ $extra ] . children = children ;
4322
+ // TODO: need to handle break stuff and relation.
4323
+ }
4305
4324
4306
- this [ $childrenToHTML ] ( {
4307
- filter : new Set ( [ "subform" , "subformSet" ] ) ,
4308
- include : true ,
4309
- } ) ;
4325
+ * [ $getContainedChildren ] ( ) {
4326
+ // This function is overriden in order to fake that subforms under
4327
+ // this set are in fact under parent subform.
4328
+ yield * getContainedChildren ( this ) ;
4329
+ }
4310
4330
4311
- return HTMLResult . success ( {
4312
- name : "div" ,
4313
- children,
4314
- attributes : {
4315
- id : this [ $uid ] ,
4316
- } ,
4317
- } ) ;
4331
+ [ $getSubformParent ] ( ) {
4332
+ let parent = this [ $getParent ] ( ) ;
4333
+ while ( ! ( parent instanceof Subform ) ) {
4334
+ parent = parent [ $getParent ] ( ) ;
4335
+ }
4336
+ return parent ;
4318
4337
}
4319
4338
}
4320
4339
0 commit comments