File Coverage

blib/lib/Report/Porf/Table/Simple.pm
Criterion Covered Total %
statement 311 430 72.3
branch 55 116 47.4
condition 1 3 33.3
subroutine 96 110 87.2
pod 0 104 0.0
total 463 763 60.6


line stmt bran cond sub pod time code
1             # perl
2             #
3             # Class Report::Porf::Table::Simple
4             #
5             # Use Configurator or Framework of namespace Report::Porf to create Instances,
6             # that export data as text, html, csv, LaTeX, for wikis and Excel
7             #
8             # Ralf Peine, Wed May 14 10:39:51 2014
9             #
10             # More documentation at the end of file
11             #------------------------------------------------------------------------------
12            
13             $VERSION = "2.001";
14            
15             #------------------------------------------------------------------------------
16             #
17             # Easy create lists like this as text, html, csv, ...:
18             #
19             # *============+======================+=========+=======+======================*
20             # @ Count @ Prename @ Surname @ Age @ TimeStamp @
21             # *------------+----------------------+---------+-------+----------------------*
22             # | 1 | Vorname 1 | Name 1 | 10 | 0.002329 |
23             # | 2 | Vorname 2 | Name 2 | 20 | 0.003106 |
24             # | 3 | Vorname 3 | Name 3 | 30 | 0.003822 |
25             # | 4 | Vorname 4 | Name 4 | 40 | 0.004533 |
26             # | 5 | Vorname 5 | Name 5 | 50 | 0.005235 |
27             # | 6 | Vorname 6 | Name 6 | 60 | 0.005944 |
28             # | 7 | Vorname 7 | Name 7 | 70 | 0.006656 |
29             # | 8 | Vorname 8 | Name 8 | 80 | 0.007362 |
30             # | 9 | Vorname 9 | Name 9 | 90 | 0.008069 |
31             # | 10 | Vorname 10 | Name 10 | 100 | 0.008779 |
32             # *============+======================+=========+=======+======================*
33             #
34             # # Time needed for export of 10 data lines: 0.001954
35             #
36             #------------------------------------------------------------------------------
37            
38 1     1   4 use strict;
  1         2  
  1         25  
39 1     1   3 use warnings;
  1         2  
  1         28  
40            
41             #--------------------------------------------------------------------------------
42             #
43             # Report::Porf::Table::Simple;
44             #
45             #--------------------------------------------------------------------------------
46            
47             package Report::Porf::Table::Simple;
48            
49 1     1   4 use Carp;
  1         1  
  1         50  
50 1     1   751 use FileHandle;
  1         15030  
  1         8  
51            
52 1     1   1400 use Report::Porf::Util;
  1         4  
  1         7302  
53            
54             #--------------------------------------------------------------------------------
55             #
56             # Creation / Filling Of Instances
57             #
58             #--------------------------------------------------------------------------------
59            
60             # --- create Instance -----------------
61             sub new
62             {
63 19     19 0 1458 my $caller = $_[0];
64 19   33     83 my $class = ref($caller) || $caller;
65            
66             # let the class go
67 19         35 my $self = {};
68 19         58 bless $self, $class;
69            
70 19         56 $self->_init();
71            
72 19         100 return $self;
73             }
74            
75             # --- initialise instance -------------
76             sub _init {
77 19     19   26 my ($self, # instance_ref
78             ) = @_;
79            
80 19         57 $self->set_default_column_width (0);
81 19         67 $self->set_max_col_width (0);
82 19         63 $self->set_max_column_idx (-2);
83 19         59 $self->set_format ('?');
84            
85 19         323 $self->set_column_widths_ref([]);
86 19         74 $self->set_header_texts_ref ([]);
87            
88 19         50 $self->set_file_start ('');
89 19         55 $self->set_page_start ('');
90 19         55 $self->set_table_start ('');
91            
92 19         68 $self->set_header_row_start ('');
93 19         57 $self->set_header_start ('');
94 19         93 $self->set_header_end ('');
95 19         52 $self->set_header_row_end ('');
96            
97 19         56 $self->set_row_start ('');
98 19         56 $self->set_cell_start ('');
99 19         58 $self->set_cell_end ('');
100 19         50 $self->set_row_end ('');
101            
102 19         47 $self->set_table_end ('');
103 19         52 $self->set_page_end ('');
104 19         63 $self->set_file_end ('');
105            
106 19         53 $self->set_default_align ('');
107            
108 19         48 $self->set_header_line ('');
109 19         50 $self->set_separator_line ('');
110 19         68 $self->set_bold_header_line ('');
111            
112 19         66 $self->set_bold ('');
113 19         62 $self->set_italics ('');
114 19         50 $self->set_left ('');
115 19         54 $self->set_right ('');
116 19         61 $self->set_center ('');
117            
118 19         65 $self->set_horizontal_separation_start ('');
119 19         55 $self->set_horizontal_separation_end ('');
120 19         58 $self->set_horizontal_separation_column_separator ('');
121 19         49 $self->set_horizontal_separation_char ('');
122 19         49 $self->set_horizontal_separation_bold_char ('');
123            
124             # $self->set_configure_column_action (sub {});
125             # $self->set_configure_complete_action (sub {});
126             # $self->set_cell_output_action (sub {});
127             # $self->set_header_output_action (sub {});
128             # $self->set_row_output_action (sub {});
129             # $self->set_start_table_output_action (sub {});
130             # $self->set_end_table_output_action (sub {});
131             # $self->set_row_group_changes_action (sub {});
132            
133 19         43 $self->set_verbose (0);
134            
135 19         29 my @CellOutputActions;
136 19         45 $self->{CellOutputActions} = \@CellOutputActions;
137             }
138            
139             #--------------------------------------------------------------------------------
140             #
141             # Attributes
142             #
143             #--------------------------------------------------------------------------------
144            
145             # Generated by peiner from CreateGetSetter.pl at Fri Apr 19 08:27:27 2013
146            
147             # --- Format ---------------------------------------------------------------
148            
149             sub set_format {
150 33     33 0 51 my ($self, # instance_ref
151             $value # value to set
152             ) = @_;
153            
154 33 50       65 if ($self->configure_is_complete()) {
155 0         0 warn ("Cannot set Format after configuration has been completed in ".(caller(3))[3]."\n");
156 0         0 return;
157             }
158            
159 33         202 $self->{Format} = $value;
160             }
161            
162             sub get_format {
163 0     0 0 0 my ($self, # instance_ref
164             ) = @_;
165            
166 0         0 return $self->{Format};
167             }
168            
169             # --- Check, if given format is used for export ---
170             sub is_format {
171 0     0 0 0 my ($self, # instance_ref
172             $format # format to compare with
173             ) = @_;
174            
175 0 0       0 return lc ($self->{Format}) eq lc($format) ? 1: 0;
176             }
177            
178             # --- MaxColWidth ---------------------------------------------------------------
179            
180             sub set_max_col_width {
181 19     19 0 106 my ($self, # instance_ref
182             $value # value to set
183             ) = @_;
184            
185 19 50       38 if ($self->configure_is_complete()) {
186 0         0 warn ("Cannot set MaxColWidth after configuration has been completed in ".(caller(3))[3]."\n");
187 0         0 return;
188             }
189            
190 19         44 $self->{MaxColWidth} = $value;
191             }
192            
193             sub get_max_col_width {
194 1     1 0 2 my ($self, # instance_ref
195             ) = @_;
196            
197 1         6 return $self->{MaxColWidth};
198             }
199            
200             # --- DefaultColumnWidth ---------------------------------------------------------------
201            
202             sub set_default_column_width {
203 29     29 0 46 my ($self, # instance_ref
204             $value # value to set
205             ) = @_;
206            
207 29 50       95 if ($self->configure_is_complete()) {
208 0         0 warn ("Cannot set DefaultColumnWidth after configuration has been completed in ".(caller(3))[3]."\n");
209 0         0 return;
210             }
211            
212 29         70 $self->{DefaultColumnWidth} = $value;
213             }
214            
215             sub get_default_column_width {
216 2     2 0 4 my ($self, # instance_ref
217             ) = @_;
218            
219 2         7 return $self->{DefaultColumnWidth};
220             }
221            
222             # --- DefaultAlign ---------------------------------------------------------------
223            
224             sub set_default_align {
225 36     36 0 167 my ($self, # instance_ref
226             $value # value to set
227             ) = @_;
228            
229 36 50       70 if ($self->configure_is_complete()) {
230 0         0 warn ("Cannot set DefaultAlign after configuration has been completed in ".(caller(3))[3]."\n");
231 0         0 return;
232             }
233            
234 36         80 $self->{DefaultAlign} = $value;
235             }
236            
237             sub get_default_align {
238 3     3 0 5 my ($self, # instance_ref
239             ) = @_;
240            
241 3         9 return $self->{DefaultAlign};
242             }
243            
244             # --- MaxColumnIdx ---------------------------------------------------------------
245            
246             sub set_max_column_idx {
247 19     19 0 27 my ($self, # instance_ref
248             $value # value to set
249             ) = @_;
250            
251 19 50       35 if ($self->configure_is_complete()) {
252 0         0 warn ("Cannot set MaxColumnIdx after configuration has been completed in ".(caller(3))[3]."\n");
253 0         0 return;
254             }
255            
256 19         39 $self->{MaxColumnIdx} = $value;
257             }
258            
259             sub get_max_column_idx {
260 1     1 0 2 my ($self, # instance_ref
261             ) = @_;
262            
263 1         5 return $self->{MaxColumnIdx};
264             }
265            
266             # --- ColumnWidthsRef ---------------------------------------------------------------
267            
268             sub set_column_widths_ref {
269 19     19 0 27 my ($self, # instance_ref
270             $value # value to set
271             ) = @_;
272            
273 19 50       33 if ($self->configure_is_complete()) {
274 0         0 warn ("Cannot set ColumnWidthsRef after configuration has been completed in ".(caller(3))[3]."\n");
275 0         0 return;
276             }
277            
278 19         41 $self->{ColumnWidthsRef} = $value;
279             }
280            
281             sub get_column_widths_ref {
282 104     104 0 116 my ($self, # instance_ref
283             ) = @_;
284            
285 104         361 return $self->{ColumnWidthsRef};
286             }
287            
288             # --- HeaderTextsRef ---------------------------------------------------------------
289            
290             sub set_header_texts_ref {
291 19     19 0 26 my ($self, # instance_ref
292             $value # value to set
293             ) = @_;
294            
295 19 50       36 if ($self->configure_is_complete()) {
296 0         0 warn ("Cannot set HeaderTextsRef after configuration has been completed in ".(caller(3))[3]."\n");
297 0         0 return;
298             }
299            
300 19         122 $self->{HeaderTextsRef} = $value;
301             }
302            
303             sub get_header_texts_ref {
304 93     93 0 113 my ($self, # instance_ref
305             ) = @_;
306            
307 93         457 return $self->{HeaderTextsRef};
308             }
309            
310             # --- FileStart ---------------------------------------------------------------
311            
312             sub set_file_start {
313 36     36 0 50 my ($self, # instance_ref
314             $value # value to set
315             ) = @_;
316            
317 36 50       63 if ($self->configure_is_complete()) {
318 0         0 warn ("Cannot set FileStart after configuration has been completed in ".(caller(3))[3]."\n");
319 0         0 return;
320             }
321            
322 36         94 $self->{FileStart} = $value;
323             }
324            
325             sub get_file_start {
326 10     10 0 151 my ($self, # instance_ref
327             ) = @_;
328            
329 10         67 return $self->{FileStart};
330             }
331            
332             # --- FileEnd ---------------------------------------------------------------
333            
334             sub set_file_end {
335 36     36 0 41 my ($self, # instance_ref
336             $value # value to set
337             ) = @_;
338            
339 36 50       64 if ($self->configure_is_complete()) {
340 0         0 warn ("Cannot set FileEnd after configuration has been completed in ".(caller(3))[3]."\n");
341 0         0 return;
342             }
343            
344 36         215 $self->{FileEnd} = $value;
345             }
346            
347             sub get_file_end {
348 10     10 0 15 my ($self, # instance_ref
349             ) = @_;
350            
351 10         491 return $self->{FileEnd};
352             }
353            
354             # --- TableStart ---------------------------------------------------------------
355            
356             sub set_table_start {
357 39     39 0 50 my ($self, # instance_ref
358             $value # value to set
359             ) = @_;
360            
361 39 50       67 if ($self->configure_is_complete()) {
362 0         0 warn ("Cannot set TableStart after configuration has been completed in ".(caller(3))[3]."\n");
363 0         0 return;
364             }
365            
366 39         94 $self->{TableStart} = $value;
367             }
368            
369             sub get_table_start {
370 10     10 0 16 my ($self, # instance_ref
371             ) = @_;
372            
373 10         47 return $self->{TableStart};
374             }
375            
376             # --- TableEnd ---------------------------------------------------------------
377            
378             sub set_table_end {
379 46     46 0 62 my ($self, # instance_ref
380             $value # value to set
381             ) = @_;
382            
383 46 50       90 if ($self->configure_is_complete()) {
384 0         0 warn ("Cannot set TableEnd after configuration has been completed in ".(caller(3))[3]."\n");
385 0         0 return;
386             }
387            
388 46         113 $self->{TableEnd} = $value;
389             }
390            
391             sub get_table_end {
392 10     10 0 20 my ($self, # instance_ref
393             ) = @_;
394            
395 10         45 return $self->{TableEnd};
396             }
397            
398             # --- HeaderRowStart ---------------------------------------------------------------
399            
400             sub set_header_row_start {
401 36     36 0 47 my ($self, # instance_ref
402             $value # value to set
403             ) = @_;
404            
405 36 50       67 if ($self->configure_is_complete()) {
406 0         0 warn ("Cannot set HeaderRowStart after configuration has been completed in ".(caller(3))[3]."\n");
407 0         0 return;
408             }
409            
410 36         139 $self->{HeaderRowStart} = $value;
411             }
412            
413             sub get_header_row_start {
414 10     10 0 14 my ($self, # instance_ref
415             ) = @_;
416            
417 10         31 return $self->{HeaderRowStart};
418             }
419            
420             # --- HeaderRowEnd ---------------------------------------------------------------
421            
422             sub set_header_row_end {
423 36     36 0 46 my ($self, # instance_ref
424             $value # value to set
425             ) = @_;
426            
427 36 50       63 if ($self->configure_is_complete()) {
428 0         0 warn ("Cannot set HeaderRowEnd after configuration has been completed in ".(caller(3))[3]."\n");
429 0         0 return;
430             }
431            
432 36         74 $self->{HeaderRowEnd} = $value;
433             }
434            
435             sub get_header_row_end {
436 10     10 0 16 my ($self, # instance_ref
437             ) = @_;
438            
439 10         97 return $self->{HeaderRowEnd};
440             }
441            
442             # --- PageStart ---------------------------------------------------------------
443            
444             sub set_page_start {
445 19     19 0 36 my ($self, # instance_ref
446             $value # value to set
447             ) = @_;
448            
449 19 50       32 if ($self->configure_is_complete()) {
450 0         0 warn ("Cannot set PageStart after configuration has been completed in ".(caller(3))[3]."\n");
451 0         0 return;
452             }
453            
454 19         66 $self->{PageStart} = $value;
455             }
456            
457             sub get_page_start {
458 0     0 0 0 my ($self, # instance_ref
459             ) = @_;
460            
461 0         0 return $self->{PageStart};
462             }
463            
464             # --- PageEnd ---------------------------------------------------------------
465            
466             sub set_page_end {
467 19     19 0 26 my ($self, # instance_ref
468             $value # value to set
469             ) = @_;
470            
471 19 50       31 if ($self->configure_is_complete()) {
472 0         0 warn ("Cannot set PageEnd after configuration has been completed in ".(caller(3))[3]."\n");
473 0         0 return;
474             }
475            
476 19         37 $self->{PageEnd} = $value;
477             }
478            
479             sub get_page_end {
480 0     0 0 0 my ($self, # instance_ref
481             ) = @_;
482            
483 0         0 return $self->{PageEnd};
484             }
485            
486             # --- RowStart ---------------------------------------------------------------
487            
488             sub set_row_start {
489 36     36 0 56 my ($self, # instance_ref
490             $value # value to set
491             ) = @_;
492            
493 36 50       70 if ($self->configure_is_complete()) {
494 0         0 warn ("Cannot set RowStart after configuration has been completed in ".(caller(3))[3]."\n");
495 0         0 return;
496             }
497            
498 36         75 $self->{RowStart} = $value;
499             }
500            
501             sub get_row_start {
502 66     66 0 133 my ($self, # instance_ref
503             ) = @_;
504            
505 66         200 return $self->{RowStart};
506             }
507            
508             # --- RowEnd ---------------------------------------------------------------
509            
510             sub set_row_end {
511 36     36 0 52 my ($self, # instance_ref
512             $value # value to set
513             ) = @_;
514            
515 36 50       70 if ($self->configure_is_complete()) {
516 0         0 warn ("Cannot set RowEnd after configuration has been completed in ".(caller(3))[3]."\n");
517 0         0 return;
518             }
519            
520 36         78 $self->{RowEnd} = $value;
521             }
522            
523             sub get_row_end {
524 66     66 0 84 my ($self, # instance_ref
525             ) = @_;
526            
527 66         190 return $self->{RowEnd};
528             }
529            
530             # --- HeaderStart ---------------------------------------------------------------
531            
532             sub set_header_start {
533 36     36 0 65 my ($self, # instance_ref
534             $value # value to set
535             ) = @_;
536            
537 36 50       52 if ($self->configure_is_complete()) {
538 0         0 warn ("Cannot set HeaderStart after configuration has been completed in ".(caller(3))[3]."\n");
539 0         0 return;
540             }
541            
542 36         83 $self->{HeaderStart} = $value;
543             }
544            
545             sub get_header_start {
546 60     60 0 200 my ($self, # instance_ref
547             ) = @_;
548            
549 60         151 return $self->{HeaderStart};
550             }
551            
552             # --- HeaderEnd ---------------------------------------------------------------
553            
554             sub set_header_end {
555 36     36 0 58 my ($self, # instance_ref
556             $value # value to set
557             ) = @_;
558            
559 36 50       58 if ($self->configure_is_complete()) {
560 0         0 warn ("Cannot set HeaderEnd after configuration has been completed in ".(caller(3))[3]."\n");
561 0         0 return;
562             }
563            
564 36         159 $self->{HeaderEnd} = $value;
565             }
566            
567             sub get_header_end {
568 60     60 0 86 my ($self, # instance_ref
569             ) = @_;
570            
571 60         277 return $self->{HeaderEnd};
572             }
573            
574             # --- CellStart ---------------------------------------------------------------
575            
576             sub set_cell_start {
577 36     36 0 48 my ($self, # instance_ref
578             $value # value to set
579             ) = @_;
580            
581 36 50       61 if ($self->configure_is_complete()) {
582 0         0 warn ("Cannot set CellStart after configuration has been completed in ".(caller(3))[3]."\n");
583 0         0 return;
584             }
585            
586 36         74 $self->{CellStart} = $value;
587             }
588            
589             sub get_cell_start {
590 97     97 0 114 my ($self, # instance_ref
591             ) = @_;
592            
593 97         353 return $self->{CellStart};
594             }
595            
596             # --- CellEnd ---------------------------------------------------------------
597            
598             sub set_cell_end {
599 36     36 0 52 my ($self, # instance_ref
600             $value # value to set
601             ) = @_;
602            
603 36 50       64 if ($self->configure_is_complete()) {
604 0         0 warn ("Cannot set CellEnd after configuration has been completed in ".(caller(3))[3]."\n");
605 0         0 return;
606             }
607            
608 36         105 $self->{CellEnd} = $value;
609             }
610            
611             sub get_cell_end {
612 113     113 0 136 my ($self, # instance_ref
613             ) = @_;
614            
615 113         421 return $self->{CellEnd};
616             }
617            
618             # --- HeaderLine ---------------------------------------------------------------
619            
620             sub set_header_line {
621 36     36 0 55 my ($self, # instance_ref
622             $value # value to set
623             ) = @_;
624            
625 36 50       92 if ($self->configure_is_complete()) {
626 0         0 warn ("Cannot set HeaderLine after configuration has been completed in ".(caller(3))[3]."\n");
627 0         0 return;
628             }
629            
630 36         90 $self->{HeaderLine} = $value;
631             }
632            
633             sub get_header_line {
634 8     8 0 15 my ($self, # instance_ref
635             ) = @_;
636            
637 8         2603 return $self->{HeaderLine};
638             }
639            
640             # --- SeparatorLine ---------------------------------------------------------------
641            
642             sub set_separator_line {
643 36     36 0 52 my ($self, # instance_ref
644             $value # value to set
645             ) = @_;
646            
647 36 50       67 if ($self->configure_is_complete()) {
648 0         0 warn ("Cannot set SeparatorLine after configuration has been completed in ".(caller(3))[3]."\n");
649 0         0 return;
650             }
651            
652 36         92 $self->{SeparatorLine} = $value;
653             }
654            
655             sub get_separator_line {
656 0     0 0 0 my ($self, # instance_ref
657             ) = @_;
658            
659 0         0 return $self->{SeparatorLine};
660             }
661            
662             # --- BoldHeaderLine ---------------------------------------------------------------
663            
664             sub set_bold_header_line {
665 32     32 0 46 my ($self, # instance_ref
666             $value # value to set
667             ) = @_;
668            
669 32 50       60 if ($self->configure_is_complete()) {
670 0         0 warn ("Cannot set BoldHeaderLine after configuration has been completed in ".(caller(3))[3]."\n");
671 0         0 return;
672             }
673            
674 32         68 $self->{BoldHeaderLine} = $value;
675             }
676            
677             sub get_bold_header_line {
678 8     8 0 15 my ($self, # instance_ref
679             ) = @_;
680            
681 8         37 return $self->{BoldHeaderLine};
682             }
683            
684             # --- Bold ---------------------------------------------------------------
685            
686             sub set_bold {
687 19     19 0 30 my ($self, # instance_ref
688             $value # value to set
689             ) = @_;
690            
691 19 50       39 if ($self->configure_is_complete()) {
692 0         0 warn ("Cannot set Bold after configuration has been completed in ".(caller(3))[3]."\n");
693 0         0 return;
694             }
695            
696 19         36 $self->{Bold} = $value;
697             }
698            
699             sub get_bold {
700 0     0 0 0 my ($self, # instance_ref
701             ) = @_;
702            
703 0         0 return $self->{Bold};
704             }
705            
706             # --- Italics ---------------------------------------------------------------
707            
708             sub set_italics {
709 19     19 0 34 my ($self, # instance_ref
710             $value # value to set
711             ) = @_;
712            
713 19 50       37 if ($self->configure_is_complete()) {
714 0         0 warn ("Cannot set Italics after configuration has been completed in ".(caller(3))[3]."\n");
715 0         0 return;
716             }
717            
718 19         45 $self->{Italics} = $value;
719             }
720            
721             sub get_italics {
722 0     0 0 0 my ($self, # instance_ref
723             ) = @_;
724            
725 0         0 return $self->{Italics};
726             }
727            
728             # --- Left ---------------------------------------------------------------
729            
730             sub set_left {
731 19     19 0 24 my ($self, # instance_ref
732             $value # value to set
733             ) = @_;
734            
735 19 50       37 if ($self->configure_is_complete()) {
736 0         0 warn ("Cannot set Left after configuration has been completed in ".(caller(3))[3]."\n");
737 0         0 return;
738             }
739            
740 19         40 $self->{Left} = $value;
741             }
742            
743             sub get_left {
744 0     0 0 0 my ($self, # instance_ref
745             ) = @_;
746            
747 0         0 return $self->{Left};
748             }
749            
750             # --- Right ---------------------------------------------------------------
751            
752             sub set_right {
753 19     19 0 26 my ($self, # instance_ref
754             $value # value to set
755             ) = @_;
756            
757 19 50       32 if ($self->configure_is_complete()) {
758 0         0 warn ("Cannot set Right after configuration has been completed in ".(caller(3))[3]."\n");
759 0         0 return;
760             }
761            
762 19         42 $self->{Right} = $value;
763             }
764            
765             sub get_right {
766 0     0 0 0 my ($self, # instance_ref
767             ) = @_;
768            
769 0         0 return $self->{Right};
770             }
771            
772             # --- Center ---------------------------------------------------------------
773            
774             sub set_center {
775 19     19 0 26 my ($self, # instance_ref
776             $value # value to set
777             ) = @_;
778            
779 19 50       50 if ($self->configure_is_complete()) {
780 0         0 warn ("Cannot set Center after configuration has been completed in ".(caller(3))[3]."\n");
781 0         0 return;
782             }
783            
784 19         48 $self->{Center} = $value;
785             }
786            
787             sub get_center {
788 0     0 0 0 my ($self, # instance_ref
789             ) = @_;
790            
791 0         0 return $self->{Center};
792             }
793            
794             # --- HorizontalSeparationStart ---------------------------------------------------------------
795            
796             sub set_horizontal_separation_start {
797 33     33 0 47 my ($self, # instance_ref
798             $value # value to set
799             ) = @_;
800            
801 33 50       58 if ($self->configure_is_complete()) {
802 0         0 warn ("Cannot set HorizontalSeparationStart after configuration has been completed in ".(caller(3))[3]."\n");
803 0         0 return;
804             }
805            
806 33         77 $self->{HorizontalSeparationStart} = $value;
807             }
808            
809             sub get_horizontal_separation_start {
810 20     20 0 39 my ($self, # instance_ref
811             ) = @_;
812            
813 20         70 return $self->{HorizontalSeparationStart};
814             }
815            
816             # --- HorizontalSeparationEnd ---------------------------------------------------------------
817            
818             sub set_horizontal_separation_end {
819 33     33 0 53 my ($self, # instance_ref
820             $value # value to set
821             ) = @_;
822            
823 33 50       57 if ($self->configure_is_complete()) {
824 0         0 warn ("Cannot set HorizontalSeparationEnd after configuration has been completed in ".(caller(3))[3]."\n");
825 0         0 return;
826             }
827            
828 33         90 $self->{HorizontalSeparationEnd} = $value;
829             }
830            
831             sub get_horizontal_separation_end {
832 20     20 0 20 my ($self, # instance_ref
833             ) = @_;
834            
835 20         121 return $self->{HorizontalSeparationEnd};
836             }
837            
838             # --- HorizontalSeparationColumnSeparator ---------------------------------------------------------------
839            
840             sub set_horizontal_separation_column_separator {
841 29     29 0 165 my ($self, # instance_ref
842             $value # value to set
843             ) = @_;
844            
845 29 50       54 if ($self->configure_is_complete()) {
846 0         0 warn ("Cannot set HorizontalSeparationColumnSeparator after configuration has been completed in ".(caller(3))[3]."\n");
847 0         0 return;
848             }
849            
850 29         98 $self->{HorizontalSeparationColumnSeparator} = $value;
851             }
852            
853             sub get_horizontal_separation_column_separator {
854 114     114 0 130 my ($self, # instance_ref
855             ) = @_;
856            
857 114         1152 return $self->{HorizontalSeparationColumnSeparator};
858             }
859            
860             # --- HorizontalSeparationChar ---------------------------------------------------------------
861            
862             sub set_horizontal_separation_char {
863 29     29 0 37 my ($self, # instance_ref
864             $value # value to set
865             ) = @_;
866            
867 29 50       48 if ($self->configure_is_complete()) {
868 0         0 warn ("Cannot set HorizontalSeparationChar after configuration has been completed in ".(caller(3))[3]."\n");
869 0         0 return;
870             }
871            
872 29         55 $self->{HorizontalSeparationChar} = $value;
873             }
874            
875             sub get_horizontal_separation_char {
876 82     82 0 388 my ($self, # instance_ref
877             ) = @_;
878            
879 82         509 return $self->{HorizontalSeparationChar};
880             }
881            
882             # --- HorizontalSeparationBoldChar ---------------------------------------------------------------
883            
884             sub set_horizontal_separation_bold_char {
885 29     29 0 37 my ($self, # instance_ref
886             $value # value to set
887             ) = @_;
888            
889 29 50       61 if ($self->configure_is_complete()) {
890 0         0 warn ("Cannot set HorizontalSeparationBoldChar after configuration has been completed in ".(caller(3))[3]."\n");
891 0         0 return;
892             }
893            
894 29         69 $self->{HorizontalSeparationBoldChar} = $value;
895             }
896            
897             sub get_horizontal_separation_bold_char {
898 82     82 0 87 my ($self, # instance_ref
899             ) = @_;
900            
901 82         313 return $self->{HorizontalSeparationBoldChar};
902             }
903            
904             # --- ConfigureColumnAction ---------------------------------------------------------------
905            
906             sub set_configure_column_action {
907 17     17 0 30 my ($self, # instance_ref
908             $value # value to set
909             ) = @_;
910            
911 17 50       30 if ($self->configure_is_complete()) {
912 0         0 warn ("Cannot set ConfigureColumnAction after configuration has been completed in ".(caller(3))[3]."\n");
913 0         0 return;
914             }
915            
916 17         46 $self->{ConfigureColumnAction} = $value;
917             }
918            
919             sub get_configure_column_action {
920 83     83 0 111 my ($self, # instance_ref
921             ) = @_;
922            
923 83         150 return $self->{ConfigureColumnAction};
924             }
925            
926             # --- ConfigureCompleteAction ---------------------------------------------------------------
927            
928             sub set_configure_complete_action {
929 17     17 0 27 my ($self, # instance_ref
930             $value # value to set
931             ) = @_;
932            
933 17 50       34 if ($self->configure_is_complete()) {
934 0         0 warn ("Cannot set ConfigureCompleteAction after configuration has been completed in ".(caller(3))[3]."\n");
935 0         0 return;
936             }
937            
938 17         48 $self->{ConfigureCompleteAction} = $value;
939             }
940            
941             sub get_configure_complete_action {
942 17     17 0 28 my ($self, # instance_ref
943             ) = @_;
944            
945 17         51 return $self->{ConfigureCompleteAction};
946             }
947            
948             # --- default_cell_value ---------------------------------------------------------------
949            
950             sub set_default_cell_value {
951 10     10 0 20 my ($self, # instance_ref
952             $value # value to set
953             ) = @_;
954            
955 10 50       24 if ($self->configure_is_complete()) {
956 0         0 warn ("Cannot set default_cell_value after configuration has been completed in ".(caller(3))[3]."\n");
957 0         0 return;
958             }
959            
960 10         89 $self->{default_cell_value} = $value;
961             }
962            
963             sub get_default_cell_value {
964 83     83 0 106 my ($self, # instance_ref
965             ) = @_;
966            
967 83         511 return $self->{default_cell_value};
968             }
969            
970             # --- CellOutputAction ---------------------------------------------------------------
971            
972             sub set_cell_output_action {
973 0     0 0 0 my ($self, # instance_ref
974             $value # value to set
975             ) = @_;
976            
977 0 0       0 if ($self->configure_is_complete()) {
978 0         0 warn ("Cannot set CellOutputAction after configuration has been completed in ".(caller(3))[3]."\n");
979 0         0 return;
980             }
981            
982 0         0 $self->{CellOutputAction} = $value;
983             }
984            
985             sub get_cell_output_action {
986 0     0 0 0 my ($self, # instance_ref
987             ) = @_;
988            
989 0         0 return $self->{CellOutputAction};
990             }
991            
992             # --- HeaderOutputAction ---------------------------------------------------------------
993            
994             sub set_header_output_action {
995 17     17 0 26 my ($self, # instance_ref
996             $value # value to set
997             ) = @_;
998            
999 17 50       93 if ($self->configure_is_complete()) {
1000 0         0 warn ("Cannot set HeaderOutputAction after configuration has been completed in ".(caller(3))[3]."\n");
1001 0         0 return;
1002             }
1003            
1004 17         49 $self->{HeaderOutputAction} = $value;
1005             }
1006            
1007             sub get_header_output_action {
1008 10     10 0 14 my ($self, # instance_ref
1009             ) = @_;
1010            
1011 10         21 return $self->{HeaderOutputAction};
1012             }
1013            
1014             # --- RowOutputAction ---------------------------------------------------------------
1015            
1016             sub set_row_output_action {
1017 17     17 0 27 my ($self, # instance_ref
1018             $value # value to set
1019             ) = @_;
1020            
1021 17 50       34 if ($self->configure_is_complete()) {
1022 0         0 warn ("Cannot set RowOutputAction after configuration has been completed in ".(caller(3))[3]."\n");
1023 0         0 return;
1024             }
1025            
1026 17         115 $self->{RowOutputAction} = $value;
1027             }
1028            
1029             sub get_row_output_action {
1030 17     17 0 35 my ($self, # instance_ref
1031             ) = @_;
1032            
1033 17         42 return $self->{RowOutputAction};
1034             }
1035            
1036             # --- StartTableOutputAction ---------------------------------------------------------------
1037            
1038             sub set_start_table_output_action {
1039 17     17 0 26 my ($self, # instance_ref
1040             $value # value to set
1041             ) = @_;
1042            
1043 17 50       34 if ($self->configure_is_complete()) {
1044 0         0 warn ("Cannot set StartTableOutputAction after configuration has been completed in ".(caller(3))[3]."\n");
1045 0         0 return;
1046             }
1047            
1048 17         46 $self->{StartTableOutputAction} = $value;
1049             }
1050            
1051             sub get_start_table_output_action {
1052 10     10 0 21 my ($self, # instance_ref
1053             ) = @_;
1054            
1055 10         29 return $self->{StartTableOutputAction};
1056             }
1057            
1058             # --- EndTableOutputAction ---------------------------------------------------------------
1059            
1060             sub set_end_table_output_action {
1061 17     17 0 30 my ($self, # instance_ref
1062             $value # value to set
1063             ) = @_;
1064            
1065 17 50       37 if ($self->configure_is_complete()) {
1066 0         0 warn ("Cannot set EndTableOutputAction after configuration has been completed in ".(caller(3))[3]."\n");
1067 0         0 return;
1068             }
1069            
1070 17         44 $self->{EndTableOutputAction} = $value;
1071             }
1072            
1073             sub get_end_table_output_action {
1074 10     10 0 34 my ($self, # instance_ref
1075             ) = @_;
1076            
1077 10         24 return $self->{EndTableOutputAction};
1078             }
1079            
1080             # --- RowGroupChangesAction --------------------------------------------------
1081            
1082             sub set_row_group_changes_action {
1083 0     0 0 0 my ($self, # instance_ref
1084             $value # value to set
1085             ) = @_;
1086            
1087 0 0       0 if ($self->configure_is_complete()) {
1088 0         0 warn ("Cannot set RowGroupChangesAction after configuration has been completed in ".(caller(3))[3]."\n");
1089 0         0 return;
1090             }
1091            
1092 0         0 $self->{RowGroupChangesAction} = $value;
1093             }
1094            
1095             sub get_row_group_changes_action {
1096 62     62 0 72 my ($self, # instance_ref
1097             ) = @_;
1098            
1099 62         150 return $self->{RowGroupChangesAction};
1100             }
1101            
1102             # --- verbose ---------------------------------------------------------------
1103            
1104             sub set_verbose {
1105 21     21 0 33 my ($self, # instance_ref
1106             $value # value to set
1107             ) = @_;
1108            
1109 21         37 $self->{verbose} = $value;
1110             }
1111            
1112             sub get_verbose {
1113 1123     1123 0 1448 my ($self, # instance_ref
1114             ) = @_;
1115            
1116 1123         3882 return $self->{verbose};
1117             }
1118            
1119             #--------------------------------------------------------------------------------
1120             #
1121             # Methods
1122             #
1123             #--------------------------------------------------------------------------------
1124            
1125             # --- CellOutputActions ---------------------------------------------------------------
1126            
1127             sub add_cell_output_action {
1128 83     83 0 111 my ($self, # instance_ref
1129             $value # value to set
1130             ) = @_;
1131            
1132 83         130 my $cell_output_actions_ref = $self->{CellOutputActions};
1133            
1134 83 50       185 print "### add_cell_output_action: $value\n" if verbose($self, 3);
1135            
1136 83         848 push (@$cell_output_actions_ref, $value);
1137             }
1138            
1139             sub get_cell_output_actions {
1140 66     66 0 83 my ($self, # instance_ref
1141             ) = @_;
1142            
1143 66         167 return $self->{CellOutputActions};
1144             }
1145            
1146             # --- store name and action for column ------------------------------------------
1147             sub cc {
1148 50     50 0 177 my $self = shift; # instance_ref
1149 50         124 $self->configure_column(@_);
1150             }
1151            
1152             # --- store name and action for column ------------------------------------------
1153             sub conf_col {
1154 0     0 0 0 my $self = shift; # instance_ref
1155 0         0 $self->configure_column(@_);
1156             }
1157            
1158             # --- store name and action for column ------------------------------------------
1159             sub configure_column {
1160 83     83 0 946 my $self = $_[0]; # instance_ref
1161            
1162 83         146 my $action = $self->get_configure_column_action();
1163            
1164 83 50       263 die "no action to store export column defined!" unless ref ($action);
1165            
1166 83         225 $action->(@_);
1167             }
1168            
1169             # --- create action and trace --------------------------------------------------
1170             sub create_action {
1171 77     77 0 185 my ($self, # instance_ref
1172             $action_str # will be evaled to a sub { ... }
1173             ) = @_;
1174            
1175 77         300 my $eval_str = 'sub { '.$action_str.' }';
1176            
1177 77 50       348 print "### eval_str = $eval_str\n" if verbose($self, 3);
1178            
1179 77         18949 my $sub_ref = eval ($eval_str);
1180            
1181 77 50       230 print "### ref(sub_ref) ".ref($sub_ref) ."\n" if verbose($self, 3);
1182 77         209 return $sub_ref;
1183             }
1184            
1185             # --- Now all columns are defined ---------------------------
1186             sub configure_complete {
1187 17     17 0 53 my $self = $_[0]; # instance_ref
1188            
1189 17         46 my $action = $self->get_configure_complete_action();
1190            
1191 17 50       51 die "no action to complete configuration defined!" unless ref ($action);
1192            
1193 17         61 $action->(@_);
1194            
1195 17         60 $self->{configure_complete} = 1;
1196             }
1197            
1198             # --- Now all columns are defined ---------------------------
1199             sub configure_is_complete {
1200 1121     1121 0 1277 my $self = $_[0]; # instance_ref
1201            
1202 1121         3159 return $self->{configure_complete};
1203             }
1204            
1205             # --- get table header row output ---------------------
1206             sub get_header_output {
1207 10     10 0 20 my ($self, # instance_ref
1208             $headers_ref, # optional: ref to array with header texts
1209             ) = @_;
1210            
1211 10         31 my $action = $self->get_header_output_action();
1212 10 50       24 die "No action to output header defined!" unless $action;
1213            
1214 10 50       33 $headers_ref = $self->get_header_texts_ref() unless $headers_ref;
1215            
1216 10         39 $action->($self, $headers_ref);
1217             }
1218            
1219             # --- get output of given row ---------------------
1220             sub get_row_output {
1221 7     7 0 38 my ($self, # instance_ref
1222             $data_ref # data to give out
1223             ) = @_;
1224            
1225 7         17 my $action = $self->get_row_output_action();
1226 7 50       19 die "No action to output row defined!" unless $action;
1227            
1228 7         25 $action->($self, $data_ref);
1229             }
1230            
1231             # --- get output of (table) start ---------------------
1232             sub get_output_start {
1233 10     10 0 14 my ($self, # instance_ref
1234             $data_ref # data to give out
1235             ) = @_;
1236            
1237 10         34 my $action = $self->get_start_table_output_action();
1238 10 50       26 die "No action to start table defined!" unless $action;
1239            
1240 10         39 $action->($self, $data_ref);
1241             }
1242            
1243             # --- get output of (table) end ---------------------
1244             sub get_output_end {
1245 10     10 0 18 my ($self, # instance_ref
1246             $data_ref # data to give out
1247             ) = @_;
1248            
1249 10         38 my $action = $self->get_end_table_output_action();
1250 10 50       26 die "No action to end table defined!" unless $action;
1251            
1252 10         37 $action->($self, $data_ref);
1253             }
1254            
1255             # --- Interprete File Parameter and return open file handle ---
1256             sub interprete_file_parameter {
1257 10     10 0 16 my ($self, # instance_ref
1258             $file_parameter # FileHandle or file name for output
1259             ) = @_;
1260            
1261 10         13 my $file_handle;
1262            
1263 10 100       21 if ($file_parameter) {
1264 6         12 my $file_ref = ref($file_parameter);
1265            
1266 6 50       14 if ($file_ref) {
1267 6 50       28 unless ($file_ref =~ /^FileHandle$/) {
1268 0         0 croak 'Only FileHandle or $file_name_string allowed as file parameter!';
1269             }
1270 6         15 $file_handle = $file_parameter;
1271             }
1272             else {
1273 0         0 $file_handle = FileHandle->new($file_parameter, 'w');
1274 0 0       0 croak "can't open file '$file_parameter' to write: $!\n" unless $file_handle;
1275             }
1276             }
1277             else {
1278 4         31 $file_handle = *STDOUT;
1279             }
1280            
1281 10         28 return $file_handle;
1282             }
1283            
1284            
1285             # --- Write out everything in one step ----
1286             sub write_all {
1287 10     10 0 29 my ($self, # instance_ref
1288             $data_rows_ref, # list of data_rows to give out
1289             $file_parameter # Optional: FileHandle or file name for output
1290             ) = @_;
1291            
1292 10         36 my $file_handle = $self->interprete_file_parameter($file_parameter);
1293            
1294 10         42 print $file_handle $self->get_output_start();
1295            
1296 10         50 my $row_output_action = $self->get_row_output_action();
1297            
1298 10         18 foreach my $data (@{$data_rows_ref}) {
  10         33  
1299 55         203 print $file_handle $row_output_action->($self, $data);
1300             }
1301            
1302 10         47 print $file_handle $self->get_output_end();
1303             }
1304            
1305            
1306             1;
1307            
1308             =head1 NAME
1309            
1310             C
1311            
1312             Reports for any output format as simple table:
1313             One line in output per data row.
1314            
1315             Part of Perl Open Report Framework (Porf).
1316            
1317             =head1 Documentation
1318            
1319             Use C or C of namespace C to
1320             create Instances, that export data as text, html, csv, LaTeX, for
1321             wikis or Excel.
1322            
1323             See Framework.pm for documentation of features and usage.
1324            
1325             =head1 LICENSE AND COPYRIGHT
1326            
1327             Copyright (c) 2013 by Ralf Peine, Germany. All rights reserved.
1328            
1329             This library is free software; you can redistribute it and/or modify
1330             it under the same terms as Perl itself, either Perl version 5.6.0 or,
1331             at your option, any later version of Perl 5 you may have available.
1332            
1333             =head1 DISCLAIMER OF WARRANTY
1334            
1335             This library is distributed in the hope that it will be useful,
1336             but without any warranty; without even the implied warranty of
1337             merchantability or fitness for a particular purpose.
1338            
1339             =cut