xs/page.xs

filter: Statementstmt 64.7% 22 / 34 Branchbran 50.0% 22 / 44 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 56.4% 44 / 78 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/font.xs ↑ Summary src/pdfmake_watermark.c »
1 MODULE = PDF::Make PACKAGE = PDF::Make::Page
2 PROTOTYPES: ENABLE
3  
4 int
5 add_font(self, name, base_font)
6 pdfmake_page_t *self
7 const char *name
8 const char *base_font
9 CODE:
10 0 RETVAL = pdfmake_page_add_font(self, name, base_font);
11 0 ▶ if (RETVAL < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) 0 0 0
12 0 croak("PDF::Make::Page::add_font: failed to add font %s", name);
13 OUTPUT:
14 RETVAL
15  
16 int
17 add_std14_font(self, name, font_id)
18 pdfmake_page_t *self
19 const char *name
20 int font_id
21 CODE:
22 698 RETVAL = pdfmake_page_add_std14_font(self, name, (pdfmake_std14_font_t)font_id);
23 698 ▶ if (RETVAL < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) 0 698 698
24 0 croak("PDF::Make::Page::add_std14_font: failed to add standard font");
25 OUTPUT:
26 RETVAL
27  
28 UV
29 add_font_ref(self, name, font_obj_num)
30 pdfmake_page_t *self
31 const char *name
32 UV font_obj_num
33 CODE:
34 3 RETVAL = pdfmake_page_add_font_ref(self, name, (uint32_t)font_obj_num);
35 3 ▶ if (RETVAL == 0)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL == 0) 0 3 3
36 0 croak("PDF::Make::Page::add_font_ref: failed to add font reference");
37 OUTPUT:
38 RETVAL
39  
40 void
41 set_content(self, content)
42 pdfmake_page_t *self
43 SV *content
44 PREINIT:
45 STRLEN len;
46 const char *data;
47 CODE:
48 612 data = SvPV(content, len);
49 612 ▶ if (pdfmake_page_set_content(self, (const uint8_t*)data, len) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_page_set_content(self, (const uint8_t*)data, len) != PDFMAKE_OK) 0 612 612
50 0 croak("PDF::Make::Page::set_content: failed to set content");
51  
52 void
53 append_content(self, content)
54 pdfmake_page_t *self
55 SV *content
56 PREINIT:
57 STRLEN len;
58 const char *data;
59 CODE:
60 0 data = SvPV(content, len);
61 0 ▶ if (pdfmake_page_append_content(self, (const uint8_t*)data, len) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_page_append_content(self, (const uint8_t*)data, len) != PDFMAKE_OK) 0 0 0
62 0 croak("PDF::Make::Page::append_content: failed");
63  
64 int
65 add_image(self, name, img_obj_num)
66 pdfmake_page_t *self
67 const char *name
68 UV img_obj_num
69 CODE:
70 17 RETVAL = pdfmake_page_add_image(self, name, (uint32_t)img_obj_num);
71 17 ▶ if (RETVAL < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) 0 17 17
72 0 croak("PDF::Make::Page::add_image: failed to add image %s", name);
73 OUTPUT:
74 RETVAL
75  
76 void
77 add_annot(self, annot_obj_num)
78 pdfmake_page_t *self
79 UV annot_obj_num
80 CODE:
81 30 ▶ if (pdfmake_page_add_annot(self, (uint32_t)annot_obj_num) != PDFMAKE_OK)
Branch: 1 branch
BranchTrueFalseTotal
if (pdfmake_page_add_annot(self, (uint32_t)annot_obj_num) != PDFMAKE_OK) 0 30 30
82 0 croak("PDF::Make::Page::add_annot: failed to add annotation %u", (unsigned)annot_obj_num);
83  
84 double
85 width(self)
86 pdfmake_page_t *self
87 CODE:
88 45 ▶ RETVAL = self->width;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->width; 40 5 45
89 OUTPUT:
90 RETVAL
91  
92 double
93 height(self)
94 pdfmake_page_t *self
95 CODE:
96 45 ▶ RETVAL = self->height;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = self->height; 40 5 45
97 OUTPUT:
98 RETVAL
99  
100 void
101 DESTROY(self)
102 pdfmake_page_t *self
103 CODE:
104 /* Page is owned by document, freed when document is freed */
105 PERL_UNUSED_VAR(self);
106  
107 int
108 add_ocg(self, name, ocg_obj_num)
109 pdfmake_page_t *self
110 const char *name
111 UV ocg_obj_num
112 CODE:
113 10 RETVAL = pdfmake_page_add_ocg(self, name, (uint32_t)ocg_obj_num);
114 10 ▶ if (RETVAL < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) 0 10 10
115 0 croak("PDF::Make::Page::add_ocg: failed to add OCG %s", name);
116 OUTPUT:
117 RETVAL
118  
119 BOOT:
120 {
121 104 HV *stash = gv_stashpv("PDF::Make::Page", GV_ADD);
122 104 ▶ PDFMAKE_REGISTER_GETTER(stash, "width", pdfmake_page_t, width, PDFMAKE_FIELD_DOUBLE);
Branch: 2 branches
BranchTrueFalseTotal
PDFMAKE_REGISTER_GETTER(stash, "width", pdfmake_page_t, width, PDFMAKE_FIELD_DOUBLE); 104 0 104
PDFMAKE_REGISTER_GETTER(stash, "width", pdfmake_page_t, width, PDFMAKE_FIELD_DOUBLE); 104 0 104
123 104 ▶ PDFMAKE_REGISTER_GETTER(stash, "height", pdfmake_page_t, height, PDFMAKE_FIELD_DOUBLE);
Branch: 2 branches
BranchTrueFalseTotal
PDFMAKE_REGISTER_GETTER(stash, "height", pdfmake_page_t, height, PDFMAKE_FIELD_DOUBLE); 104 0 104
PDFMAKE_REGISTER_GETTER(stash, "height", pdfmake_page_t, height, PDFMAKE_FIELD_DOUBLE); 104 0 104
124  
125 /* Page method dispatch (returns int, not self) */
126 enum { POP_ADD_FONT, POP_ADD_STD14, POP_ADD_IMAGE, POP_ADD_OCG, POP_COUNT };
127 static pdfmake_chain_entry_t page_dispatch[POP_COUNT] = {
128 [POP_ADD_FONT] = { (void*)pdfmake_page_add_font, 2, {PDFMAKE_ARG_STRING, PDFMAKE_ARG_STRING}, .ret_mode=1 },
129 [POP_ADD_STD14] = { (void*)pdfmake_page_add_std14_font, 2, {PDFMAKE_ARG_STRING, PDFMAKE_ARG_INT}, 1 },
130 [POP_ADD_IMAGE] = { (void*)pdfmake_page_add_image, 2, {PDFMAKE_ARG_STRING, PDFMAKE_ARG_INT}, 1 },
131 [POP_ADD_OCG] = { (void*)pdfmake_page_add_ocg, 2, {PDFMAKE_ARG_STRING, PDFMAKE_ARG_INT}, 1 },
132 };
133 104 int page_table_id = pdfmake_chain_table_count++;
134 104 pdfmake_chain_tables[page_table_id] = page_dispatch;
135  
136 104 ▶ PDFMAKE_REGISTER_CHAIN(stash, "add_font", page_table_id, POP_ADD_FONT);
Branch: 2 branches
BranchTrueFalseTotal
PDFMAKE_REGISTER_CHAIN(stash, "add_font", page_table_id, POP_ADD_FONT); 104 0 104
PDFMAKE_REGISTER_CHAIN(stash, "add_font", page_table_id, POP_ADD_FONT); 104 0 104
137 104 ▶ PDFMAKE_REGISTER_CHAIN(stash, "add_std14_font", page_table_id, POP_ADD_STD14);
Branch: 2 branches
BranchTrueFalseTotal
PDFMAKE_REGISTER_CHAIN(stash, "add_std14_font", page_table_id, POP_ADD_STD14); 104 0 104
PDFMAKE_REGISTER_CHAIN(stash, "add_std14_font", page_table_id, POP_ADD_STD14); 104 0 104
138 104 ▶ PDFMAKE_REGISTER_CHAIN(stash, "add_image", page_table_id, POP_ADD_IMAGE);
Branch: 2 branches
BranchTrueFalseTotal
PDFMAKE_REGISTER_CHAIN(stash, "add_image", page_table_id, POP_ADD_IMAGE); 104 0 104
PDFMAKE_REGISTER_CHAIN(stash, "add_image", page_table_id, POP_ADD_IMAGE); 104 0 104
139 104 ▶ PDFMAKE_REGISTER_CHAIN(stash, "add_ocg", page_table_id, POP_ADD_OCG);
Branch: 2 branches
BranchTrueFalseTotal
PDFMAKE_REGISTER_CHAIN(stash, "add_ocg", page_table_id, POP_ADD_OCG); 104 0 104
PDFMAKE_REGISTER_CHAIN(stash, "add_ocg", page_table_id, POP_ADD_OCG); 104 0 104
140 }
« xs/font.xs ↑ Summary src/pdfmake_watermark.c »