xs/form.xs

filter: Statementstmt 79.6% 160 / 201 Branchbran 65.1% 73 / 112 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 74.4% 233 / 313 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/pdfmake_types.c ↑ Summary src/pdfmake_textract.c »
1 MODULE = PDF::Make PACKAGE = PDF::Make::FormPtr
2 PROTOTYPES: ENABLE
3  
4 #===============================================================================
5 # Form access from document
6 #===============================================================================
7  
8 pdfmake_form_t *
9 get(doc)
10 pdfmake_doc_t *doc
11 CODE:
12 553 RETVAL = pdfmake_doc_get_form(doc);
13 553 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 526 27 553
14 526 XSRETURN_UNDEF;
15 OUTPUT:
16 RETVAL
17  
18 pdfmake_form_t *
19 create(doc)
20 pdfmake_doc_t *doc
21 CODE:
22 50 RETVAL = pdfmake_doc_create_form(doc);
23 50 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 50 50
24 0 croak("PDF::Make::Form::create: failed to create form");
25 OUTPUT:
26 RETVAL
27  
28 #===============================================================================
29 # Form properties
30 #===============================================================================
31  
32 void
33 set_need_appearances(self, need)
34 pdfmake_form_t *self
35 int need
36 CODE:
37 10 ▶ if (pdfmake_form_set_need_appearances(self, need) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_form_set_need_appearances(self, need) != PDFMAKE_OK) 0 10 10
38 0 croak("PDF::Make::Form::set_need_appearances: failed");
39  
40 size_t
41 field_count(self)
42 pdfmake_form_t *self
43 CODE:
44 7 RETVAL = pdfmake_form_field_count(self);
45 OUTPUT:
46 RETVAL
47  
48 pdfmake_field_t *
49 field_at(self, idx)
50 pdfmake_form_t *self
51 size_t idx
52 CODE:
53 6 RETVAL = pdfmake_form_field_at(self, idx);
54 6 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 3 3 6
55 3 XSRETURN_UNDEF;
56 OUTPUT:
57 RETVAL
58  
59 pdfmake_field_t *
60 field_by_name(self, name)
61 pdfmake_form_t *self
62 const char *name
63 CODE:
64 6 RETVAL = pdfmake_form_field_by_name(self, name);
65 6 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 3 3 6
66 3 XSRETURN_UNDEF;
67 OUTPUT:
68 RETVAL
69  
70 void
71 fields(self)
72 pdfmake_form_t *self
73 PPCODE:
74 3 size_t count = pdfmake_form_field_count(self);
75 9 ▶ for (size_t i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (size_t i = 0; i < count; i++) { 6 3 9
76 6 pdfmake_field_t *field = pdfmake_form_field_at(self, i);
77 6 ▶ if (field) {
Branch: 1 branch
BranchTrueFalseTotal
if (field) { 6 0 6
78 6 SV *sv = sv_newmortal();
79 6 sv_setref_pv(sv, "PDF::Make::Field", field);
80 6 ▶ XPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv); 0 6 6
81 }
82 }
83  
84 #===============================================================================
85 # Finalization and export
86 #===============================================================================
87  
88 void
89 finalize(self)
90 pdfmake_form_t *self
91 CODE:
92 14 ▶ if (pdfmake_form_finalize(self) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_form_finalize(self) != PDFMAKE_OK) 0 14 14
93 0 croak("PDF::Make::Form::finalize: failed to finalize form");
94  
95 void
96 flatten(self)
97 pdfmake_form_t *self
98 CODE:
99 3 ▶ if (pdfmake_form_flatten(self) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_form_flatten(self) != PDFMAKE_OK) 0 3 3
100 0 croak("PDF::Make::Form::flatten: failed to flatten form");
101  
102 SV *
103 export_fdf(self)
104 pdfmake_form_t *self
105 CODE:
106 pdfmake_buf_t buf;
107 3 pdfmake_buf_init(&buf);
108 3 ▶ if (pdfmake_form_export_fdf(self, &buf) != PDFMAKE_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_form_export_fdf(self, &buf) != PDFMAKE_OK) { 0 3 3
109 0 pdfmake_buf_free(&buf);
110 0 croak("PDF::Make::Form::export_fdf: export failed");
111 }
112 3 RETVAL = newSVpvn((char *)buf.data, buf.len);
113 3 pdfmake_buf_free(&buf);
114 OUTPUT:
115 RETVAL
116  
117 SV *
118 export_xfdf(self)
119 pdfmake_form_t *self
120 CODE:
121 pdfmake_buf_t buf;
122 3 pdfmake_buf_init(&buf);
123 3 ▶ if (pdfmake_form_export_xfdf(self, &buf) != PDFMAKE_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_form_export_xfdf(self, &buf) != PDFMAKE_OK) { 0 3 3
124 0 pdfmake_buf_free(&buf);
125 0 croak("PDF::Make::Form::export_xfdf: export failed");
126 }
127 3 RETVAL = newSVpvn((char *)buf.data, buf.len);
128 3 pdfmake_buf_free(&buf);
129 OUTPUT:
130 RETVAL
131  
132 void
133 import_fdf(self, data)
134 pdfmake_form_t *self
135 SV *data
136 PREINIT:
137 STRLEN len;
138 const char *bytes;
139 CODE:
140 1 bytes = SvPV(data, len);
141 1 ▶ if (pdfmake_form_import_fdf(self, (const uint8_t *)bytes, len) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_form_import_fdf(self, (const uint8_t *)bytes, len) != PDFMAKE_OK) 0 1 1
142 0 croak("PDF::Make::Form::import_fdf: import failed");
143  
144 void
145 import_xfdf(self, data)
146 pdfmake_form_t *self
147 SV *data
148 PREINIT:
149 STRLEN len;
150 const char *bytes;
151 CODE:
152 1 bytes = SvPV(data, len);
153 1 ▶ if (pdfmake_form_import_xfdf(self, (const uint8_t *)bytes, len) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_form_import_xfdf(self, (const uint8_t *)bytes, len) != PDFMAKE_OK) 0 1 1
154 0 croak("PDF::Make::Form::import_xfdf: import failed");
155  
156 MODULE = PDF::Make PACKAGE = PDF::Make::FieldPtr
157 PROTOTYPES: ENABLE
158  
159 #===============================================================================
160 # Field builders
161 #===============================================================================
162  
163 pdfmake_field_t *
164 text(doc, name, x, y, width, height)
165 pdfmake_doc_t *doc
166 const char *name
167 double x
168 double y
169 double width
170 double height
171 PREINIT:
172 pdfmake_rect_t rect;
173 CODE:
174 49 rect.x1 = x;
175 49 rect.y1 = y;
176 49 rect.x2 = x + width;
177 49 rect.y2 = y + height;
178 49 RETVAL = pdfmake_field_text(doc, name, rect);
179 49 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 49 49
180 0 croak("PDF::Make::Field::text: failed to create text field");
181 OUTPUT:
182 RETVAL
183  
184 pdfmake_field_t *
185 checkbox(doc, name, x, y, width, height, on_value = "Yes")
186 pdfmake_doc_t *doc
187 const char *name
188 double x
189 double y
190 double width
191 double height
192 const char *on_value
193 PREINIT:
194 pdfmake_rect_t rect;
195 CODE:
196 8 rect.x1 = x;
197 8 rect.y1 = y;
198 8 rect.x2 = x + width;
199 8 rect.y2 = y + height;
200 8 RETVAL = pdfmake_field_checkbox(doc, name, rect, on_value);
201 8 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 8 8
202 0 croak("PDF::Make::Field::checkbox: failed to create checkbox field");
203 OUTPUT:
204 RETVAL
205  
206 pdfmake_field_t *
207 radio_group(doc, name)
208 pdfmake_doc_t *doc
209 const char *name
210 CODE:
211 8 RETVAL = pdfmake_field_radio_group(doc, name);
212 8 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 8 8
213 0 croak("PDF::Make::Field::radio_group: failed to create radio group");
214 OUTPUT:
215 RETVAL
216  
217 pdfmake_field_t *
218 add_radio_option(group, x, y, width, height, value)
219 pdfmake_field_t *group
220 double x
221 double y
222 double width
223 double height
224 const char *value
225 PREINIT:
226 pdfmake_rect_t rect;
227 CODE:
228 18 rect.x1 = x;
229 18 rect.y1 = y;
230 18 rect.x2 = x + width;
231 18 rect.y2 = y + height;
232 18 RETVAL = pdfmake_field_add_radio_option(group, rect, value);
233 18 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 18 18
234 0 croak("PDF::Make::Field::add_radio_option: failed to add radio option");
235 OUTPUT:
236 RETVAL
237  
238 pdfmake_field_t *
239 choice(doc, name, x, y, width, height, combo = 0)
240 pdfmake_doc_t *doc
241 const char *name
242 double x
243 double y
244 double width
245 double height
246 int combo
247 PREINIT:
248 pdfmake_rect_t rect;
249 CODE:
250 7 rect.x1 = x;
251 7 rect.y1 = y;
252 7 rect.x2 = x + width;
253 7 rect.y2 = y + height;
254 7 RETVAL = pdfmake_field_choice(doc, name, rect, combo);
255 7 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 7 7
256 0 croak("PDF::Make::Field::choice: failed to create choice field");
257 OUTPUT:
258 RETVAL
259  
260 pdfmake_field_t *
261 combo(doc, name, x, y, width, height)
262 pdfmake_doc_t *doc
263 const char *name
264 double x
265 double y
266 double width
267 double height
268 PREINIT:
269 pdfmake_rect_t rect;
270 CODE:
271 2 rect.x1 = x;
272 2 rect.y1 = y;
273 2 rect.x2 = x + width;
274 2 rect.y2 = y + height;
275 2 RETVAL = pdfmake_field_choice(doc, name, rect, 1);
276 2 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 2 2
277 0 croak("PDF::Make::Field::combo: failed to create combo field");
278 OUTPUT:
279 RETVAL
280  
281 pdfmake_field_t *
282 listbox(doc, name, x, y, width, height)
283 pdfmake_doc_t *doc
284 const char *name
285 double x
286 double y
287 double width
288 double height
289 PREINIT:
290 pdfmake_rect_t rect;
291 CODE:
292 2 rect.x1 = x;
293 2 rect.y1 = y;
294 2 rect.x2 = x + width;
295 2 rect.y2 = y + height;
296 2 RETVAL = pdfmake_field_choice(doc, name, rect, 0);
297 2 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 2 2
298 0 croak("PDF::Make::Field::listbox: failed to create listbox field");
299 OUTPUT:
300 RETVAL
301  
302 pdfmake_field_t *
303 button(doc, name, x, y, width, height, caption)
304 pdfmake_doc_t *doc
305 const char *name
306 double x
307 double y
308 double width
309 double height
310 const char *caption
311 PREINIT:
312 pdfmake_rect_t rect;
313 CODE:
314 9 rect.x1 = x;
315 9 rect.y1 = y;
316 9 rect.x2 = x + width;
317 9 rect.y2 = y + height;
318 9 RETVAL = pdfmake_field_button(doc, name, rect, caption);
319 9 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 9 9
320 0 croak("PDF::Make::Field::button: failed to create button field");
321 OUTPUT:
322 RETVAL
323  
324 pdfmake_field_t *
325 signature(doc, name, x, y, width, height)
326 pdfmake_doc_t *doc
327 const char *name
328 double x
329 double y
330 double width
331 double height
332 PREINIT:
333 pdfmake_rect_t rect;
334 CODE:
335 3 rect.x1 = x;
336 3 rect.y1 = y;
337 3 rect.x2 = x + width;
338 3 rect.y2 = y + height;
339 3 RETVAL = pdfmake_field_signature(doc, name, rect);
340 3 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 3 3
341 0 croak("PDF::Make::Field::signature: failed to create signature field");
342 OUTPUT:
343 RETVAL
344  
345 #===============================================================================
346 # Field properties (getters)
347 #===============================================================================
348  
349 const char *
350 type(self)
351 pdfmake_field_t *self
352 CODE:
353 7 pdfmake_field_type_t ft = pdfmake_field_type(self);
354 7 switch (ft) {
355 2 case PDFMAKE_FIELD_TEXT: RETVAL = "text"; break;
356 3 case PDFMAKE_FIELD_BUTTON: RETVAL = "button"; break;
357 1 case PDFMAKE_FIELD_CHOICE: RETVAL = "choice"; break;
358 1 case PDFMAKE_FIELD_SIGNATURE: RETVAL = "signature"; break;
359 0 default: RETVAL = "unknown"; break;
360 }
361 OUTPUT:
362 RETVAL
363  
364 const char *
365 name(self)
366 pdfmake_field_t *self
367 CODE:
368 9 RETVAL = pdfmake_field_name(self);
369 9 ▶ if (!RETVAL) RETVAL = "";
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) RETVAL = ""; 0 9 9
370 OUTPUT:
371 RETVAL
372  
373 const char *
374 full_name(self)
375 pdfmake_field_t *self
376 CODE:
377 2 RETVAL = pdfmake_field_full_name(self);
378 2 ▶ if (!RETVAL) RETVAL = "";
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) RETVAL = ""; 0 2 2
379 OUTPUT:
380 RETVAL
381  
382 SV *
383 value(self, ...)
384 pdfmake_field_t *self
385 CODE:
386 20 ▶ if (items > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { 3 17 20
387 3 const char *val = SvPV_nolen(ST(1));
388 3 ▶ if (pdfmake_field_set_value(self, val) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_set_value(self, val) != PDFMAKE_OK) 0 3 3
389 0 croak("PDF::Make::Field::value: failed to set value");
390 3 RETVAL = ST(1);
391 3 SvREFCNT_inc(RETVAL);
392 } else {
393 17 const char *val = pdfmake_field_value(self);
394 17 ▶ RETVAL = val ? newSVpv(val, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = val ? newSVpv(val, 0) : &PL_sv_undef; 17 0 17
395 }
396 OUTPUT:
397 RETVAL
398  
399 void
400 set_value(self, value)
401 pdfmake_field_t *self
402 const char *value
403 CODE:
404 33 ▶ if (pdfmake_field_set_value(self, value) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_set_value(self, value) != PDFMAKE_OK) 0 33 33
405 0 croak("PDF::Make::Field::set_value: failed to set value");
406  
407 void
408 set_default_value(self, value)
409 pdfmake_field_t *self
410 const char *value
411 CODE:
412 2 ▶ if (pdfmake_field_set_default_value(self, value) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_set_default_value(self, value) != PDFMAKE_OK) 0 2 2
413 0 croak("PDF::Make::Field::set_default_value: failed to set default value");
414  
415 #===============================================================================
416 # Field flags
417 #===============================================================================
418  
419 UV
420 flags(self)
421 pdfmake_field_t *self
422 CODE:
423 7 ▶ RETVAL = pdfmake_field_flags(self);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = pdfmake_field_flags(self); 6 1 7
424 OUTPUT:
425 RETVAL
426  
427 void
428 set_flags(self, flags)
429 pdfmake_field_t *self
430 UV flags
431 CODE:
432 1 ▶ if (pdfmake_field_set_flags(self, (uint32_t)flags) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_set_flags(self, (uint32_t)flags) != PDFMAKE_OK) 0 1 1
433 0 croak("PDF::Make::Field::set_flags: failed");
434  
435 void
436 add_flags(self, flags)
437 pdfmake_field_t *self
438 UV flags
439 CODE:
440 2 ▶ if (pdfmake_field_add_flags(self, (uint32_t)flags) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_add_flags(self, (uint32_t)flags) != PDFMAKE_OK) 0 2 2
441 0 croak("PDF::Make::Field::add_flags: failed");
442  
443 void
444 clear_flags(self, flags)
445 pdfmake_field_t *self
446 UV flags
447 CODE:
448 1 ▶ if (pdfmake_field_clear_flags(self, (uint32_t)flags) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_clear_flags(self, (uint32_t)flags) != PDFMAKE_OK) 0 1 1
449 0 croak("PDF::Make::Field::clear_flags: failed");
450  
451 void
452 readonly(self, val = 1)
453 pdfmake_field_t *self
454 int val
455 CODE:
456 8 ▶ if (val)
Branch: 1 branch
BranchTrueFalseTotal
if (val) 6 2 8
457 6 pdfmake_field_add_flags(self, PDFMAKE_FF_READONLY);
458 else
459 2 pdfmake_field_clear_flags(self, PDFMAKE_FF_READONLY);
460  
461 void
462 required(self, val = 1)
463 pdfmake_field_t *self
464 int val
465 CODE:
466 6 ▶ if (val)
Branch: 1 branch
BranchTrueFalseTotal
if (val) 4 2 6
467 4 pdfmake_field_add_flags(self, PDFMAKE_FF_REQUIRED);
468 else
469 2 pdfmake_field_clear_flags(self, PDFMAKE_FF_REQUIRED);
470  
471 void
472 noexport(self, val = 1)
473 pdfmake_field_t *self
474 int val
475 CODE:
476 2 ▶ if (val)
Branch: 1 branch
BranchTrueFalseTotal
if (val) 1 1 2
477 1 pdfmake_field_add_flags(self, PDFMAKE_FF_NOEXPORT);
478 else
479 1 pdfmake_field_clear_flags(self, PDFMAKE_FF_NOEXPORT);
480  
481 void
482 multiline(self, val = 1)
483 pdfmake_field_t *self
484 int val
485 CODE:
486 5 ▶ if (val)
Branch: 1 branch
BranchTrueFalseTotal
if (val) 4 1 5
487 4 pdfmake_field_add_flags(self, PDFMAKE_FF_MULTILINE);
488 else
489 1 pdfmake_field_clear_flags(self, PDFMAKE_FF_MULTILINE);
490  
491 void
492 password(self, val = 1)
493 pdfmake_field_t *self
494 int val
495 CODE:
496 3 ▶ if (val)
Branch: 1 branch
BranchTrueFalseTotal
if (val) 2 1 3
497 2 pdfmake_field_add_flags(self, PDFMAKE_FF_PASSWORD);
498 else
499 1 pdfmake_field_clear_flags(self, PDFMAKE_FF_PASSWORD);
500  
501 int
502 is_readonly(self)
503 pdfmake_field_t *self
504 CODE:
505 5 ▶ RETVAL = (pdfmake_field_flags(self) & PDFMAKE_FF_READONLY) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (pdfmake_field_flags(self) & PDFMAKE_FF_READONLY) ? 1 : 0; 2 3 5
506 OUTPUT:
507 RETVAL
508  
509 int
510 is_required(self)
511 pdfmake_field_t *self
512 CODE:
513 4 ▶ RETVAL = (pdfmake_field_flags(self) & PDFMAKE_FF_REQUIRED) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (pdfmake_field_flags(self) & PDFMAKE_FF_REQUIRED) ? 1 : 0; 1 3 4
514 OUTPUT:
515 RETVAL
516  
517 #===============================================================================
518 # Appearance settings
519 #===============================================================================
520  
521 void
522 set_da(self, da)
523 pdfmake_field_t *self
524 const char *da
525 CODE:
526 26 ▶ if (pdfmake_field_set_da(self, da) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_set_da(self, da) != PDFMAKE_OK) 0 26 26
527 0 croak("PDF::Make::Field::set_da: failed");
528  
529 void
530 set_quadding(self, q)
531 pdfmake_field_t *self
532 int q
533 CODE:
534 2 ▶ if (pdfmake_field_set_quadding(self, (pdfmake_quadding_t)q) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_set_quadding(self, (pdfmake_quadding_t)q) != PDFMAKE_OK) 0 2 2
535 0 croak("PDF::Make::Field::set_quadding: failed");
536  
537 void
538 align_left(self)
539 pdfmake_field_t *self
540 CODE:
541 1 pdfmake_field_set_quadding(self, PDFMAKE_QUADDING_LEFT);
542  
543 void
544 align_center(self)
545 pdfmake_field_t *self
546 CODE:
547 2 pdfmake_field_set_quadding(self, PDFMAKE_QUADDING_CENTER);
548  
549 void
550 align_right(self)
551 pdfmake_field_t *self
552 CODE:
553 1 pdfmake_field_set_quadding(self, PDFMAKE_QUADDING_RIGHT);
554  
555 void
556 set_max_len(self, max_len)
557 pdfmake_field_t *self
558 int max_len
559 CODE:
560 3 ▶ if (pdfmake_field_set_max_len(self, max_len) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_set_max_len(self, max_len) != PDFMAKE_OK) 0 3 3
561 0 croak("PDF::Make::Field::set_max_len: failed");
562  
563 #===============================================================================
564 # Choice field options
565 #===============================================================================
566  
567 size_t
568 option_count(self)
569 pdfmake_field_t *self
570 CODE:
571 3 RETVAL = pdfmake_field_option_count(self);
572 OUTPUT:
573 RETVAL
574  
575 void
576 add_option(self, display, export_val = NULL)
577 pdfmake_field_t *self
578 const char *display
579 const char *export_val
580 CODE:
581 32 ▶ if (pdfmake_field_add_option(self, display, export_val) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_add_option(self, display, export_val) != PDFMAKE_OK) 0 32 32
582 0 croak("PDF::Make::Field::add_option: failed to add option");
583  
584 void
585 options(self)
586 pdfmake_field_t *self
587 PPCODE:
588 2 size_t count = pdfmake_field_option_count(self);
589 7 ▶ for (size_t i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (size_t i = 0; i < count; i++) { 5 2 7
590 5 const char *display = pdfmake_field_option_display(self, i);
591 5 const char *export_val = pdfmake_field_option_export(self, i);
592 5 HV *opt = newHV();
593 5 ▶ if (display)
Branch: 1 branch
BranchTrueFalseTotal
if (display) 5 0 5
594 5 hv_store(opt, "display", 7, newSVpv(display, 0), 0);
595 5 ▶ if (export_val)
Branch: 1 branch
BranchTrueFalseTotal
if (export_val) 5 0 5
596 5 hv_store(opt, "export", 6, newSVpv(export_val, 0), 0);
597 5 ▶ XPUSHs(sv_2mortal(newRV_noinc((SV *)opt)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newRV_noinc((SV *)opt))); 0 5 5
598 }
599  
600 #===============================================================================
601 # Field-page association
602 #===============================================================================
603  
604 void
605 add_to_page(self, page)
606 pdfmake_field_t *self
607 pdfmake_page_t *page
608 CODE:
609 70 ▶ if (pdfmake_page_add_field(page, self) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_page_add_field(page, self) != PDFMAKE_OK) 0 70 70
610 0 croak("PDF::Make::Field::add_to_page: failed to add field to page");
611  
612 #===============================================================================
613 # Button actions
614 #===============================================================================
615  
616 void
617 set_submit_url(self, url)
618 pdfmake_field_t *self
619 const char *url
620 PREINIT:
621 size_t len;
622 char *copy;
623 CODE:
624 0 len = strlen(url);
625 0 copy = (char *)pdfmake_arena_alloc(self->doc->arena, len + 1);
626 0 memcpy(copy, url, len + 1);
627 0 self->action_url = copy;
628  
629 void
630 set_uri_action(self, uri)
631 pdfmake_field_t *self
632 const char *uri
633 PREINIT:
634 size_t len;
635 char *copy;
636 CODE:
637 2 len = strlen(uri);
638 2 copy = (char *)pdfmake_arena_alloc(self->doc->arena, len + 1);
639 2 memcpy(copy, uri, len + 1);
640 2 self->action_uri = copy;
641  
642 void
643 set_reset_action(self)
644 pdfmake_field_t *self
645 CODE:
646 1 self->action_reset = 1;
647  
648 void
649 set_javascript(self, js)
650 pdfmake_field_t *self
651 const char *js
652 PREINIT:
653 size_t len;
654 char *copy;
655 CODE:
656 0 len = strlen(js);
657 0 copy = (char *)pdfmake_arena_alloc(self->doc->arena, len + 1);
658 0 memcpy(copy, js, len + 1);
659 0 self->action_js = copy;
660  
661 #===============================================================================
662 # Appearance generation and flattening
663 #===============================================================================
664  
665 void
666 generate_appearance(self)
667 pdfmake_field_t *self
668 CODE:
669 1 ▶ if (pdfmake_field_generate_appearance(self) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_generate_appearance(self) != PDFMAKE_OK) 0 1 1
670 0 croak("PDF::Make::Field::generate_appearance: failed");
671  
672 void
673 flatten(self)
674 pdfmake_field_t *self
675 CODE:
676 1 ▶ if (pdfmake_field_flatten(self) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_field_flatten(self) != PDFMAKE_OK) 0 1 1
677 0 croak("PDF::Make::Field::flatten: failed to flatten field");
678  
679 #===============================================================================
680 # Field hierarchy
681 #===============================================================================
682  
683 pdfmake_field_t *
684 parent(self)
685 pdfmake_field_t *self
686 CODE:
687 2 RETVAL = self->parent;
688 2 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 1 1 2
689 1 XSRETURN_UNDEF;
690 OUTPUT:
691 RETVAL
692  
693 void
694 children(self)
695 pdfmake_field_t *self
696 PPCODE:
697 2 pdfmake_field_t *child = self->first_child;
698 7 ▶ while (child) {
Branch: 1 branch
BranchTrueFalseTotal
while (child) { 5 2 7
699 5 SV *sv = sv_newmortal();
700 5 sv_setref_pv(sv, "PDF::Make::Field", child);
701 5 ▶ XPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv); 0 5 5
702 5 child = child->next_sibling;
703 }
704  
705 int
706 has_children(self)
707 pdfmake_field_t *self
708 CODE:
709 2 ▶ RETVAL = (self->first_child != NULL);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (self->first_child != NULL); 1 1 2
710 OUTPUT:
711 RETVAL
« src/pdfmake_types.c ↑ Summary src/pdfmake_textract.c »