| 1 | package Spreadsheet::ParseExcel::FmtUnicode; | ||
| 2 | |||
| 3 | ############################################################################### | ||
| 4 | # | ||
| 5 | # Spreadsheet::ParseExcel::FmtUnicode - A class for Cell formats. | ||
| 6 | # | ||
| 7 | # Used in conjunction with Spreadsheet::ParseExcel. | ||
| 8 | # | ||
| 9 | # Copyright (c) 2014 Douglas Wilson | ||
| 10 | # Copyright (c) 2009-2013 John McNamara | ||
| 11 | # Copyright (c) 2006-2008 Gabor Szabo | ||
| 12 | # Copyright (c) 2000-2006 Kawai Takanori | ||
| 13 | # | ||
| 14 | # perltidy with standard settings. | ||
| 15 | # | ||
| 16 | # Documentation after __END__ | ||
| 17 | # | ||
| 18 | |||
| 19 | use strict; | ||
| 20 | use warnings; | ||
| 21 | |||
| 22 | use Unicode::Map; | ||
| 23 | use base 'Spreadsheet::ParseExcel::FmtDefault'; | ||
| 24 | |||
| 25 | our $VERSION = '0.66'; | ||
| 26 | |||
| 27 | #------------------------------------------------------------------------------ | ||
| 28 | # new (for Spreadsheet::ParseExcel::FmtUnicode) | ||
| 29 | #------------------------------------------------------------------------------ | ||
| 30 | sub new { | ||
| 31 | my ( $sPkg, %hKey ) = @_; | ||
| 32 | my $sMap = $hKey{Unicode_Map}; | ||
| 33 | my $oMap; | ||
| 34 | $oMap = Unicode::Map->new($sMap) if $sMap; | ||
| 35 | my $oThis = { | ||
| 36 | Unicode_Map => $sMap, | ||
| 37 | _UniMap => $oMap, | ||
| 38 | }; | ||
| 39 | bless $oThis; | ||
| 40 | return $oThis; | ||
| 41 | } | ||
| 42 | |||
| 43 | #------------------------------------------------------------------------------ | ||
| 44 | # TextFmt (for Spreadsheet::ParseExcel::FmtUnicode) | ||
| 45 | #------------------------------------------------------------------------------ | ||
| 46 | sub TextFmt { | ||
| 47 | my ( $oThis, $sTxt, $sCode ) = @_; | ||
| 48 | if ( $oThis->{_UniMap} ) { | ||
| 49 | if ( !defined($sCode) ) { | ||
| 50 | my $sSv = $sTxt; | ||
| 51 | $sTxt =~ s/(.)/\x00$1/sg; | ||
| 52 | $sTxt = $oThis->{_UniMap}->from_unicode($sTxt); | ||
| 53 | $sTxt = $sSv unless ($sTxt); | ||
| 54 | } | ||
| 55 | elsif ( $sCode eq 'ucs2' ) { | ||
| 56 | $sTxt = $oThis->{_UniMap}->from_unicode($sTxt); | ||
| 57 | } | ||
| 58 | |||
| 59 | # $sTxt = $oThis->{_UniMap}->from_unicode($sTxt) | ||
| 60 | # if(defined($sCode) && $sCode eq 'ucs2'); | ||
| 61 | return $sTxt; | ||
| 62 | } | ||
| 63 | else { | ||
| 64 | return $sTxt; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | 1; | ||
| 68 | |||
| 69 | __END__ |