The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Document::OOXML::Part::WordprocessingML - WordprocessingML document part handling

VERSION

version 0.172601

ATTRIBUTES

xml

XML::LibXML::Document containing the parsed XML of the WordprocessingML part.

xpc

XML::LibXML::XPathContext that will be used to find elements in the WordprocessingML.

has_merged_runs

Boolean value indicating whether the document has merged runs.

Used internally to prevent running the (expensive) "merge_runs" method twice in a row.

METHODS

new_from_xml($part_name, $xml, $strict)

Create a new instance based on XML data.

find_text_nodes($regex, $exclude_tables)

Returns a list of <w:t> elements (see XML::LibXML::Element) matching the regular expression.

First, all adjacent identical runs are merged (see "merge_runs"), then all text elements are matched against the regular expression. The runs with matching text are then split into "pre-match", "match" and "post-match" parts. The "match" parts are then returned.

This regular expression should not contain matching groups, as this will confuse the splitting code.

If $exclude_tables is true, the regular expression will not match text in tables. This option may change in the future.

remove_spellcheck_markers

Remove all <w:proofErr> elements from the document. This removes the red "squigglies" until another spelling/grammar check is done.

merge_runs

Walks over all runs (<w:r>) in the document. If two adjacent runs in the same paragraph have identical properties, the contents of the second run are merged into the first run.

This makes it easier to find stretches of text for search/replace.

replace_text($search, $replace)

Replace all occurrences of $search with $replace in every text (<w:t>) element in the document.

Does not yet follow references, so text in headers, footers and other external parts of the document isn't changed.

SEE ALSO

AUTHOR

Martijn van de Streek <martijn@vandestreek.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Martijn van de Streek.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.