This file is indexed.

/usr/bin/odf_set_fields is in libopenoffice-oodoc-perl 2.125-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
#!/usr/bin/perl

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell
#-----------------------------------------------------------------------------
#	$Id : odf_set_fields 0.4 2010-01-27 JMG$
#-----------------------------------------------------------------------------

=head1	NAME

odf_set_fields - Set names & values for user-defined fields

=head1	USAGE

odf_set_fields <filename> -options 

=head1	SYNOPSIS

Sample script updating or creating 4 user-defined fields of an ODF
file and adding new keywords. Existing keywords are preserved. Old user-defined
fields names and values are deleted and replaced. The revision number of the
document is incremented by 1.

The keywords must be passed as a comma-separated list through the -keywords
option.

The user-defined fields/options are :
-contact -organization -status -diffusion

Examples:

odf_set_fields foo.odt -contact "Donald Duck" -organization "Genicorp"

odf_set_fields foo.odt -status "Complete" -keywords "software, office"

=cut

use OpenOffice::OODoc::Meta;
use Getopt::Long;

	# default values for the user-defined fields (examples)
my $contact		= 'Corporate Editor';
my $organization	= 'Foo Unlimited';
my $status		= 'Draft';
my $diffusion		= 'Public/Unclassified';
my $keywords		= undef;

	# get the command line options
GetOptions
	(
	'contact=s'		=> \$contact,
	'organization=s'	=> \$organization,
	'status=s'		=> \$status,
	'diffusion=s'		=> \$diffusion,
	'keywords=s'		=> \$keywords
	);

	# get the command line argument as filename
my $filename	= $ARGV[0]
	or die "usage : odf_set_fields filename [-options]\n";

	# create a meta-data object linked to the file
my $doc	= OpenOffice::OODoc::Meta->new(file => $filename)
	or die "I can't open $filename as an ODF document\n";

	# set the user-defined fields using a list of name/value pairs
	# (the names are hard-coded in my example but they could be
	# dynamically defined just like the values)
$doc->user_defined
		(
		Contact		=> $contact,
		Organization	=> $organization,
		Status		=> $status,
		Diffusion	=> $diffusion
		);

	# add the new keyword list (got from the -keyword command line option
	# if any). The 'keywords' method needs a list, so we have to split the
	# content of the -keywords option, assuming separator=comma
	# There is no risk to introduce some keyword redundancy here, because
	# the 'keywords' method from OpenOffice::OODoc::Meta adds only non-existing
	# keywords
$doc->keywords(split(",", $keywords))	if $keywords;

	# because I'm sometimes a perfectionist, I want to
	# put the program signature in the 'generator' field (unavailable for
	# the end-user, but readable/updateable for OpenOffice::OODoc::Meta just as for
	# the OpenOffice.org software); useful to allow any other program to know
	# if this version comes directly from the StarOffice/OpenOffice suite or
	# has been generated by my program
$doc->generator('odf_set_fields Version 0.4');

	# with the same kind of idea, I want to
	# increment the editing cycles count (just to mimic the OpenOffice.org
	# software each time the file is edited, and maybe
	# to help some other workflow/versioning management program)
$doc->increment_editing_cycles;

	# commit all and leave
$doc->save;
exit;