[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1658] trunk
- Subject: SF.net SVN: ledger-smb: [1658] trunk
- From: ..hidden..
- Date: Mon, 24 Sep 2007 12:24:15 -0700
Revision: 1658
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1658&view=rev
Author: tetragon
Date: 2007-09-24 12:24:15 -0700 (Mon, 24 Sep 2007)
Log Message:
-----------
Starting the addition of style support to LSMB::T::ODS
Modified Paths:
--------------
trunk/LedgerSMB/Template/ODS.pm
trunk/UI/am-list-accounts.odst
Modified: trunk/LedgerSMB/Template/ODS.pm
===================================================================
--- trunk/LedgerSMB/Template/ODS.pm 2007-09-24 00:41:09 UTC (rev 1657)
+++ trunk/LedgerSMB/Template/ODS.pm 2007-09-24 19:24:15 UTC (rev 1658)
@@ -94,9 +94,79 @@
sub _cell_handler {
my $cell = $ods->getCell(-1, $rowcount, $currcol);
$ods->cellValue($cell, $_->{att}->{text});
+ if (@basestyle) {
+ $ods->cellStyle($cell, $basestyle[0][0]);
+ }
$currcol++;
}
+sub _format_handler {
+ my ($t, $format) = @_;
+ my $style = "ce$stylecount";
+
+ my @width = ('none', '0.018cm solid', '0.035cm solid',
+ '0.018cm dashed', '0.018cm dotted', '0.141cm solid',
+ '0.039cm double', '0.002cm solid');
+ my %properties;
+ if (@basestyle) {
+ %properties = %{$basestyle[0][1]};
+ }
+ while (my ($attr, $val) = each %{$format->{att}}) {
+ if ($attr eq 'bottom') {
+ $properties{cell}{'fo:border-bottom'} = "$width[$val] #000000";
+ } elsif ($attr eq 'top') {
+ $properties{cell}{'fo:border-top'} = "$width[$val] #000000";
+ } elsif ($attr eq 'left') {
+ $properties{cell}{'fo:border-left'} = "$width[$val] #000000";
+ } elsif ($attr eq 'right') {
+ $properties{cell}{'fo:border-right'} = "$width[$val] #000000";
+ } elsif ($attr eq 'border') {
+ $properties{cell}{'fo:border'} = "$width[$val] #000000";
+ } elsif ($attr eq 'align') {
+ $properties{text}{'fo:text-align'} = $val;
+ } elsif ($attr eq 'valign') {
+ # takes top, vcenter, bottom, or vjustify
+ # needs top, middle, or bottom
+ if ($val =~ /^v/) {
+ $properties{text}{'fo:vertical-align'} = 'middle';
+ } else {
+ $properties{text}{'fo:vertical-align'} = $val;
+ }
+ } elsif ($attr eq 'bold') {
+ if ($properties{text}{'fo:font-weight'} and !$val) {
+ delete $properties{'fo:font-weight'};
+ } elsif ($val) {
+ $properties{text}{'fo:font-weight'} = 'bold';
+ }
+ } elsif ($attr eq 'italic') {
+ if ($properties{'fo:font-style'} and !$val) {
+ delete $properties{text}{'fo:font-style'};
+ } elsif ($val) {
+ $properties{text}{'fo:font-style'} = 'italic';
+ }
+ }
+ }
+ $ods->createStyle(
+ $style,
+ family => 'table-cell',
+ properties => $properties{cell},
+ );
+ $ods->updateStyle(
+ $style,
+ properties => {
+ -area => 'text',
+ %{$properties{text}}
+ }
+ );
+ unshift @basestyle, [$style, \%properties];
+ $stylecount++;
+}
+
+sub _format_cleanup_handler {
+ my ($t, $format) = @_;
+ shift @basestyle;
+}
+
sub _ods_process {
my ($filename, $template, $user) = @_;
@@ -105,18 +175,21 @@
local $sheet;
local $rowcount;
local $currcol;
+ local $stylecount = 1;
+ local @basestyle;
my $parser = XML::Twig->new(
start_tag_handlers => {
worksheet => \&_worksheet_handler,
row => \&_row_handler,
+ cell => \&_cell_handler,
+ format => \&_format_handler,
},
twig_handlers => {
- cell => \&_cell_handler,
+ format => \&_format_cleanup_handler,
}
);
$parser->parse($template);
$parser->flush;
- #$ods->normalizeSheet($sheet, $rowcount, $colcount);
$ods->save;
}
Modified: trunk/UI/am-list-accounts.odst
===================================================================
--- trunk/UI/am-list-accounts.odst 2007-09-24 00:41:09 UTC (rev 1657)
+++ trunk/UI/am-list-accounts.odst 2007-09-24 19:24:15 UTC (rev 1658)
@@ -1,11 +1,11 @@
<workbook>
<worksheet name="test" rows="<?lsmb rows.size + 1 ?>" columns="<?lsmb columns.size ?>">
- <format bottom="1"><row>
+ <format bottom="6"><row>
<?lsmb FOREACH column IN columns ?>
- <?lsmb IF heading.$column.text ?>
- <cell text="<?lsmb heading.$column.text ?>" />
- <?lsmb ELSE ?>
- <cell text="<?lsmb heading.$column ?>" />
+ <?lsmb IF heading.$column.text ?><format italic="1">
+ <cell text="<?lsmb heading.$column.text ?>" /></format>
+ <?lsmb ELSE ?><format bold="1">
+ <cell text="<?lsmb heading.$column ?>" /></format>
<?lsmb END; END ?>
</row></format>
<?lsmb FOREACH row IN rows ?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.