1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
var fields = [];
for (var i = 0; i < this.numFields; i++) {
fields.push(this.getNthFieldName(i));
}
for (var i = 0; i < fields.length; i++) {
var source_name = fields[i];
// modifications to name
var target_name = source_name;
// other replacements (examples)
/*
target_name = source_name.replace(/\./g, '#');
target_name = target_name.toLowerCase();
target_name = target_name.replace(/\s/g, '');
target_name = target_name.replace(/\ß/g, 'ss');
target_name = target_name.replace(/\-|\/|\*|\.|\;|\:/g, '_');
*/
var source_field = this.getField(source_name);
if (source_field !== null && source_field.page.length > 1) {
// debug output (if needed)
//console.println(JSON.stringify([target_name, source_field.type, source_field.page, source_field.rect]));
for (var j in source_field.page) {
target_name = source_name + "#" + j;
var target_field = this.addField(
target_name,
source_field.type,
source_field.page[j],
source_field.rect
);
var props = [
'alignment',
'borderStyle',
'buttonAlignX',
'buttonAlignY',
'buttonFitBounds',
'buttonScaleHow',
'buttonScaleWhen',
'comb',
'display',
'doNotScroll',
'editable',
'exportValues',
'fileSelect',
'fillColor',
'highlight',
'lineWidth',
'multiline',
'multipleSelection',
'numItems',
'password',
'readonly',
'richText',
'richValue',
'rotation',
'strokeColor',
'style',
'textColor',
'textFont',
'textSize',
'userName',
];
for (var p = 0; p < props.length; p++) {
if (testField(source_field, props[p])) {
target_field[props[p]] = source_field[props[p]];
}
}
if (j === '0') {
target_field.value = source_field.value;
}
}
this.removeField(source_name);
}
}
function testField(field, prop) {
try {
var tprop = field[prop];
return true;
} catch (e) {
return false;
}
}
|