~ubuntu-branches/ubuntu/raring/libopenoffice-oodoc-perl/raring

« back to all changes in this revision

Viewing changes to examples/odf_set_fields

  • Committer: Bazaar Package Importer
  • Author(s): Franck Joncourt
  • Date: 2010-01-28 22:21:30 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100128222130-glx825qrtkagjiwd
Tags: 2.112-1
* New upstream release
* Refreshed my email address.
* Bumped up Standards-Version to 3.8.4 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl
2
2
#-----------------------------------------------------------------------------
3
 
#       $Id : odf_set_fields 0.2 2008-05-04 JMG$
 
3
#       $Id : odf_set_fields 0.4 2010-01-27 JMG$
4
4
#-----------------------------------------------------------------------------
5
5
 
6
6
=head1  NAME
13
13
 
14
14
=head1  SYNOPSIS
15
15
 
16
 
Sample script updating or creating the 4 first user-defined fields of an ODF
 
16
Sample script updating or creating 4 user-defined fields of an ODF
17
17
file and adding new keywords. Existing keywords are preserved. Old user-defined
18
 
fields names and values are deleted and replaced.
 
18
fields names and values are deleted and replaced. The revision number of the
 
19
document is incremented by 1.
19
20
 
20
21
The keywords must be passed as a comma-separated list through the -keywords
21
22
option.
53
54
 
54
55
        # get the command line argument as filename
55
56
my $filename    = $ARGV[0]
56
 
        or die "usage : oo_set_fields filename [-options]\n";
 
57
        or die "usage : odf_set_fields filename [-options]\n";
57
58
 
58
59
        # create a meta-data object linked to the file
59
60
my $doc = OpenOffice::OODoc::Meta->new(file => $filename)
60
 
        or die "I can't open $filename as an OpenOffice.org document\n";
 
61
        or die "I can't open $filename as an ODF document\n";
61
62
 
62
63
        # set the user-defined fields using a list of name/value pairs
63
64
        # (the names are hard-coded in my example but they could be
84
85
        # the OpenOffice.org software); useful to allow any other program to know
85
86
        # if this version comes directly from the StarOffice/OpenOffice suite or
86
87
        # has been generated by my program
87
 
$doc->generator('My document management application Version 1.0');
 
88
$doc->generator('odf_set_fields Version 0.4');
88
89
 
89
90
        # with the same kind of idea, I want to
90
91
        # increment the editing cycles count (just to mimic the OpenOffice.org
91
92
        # software each time the file is edited, and maybe
92
93
        # to help some other workflow/versioning management program)
93
 
my $editing_cycles = $doc->editing_cycles;
94
 
$doc->editing_cycles($editing_cycles + 1);
 
94
$doc->increment_editing_cycles;
95
95
 
96
96
        # commit all and leave
97
97
$doc->save;