Fields, Links, And Review Notes¶
Field, hyperlink, note, comment, and revision APIs are available on
featherdoc::Document. Field and hyperlink operations that can be scoped to a
body, header, footer, or section part are also available on
featherdoc::TemplatePart.
Typed Signature Guide¶
Field, hyperlink, note, comment, and revision indexes are zero-based and come
from the corresponding list_* method. Append methods returning
std::size_t return a created count. Methods returning bool report
whether a specific indexed item was changed.
Signature |
Parameters |
Return semantics |
|---|---|---|
|
None. |
Field summaries in the selected document part. |
|
|
|
|
|
|
|
|
Created hyperlink count; |
|
|
Created comment count; |
|
|
|
|
|
|
|
None. |
Number of tracked revisions accepted. |
Summary Types¶
Type |
Key fields |
Purpose |
|---|---|---|
|
|
Describes a simple or complex Word field. |
|
|
Describes an internal or external hyperlink. |
|
|
Describes footnotes, endnotes, comments, and comment replies. |
|
|
Describes tracked insertions, deletions, and related revision records. |
Fields¶
Method |
Returns |
Purpose |
|---|---|---|
|
|
Enumerate fields in the selected document part. |
|
|
Append a simple field instruction and optional display result. |
|
|
Append a complex Word field. |
|
|
Append a PAGE field. |
|
|
Append a NUMPAGES field. |
|
|
Append a TOC field. |
|
|
Append a REF field that points at a bookmark. |
|
|
Replace a field instruction and result by index. |
Hyperlinks¶
Method |
Returns |
Purpose |
|---|---|---|
|
|
Enumerate hyperlinks. |
|
|
Append a hyperlink and return the created hyperlink count; |
|
|
Replace hyperlink text and target. |
|
|
Remove one hyperlink. |
Notes, Comments, And Revisions¶
Review-note and tracked-change identifiers use the non-negative signed 64-bit
range. Allocators scan every relevant document story, including the body,
headers, footers, footnotes, endnotes, and comments as applicable. Operations
that need more than one identifier reserve the complete set before changing
XML; exhaustion returns document_errc::identifier_space_exhausted.
Edits to an existing footnote, endnote, or comment validate the optional part,
target index, required paragraph metadata, and identifier capacity before
creating relationships, Content Types entries, or review parts. Every affected
XML document, relationship, Content Types entry, review sidecar, and dirty flag
is prepared before one publication step. Missing or out-of-range targets,
identifier exhaustion, pugixml allocation failure, and std::bad_alloc
therefore leave the DOM, package metadata, and existing handles unchanged.
Allocation failure is reported through last_error() as
std::errc::not_enough_memory.
Method |
Returns |
Purpose |
|---|---|---|
|
|
Enumerate footnotes or endnotes. |
|
|
Append a footnote. |
|
|
Append an endnote. |
|
|
Replace one footnote. |
|
|
Remove one endnote. |
|
|
Enumerate comments. |
|
|
Append a comment anchored to selected text. |
|
|
Comment a text range. |
|
|
Mark a comment resolved or unresolved. |
|
|
Enumerate tracked revisions. |
|
|
Resolve one revision. |
|
|
Resolve all tracked revisions. |
Example¶
featherdoc::Document doc{"review.docx"};
doc.open();
auto body = doc.body_template();
body.append_page_number_field();
body.append_hyperlink("FeatherDoc", "https://github.com/wuxianggujun/FeatherDoc");
for (const auto &comment : doc.list_comments()) {
if (!comment.resolved) {
doc.set_comment_resolved(comment.index, true);
}
}