%
my %stylemap = (
Text_body => 'para',
);
sub get_actual_style {
my ($node) = @_;
my $autostyle = $node->getAttribute('text:style-name');
my $actualstyle = findvalue(
"translate(/office:document
/office:automatic-styles
/style:style[\@style:name='$autostyle']
/\@style:parent-style-name, ' ', '_')");
return $stylemap{$actualstyle} || $actualstyle;
}
$t->{'text:sequence-decls'}{testcode} = sub { 0; };
# For headings we put in \n before and \n after.
$t->{'text:h'}{testcode} = sub {
my ($node, $t2) = @_;
my $actualstyle = get_actual_style($node);
$t2->{pre} = "\n<${actualstyle}>";
$t2->{post} = "${actualstyle}>\n";
return 1;
};
# p is same as headings, but without the \n's
$t->{'text:p'}{testcode} = sub {
my ($node, $t2) = @_;
my $actualstyle = get_actual_style($node);
$t2->{pre} = "<${actualstyle}>";
$t2->{post} = "${actualstyle}>";
return 1;
};
# make lists more docbook-like
$t->{'text:ordered-list'}{pre} = '';
$t->{'text:ordered-list'}{post} = '';
$t->{'text:unordered-list'}{pre} = '';
$t->{'text:unordered-list'}{post} = '';
$t->{'text:list-item'}{pre} = '';
$t->{'text:list-item'}{post} = '';
# span is same as HTML span. Here we extract fo:* attributes
# and turn them into CSS styles.
$t->{'text:span'}{testcode} = sub {
my ($node, $t) = @_;
my $autostyle = $node->getAttribute('text:style-name');
# get the actual style node
my ($property) = findnodes(
"/office:document
/office:automatic-styles
/style:style[\@style:name='$autostyle']
/style:properties");
$t->{pre} = "findnodes('@fo:*')) {
$t->{pre} .= $fo->getLocalName . ': ' . $fo->getValue . '; ';
}
$t->{pre} .= '">';
$t->{post} = "";
return 1;
};
$t->{'text:line-break'}{pre} = "
\n";
$t->{'text:s'}{pre} = ' ';
%>
<%
# here we don't use apply_templates only because we get too many
# namespace declarations if we do, so this creates a simpler version.
# Old version was:
# apply_templates('/office:document/office:meta/dc:*')
foreach my $meta (findnodes('/office:document/office:meta/dc:*')) {
print "<", $meta->getName, ">",
$meta->string_value, "", $meta->getName, ">\n";
}
%>
<%= apply_templates('/office:document/office:body/*') %>