| 1 | #============================================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright (c) 2010 Ars Aperta, Itaapy, Pierlis, Talend. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Copyright (c) 2014 Jean-Marie Gouarné. | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # Author: Jean-Marie Gouarné <jean.marie.gouarne@online.fr> | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | #============================================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use 5.010_001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use experimental 'smartmatch'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | #============================================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # Common lpOD/Perl parameters and utility functions | ||||||||||||||||||||||||||||||||||||||||||
| 13 | #============================================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 14 | package ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | our $VERSION = '1.013'; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use constant PACKAGE_DATE => '2014-04-30T08:32:52'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | our @EXPORT = qw | |||||||||||||||||||||||||||||||||||||||||
| 22 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 23 | lpod_common lpod | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | odf_get_document odf_new_document odf_create_document | ||||||||||||||||||||||||||||||||||||||||||
| 26 | odf_new_document_from_template odf_new_document_from_type | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | odf_get_container odf_new_container | ||||||||||||||||||||||||||||||||||||||||||
| 29 | odf_new_container_from_template odf_new_container_from_type | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | odf_get_xmlpart | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | odf_create_element odf_create_paragraph odf_create_heading | ||||||||||||||||||||||||||||||||||||||||||
| 34 | odf_create_section odf_create_draw_page | ||||||||||||||||||||||||||||||||||||||||||
| 35 | odf_create_shape | ||||||||||||||||||||||||||||||||||||||||||
| 36 | odf_create_area odf_create_rectangle odf_create_ellipse | ||||||||||||||||||||||||||||||||||||||||||
| 37 | odf_create_vector odf_create_line odf_create_connector | ||||||||||||||||||||||||||||||||||||||||||
| 38 | odf_create_frame odf_create_text_frame odf_create_image_frame | ||||||||||||||||||||||||||||||||||||||||||
| 39 | odf_create_image | ||||||||||||||||||||||||||||||||||||||||||
| 40 | odf_create_list | ||||||||||||||||||||||||||||||||||||||||||
| 41 | odf_create_table odf_create_column odf_create_row odf_create_cell | ||||||||||||||||||||||||||||||||||||||||||
| 42 | odf_create_column_group odf_create_row_group | ||||||||||||||||||||||||||||||||||||||||||
| 43 | odf_create_field odf_create_simple_variable odf_create_user_variable | ||||||||||||||||||||||||||||||||||||||||||
| 44 | odf_create_note odf_create_annotation | ||||||||||||||||||||||||||||||||||||||||||
| 45 | odf_create_style odf_create_font_declaration | ||||||||||||||||||||||||||||||||||||||||||
| 46 | odf_create_toc | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | odf_document odf_container | ||||||||||||||||||||||||||||||||||||||||||
| 49 | odf_xmlpart odf_content odf_styles odf_meta odf_settings odf_manifest | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | odf_element odf_text_node | ||||||||||||||||||||||||||||||||||||||||||
| 52 | odf_text_element odf_text_hyperlink | ||||||||||||||||||||||||||||||||||||||||||
| 53 | odf_bibliography_mark odf_note odf_annotation odf_changed_region | ||||||||||||||||||||||||||||||||||||||||||
| 54 | odf_paragraph odf_heading odf_draw_page odf_image odf_shape odf_frame | ||||||||||||||||||||||||||||||||||||||||||
| 55 | odf_area odf_rectangle odf_ellipse odf_vector odf_line odf_connector | ||||||||||||||||||||||||||||||||||||||||||
| 56 | odf_field odf_variable odf_simple_variable odf_user_variable | ||||||||||||||||||||||||||||||||||||||||||
| 57 | odf_text_field odf_classify_text_field | ||||||||||||||||||||||||||||||||||||||||||
| 58 | odf_list odf_table odf_column odf_row odf_cell | ||||||||||||||||||||||||||||||||||||||||||
| 59 | odf_matrix odf_column_group odf_row_group odf_table_element | ||||||||||||||||||||||||||||||||||||||||||
| 60 | odf_structured_container | ||||||||||||||||||||||||||||||||||||||||||
| 61 | odf_section odf_toc odf_named_range | ||||||||||||||||||||||||||||||||||||||||||
| 62 | odf_file_entry | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | odf_style | ||||||||||||||||||||||||||||||||||||||||||
| 65 | odf_text_style odf_paragraph_style | ||||||||||||||||||||||||||||||||||||||||||
| 66 | odf_list_style odf_list_level_style odf_outline_style | ||||||||||||||||||||||||||||||||||||||||||
| 67 | odf_table_style odf_column_style odf_row_style odf_cell_style | ||||||||||||||||||||||||||||||||||||||||||
| 68 | odf_data_style | ||||||||||||||||||||||||||||||||||||||||||
| 69 | odf_master_page odf_page_end_style odf_drawing_page_style | ||||||||||||||||||||||||||||||||||||||||||
| 70 | odf_page_layout odf_presentation_page_layout | ||||||||||||||||||||||||||||||||||||||||||
| 71 | odf_graphic_style odf_gradient | ||||||||||||||||||||||||||||||||||||||||||
| 72 | odf_font_declaration | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | TRUE FALSE PRETTY | ||||||||||||||||||||||||||||||||||||||||||
| 75 | is_true is_false defined_false | ||||||||||||||||||||||||||||||||||||||||||
| 76 | is_odf_datatype odf_boolean process_options | ||||||||||||||||||||||||||||||||||||||||||
| 77 | alpha_to_num translate_coordinates translate_range | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | xelt xtwig | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | META CONTENT STYLES SETTINGS MANIFEST MIMETYPE | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | text_segment TEXT_SEGMENT | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | input_conversion output_conversion search_string count_substrings | ||||||||||||||||||||||||||||||||||||||||||
| 86 | color_code color_name load_color_map unload_color_map | ||||||||||||||||||||||||||||||||||||||||||
| 87 | is_numeric iso_date numeric_date check_odf_value odf_value | ||||||||||||||||||||||||||||||||||||||||||
| 88 | file_parse file_type load_file image_size input_2d_value | ||||||||||||||||||||||||||||||||||||||||||
| 89 | alert not_implemented | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | XML_PRETTY_PRINT PRETTY_PRINT EMPTY_TAGS | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | FIRST_CHILD LAST_CHILD NEXT_SIBLING PREV_SIBLING WITHIN PARENT | ||||||||||||||||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | #=== package name aliases ==================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 97 | #--- ODF package & parts ----------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | use constant | ||||||||||||||||||||||||||||||||||||||||||
| 100 | { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 2 | odf_document => 'ODF::lpOD::Document', | |||||||||||||||||||||||||||||||||||||||||
| 102 | odf_container => 'ODF::lpOD::Container', | ||||||||||||||||||||||||||||||||||||||||||
| 103 | odf_xmlpart => 'ODF::lpOD::XMLPart', | ||||||||||||||||||||||||||||||||||||||||||
| 104 | odf_content => 'ODF::lpOD::Content', | ||||||||||||||||||||||||||||||||||||||||||
| 105 | odf_styles => 'ODF::lpOD::Styles', | ||||||||||||||||||||||||||||||||||||||||||
| 106 | odf_meta => 'ODF::lpOD::Meta', | ||||||||||||||||||||||||||||||||||||||||||
| 107 | odf_settings => 'ODF::lpOD::Settings', | ||||||||||||||||||||||||||||||||||||||||||
| 108 | odf_manifest => 'ODF::lpOD::Manifest' | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | #--- ODF element ------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | use constant | ||||||||||||||||||||||||||||||||||||||||||
| 114 | { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | odf_element => 'ODF::lpOD::Element', | |||||||||||||||||||||||||||||||||||||||||
| 116 | odf_text_node => 'ODF::lpOD::TextNode', | ||||||||||||||||||||||||||||||||||||||||||
| 117 | odf_text_element => 'ODF::lpOD::TextElement', | ||||||||||||||||||||||||||||||||||||||||||
| 118 | odf_text_hyperlink => 'ODF::lpOD::TextHyperlink', | ||||||||||||||||||||||||||||||||||||||||||
| 119 | odf_paragraph => 'ODF::lpOD::Paragraph', | ||||||||||||||||||||||||||||||||||||||||||
| 120 | odf_heading => 'ODF::lpOD::Heading', | ||||||||||||||||||||||||||||||||||||||||||
| 121 | odf_list => 'ODF::lpOD::List', | ||||||||||||||||||||||||||||||||||||||||||
| 122 | odf_field => 'ODF::lpOD::Field', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | odf_variable => 'ODF::lpOD::Variable', | ||||||||||||||||||||||||||||||||||||||||||
| 124 | odf_simple_variable => 'ODF::lpOD::SimpleVariable', | ||||||||||||||||||||||||||||||||||||||||||
| 125 | odf_user_variable => 'ODF::lpOD::UserVariable', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | odf_text_field => 'ODF::lpOD::TextField', | ||||||||||||||||||||||||||||||||||||||||||
| 127 | odf_table => 'ODF::lpOD::Table', | ||||||||||||||||||||||||||||||||||||||||||
| 128 | odf_table_element => 'ODF::lpOD::TableElement', | ||||||||||||||||||||||||||||||||||||||||||
| 129 | odf_matrix => 'ODF::lpOD::Matrix', | ||||||||||||||||||||||||||||||||||||||||||
| 130 | odf_column_group => 'ODF::lpOD::ColumnGroup', | ||||||||||||||||||||||||||||||||||||||||||
| 131 | odf_row_group => 'ODF::lpOD::RowGroup', | ||||||||||||||||||||||||||||||||||||||||||
| 132 | odf_column => 'ODF::lpOD::Column', | ||||||||||||||||||||||||||||||||||||||||||
| 133 | odf_row => 'ODF::lpOD::Row', | ||||||||||||||||||||||||||||||||||||||||||
| 134 | odf_cell => 'ODF::lpOD::Cell', | ||||||||||||||||||||||||||||||||||||||||||
| 135 | odf_draw_page => 'ODF::lpOD::DrawPage', | ||||||||||||||||||||||||||||||||||||||||||
| 136 | odf_shape => 'ODF::lpOD::Shape', | ||||||||||||||||||||||||||||||||||||||||||
| 137 | odf_area => 'ODF::lpOD::Area', | ||||||||||||||||||||||||||||||||||||||||||
| 138 | odf_rectangle => 'ODF::lpOD::Rectangle', | ||||||||||||||||||||||||||||||||||||||||||
| 139 | odf_ellipse => 'ODF::lpOD::Ellipse', | ||||||||||||||||||||||||||||||||||||||||||
| 140 | odf_vector => 'ODF::lpOD::Vector', | ||||||||||||||||||||||||||||||||||||||||||
| 141 | odf_line => 'ODF::lpOD::Line', | ||||||||||||||||||||||||||||||||||||||||||
| 142 | odf_connector => 'ODF::lpOD::Connector', | ||||||||||||||||||||||||||||||||||||||||||
| 143 | odf_frame => 'ODF::lpOD::Frame', | ||||||||||||||||||||||||||||||||||||||||||
| 144 | odf_image => 'ODF::lpOD::Image', | ||||||||||||||||||||||||||||||||||||||||||
| 145 | odf_section => 'ODF::lpOD::Section', | ||||||||||||||||||||||||||||||||||||||||||
| 146 | odf_bibliography_mark => 'ODF::lpOD::BibliographyMark', | ||||||||||||||||||||||||||||||||||||||||||
| 147 | odf_note => 'ODF::lpOD::Note', | ||||||||||||||||||||||||||||||||||||||||||
| 148 | odf_annotation => 'ODF::lpOD::Annotation', | ||||||||||||||||||||||||||||||||||||||||||
| 149 | odf_changed_region => 'ODF::lpOD::ChangedRegion', | ||||||||||||||||||||||||||||||||||||||||||
| 150 | odf_font_declaration => 'ODF::lpOD::FontDeclaration', | ||||||||||||||||||||||||||||||||||||||||||
| 151 | odf_style => 'ODF::lpOD::Style', | ||||||||||||||||||||||||||||||||||||||||||
| 152 | odf_text_style => 'ODF::lpOD::TextStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 153 | odf_paragraph_style => 'ODF::lpOD::ParagraphStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 154 | odf_list_style => 'ODF::lpOD::ListStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 155 | odf_list_level_style => 'ODF::lpOD::ListLevelStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 156 | odf_outline_style => 'ODF::lpOD::OutlineStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 157 | odf_table_style => 'ODF::lpOD::TableStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 158 | odf_column_style => 'ODF::lpOD::ColumnStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 159 | odf_row_style => 'ODF::lpOD::RowStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 160 | odf_cell_style => 'ODF::lpOD::CellStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 161 | odf_data_style => 'ODF::lpOD::DataStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 162 | odf_master_page => 'ODF::lpOD::MasterPage', | ||||||||||||||||||||||||||||||||||||||||||
| 163 | odf_page_layout => 'ODF::lpOD::PageLayout', | ||||||||||||||||||||||||||||||||||||||||||
| 164 | odf_presentation_page_layout => 'ODF::lpOD::PresentationPageLayout', | ||||||||||||||||||||||||||||||||||||||||||
| 165 | odf_graphic_style => 'ODF::lpOD::GraphicStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 166 | odf_gradient => 'ODF::lpOD::Gradient', | ||||||||||||||||||||||||||||||||||||||||||
| 167 | odf_page_end_style => 'ODF::lpOD::PageEndStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 168 | odf_drawing_page_style => 'ODF::lpOD::DrawingPageStyle', | ||||||||||||||||||||||||||||||||||||||||||
| 169 | odf_file_entry => 'ODF::lpOD::FileEntry', | ||||||||||||||||||||||||||||||||||||||||||
| 170 | odf_toc => 'ODF::lpOD::TOC', | ||||||||||||||||||||||||||||||||||||||||||
| 171 | odf_named_range => 'ODF::lpOD::NamedRange', | ||||||||||||||||||||||||||||||||||||||||||
| 172 | odf_structured_container => 'ODF::lpOD::StructuredContainer' | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | #--- basic API shortcuts ----------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | use constant | ||||||||||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | xelt => 'XML::Twig::Elt', | |||||||||||||||||||||||||||||||||||||||||
| 180 | xtwig => 'XML::Twig' | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | #--- lpOD common tools and parameters ---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | use constant | ||||||||||||||||||||||||||||||||||||||||||
| 186 | { | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | lpod_common => 'ODF::lpOD::Common', | |||||||||||||||||||||||||||||||||||||||||
| 188 | lpod => 'ODF::lpOD::Common' | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | #--- ODF data types ---------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | our @DATA_TYPES = qw(string float currency percentage date time boolean); | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | #--- default string comparison function -------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | our $COMPARE = sub { shift cmp shift }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | #=== common parameters ======================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | use constant # common constants | ||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | TRUE => 1, | |||||||||||||||||||||||||||||||||||||||||
| 204 | FALSE => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | use constant # ODF package parts | ||||||||||||||||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | META => 'meta.xml', | |||||||||||||||||||||||||||||||||||||||||
| 210 | CONTENT => 'content.xml', | ||||||||||||||||||||||||||||||||||||||||||
| 211 | STYLES => 'styles.xml', | ||||||||||||||||||||||||||||||||||||||||||
| 212 | SETTINGS => 'settings.xml', | ||||||||||||||||||||||||||||||||||||||||||
| 213 | MANIFEST => 'META-INF/manifest.xml', | ||||||||||||||||||||||||||||||||||||||||||
| 214 | MIMETYPE => 'mimetype' | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | use constant | ||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | TEXT_SEGMENT => '#PCDATA', | |||||||||||||||||||||||||||||||||||||||||
| 220 | text_segment => '#PCDATA' | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | use constant # XML::Twig specific | ||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | EMPTY_TAGS => 'normal' | |||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | use constant # element insert positions | ||||||||||||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | FIRST_CHILD => 'FIRST_CHILD', | |||||||||||||||||||||||||||||||||||||||||
| 231 | LAST_CHILD => 'LAST_CHILD', | ||||||||||||||||||||||||||||||||||||||||||
| 232 | NEXT_SIBLING => 'NEXT_SIBLING', | ||||||||||||||||||||||||||||||||||||||||||
| 233 | PREV_SIBLING => 'PREV_SIBLING', | ||||||||||||||||||||||||||||||||||||||||||
| 234 | WITHIN => 'WITHIN', | ||||||||||||||||||||||||||||||||||||||||||
| 235 | PARENT => 'PARENT' | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | our %ODF_TEMPLATE = | |||||||||||||||||||||||||||||||||||||||||
| 239 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 'text' => 'text.odt', | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 'spreadsheet' => 'spreadsheet.ods', | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 'presentation' => 'presentation.odp', | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 'drawing' => 'drawing.odg' | ||||||||||||||||||||||||||||||||||||||||||
| 244 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | our $LINE_BREAK = "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | our $TAB_STOP = "\t"; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | our $INSTALLATION_PATH = undef; # lpOD library installation path | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | our $LPOD_MARK = '#lpod:mark'; # lpOD session bookmark tag | |||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | our $LPOD_ID = '#lpod:id'; # lpOD XML ID attribute | |||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | our $LPOD_PART = '#lpod:part'; # lpOD link from element to xmlpart | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | #=== common function aliases ================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | ▶ | *odf_get_document = *ODF::lpOD::Document::get_from_uri; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | *odf_new_document_from_template | |||||||||||||||||||||||||||||||||||||||||
| 260 | = *ODF::lpOD::Document::create_from_template; | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | *odf_new_document_from_type | |||||||||||||||||||||||||||||||||||||||||
| 262 | = *ODF::lpOD::Document::_create; | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | *odf_new_document = *ODF::lpOD::Document::_create; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | *odf_create_document = *ODF::lpOD::Document::_create; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | *odf_get_container = *ODF::lpOD::Container::get_from_uri; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | *odf_new_container_from_template | |||||||||||||||||||||||||||||||||||||||||
| 267 | = *ODF::lpOD::Container::create_from_template; | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | *odf_new_container = *ODF::lpOD::Container::create; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | *odf_new_container_from_type | |||||||||||||||||||||||||||||||||||||||||
| 270 | = *ODF::lpOD::Container::create; | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | *odf_get_xmlpart = *ODF::lpOD::XMLPart::get; | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | *odf_create_element = *ODF::lpOD::Element::_create; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | *odf_create_paragraph = *ODF::lpOD::Paragraph::_create; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | *odf_create_heading = *ODF::lpOD::Heading::_create; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | *odf_create_field = *ODF::lpOD::Field::_create; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | *odf_create_simple_variable | |||||||||||||||||||||||||||||||||||||||||
| 278 | = *ODF::lpOD::SimpleVariable::_create; | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | *odf_create_user_variable | |||||||||||||||||||||||||||||||||||||||||
| 280 | = *ODF::lpOD::UserVariable::_create; | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | *odf_create_table = *ODF::lpOD::Table::_create; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | *odf_create_row_group = *ODF::lpOD::RowGroup::_create; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | *odf_create_column_group | |||||||||||||||||||||||||||||||||||||||||
| 284 | = *ODF::lpOD::ColumnGroup::_create; | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 2 | *odf_create_column = *ODF::lpOD::Column::_create; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 2 | *odf_create_row = *ODF::lpOD::Row::_create; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 2 | *odf_create_cell = *ODF::lpOD::Cell::_create; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 2 | *odf_create_section = *ODF::lpOD::Section::_create; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 2 | *odf_create_list = *ODF::lpOD::List::_create; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 2 | *odf_create_draw_page = *ODF::lpOD::DrawPage::_create; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | *odf_create_shape = *ODF::lpOD::Shape::_create; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | *odf_create_area = *ODF::lpOD::Area::_create; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | *odf_create_rectangle = *ODF::lpOD::Rectangle::_create; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | *odf_create_ellipse = *ODF::lpOD::Ellipse::_create; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 2 | *odf_create_vector = *ODF::lpOD::Vector::_create; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 2 | *odf_create_line = *ODF::lpOD::Line::_create; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | *odf_create_connector = *ODF::lpOD::Connector::_create; | |||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | *odf_create_frame = *ODF::lpOD::Frame::_create; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | *odf_create_image = *ODF::lpOD::Image::_create; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 2 | *odf_create_text_frame = *ODF::lpOD::Frame::_create_text; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 2 | *odf_create_image_frame = *ODF::lpOD::Frame::_create_image; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 2 | *odf_create_note = *ODF::lpOD::Note::_create; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 2 | *odf_create_annotation = *ODF::lpOD::Annotation::_create; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | *odf_create_font_declaration | |||||||||||||||||||||||||||||||||||||||||
| 305 | = *ODF::lpOD::FontDeclaration::_create; | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | *odf_create_style = *ODF::lpOD::Style::_create; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | *odf_classify_text_field | |||||||||||||||||||||||||||||||||||||||||
| 308 | = *ODF::lpOD::TextField::classify; | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 2 | *odf_create_toc = *ODF::lpOD::TOC::_create; | |||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 2 | *is_numeric = *Scalar::Util::looks_like_number; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 2 | *odf_value = *check_odf_value; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | *PRETTY_PRINT = *XML_PRETTY_PRINT; | |||||||||||||||||||||||||||||||||||||||||
| 315 | #initializations | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | #=== exported utilities ====================================================== | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | our $DEBUG = FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | sub alert | ||||||||||||||||||||||||||||||||||||||||||
| 324 | { | ||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if ($DEBUG) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alert: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | return Carp::cluck(@_); | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | warn "$_\n" for @_; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | sub info | ||||||||||||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | return wantarray ? | ||||||||||||||||||||||||||||||||||||||||||
| 336 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | name => "ODF::lpOD", | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
info: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | version => $ODF::lpOD::VERSION, | ||||||||||||||||||||||||||||||||||||||||||
| 339 | date => ODF::lpOD->PACKAGE_DATE, | ||||||||||||||||||||||||||||||||||||||||||
| 340 | path => lpod->installation_path | ||||||||||||||||||||||||||||||||||||||||||
| 341 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 342 | : | ||||||||||||||||||||||||||||||||||||||||||
| 343 | "ODF::lpOD $ODF::lpOD::VERSION" . | ||||||||||||||||||||||||||||||||||||||||||
| 344 | " " . ODF::lpOD->PACKAGE_DATE . | ||||||||||||||||||||||||||||||||||||||||||
| 345 | " " . lpod->installation_path; | ||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | sub signature { scalar lpod->info } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signature: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | sub debug | ||||||||||||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | my $param = shift // ""; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=3 SCAR=24.8
Pod
undocumented
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | $param = shift if $param eq lpod; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | given ($param) | |||||||||||||||||||||||||||||||||||||||||
| 355 | { | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | when (undef) {} | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | when (TRUE || FALSE) { $DEBUG = $_; } | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | default { alert "Wrong argument"; } | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | return $DEBUG; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | sub is_true | ||||||||||||||||||||||||||||||||||||||||||
| 364 | { | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | my $arg = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_true: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | return FALSE unless $arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $v = lc $arg; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | return $v ~~ ["false", "off", "no"] ? FALSE : TRUE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | sub is_false | ||||||||||||||||||||||||||||||||||||||||||
| 372 | { | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | return is_true(shift) ? FALSE : TRUE; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_false: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | sub defined_false | ||||||||||||||||||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | my $arg = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defined_false: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | return FALSE unless defined $arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | return is_false($arg) ? TRUE : FALSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | sub odf_boolean | ||||||||||||||||||||||||||||||||||||||||||
| 384 | { | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | my $value = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
odf_boolean: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | return undef unless defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | return is_true($value) ? 'true' : 'false'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | sub is_odf_datatype | ||||||||||||||||||||||||||||||||||||||||||
| 391 | { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | my $type = shift or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_odf_datatype: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | return $type ~~ @DATA_TYPES ? TRUE : FALSE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | sub check_odf_value | ||||||||||||||||||||||||||||||||||||||||||
| 397 | { | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | my $value = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_odf_value: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | return undef unless defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | given ($type) | |||||||||||||||||||||||||||||||||||||||||
| 402 | { | ||||||||||||||||||||||||||||||||||||||||||
| 403 | when (['float', 'currency', 'percentage']) | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | { | |||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | $value = undef unless is_numeric($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | when ('boolean') | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | { | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if (is_true($value)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $value = 'true'; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | else | ||||||||||||||||||||||||||||||||||||||||||
| 414 | { | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $value = 'false'; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | when ('date') | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | { | |||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if (is_numeric($value)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | { | ||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $value = iso_date($value); | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | else | ||||||||||||||||||||||||||||||||||||||||||
| 425 | { | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $num = numeric_date($value); | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | $value = defined $num ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | iso_date($num) : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | sub process_options | ||||||||||||||||||||||||||||||||||||||||||
| 436 | { | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | my %in = (@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_options: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my %out = (); | |||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | foreach my $ink (keys %in) | |||||||||||||||||||||||||||||||||||||||||
| 440 | { | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $outk = $ink; | |||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | $outk =~ s/[ -]/_/g; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $out{$outk} = $in{$ink}; | |||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | return %out; | |||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | sub alpha_to_num | ||||||||||||||||||||||||||||||||||||||||||
| 449 | { | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | my $arg = shift or return 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alpha_to_num: not called CC=7 SCAR=40.3
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | $arg = shift if ref($arg) || $arg eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $arg or $arg eq __PACKAGE__
MC/DC0%0/2
ref $arg or $arg eq __PACKAGE__
ref $arg
$arg eq __PACKAGE__
Truth table0%0/3
A or B
A= ref $argB= $arg eq __PACKAGE__
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $alpha = uc $arg; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | unless ($alpha =~ /^[A-Z]*$/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | return $arg if $alpha =~ /^[0-9\-]*$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | alert "Wrong alpha value $arg"; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my @asplit = split('', $alpha); | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my $num = 0; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | foreach my $p (@asplit) | |||||||||||||||||||||||||||||||||||||||||
| 462 | { | ||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $num *= 26; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $num += ((ord($p) - ord('A')) + 1); | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $num--; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | return $num; | |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | sub translate_coordinates # adapted from OpenOffice::OODoc (Genicorp) | ||||||||||||||||||||||||||||||||||||||||||
| 471 | { | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | my $arg = shift // return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
translate_coordinates: not called CC=10 SCAR=47.0
Pod
documented
Condition0%0/2
shift() // (return undef)
MC/DC0%0/1
shift() // (return undef)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my $ra = ref $arg; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | if ($ra) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | { | ||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | if ($ra eq 'ARRAY') { return @$arg } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | else { shift } | |||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | elsif ($arg eq __PACKAGE__) | ||||||||||||||||||||||||||||||||||||||||||
| 480 | { | ||||||||||||||||||||||||||||||||||||||||||
| 481 | shift | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | return ($arg, @_) unless defined $arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $coord = uc $arg; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | return ($arg, @_) unless $coord =~ /[A-Z]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $coord =~ s/\s*//g; | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $coord =~ /(^[A-Z]*)(\d*)/; | |||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my $c = $1; | |||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | my $r = $2; | |||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | return ($arg, @_) unless $c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $colnum = alpha_to_num($c); | |||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | if (defined $r and $r gt "") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $r and $r gt ""
MC/DC0%0/2
defined $r and $r gt ""
defined $r
$r gt ""
Truth table0%0/3
A and B
A= defined $rB= $r gt ""
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | { | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $r--; | |||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | return ($r, $colnum, @_); | |||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | else | ||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | return ($colnum, @_); | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | sub translate_range | ||||||||||||||||||||||||||||||||||||||||||
| 505 | { | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | my $arg = shift // return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
translate_range: not called CC=7 SCAR=40.3
Pod
documented
Condition0%0/2
shift() // (return undef)
MC/DC0%0/1
shift() // (return undef)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | $arg = shift if ref($arg) || $arg eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $arg or $arg eq __PACKAGE__
MC/DC0%0/2
ref $arg or $arg eq __PACKAGE__
ref $arg
$arg eq __PACKAGE__
Truth table0%0/3
A or B
A= ref $argB= $arg eq __PACKAGE__
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | return ($arg, @_) unless (defined $arg && $arg =~ /:/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $arg and $arg =~ /:/
MC/DC0%0/2
defined $arg and $arg =~ /:/
defined $arg
$arg =~ /:/
Truth table0%0/3
A and B
A= defined $argB= $arg =~ /:/
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my $range = uc $arg; | |||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $range =~ s/\s*//g; | |||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my ($start, $end) = split(':', $range); | |||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my @r = (); | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | push @r, translate_coordinates($_) for ($start, $end); | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | return @r; | |||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | #--- external character set conversion utilities ----------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 2 | our $INPUT_CHARSET = 'utf8'; | |||||||||||||||||||||||||||||||||||||||||
| 520 | 2 | our $OUTPUT_CHARSET = 'utf8'; | |||||||||||||||||||||||||||||||||||||||||
| 521 | 2 | our $INPUT_ENCODER = Encode::find_encoding($INPUT_CHARSET); | |||||||||||||||||||||||||||||||||||||||||
| 522 | 2 | our $OUTPUT_ENCODER = Encode::find_encoding($OUTPUT_CHARSET); | |||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | sub get_input_charset { $INPUT_CHARSET } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_input_charset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | sub get_output_charset { $OUTPUT_CHARSET } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_output_charset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | sub set_input_charset | ||||||||||||||||||||||||||||||||||||||||||
| 529 | { | ||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | my $charset = shift // ""; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_input_charset: not called CC=4 SCAR=30.0
Pod
undocumented
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | $charset = shift if ($charset eq lpod); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | my $enc = Encode::find_encoding($charset); | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | unless ($enc) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | { | ||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | alert("Unsupported $charset input character set"); | |||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | $INPUT_ENCODER = $enc; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $INPUT_CHARSET = $charset; | |||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | return $INPUT_CHARSET; | |||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | sub set_output_charset | ||||||||||||||||||||||||||||||||||||||||||
| 544 | { | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | my $charset = shift // ""; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_output_charset: not called CC=4 SCAR=30.0
Pod
undocumented
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | $charset = shift if ($charset eq lpod); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $enc = Encode::find_encoding($charset); | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | unless ($enc) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | { | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | alert("Unsupported output character set"); | |||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | $OUTPUT_ENCODER = $enc; | |||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $OUTPUT_CHARSET = $charset; | |||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | return $OUTPUT_CHARSET; | |||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | sub input_conversion | ||||||||||||||||||||||||||||||||||||||||||
| 559 | { | ||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | my $text = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
input_conversion: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | return $text unless $INPUT_CHARSET; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | unless ($INPUT_ENCODER) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | { | ||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | alert "Unsupported input character conversion"; | |||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | return (defined $text) ? $INPUT_ENCODER->decode($text) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | sub output_conversion | ||||||||||||||||||||||||||||||||||||||||||
| 572 | { | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | my $text = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_conversion: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | return $text unless $OUTPUT_CHARSET; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | unless ($OUTPUT_ENCODER) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | { | ||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | alert "Unsupported output character conversion"; | |||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | return (defined $text) ? $OUTPUT_ENCODER->encode($text) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | #--- ISO-9601 / internal date conversion ------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | sub iso_date | ||||||||||||||||||||||||||||||||||||||||||
| 588 | { | ||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | my $time = shift // time(); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iso_date: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/3
shift() // time
MC/DC0%0/2
shift() // time
shift()
time
Truth table0%0/3
A // B
A= shift()B= time
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my @t = localtime($time); | |||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | return sprintf | |||||||||||||||||||||||||||||||||||||||||
| 592 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 593 | "%04d-%02d-%02dT%02d:%02d:%02d", | ||||||||||||||||||||||||||||||||||||||||||
| 594 | $t[5] + 1900, $t[4] + 1, $t[3], $t[2], $t[1], $t[0] | ||||||||||||||||||||||||||||||||||||||||||
| 595 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | sub numeric_date # in progress | ||||||||||||||||||||||||||||||||||||||||||
| 599 | { | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | require Time::Local; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
numeric_date: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | my $iso_date = shift or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | $iso_date .= 'T00:00:00'unless ($iso_date =~ /T/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $iso_date =~ /(\d*)-(\d*)-(\d*)T(\d*):(\d*):(\d*)/; | |||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | my $sec = $6 || 0; my $min = $5 || 0; my $hrs = $4 || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$6 || 0
$5 || 0
$4 || 0
MC/DC0%0/1
$6 || 0
$6
MC/DC0%0/1
$5 || 0
$5
MC/DC0%0/1
$4 || 0
$4
Truth table0%0/2
A
A= $6
Truth table0%0/2
A
A= $5
Truth table0%0/2
A
A= $4
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | my $day = $3 || 1; my $mon = $2 || 1; my $year = $1 || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$3 || 1
$2 || 1
$1 || 0
MC/DC0%0/1
$3 || 1
$3
MC/DC0%0/1
$2 || 1
$2
MC/DC0%0/1
$1 || 0
$1
Truth table0%0/2
A
A= $3
Truth table0%0/2
A
A= $2
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | return Time::Local::timelocal($sec,$min,$hrs,$day,$mon-1,$year); | |||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | sub count_substrings | ||||||||||||||||||||||||||||||||||||||||||
| 613 | { | ||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | my $content = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_substrings: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my $expr = shift; | |||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | return undef unless defined $expr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my @matches = ($content =~ /$expr/g); | |||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | return scalar @matches; | |||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | sub search_string | ||||||||||||||||||||||||||||||||||||||||||
| 622 | { | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | my $content = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_string: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my $expr = shift; | |||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | return undef unless defined $expr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my %opt = | |||||||||||||||||||||||||||||||||||||||||
| 627 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 628 | replace => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 629 | offset => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 630 | range => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 631 | @_ | ||||||||||||||||||||||||||||||||||||||||||
| 632 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $start = $opt{offset}; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my $ln = length($content); | |||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | if ((defined $start) and (abs($start) >= $ln)) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $start and abs $start >= $ln
MC/DC0%0/2
defined $start and abs $start >= $ln
defined $start
abs $start >= $ln
Truth table0%0/3
A and B
A= defined $startB= abs $start >= $ln
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | { | ||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | alert "[$start $ln] out of range"; | |||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | my $range = $opt{range}; | |||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | if (defined $start) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 642 | { | ||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | $start = $start + $ln if $start < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | $content = defined $range ? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | substr($content, $start, $range) : | ||||||||||||||||||||||||||||||||||||||||||
| 646 | substr($content, $start); | ||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | unless (defined $opt{replace}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | { | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | if ($content =~ /$expr/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | { | ||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my $start_pos = length($`); | |||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | $start_pos += $start if defined $start; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my $end_pos = $start_pos + length($&); | |||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my $match = $&; | |||||||||||||||||||||||||||||||||||||||||
| 656 | return wantarray ? | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | ($start_pos, $end_pos, $match) : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 658 | $start_pos; | ||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | else | ||||||||||||||||||||||||||||||||||||||||||
| 661 | { | ||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | return wantarray ? (undef) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||
| 665 | else | ||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | my $rep = $opt{replace}; | |||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $count = ($content =~ s/$expr/$rep/g); | |||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | if (wantarray) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 670 | { | ||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | return ($content, $count); | |||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | else | ||||||||||||||||||||||||||||||||||||||||||
| 674 | { | ||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | return $count ? $content : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||
| 680 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | sub file_type | ||||||||||||||||||||||||||||||||||||||||||
| 683 | { | ||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | require File::Type; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_type: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my $f = shift; | |||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | return undef unless (-r $f && -f $f); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-r $f and -f $f
MC/DC0%0/2
-r $f and -f $f
-r $f
-f $f
Truth table0%0/3
A and B
A= -r $fB= -f $f
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | return File::Type->new->mime_type($f); | |||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | sub file_parse | ||||||||||||||||||||||||||||||||||||||||||
| 691 | { | ||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | require File::Basename; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_parse: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | my $source = shift; | |||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | if (wantarray) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | { | ||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | my ($name,$path,$suffix) = | |||||||||||||||||||||||||||||||||||||||||
| 697 | File::Basename::fileparse($source, qr/\.[^.]*/); | ||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | if (defined $suffix) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | { | ||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $name .= $suffix; | |||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | $suffix =~ s/^\.//; | |||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | return ($name, $path, $suffix); | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | return File::Basename::fileparse($source); | |||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | sub load_file | ||||||||||||||||||||||||||||||||||||||||||
| 709 | { | ||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | my $url = shift or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_file: not called CC=8 SCAR=42.8
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | my $mode = shift // ':utf8'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // ":utf8"
MC/DC0%0/1
shift() // ":utf8"
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | if (! ref $url and $url =~ /:/ and uc($url) !~ /^[A-Z]:/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not ref $url and $url =~ /:/ and not uc($url) =~ /^[A-Z]:/
not ref $url and $url =~ /:/
MC/DC0%0/3
not ref $url and $url =~ /:/ and not uc($url) =~ /^[A-Z]:/
not ref $url
$url =~ /:/
not uc($url) =~ /^[A-Z]:/
Truth table0%0/4
not(A) and B and not(C)
A= not ref $urlB= $url =~ /:/C= not uc($url) =~ /^[A-Z]:/
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | { | ||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | require LWP::Simple; | |||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | $url =~ s{\\}{/}; | |||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | return LWP::Simple::get($url); | |||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||
| 719 | else | ||||||||||||||||||||||||||||||||||||||||||
| 720 | { | ||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | return undef unless ref $url or -r -f -e $url; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $url or -r -f -e $url
MC/DC0%0/2
ref $url or -r -f -e $url
ref $url
-r -f -e $url
Truth table0%0/3
A or B
A= ref $urlB= -r -f -e $url
| |||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | require File::Slurp; | |||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | return scalar File::Slurp::read_file | |||||||||||||||||||||||||||||||||||||||||
| 724 | ($url, binmode => $mode); | ||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | sub image_size | ||||||||||||||||||||||||||||||||||||||||||
| 729 | { | ||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | my $url = shift or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
image_size: not called CC=7 SCAR=40.3
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my $source; | |||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | if (ref $url eq 'SCALAR') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 735 | { | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $source = $url; | |||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||
| 738 | elsif ($opt{document}) | ||||||||||||||||||||||||||||||||||||||||||
| 739 | { | ||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | $source = \($opt{document}->get_part($url)); | |||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | else | ||||||||||||||||||||||||||||||||||||||||||
| 743 | { | ||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | $source = \(load_file($url, ':raw')); | |||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | if ($source) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 748 | { | ||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | require Image::Size; | |||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | my ($w, $h) = Image::Size::imgsize($source); | |||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | return undef unless defined $w; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | if (wantarray) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | { | ||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | return ($w, $h); | |||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||
| 756 | else | ||||||||||||||||||||||||||||||||||||||||||
| 757 | { | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | $w .= 'pt'; $h .= 'pt'; | |||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | return [$w, $h]; | |||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 762 | else | ||||||||||||||||||||||||||||||||||||||||||
| 763 | { | ||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | sub input_2d_value | ||||||||||||||||||||||||||||||||||||||||||
| 769 | { | ||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | my $arg = shift or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
input_2d_value: not called CC=11 SCAR=48.8
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | my $u = shift // 'cm'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // "cm"
MC/DC0%0/1
shift() // "cm"
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | my ($x, $y); | |||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | if (ref $arg) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 774 | { | ||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | $x = $arg->[0]; $y = $arg->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||
| 777 | elsif ($arg) | ||||||||||||||||||||||||||||||||||||||||||
| 778 | { | ||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | if ($arg =~ /,/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | { | ||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $arg =~ s/\s*//g; | |||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ($x, $y) = split(',', $arg); | |||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||
| 784 | else | ||||||||||||||||||||||||||||||||||||||||||
| 785 | { | ||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | $x = $arg; $y = shift; | |||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | $x ||= ('0' . $u); $y ||= ('0' . $u); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$x ||= '0' . $u
$y ||= '0' . $u
MC/DC0%0/2
$x ||= '0' . $u
$x
'0' . $u
MC/DC0%0/2
$y ||= '0' . $u
$y
'0' . $u
Truth table0%0/3
A ||= B
A= $xB= '0' . $u
Truth table0%0/3
A ||= B
A= $yB= '0' . $u
| |||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | ▶ | $x .= $u unless $x =~ /[a-zA-Z]$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | $y .= $u unless $y =~ /[a-zA-Z]$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | return wantarray ? ($x, $y) : [$x, $y]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | #--- symbolic color names handling ------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | 2 | our %COLORCODE = (); | |||||||||||||||||||||||||||||||||||||||||
| 798 | 2 | our %COLORNAME = (); | |||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||
| 800 | sub color_code | ||||||||||||||||||||||||||||||||||||||||||
| 801 | { | ||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | my $name = shift or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color_code: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | ▶ | if ($name && ($name =~ /^#/)) { return $name } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and $name =~ /^#/
MC/DC0%0/2
$name and $name =~ /^#/
$name
$name =~ /^#/
Truth table0%0/3
A and B
A= $nameB= $name =~ /^#/
| |||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | return $COLORCODE{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | sub color_name | ||||||||||||||||||||||||||||||||||||||||||
| 808 | { | ||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | my $code = shift or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color_name: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | return $COLORNAME{lc $code}; | |||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | sub load_color_map | ||||||||||||||||||||||||||||||||||||||||||
| 814 | { | ||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | my $filename = shift || (installation_path() . '/data/rgb.txt'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_color_map: not called CC=9 SCAR=45.0
Pod
undocumented
Condition0%0/2
shift() || installation_path() . '/data/rgb.txt'
MC/DC0%0/1
shift() || installation_path() . '/data/rgb.txt'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | unless ( -e $filename && -r $filename ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $filename and -r $filename
MC/DC0%0/2
-e $filename and -r $filename
-e $filename
-r $filename
Truth table0%0/3
A and B
A= -e $filenameB= -r $filename
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | { | ||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | warn "Color map file non existent or unreadable" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 819 | if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my $r = open COLORS, "<", $filename; | |||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | ▶ | unless ($r) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 824 | { | ||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | alert "Error opening $filename"; return FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | while (my $line = <COLORS>) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 828 | { | ||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | $line =~ s/^\s*//; $line =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | next unless $line =~ /^[0-9]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | $line =~ /(\d*)\s*(\d*)\s*(\d*)\s*(.*)/; | |||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | my $name = $4; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | ▶ | $COLORCODE{$name} = sprintf("#%02x%02x%02x", $1, $2, $3) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 834 | if $name; | ||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | close COLORS; | |||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | %COLORNAME = reverse %COLORCODE; | |||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | sub unload_color_map | ||||||||||||||||||||||||||||||||||||||||||
| 842 | { | ||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unload_color_map: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | %COLORCODE = (); | |||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | %COLORNAME = (); | |||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | sub installation_path { $INSTALLATION_PATH } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
installation_path: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||
| 853 | sub template | ||||||||||||||||||||||||||||||||||||||||||
| 854 | { | ||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | my $type = shift // ""; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
template: not called CC=5 SCAR=34.0
Pod
undocumented
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | ▶ | $type = shift if $type eq lpod; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | my $filename = $ODF_TEMPLATE{$type}; | |||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | unless ($filename) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 860 | { | ||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | alert("Unsupported type"); | |||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | my $fullpath = installation_path() . '/templates/' . $filename; | |||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | unless (-r -f -e $fullpath) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | { | ||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | alert("Template not available"); | |||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | return $fullpath; | |||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||
| 873 | #--- session ID generator ---------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | 2 | our $LPOD_ID_PATTERN = 'lpOD_%09x'; | |||||||||||||||||||||||||||||||||||||||||
| 876 | sub new_id | ||||||||||||||||||||||||||||||||||||||||||
| 877 | { | ||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | state $count = 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | return sprintf($LPOD_ID_PATTERN, ++$count); | |||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | #--- pretty XML output option ------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | 2 | our $XML_PRETTY_PRINT_MODE = 'indented'; | |||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | sub XML_PRETTY_PRINT | ||||||||||||||||||||||||||||||||||||||||||
| 887 | { | ||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | my $pp = shift // ""; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
XML_PRETTY_PRINT: not called CC=4 SCAR=30.0
Pod
undocumented
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | $pp = shift if ($pp eq lpod); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | $XML_PRETTY_PRINT_MODE = $pp if $pp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | return $XML_PRETTY_PRINT_MODE; | |||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | sub not_implemented | ||||||||||||||||||||||||||||||||||||||||||
| 897 | { | ||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | alert("NOT IMPLEMENTED"); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not_implemented: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | #============================================================================= | ||||||||||||||||||||||||||||||||||||||||||
| 903 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||