NAME

MsOffice::Word::Surgeon::Run - internal representation for a "run of text"

DESCRIPTION

This is used internally by MsOffice::Word::Surgeon for storing a "run of text" in a MsWord document. It loosely corresponds to a <w:r> node in OOXML, but may also contain an anonymous XML fragment which is the part of the document just before the <w:r> node -- used for reconstructing the complete document after having changed the contents of some runs.

METHODS

new

my $run = MsOffice::Word::Surgeon::Run(
  xml_before  => $xml_string,
  props       => $properties_string,
  inner_texts => [MsOffice::Word::Surgeon::Text(...), ...],
);

Constructor for a new run object. Arguments are :

xml_before

A string containing arbitrary XML preceding that run in the complete document. The string may be empty but must be present.

props

A string containing XML for the properties of this run (for example instructions for bold, italic, font, etc.). The module does not parse this information; it just compares the string for equality with the next run.

inner_texts

An array of MsOffice::Word::Surgeon::Text objects, corresponding to the XML <w:t> nodes inside the run.

as_xml

my $xml = $run->as_xml;

Returns the XML representation of that run.

merge

$run->merge($next_run);

Merge the contents of $next_run together with the current run. This is only possible if both runs have the same properties (same string returned by the props method), and if the next run has an empty xml_before attribute; if the conditions are not met, an exception is raised.

replace

my $xml = $run->replace($pattern, $replacement_callback, %replacement_args);

Replaces all occurrences of $pattern within all text nodes by a new string computed by $replacement_callback, and returns a new xml string corresponding to the result of all these replacements. This is the internal implementation for public method "replace" in MsOffice::Word::Surgeon.

remove_caps_property

Searches in the run properties for a <w:caps/> property; if found, removes it, and replaces all inner texts by their uppercase equivalents.