yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | package Spreadsheet::ParseExcel::FmtJapan2; |
| 2 | |
| 3 | ############################################################################### |
| 4 | # |
| 5 | # Spreadsheet::ParseExcel::FmtJapan2 - A class for Cell formats. |
| 6 | # |
| 7 | # Used in conjunction with Spreadsheet::ParseExcel. |
| 8 | # |
| 9 | # Copyright (c) 2009 John McNamara |
| 10 | # Copyright (c) 2006-2008 Gabor Szabo |
| 11 | # Copyright (c) 2000-2006 Kawai Takanori |
| 12 | # |
| 13 | # perltidy with standard settings. |
| 14 | # |
| 15 | # Documentation after __END__ |
| 16 | # |
| 17 | |
| 18 | use strict; |
| 19 | use warnings; |
| 20 | |
| 21 | use Jcode; |
| 22 | use Unicode::Map; |
| 23 | use base 'Spreadsheet::ParseExcel::FmtJapan'; |
| 24 | our $VERSION = '0.59'; |
| 25 | |
| 26 | #------------------------------------------------------------------------------ |
| 27 | # new (for Spreadsheet::ParseExcel::FmtJapan2) |
| 28 | #------------------------------------------------------------------------------ |
| 29 | sub new { |
| 30 | my ( $sPkg, %hKey ) = @_; |
| 31 | my $oMap = Unicode::Map->new('CP932Excel'); |
| 32 | die "NO MAP FILE CP932Excel!!" |
| 33 | unless ( -r Unicode::Map->mapping("CP932Excel") ); |
| 34 | |
| 35 | my $oThis = { |
| 36 | Code => $hKey{Code}, |
| 37 | _UniMap => $oMap, |
| 38 | }; |
| 39 | bless $oThis; |
| 40 | $oThis->SUPER::new(%hKey); |
| 41 | return $oThis; |
| 42 | } |
| 43 | |
| 44 | #------------------------------------------------------------------------------ |
| 45 | # TextFmt (for Spreadsheet::ParseExcel::FmtJapan2) |
| 46 | #------------------------------------------------------------------------------ |
| 47 | sub TextFmt { |
| 48 | my ( $oThis, $sTxt, $sCode ) = @_; |
| 49 | |
| 50 | # $sCode = 'sjis' if((! defined($sCode)) || ($sCode eq '_native_')); |
| 51 | if ( $oThis->{Code} ) { |
| 52 | if ( !defined($sCode) ) { |
| 53 | $sTxt =~ s/(.)/\x00$1/sg; |
| 54 | $sTxt = $oThis->{_UniMap}->from_unicode($sTxt); |
| 55 | } |
| 56 | elsif ( $sCode eq 'ucs2' ) { |
| 57 | $sTxt = $oThis->{_UniMap}->from_unicode($sTxt); |
| 58 | } |
| 59 | return Jcode::convert( $sTxt, $oThis->{Code}, 'sjis' ); |
| 60 | } |
| 61 | else { |
| 62 | return $sTxt; |
| 63 | } |
| 64 | } |
| 65 | 1; |
| 66 | |
| 67 | __END__ |
| 68 | |
| 69 | =pod |
| 70 | |
| 71 | =head1 NAME |
| 72 | |
| 73 | Spreadsheet::ParseExcel::FmtJapan2 - A class for Cell formats. |
| 74 | |
| 75 | =head1 SYNOPSIS |
| 76 | |
| 77 | See the documentation for Spreadsheet::ParseExcel. |
| 78 | |
| 79 | =head1 DESCRIPTION |
| 80 | |
| 81 | This module is used in conjunction with Spreadsheet::ParseExcel. See the documentation for Spreadsheet::ParseExcel. |
| 82 | |
| 83 | =head1 AUTHOR |
| 84 | |
| 85 | Maintainer 0.40+: John McNamara jmcnamara@cpan.org |
| 86 | |
| 87 | Maintainer 0.27-0.33: Gabor Szabo szabgab@cpan.org |
| 88 | |
| 89 | Original author: Kawai Takanori kwitknr@cpan.org |
| 90 | |
| 91 | =head1 COPYRIGHT |
| 92 | |
| 93 | Copyright (c) 2009-2010 John McNamara |
| 94 | |
| 95 | Copyright (c) 2006-2008 Gabor Szabo |
| 96 | |
| 97 | Copyright (c) 2000-2006 Kawai Takanori |
| 98 | |
| 99 | All rights reserved. |
| 100 | |
| 101 | You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. |
| 102 | |
| 103 | =cut |