summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-26 15:44:34 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-26 15:44:34 +0000
commitec4478356acc7aa8bf84ee37b8c2b9307198c6ab (patch)
tree9f1e6cfe4e0d2bf03d165213003703c729ebfe7e
parentefe48c56c79c5130bc003de2cfa507b6c97e3534 (diff)
Add hashing for non-number formats
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1664 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--LedgerSMB/Template/ODS.pm64
1 files changed, 36 insertions, 28 deletions
diff --git a/LedgerSMB/Template/ODS.pm b/LedgerSMB/Template/ODS.pm
index 080be91b..7c3df270 100644
--- a/LedgerSMB/Template/ODS.pm
+++ b/LedgerSMB/Template/ODS.pm
@@ -44,6 +44,7 @@ holders, see the CONTRIBUTORS file.
package LedgerSMB::Template::ODS;
use Error qw(:try);
+use Data::Dumper;
use CGI::Simple::Standard qw(:html);
use Template;
use XML::Twig;
@@ -356,22 +357,22 @@ sub _format_handler {
my %nproperties;
my @nextras;
my $nstyle;
- my $fval = sprintf '%02d', $val;
- @extras = ('references', {'style:data-style-name' => "N$fval"});
+ my $fval = sprintf 'N%02d', $val;
+ @extras = ('references', {'style:data-style-name' => $fval});
if ($sstyles{$fval}) {
# pass through
} elsif ($val == 0) {
$celltype{$style} = 'float';
} elsif ($val == 1) {
- $celltype{$style} = ['float', "N$stylecount"];
+ $celltype{$style} = ['float', 'N01'];
$nstyle = 'number-style';
%nproperties = %{&_prepare_float('0')}
} elsif ($val == 2) {
- $celltype{$style} = ['float', "N$stylecount"];
+ $celltype{$style} = ['float', 'N02'];
$nstyle = 'number-style';
%nproperties = %{&_prepare_float('0.00')}
} elsif ($val == 3) {
- $celltype{$style} = ['float', "N$stylecount"];
+ $celltype{$style} = ['float', 'N03'];
$nstyle = 'number-style';
%nproperties = %{&_prepare_float('#,##0')}
} elsif ($val == 4) {
@@ -677,32 +678,39 @@ sub _format_handler {
$cstyle->insert_new_elt('last_child',
@$child);
}
- $sstyles{$fval} = $fval;
+ $sstyles{$fval} = 1;
}
}
}
- $ods->createStyle(
- $style,
- family => 'table-cell',
- properties => $properties{cell},
- @extras,
- );
- $ods->updateStyle(
- $style,
- properties => {
- -area => 'text',
- %{$properties{text}}
- }
- );
- $ods->updateStyle(
- $style,
- properties => {
- -area => 'paragraph',
- %{$properties{paragraph}}
- }
- );
- unshift @basestyle, [$style, \%properties];
- $stylecount++;
+
+ # Maintain a hash table to keep the final style list size down
+ $Data::Dumper::Sortkeys = 1;
+ my $mystyle = Digest::MD5::md5_hex(Dumper(\%properties, \@extras));
+ if (!$sstyles{$mystyle}) {
+ $ods->createStyle(
+ $style,
+ family => 'table-cell',
+ properties => $properties{cell},
+ @extras,
+ );
+ $ods->updateStyle(
+ $style,
+ properties => {
+ -area => 'text',
+ %{$properties{text}}
+ }
+ );
+ $ods->updateStyle(
+ $style,
+ properties => {
+ -area => 'paragraph',
+ %{$properties{paragraph}}
+ }
+ );
+ $stylecount++;
+ $sstyles{$mystyle} = [$style, \%properties];
+ }
+ unshift @basestyle, $sstyles{$mystyle};
}
sub _format_cleanup_handler {