This file is indexed.

/usr/bin/odfhighlight 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/perl

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

=head1	NAME

odfhighlight - search, replace and highlight text in a document

=head1	SYNOPSIS

odfhighlight "source.odt" "search string" -r "replacement" -o "target.odt"

replaces "search string" by "replacement" in the file "source.odt", highlights
each replacement with a yellow (default) backgound, then writes the resulting
document as "target.odt"

odfhighlight "myfile.odt" "search string" -color "green"

highlights each occurrence of "search string" in "myfile.odt" with a green
background color, without changing the text (without "-o" option, the changes
apply to "myfile.odt"

=head1	ARGUMENTS AND OPTIONS

=head2	Default behaviour

With the "minimal" command line, with only a filename and a string as
arguments, each matching string is highlighted with a yellow background
and represented with the "Standard" style.

=head2	Options

	-e --encoding "xxxxxx"

		character set to use, if different from the default
		
	-r --replacement "new string"

		"new string" is used as a replacement for "search string"

	-c --color "code"

		an RGB color code, expressed either as the concatenation of
		3 comma-separated decimal values (each one in the range
		0..255, ex: "72,61,139" for a dark slate blue), or a 6-digit
		hexadecimal number, preceded by a "#" (ex: #00ff00 for green)
		or, if a colormap is available and known in your
		OpenOffice::OODoc installation, a symbolic color name (ex:
		"sky blue")

	-s --stylename "name"

		the name of the color style (default: "MyHighlight"); the
		user must provide a style name that is not already in use
		in the document

	-p --property "property=value"

		This option can be repeated; each occurrence gives an
		additional property for the highlight style (font name, size,
		foreground color, ...). For example, with the combination of
		-p 'fo:color=#ff0000' and -p 'fo:font-size=18pt', the
		highlighted text will be made of 18pt-sized, red characters.
		In order to master these options, you should have some
		knowledge of the Form Objects (FO) vocabulary that is used
		in the OpenDocument specification.
	
	-o --output "filename"
	-t --target "filename"

		an alternative filename to save the modified document, when
		the source document must remain unchanged

=cut


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

use OpenOffice::OODoc	2.101;
use Getopt::Long;

#-----------------------------------------------------------------------------
# getting the arguments and options

my $encoding		= $OpenOffice::OODoc::XPath::LOCAL_CHARSET;
my $target		= undef;
my $replace		= undef;
my $color		= '#ffff00'; # yellow
my $stylename		= 'MyHighLight';
my %properties		= ();

GetOptions
	(
	'encoding=s'		=> \$encoding,
	'replacement=s'		=> \$replace,
	'color=s'		=> \$color,
	'stylename=s'		=> \$stylename,
	'property=s'		=> \%properties,
	'output|target=s'	=> \$target
	);

$color	= odfColor($color) or die "Color code is not valid\n";

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

my $filename	= $ARGV[0];
my $search	= $ARGV[1];
die "usage: odfhighlight <file> <search_string> [-options]\n"
	unless ($filename && $search);

#-----------------------------------------------------------------------------
# opening the document

my $doc		= odfDocument
			(
			file		=> $filename,
			local_encoding	=> $encoding
			)
	or die "File unavailable or non-ODF file\n";

#-----------------------------------------------------------------------------
# creating the highlight style

my $attr = $doc->{'opendocument'} ?
		'fo:background-color' : 'style:text-background-color';
$properties{$attr} = $color;

$doc->createStyle
	(
	$stylename,
	family		=> 'text',
	properties	=> { %properties }
	)
	or die "Please choose another style name.\n";
	
#-----------------------------------------------------------------------------
# searching and replacing

my @list = $doc->selectElementsByContent($search, $replace);

#-----------------------------------------------------------------------------
# coloring

if (defined $replace)
	{
		# just in order to avoid unneeded metacharacter processing
	$replace =~ s/([\\\(\)\.\*\?\[\]\|\-])/\\$1/g;
	$search	= $replace;
	}

foreach my $element (@list)
	{
	$doc->setSpan($element, $search, $stylename);
	}

#-----------------------------------------------------------------------------
# saving the result

$doc->save($target);
exit;

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