« lib/Spreadsheet/Reader/ExcelXML/XMLReader/WorkbookProps.pm
↑ Summary
lib/Spreadsheet/Reader/ExcelXML/Row.pm »
| 1 | package Spreadsheet::Reader::ExcelXML::Cell; | ||||||||||||||||||
| 2 | 19 | our $AUTHORITY = 'cpan:JANDREW'; | |||||||||||||||||
| 3 | 19 | ▶ | use version; our $VERSION = version->declare('v0.16.8'); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | ###LogSD warn "You uncovered internal logging statements for Spreadsheet::Reader::ExcelXML::Cell-$VERSION"; | ||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | 19 | $| = 1; | |||||||||||||||||
| 7 | 19 | ▶ | use 5.010; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 19 | ▶ | use Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | 19 | ▶ | use MooseX::StrictConstructor; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | 19 | ▶ | use MooseX::HasDefaults::RO; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | 19 | ▶ | use Types::Standard qw( | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 12 | Str InstanceOf HashRef | ||||||||||||||||||
| 13 | Enum HasMethods ArrayRef | ||||||||||||||||||
| 14 | Int Maybe CodeRef | ||||||||||||||||||
| 15 | is_Object | ||||||||||||||||||
| 16 | 19 | ); | |||||||||||||||||
| 17 | 19 | ▶ | use lib '../../../../lib'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 18 | ###LogSD use Log::Shiras::Telephone; | ||||||||||||||||||
| 19 | 19 | ▶ | use Spreadsheet::Reader::ExcelXML::Types qw( CellID ); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 20 | ###LogSD with 'Log::Shiras::LogSpace'; | ||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 19 | has error_inst =>( | |||||||||||||||||
| 25 | isa => InstanceOf[ 'Spreadsheet::Reader::ExcelXML::Error' ], | ||||||||||||||||||
| 26 | clearer => '_clear_error_inst', | ||||||||||||||||||
| 27 | reader => '_get_error_inst', | ||||||||||||||||||
| 28 | required => 1, | ||||||||||||||||||
| 29 | handles =>[ qw( | ||||||||||||||||||
| 30 | error set_error clear_error set_warnings if_warn | ||||||||||||||||||
| 31 | ) ], | ||||||||||||||||||
| 32 | ); | ||||||||||||||||||
| 33 | |||||||||||||||||||
| 34 | 19 | has cell_xml_value =>( | |||||||||||||||||
| 35 | isa => Maybe[Str], | ||||||||||||||||||
| 36 | reader => 'xml_value', | ||||||||||||||||||
| 37 | predicate => 'has_xml_value', | ||||||||||||||||||
| 38 | ); | ||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | 19 | has cell_unformatted =>( | |||||||||||||||||
| 41 | isa => Maybe[Str], | ||||||||||||||||||
| 42 | reader => 'unformatted', | ||||||||||||||||||
| 43 | predicate => 'has_unformatted', | ||||||||||||||||||
| 44 | ); | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | 19 | has rich_text =>( | |||||||||||||||||
| 47 | isa => ArrayRef, | ||||||||||||||||||
| 48 | reader => 'get_rich_text', | ||||||||||||||||||
| 49 | predicate => 'has_rich_text', | ||||||||||||||||||
| 50 | ); | ||||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | 19 | has cell_font =>( | |||||||||||||||||
| 53 | isa => HashRef, | ||||||||||||||||||
| 54 | reader => 'get_font', | ||||||||||||||||||
| 55 | predicate => 'has_font', | ||||||||||||||||||
| 56 | ); | ||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | 19 | has cell_border =>( | |||||||||||||||||
| 59 | isa => HashRef, | ||||||||||||||||||
| 60 | reader => 'get_border', | ||||||||||||||||||
| 61 | predicate => 'has_border', | ||||||||||||||||||
| 62 | ); | ||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | 19 | has cell_style =>( | |||||||||||||||||
| 65 | isa => Str, | ||||||||||||||||||
| 66 | reader => 'get_style', | ||||||||||||||||||
| 67 | predicate => 'has_style', | ||||||||||||||||||
| 68 | ); | ||||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | 19 | has cell_fill =>( | |||||||||||||||||
| 71 | isa => HashRef, | ||||||||||||||||||
| 72 | reader => 'get_fill', | ||||||||||||||||||
| 73 | predicate => 'has_fill', | ||||||||||||||||||
| 74 | ); | ||||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | 19 | has cell_alignment =>( | |||||||||||||||||
| 77 | isa => HashRef, | ||||||||||||||||||
| 78 | reader => 'get_alignment', | ||||||||||||||||||
| 79 | predicate => 'has_alignment', | ||||||||||||||||||
| 80 | ); | ||||||||||||||||||
| 81 | |||||||||||||||||||
| 82 | 19 | has cell_type =>( | |||||||||||||||||
| 83 | isa => Enum[qw( Text Numeric Date Custom )], | ||||||||||||||||||
| 84 | reader => 'type', | ||||||||||||||||||
| 85 | writer => '_set_cell_type', | ||||||||||||||||||
| 86 | predicate => 'has_type', | ||||||||||||||||||
| 87 | ); | ||||||||||||||||||
| 88 | |||||||||||||||||||
| 89 | 19 | has cell_encoding =>( | |||||||||||||||||
| 90 | isa => Str, | ||||||||||||||||||
| 91 | reader => 'encoding', | ||||||||||||||||||
| 92 | predicate => 'has_encoding', | ||||||||||||||||||
| 93 | ); | ||||||||||||||||||
| 94 | |||||||||||||||||||
| 95 | 19 | has cell_merge =>( | |||||||||||||||||
| 96 | isa => Str, | ||||||||||||||||||
| 97 | reader => 'merge_range', | ||||||||||||||||||
| 98 | predicate => 'is_merged', | ||||||||||||||||||
| 99 | ); | ||||||||||||||||||
| 100 | |||||||||||||||||||
| 101 | 19 | has cell_formula =>( | |||||||||||||||||
| 102 | isa => Str, | ||||||||||||||||||
| 103 | reader => 'formula', | ||||||||||||||||||
| 104 | predicate => 'has_formula', | ||||||||||||||||||
| 105 | ); | ||||||||||||||||||
| 106 | |||||||||||||||||||
| 107 | 19 | has cell_row =>( | |||||||||||||||||
| 108 | isa => Int, | ||||||||||||||||||
| 109 | reader => 'row', | ||||||||||||||||||
| 110 | predicate => 'has_row', | ||||||||||||||||||
| 111 | ); | ||||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | 19 | has cell_col =>( | |||||||||||||||||
| 114 | isa => Int, | ||||||||||||||||||
| 115 | reader => 'col', | ||||||||||||||||||
| 116 | predicate => 'has_col', | ||||||||||||||||||
| 117 | ); | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | 19 | has r =>( | |||||||||||||||||
| 120 | isa => CellID, | ||||||||||||||||||
| 121 | reader => 'cell_id', | ||||||||||||||||||
| 122 | predicate => 'has_cell_id', | ||||||||||||||||||
| 123 | ); | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | 19 | has cell_hyperlink =>( | |||||||||||||||||
| 126 | isa => ArrayRef, | ||||||||||||||||||
| 127 | reader => 'get_hyperlink', | ||||||||||||||||||
| 128 | predicate => 'has_hyperlink', | ||||||||||||||||||
| 129 | ); | ||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | 19 | has cell_hidden =>( | |||||||||||||||||
| 132 | isa => Enum[qw( sheet column row 0 )], | ||||||||||||||||||
| 133 | reader => 'is_hidden', | ||||||||||||||||||
| 134 | default => 0, | ||||||||||||||||||
| 135 | ); | ||||||||||||||||||
| 136 | |||||||||||||||||||
| 137 | 19 | has cell_coercion =>( | |||||||||||||||||
| 138 | isa => HasMethods[ 'assert_coerce', 'display_name' ], | ||||||||||||||||||
| 139 | reader => 'get_coercion', | ||||||||||||||||||
| 140 | writer => 'set_coercion', | ||||||||||||||||||
| 141 | predicate => 'has_coercion', | ||||||||||||||||||
| 142 | clearer => 'clear_coercion', | ||||||||||||||||||
| 143 | handles =>{ | ||||||||||||||||||
| 144 | coercion_name => 'display_name',# | ||||||||||||||||||
| 145 | }, | ||||||||||||||||||
| 146 | ); | ||||||||||||||||||
| 147 | |||||||||||||||||||
| 148 | #########1 Public Methods 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||
| 149 | |||||||||||||||||||
| 150 | ###LogSD sub get_class_space{ 'Cell' } | ||||||||||||||||||
| 151 | |||||||||||||||||||
| 152 | 210 | ▶ | sub value{ | ||||||||||||||||
|
Subroutine
value: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||
| 153 | 210 | my( $self, ) = @_; | |||||||||||||||||
| 154 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||
| 155 | ###LogSD $self->get_all_space . '::value', ); | ||||||||||||||||||
| 156 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||
| 157 | ###LogSD 'Reached the -value- function' ] ); | ||||||||||||||||||
| 158 | ###LogSD $phone->talk( level => 'trace', message => [ "Cell:", $self ] ); | ||||||||||||||||||
| 159 | 210 | ▶ | my $unformatted = | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 160 | defined $self->has_xml_value ? $self->xml_value : | ||||||||||||||||||
| 161 | defined $self->has_unformatted ? $self->_unformatted : undef; | ||||||||||||||||||
| 162 | 210 | return $self->_return_value_only( | |||||||||||||||||
| 163 | $unformatted, | ||||||||||||||||||
| 164 | $self->get_coercion, | ||||||||||||||||||
| 165 | $self->_get_error_inst, | ||||||||||||||||||
| 166 | ); | ||||||||||||||||||
| 167 | } | ||||||||||||||||||
| 168 | |||||||||||||||||||
| 169 | #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||
| 170 | |||||||||||||||||||
| 171 | |||||||||||||||||||
| 172 | |||||||||||||||||||
| 173 | #########1 Private Methods 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||
| 174 | |||||||||||||||||||
| 175 | 0 | ▶ | after 'set_coercion' => sub{ | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 176 | 0 | my ( $self, ) = @_; | |||||||||||||||||
| 177 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||
| 178 | ###LogSD $self->get_all_space . '::set_coercion', ); | ||||||||||||||||||
| 179 | ###LogSD $phone->talk( level => 'debug', message =>[ | ||||||||||||||||||
| 180 | ###LogSD "Setting 'cell_type' to custom since the coercion has been set" ] ); | ||||||||||||||||||
| 181 | 0 | $self->_set_cell_type( 'Custom' ); | |||||||||||||||||
| 182 | 19 | }; | |||||||||||||||||
| 183 | |||||||||||||||||||
| 184 | 526 | ▶ | sub _return_value_only{ | ||||||||||||||||
|
Subroutine
_return_value_only: called CC=6 SCAR=17.9
| |||||||||||||||||||
| 185 | 526 | my ( $self, $unformatted, $coercion, $error_inst | |||||||||||||||||
| 186 | ###LogSD , $alt_log_space | ||||||||||||||||||
| 187 | ) = @_;# To be used by GetCell too | ||||||||||||||||||
| 188 | ###LogSD $alt_log_space //= $self->get_all_space; | ||||||||||||||||||
| 189 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||
| 190 | ###LogSD $alt_log_space . '::_hidden::_return_value_only', ); | ||||||||||||||||||
| 191 | ###LogSD $phone->talk( level => 'debug', message =>[ | ||||||||||||||||||
| 192 | ###LogSD "Returning the coerced value of -" . ( defined $unformatted ? $unformatted : '') . '-', ] ); | ||||||||||||||||||
| 193 | ###LogSD $phone->talk( level => 'trace', message =>[ | ||||||||||||||||||
| 194 | ###LogSD '..using coercion:' , $coercion ] ) if $coercion; | ||||||||||||||||||
| 195 | 526 | my $formatted = $unformatted; | |||||||||||||||||
| 196 | 526 | ▶ | if( !$coercion ){ | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 197 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||
| 198 | ###LogSD "No coercion passed" ] ); | ||||||||||||||||||
| 199 | 236 | return $unformatted; | |||||||||||||||||
| 200 | }elsif( !defined $unformatted ){ | ||||||||||||||||||
| 201 | 21 | $error_inst->set_error( "The cell does not have a value" ); | |||||||||||||||||
| 202 | }elsif( $unformatted eq '' ){ | ||||||||||||||||||
| 203 | 6 | $error_inst->set_error( "The cell has the empty string for a value" ); | |||||||||||||||||
| 204 | }else{ | ||||||||||||||||||
| 205 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||
| 206 | ###LogSD "Attempting to return the value of the cell formatted to " . | ||||||||||||||||||
| 207 | ###LogSD (($coercion) ? $coercion->display_name : 'No conversion available' ) ] ); | ||||||||||||||||||
| 208 | 263 | my $sig_warn = $SIG{__WARN__}; | |||||||||||||||||
| 209 | 263 | ▶ | $SIG{__WARN__} = sub{}; | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||
| 210 | 263 | eval '$formatted = $coercion->assert_coerce( $unformatted )'; | |||||||||||||||||
| 211 | 263 | ▶ | $error_inst->set_error( $@ ) if( $@ ); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 212 | 263 | $SIG{__WARN__} = $sig_warn; | |||||||||||||||||
| 213 | } | ||||||||||||||||||
| 214 | 290 | ▶ | $formatted =~ s/\\//g if $formatted; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 215 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||
| 216 | ###LogSD "Format is:", $coercion->display_name, | ||||||||||||||||||
| 217 | ###LogSD "Returning the formated value: " . | ||||||||||||||||||
| 218 | ###LogSD ( $formatted ? $formatted : '' ), ] ); | ||||||||||||||||||
| 219 | 290 | return $formatted; | |||||||||||||||||
| 220 | } | ||||||||||||||||||
| 221 | |||||||||||||||||||
| 222 | #########1 Private Methods 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||
| 223 | |||||||||||||||||||
| 224 | 249 | ▶ | sub DEMOLISH{ | ||||||||||||||||
|
Subroutine
DEMOLISH: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 225 | 249 | my ( $self ) = @_; | |||||||||||||||||
| 226 | ###LogSD my $phone = Log::Shiras::Telephone->new( name_space => | ||||||||||||||||||
| 227 | ###LogSD $self->get_all_space . '::hidden::DEMOLISH', ); | ||||||||||||||||||
| 228 | ###LogSD $phone->talk( level => 'debug', message => [ | ||||||||||||||||||
| 229 | ###LogSD "clearing the cell for cell-ID:" . $self->cell_id, ] ); | ||||||||||||||||||
| 230 | #~ print "Clearing coercion\n"; | ||||||||||||||||||
| 231 | 249 | $self->clear_coercion; | |||||||||||||||||
| 232 | #~ print "Clearing error instance\n"; | ||||||||||||||||||
| 233 | 249 | $self->_clear_error_inst; | |||||||||||||||||
| 234 | #~ print "Cell closed\n"; | ||||||||||||||||||
| 235 | } | ||||||||||||||||||
| 236 | |||||||||||||||||||
| 237 | #########1 Phinish 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||
| 238 | |||||||||||||||||||
| 239 | 19 | ▶ | no Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 240 | 19 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||
| 241 | |||||||||||||||||||
| 242 | 19 | 1; | |||||||||||||||||
| 243 | |||||||||||||||||||
| 244 | #########1 Documentation 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||
| 245 | __END__ | ||||||||||||||||||