Properly detect and handle requests for multi-page --svg or --eps output.
All checks were successful
Remind unit tests / tests (push) Successful in 42s

This commit is contained in:
Dianne Skoll
2024-12-26 09:38:05 -05:00
parent c80d72f623
commit 18b57d26b4
2 changed files with 20 additions and 18 deletions

View File

@@ -257,6 +257,7 @@ if ($settings->{ps} && $settings->{landscape}) {
}
my $warned = 0;
my $index = 0;
while(1) {
if ($settings->{ps}) {
$surface->dsc_begin_page_setup();
@@ -277,14 +278,8 @@ while(1) {
}
last;
}
if (($settings->{eps} || $settings->{svg}) && $done_one) {
if (!$warned) {
print STDERR "WARNING: --eps and --svg can only output one page; ignoring subsequent\nmonths in a multi-month calendar.\n";
$warned = 1;
}
next;
}
$obj->render($cr, $settings);
$index++;
$obj->render($cr, $settings, $index, -1);
$done_one = 1;
}

View File

@@ -468,6 +468,14 @@ sub render
{
my ($self, $cr, $settings, $index, $total) = @_;
if ($settings->{svg} || $settings->{eps}) {
if ($index > 1) {
if ($index == 2) {
print STDERR "WARNING: --svg/--eps can only output one page; ignoring subsequent\nmonths in a multi-month calendar.\n";
}
return;
}
}
$self->setup_daymap($settings);
$self->{horiz_lines} = [];
$cr->set_line_cap('square');
@@ -1011,20 +1019,10 @@ as were read from the C<remind -ppp> stream
sub render
{
my ($self, $cr, $settings) = @_;
my $done = 0;
my $warned = 0;
my $index = 0;
my $total = scalar(@{$self->{entries}});
foreach my $e (@{$self->{entries}}) {
if ($settings->{svg} && $done) {
if (!$warned) {
print STDERR "WARNING: --svg can only output one page; ignoring subsequent\nmonths in a multi-month calendar.\n";
$warned = 1;
}
next;
}
$done = 1;
$index++;
$e->render($cr, $settings, $index, $total);
}
@@ -1042,6 +1040,15 @@ Remind::PDF::Weekly - render a weekly calendar
sub render
{
my ($self, $cr, $settings, $index, $total) = @_;
if ($settings->{svg} || $settings->{eps}) {
if ($index > $settings->{weeks_per_page}) {
if ($index == $settings->{weeks_per_page}+1) {
print STDERR "WARNING: --svg/--eps can only output one page; ignoring subsequent pages.\n";
}
return;
}
}
$settings->{numbers_on_left} = 1;
# Set up bounding box
if ($settings->{weeks_per_page} == 1) {