MsOffice::Word::Surgeon::Text(3pm)

MsOffice::Word::Surgeon::Text3pm

Internal representation for a node of literal text

Overview

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

Methods

new

  my $text_node = MsOffice::Word::Surgeon::Text(
    xml_before   => $xml_string,
    literal_text => $text_string,
  );

Constructor for a new text object. Arguments are :

xml_before

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

literal_text

A string of literal text.

as_xml

  my $xml = $text_node->as_xml;

Returns the XML representation of that text node. The attribute "xml:space="preserve"" is automatically added if the literal text starts of ends with a space character.

merge

  $text_node->merge($next_text_node);

Merge the contents of $next_text_node together with the current text node. This is only possible if the next text node has an empty "xml_before" attribute; if this condition is not met, an exception is raised.

replace

  my $xml = $text_node->replace($pattern, $replacement_callback, %args);

Replaces all occurrences of $pattern within the text node 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.

to_uppercase

Puts the literal text within the node into uppercase letters.

Author

Laurent Dami, <dami AT cpan DOT org<gt>

From libmsoffice-word-surgeon-perl 2.10-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.