collect abstract and then generate document
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 26 Apr 2016 12:30:21 +0000 (14:30 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 26 Apr 2016 12:30:21 +0000 (14:30 +0200)
star2016-contributions.pl

index 9ba6396..3c2869b 100755 (executable)
@@ -15,13 +15,13 @@ use OpenOffice::OODoc       2.101;
 my $doc = odfDocument(file => $odt_file, create => 'text');
 
 my $stat;
-my $id2nr;
+my $abstracts;
 
 $doc->createStyle(
        "Abstract",
        family          => 'paragraph',
-       parent          => 'Default Style',
-       category        => 'auto',
+       parent          => 'Standard',
+#      category        => 'auto',
        properties      => {
                -area                   => 'paragraph',
                'fo:text-align' => 'justify'
@@ -58,7 +58,7 @@ print $xml;
        warn "# $id abstract = ", dump($abstract);
 
        foreach my $k (qw( ContributionType )) {
-               $stat->{$k}->{ $abstract->{$k}->[0] } ++;
+               push @{ $stat->{$k}->{ $abstract->{$k}->[0] } }, $id;
        }
 
        if ( my $s = $abstract->{Symposium_title} ) {
@@ -66,22 +66,16 @@ print $xml;
                push @{ $stat->{_symposium}->{$s} }, $id;
        }
 
-       my $f = $abstract->{field};
-
-       push @{ $stat->{_symposium}->{ $f->{1}->{'content'} } }, $id if exists $f->{1}->{content};
-       push @{ $stat->{_theme}->{     $f->{2}->{'content'} } }, $id if exists $f->{2}->{content};
-
-       $stat->{field}->{ $_ }++ foreach keys %$f;
-
-       $id2nr->{ $id } = $nr++;
+       $abstracts->{ $id } = $abstract;
 
 }
 
 warn "# stat = ",dump($stat);
 
-__END__
+sub abstract2doc {
+       my $id = shift;
 
-warn "$nr";
+       my $abstract = $abstracts->{$id} || die "no $id in abstracts ",dump($abstracts);
 
        my $t = $doc->appendParagraph(text => $abstract->{Title}->[0], style => 'Heading 1');
        $doc->setPageBreak( $t, position => 'before', style => 'Heading 1');
@@ -105,6 +99,12 @@ warn "$nr";
        
 
        $doc->appendParagraph(text => "\nID: " . $abstract->{Id}->[0], style => 'Abstract');
+
+       warn "# added $id to document\n";
+}
+
+foreach my $id ( keys %$abstracts ) {
+       abstract2doc($id);
 }
 
 warn "# stat = ",dump($stat);