This file is indexed.

/usr/bin/odfsearch 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
#!/usr/bin/perl

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

=head1	NAME

odfsearch - Text selection and copy from one document to another using callback

=head1	SYNOPSIS

This sample script extracts the content of every text element (paragraph,
header, list item) in a source document matching a given pattern (string or
regex), and appends it as a new paragraph to a target document. The target
document must exist.

The target document must exist (it can be an empty document or a template).

usage : odfsearch target_file source_file "search_string"

=cut

use OpenOffice::OODoc	2.101;

our $count	= 0;

#-----------------------------------------------------------------------------
# callback function executed each time a matching element is found while
# the selectElementsByContent method is running.
# the last argument is the selected element; it's preceded by
# application-specific arguments

sub	append_text
	{
	my ($dst, $stylename, $element) = @_;
	$count++;
		# convert the given element to flat text
		# we use getText as a class method; here we don't need/know
		# the context of the source document
	my $text	= OpenOffice::OODoc::Text->getText($element);
		# append as a new paragraph to target document
	$dst->appendParagraph(text => $text, style => $stylename);
	return undef;
	}

#-----------------------------------------------------------------------------
# main program

	# get the command line arguments
my $target_file		= $ARGV[0];
my $source_file		= $ARGV[1];
my $search_string	= $ARGV[2];
my $stylename		= $ARGV[3] || 'Text body';

die "Usage : odfsearch target_file source_file search_string\n"
	unless ($target_file && $source_file && $search_string);

	# create the 2 Document instances
print "Opening the target file $target_file...\n";
my $target_doc	= odfDocument(file => $target_file)
	or die "$target_file is not available\n";
print "Opening the source file $source_file...\n";
my $source_doc	= odfDocument(file => $source_file)
	or die "$source_file is not available\n";

	# the main processing takes place here :
	# the search method invocation, with search string and reference to
	# the procedure to be executed to process each selected element.
	# The selected element is automatically passed as an argument to the
	# callback, following explicit (optional) arguments provided by
	# the application (here $source_doc, $target_doc, $stylename)
print "Selecting the content...\n";
$source_doc->selectElementsByContent
			(
			$search_string,		# filter expression
			\&append_text,		# callback function reference
			$target_doc, $stylename	# callback function arguments
			);

	# append a conclusion
my $report	=	"$count text elements from $source_file "	.
			"have been selected, converted in paragraphs " .
			"and appended to $target_file. Good reading.";
$target_doc->appendParagraph(text => $report, style => $stylename);
		
	# save the changes and leave
print "Saving the target document...\n";
$target_doc->save;
print "Job complete\n";
exit;

#-----------------------------------------------------------------------------