public abstract class InlineStory extends CompositeNode
To learn more, visit the Logical Levels of Nodes in a Document documentation article.
Remarks:
InlineStory is a container for block-level nodes Paragraph and Table.
The classes that derive from InlineStory are inline-level nodes that can contain their own text (paragraphs and tables). For example, a Comment node contains text of a comment and a Footnote contains text of a footnote.
Examples:
Shows how to add a comment to a paragraph.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("Hello world!");
Comment comment = new Comment(doc, "John Doe", "JD", new Date());
builder.getCurrentParagraph().appendChild(comment);
builder.moveTo(comment.appendChild(new Paragraph(doc)));
builder.write("Comment text.");
Assert.assertEquals(new Date(), comment.getDateTime());
// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc.save(getArtifactsDir() + "InlineStory.AddComment.docx");
Shows how to insert and customize footnotes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add text, and reference it with a footnote. This footnote will place a small superscript reference
// mark after the text that it references and create an entry below the main body text at the bottom of the page.
// This entry will contain the footnote's reference mark and the reference text,
// which we will pass to the document builder's "InsertFootnote" method.
builder.write("Main body text.");
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
// If this property is set to "true", then our footnote's reference mark
// will be its index among all the section's footnotes.
// This is the first footnote, so the reference mark will be "1".
Assert.assertTrue(footnote.isAuto());
// We can move the document builder inside the footnote to edit its reference text.
builder.moveTo(footnote.getFirstParagraph());
builder.write(" More text added by a DocumentBuilder.");
builder.moveToDocumentEnd();
Assert.assertEquals(footnote.getParagraphs().get(0).toString(SaveFormat.TEXT).trim(), "Footnote text. More text added by a DocumentBuilder.");
builder.write(" More main body text.");
footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
// We can set a custom reference mark which the footnote will use instead of its index number.
footnote.setReferenceMark("RefMark");
Assert.assertFalse(footnote.isAuto());
// A bookmark with the "IsAuto" flag set to true will still show its real index
// even if previous bookmarks display custom reference marks, so this bookmark's reference mark will be a "3".
builder.write(" More main body text.");
footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
Assert.assertTrue(footnote.isAuto());
doc.save(getArtifactsDir() + "InlineStory.AddFootnote.docx");
| Constructor and Description |
|---|
InlineStory() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearRunAttrs() |
void |
ensureMinimum()
If the last child is not a paragraph, creates and appends one empty paragraph.
|
java.lang.Object |
fetchInheritedRunAttr(int fontAttr) |
java.lang.Object |
getDirectRunAttr(int key) |
java.lang.Object |
getDirectRunAttr(int key,
int revisionsView) |
DocumentBase |
getDocument_IInline() |
Paragraph |
getFirstParagraph()
Gets the first paragraph in the story.
|
Font |
getFont()
Provides access to the font formatting of the anchor character of this object.
|
Paragraph |
getLastParagraph()
Gets the last paragraph in the story.
|
ParagraphCollection |
getParagraphs()
Gets a collection of paragraphs that are immediate children of the story.
|
Paragraph |
getParentParagraph_IInline() |
Paragraph |
getParentParagraph()
Retrieves the parent
Paragraph of this node. |
abstract int |
getStoryType()
Returns the type of the story.
|
TableCollection |
getTables()
Gets a collection of tables that are immediate children of the story.
|
boolean |
isDeleteRevision()
Returns true if this object was deleted in Microsoft Word while change tracking was enabled.
|
boolean |
isInsertRevision()
Returns true if this object was inserted in Microsoft Word while change tracking was enabled.
|
boolean |
isMoveFromRevision()
Returns
true if this object was moved (deleted) in Microsoft Word while change tracking was enabled. |
boolean |
isMoveToRevision()
Returns
true if this object was moved (inserted) in Microsoft Word while change tracking was enabled. |
void |
removeRunAttr(int key) |
void |
setRunAttr(int fontAttr,
java.lang.Object value) |
acceptChildren, acceptCore, acceptEnd, acceptStart, appendChild, coreRemoveSelfOnly, getChild, getChildNodes, getContainer, getCount, getCurrentNode, getFirstChild, getLastChild, getNextMatchingNode, getText, hasChildNodes, indexOf, insertAfter, insertBefore, isComposite, iterator, prependChild, removeAllChildren, removeChild, removeSmartTags, selectNodes, selectSingleNodeaccept, deepClone, getAncestor, getAncestor, getCustomNodeId, getDocument, getNextSibling, getNodeType, getParentNode, getPreviousSibling, getRange, memberwiseClone, nextPreOrder, nodeTypeToString, previousPreOrder, remove, setCustomNodeId, toString, toString, toString, visitorActionToBoolpublic abstract int getStoryType()
Examples:
Shows how to insert InlineStory nodes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, null);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
Table table = new Table(doc);
table.ensureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
Assert.assertEquals(footnote.getTables().getCount(), 0);
footnote.appendChild(table);
Assert.assertEquals(footnote.getTables().getCount(), 1);
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.TABLE);
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote.ensureMinimum();
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote.getFont().setName("Arial");
footnote.getFont().setColor(Color.GREEN);
// All inline story nodes have their respective story types.
Assert.assertEquals(footnote.getStoryType(), StoryType.FOOTNOTES);
// A comment is another type of inline story.
Comment comment = (Comment) builder.getCurrentParagraph().appendChild(new Comment(doc, "John Doe", "J. D.", new Date()));
// The parent paragraph of an inline story node will be the one from the main document body.
Assert.assertEquals(doc.getFirstSection().getBody().getFirstParagraph(), comment.getParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
Assert.assertNull(comment.getLastParagraph());
comment.ensureMinimum();
Assert.assertEquals(comment.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder.moveTo(comment.getLastParagraph());
builder.write("My comment.");
Assert.assertEquals(comment.getStoryType(), StoryType.COMMENTS);
doc.save(getArtifactsDir() + "InlineStory.InsertInlineStoryNodes.docx");
StoryType constants.public Paragraph getParentParagraph()
Paragraph of this node.
Examples:
Shows how to insert InlineStory nodes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, null);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
Table table = new Table(doc);
table.ensureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
Assert.assertEquals(footnote.getTables().getCount(), 0);
footnote.appendChild(table);
Assert.assertEquals(footnote.getTables().getCount(), 1);
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.TABLE);
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote.ensureMinimum();
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote.getFont().setName("Arial");
footnote.getFont().setColor(Color.GREEN);
// All inline story nodes have their respective story types.
Assert.assertEquals(footnote.getStoryType(), StoryType.FOOTNOTES);
// A comment is another type of inline story.
Comment comment = (Comment) builder.getCurrentParagraph().appendChild(new Comment(doc, "John Doe", "J. D.", new Date()));
// The parent paragraph of an inline story node will be the one from the main document body.
Assert.assertEquals(doc.getFirstSection().getBody().getFirstParagraph(), comment.getParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
Assert.assertNull(comment.getLastParagraph());
comment.ensureMinimum();
Assert.assertEquals(comment.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder.moveTo(comment.getLastParagraph());
builder.write("My comment.");
Assert.assertEquals(comment.getStoryType(), StoryType.COMMENTS);
doc.save(getArtifactsDir() + "InlineStory.InsertInlineStoryNodes.docx");
Paragraph value.public Paragraph getFirstParagraph()
Examples:
Shows how to add a comment to a paragraph.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("Hello world!");
Comment comment = new Comment(doc, "John Doe", "JD", new Date());
builder.getCurrentParagraph().appendChild(comment);
builder.moveTo(comment.appendChild(new Paragraph(doc)));
builder.write("Comment text.");
Assert.assertEquals(new Date(), comment.getDateTime());
// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc.save(getArtifactsDir() + "InlineStory.AddComment.docx");
Shows how to insert and customize footnotes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add text, and reference it with a footnote. This footnote will place a small superscript reference
// mark after the text that it references and create an entry below the main body text at the bottom of the page.
// This entry will contain the footnote's reference mark and the reference text,
// which we will pass to the document builder's "InsertFootnote" method.
builder.write("Main body text.");
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
// If this property is set to "true", then our footnote's reference mark
// will be its index among all the section's footnotes.
// This is the first footnote, so the reference mark will be "1".
Assert.assertTrue(footnote.isAuto());
// We can move the document builder inside the footnote to edit its reference text.
builder.moveTo(footnote.getFirstParagraph());
builder.write(" More text added by a DocumentBuilder.");
builder.moveToDocumentEnd();
Assert.assertEquals(footnote.getParagraphs().get(0).toString(SaveFormat.TEXT).trim(), "Footnote text. More text added by a DocumentBuilder.");
builder.write(" More main body text.");
footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
// We can set a custom reference mark which the footnote will use instead of its index number.
footnote.setReferenceMark("RefMark");
Assert.assertFalse(footnote.isAuto());
// A bookmark with the "IsAuto" flag set to true will still show its real index
// even if previous bookmarks display custom reference marks, so this bookmark's reference mark will be a "3".
builder.write(" More main body text.");
footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
Assert.assertTrue(footnote.isAuto());
doc.save(getArtifactsDir() + "InlineStory.AddFootnote.docx");
public Paragraph getLastParagraph()
Examples:
Shows how to insert InlineStory nodes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, null);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
Table table = new Table(doc);
table.ensureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
Assert.assertEquals(footnote.getTables().getCount(), 0);
footnote.appendChild(table);
Assert.assertEquals(footnote.getTables().getCount(), 1);
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.TABLE);
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote.ensureMinimum();
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote.getFont().setName("Arial");
footnote.getFont().setColor(Color.GREEN);
// All inline story nodes have their respective story types.
Assert.assertEquals(footnote.getStoryType(), StoryType.FOOTNOTES);
// A comment is another type of inline story.
Comment comment = (Comment) builder.getCurrentParagraph().appendChild(new Comment(doc, "John Doe", "J. D.", new Date()));
// The parent paragraph of an inline story node will be the one from the main document body.
Assert.assertEquals(doc.getFirstSection().getBody().getFirstParagraph(), comment.getParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
Assert.assertNull(comment.getLastParagraph());
comment.ensureMinimum();
Assert.assertEquals(comment.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder.moveTo(comment.getLastParagraph());
builder.write("My comment.");
Assert.assertEquals(comment.getStoryType(), StoryType.COMMENTS);
doc.save(getArtifactsDir() + "InlineStory.InsertInlineStoryNodes.docx");
public ParagraphCollection getParagraphs()
Examples:
Shows how to add a comment to a paragraph.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("Hello world!");
Comment comment = new Comment(doc, "John Doe", "JD", new Date());
builder.getCurrentParagraph().appendChild(comment);
builder.moveTo(comment.appendChild(new Paragraph(doc)));
builder.write("Comment text.");
Assert.assertEquals(new Date(), comment.getDateTime());
// In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc.save(getArtifactsDir() + "InlineStory.AddComment.docx");
Shows how to insert and customize footnotes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add text, and reference it with a footnote. This footnote will place a small superscript reference
// mark after the text that it references and create an entry below the main body text at the bottom of the page.
// This entry will contain the footnote's reference mark and the reference text,
// which we will pass to the document builder's "InsertFootnote" method.
builder.write("Main body text.");
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
// If this property is set to "true", then our footnote's reference mark
// will be its index among all the section's footnotes.
// This is the first footnote, so the reference mark will be "1".
Assert.assertTrue(footnote.isAuto());
// We can move the document builder inside the footnote to edit its reference text.
builder.moveTo(footnote.getFirstParagraph());
builder.write(" More text added by a DocumentBuilder.");
builder.moveToDocumentEnd();
Assert.assertEquals(footnote.getParagraphs().get(0).toString(SaveFormat.TEXT).trim(), "Footnote text. More text added by a DocumentBuilder.");
builder.write(" More main body text.");
footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
// We can set a custom reference mark which the footnote will use instead of its index number.
footnote.setReferenceMark("RefMark");
Assert.assertFalse(footnote.isAuto());
// A bookmark with the "IsAuto" flag set to true will still show its real index
// even if previous bookmarks display custom reference marks, so this bookmark's reference mark will be a "3".
builder.write(" More main body text.");
footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, "Footnote text.");
Assert.assertTrue(footnote.isAuto());
doc.save(getArtifactsDir() + "InlineStory.AddFootnote.docx");
public TableCollection getTables()
Examples:
Shows how to insert InlineStory nodes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, null);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
Table table = new Table(doc);
table.ensureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
Assert.assertEquals(footnote.getTables().getCount(), 0);
footnote.appendChild(table);
Assert.assertEquals(footnote.getTables().getCount(), 1);
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.TABLE);
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote.ensureMinimum();
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote.getFont().setName("Arial");
footnote.getFont().setColor(Color.GREEN);
// All inline story nodes have their respective story types.
Assert.assertEquals(footnote.getStoryType(), StoryType.FOOTNOTES);
// A comment is another type of inline story.
Comment comment = (Comment) builder.getCurrentParagraph().appendChild(new Comment(doc, "John Doe", "J. D.", new Date()));
// The parent paragraph of an inline story node will be the one from the main document body.
Assert.assertEquals(doc.getFirstSection().getBody().getFirstParagraph(), comment.getParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
Assert.assertNull(comment.getLastParagraph());
comment.ensureMinimum();
Assert.assertEquals(comment.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder.moveTo(comment.getLastParagraph());
builder.write("My comment.");
Assert.assertEquals(comment.getStoryType(), StoryType.COMMENTS);
doc.save(getArtifactsDir() + "InlineStory.InsertInlineStoryNodes.docx");
public boolean isInsertRevision()
Examples:
Shows how to view revision-related properties of InlineStory nodes.
Document doc = new Document(getMyDir() + "Revision footnotes.docx");
// When we edit the document while the "Track Changes" option, found in via Review -> Tracking,
// is turned on in Microsoft Word, the changes we apply count as revisions.
// When editing a document using Aspose.Words, we can begin tracking revisions by
// invoking the document's "StartTrackRevisions" method and stop tracking by using the "StopTrackRevisions" method.
// We can either accept revisions to assimilate them into the document
// or reject them to undo and discard the proposed change.
Assert.assertTrue(doc.hasRevisions());
NodeCollection footnotes = doc.getChildNodes(NodeType.FOOTNOTE, true);
Assert.assertEquals(5, footnotes.getCount());
// Below are five types of revisions that can flag an InlineStory node.
// 1 - An "insert" revision:
// This revision occurs when we insert text while tracking changes.
Footnote footnote = (Footnote) footnotes.get(2);
Assert.assertTrue(footnote.isInsertRevision());
// 2 - A "move from" revision:
// When we highlight text in Microsoft Word, and then drag it to a different place in the document
// while tracking changes, two revisions appear.
// The "move from" revision is a copy of the text originally before we moved it.
footnote = (Footnote) footnotes.get(4);
Assert.assertTrue(footnote.isMoveFromRevision());
// 3 - A "move to" revision:
// The "move to" revision is the text that we moved in its new position in the document.
// "Move from" and "move to" revisions appear in pairs for every move revision we carry out.
// Accepting a move revision deletes the "move from" revision and its text,
// and keeps the text from the "move to" revision.
// Rejecting a move revision conversely keeps the "move from" revision and deletes the "move to" revision.
footnote = (Footnote) footnotes.get(1);
Assert.assertTrue(footnote.isMoveToRevision());
// 4 - A "delete" revision:
// This revision occurs when we delete text while tracking changes. When we delete text like this,
// it will stay in the document as a revision until we either accept the revision,
// which will delete the text for good, or reject the revision, which will keep the text we deleted where it was.
footnote = (Footnote) footnotes.get(3);
Assert.assertTrue(footnote.isDeleteRevision());
public boolean isDeleteRevision()
Examples:
Shows how to view revision-related properties of InlineStory nodes.
Document doc = new Document(getMyDir() + "Revision footnotes.docx");
// When we edit the document while the "Track Changes" option, found in via Review -> Tracking,
// is turned on in Microsoft Word, the changes we apply count as revisions.
// When editing a document using Aspose.Words, we can begin tracking revisions by
// invoking the document's "StartTrackRevisions" method and stop tracking by using the "StopTrackRevisions" method.
// We can either accept revisions to assimilate them into the document
// or reject them to undo and discard the proposed change.
Assert.assertTrue(doc.hasRevisions());
NodeCollection footnotes = doc.getChildNodes(NodeType.FOOTNOTE, true);
Assert.assertEquals(5, footnotes.getCount());
// Below are five types of revisions that can flag an InlineStory node.
// 1 - An "insert" revision:
// This revision occurs when we insert text while tracking changes.
Footnote footnote = (Footnote) footnotes.get(2);
Assert.assertTrue(footnote.isInsertRevision());
// 2 - A "move from" revision:
// When we highlight text in Microsoft Word, and then drag it to a different place in the document
// while tracking changes, two revisions appear.
// The "move from" revision is a copy of the text originally before we moved it.
footnote = (Footnote) footnotes.get(4);
Assert.assertTrue(footnote.isMoveFromRevision());
// 3 - A "move to" revision:
// The "move to" revision is the text that we moved in its new position in the document.
// "Move from" and "move to" revisions appear in pairs for every move revision we carry out.
// Accepting a move revision deletes the "move from" revision and its text,
// and keeps the text from the "move to" revision.
// Rejecting a move revision conversely keeps the "move from" revision and deletes the "move to" revision.
footnote = (Footnote) footnotes.get(1);
Assert.assertTrue(footnote.isMoveToRevision());
// 4 - A "delete" revision:
// This revision occurs when we delete text while tracking changes. When we delete text like this,
// it will stay in the document as a revision until we either accept the revision,
// which will delete the text for good, or reject the revision, which will keep the text we deleted where it was.
footnote = (Footnote) footnotes.get(3);
Assert.assertTrue(footnote.isDeleteRevision());
public boolean isMoveFromRevision()
true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.
Examples:
Shows how to view revision-related properties of InlineStory nodes.
Document doc = new Document(getMyDir() + "Revision footnotes.docx");
// When we edit the document while the "Track Changes" option, found in via Review -> Tracking,
// is turned on in Microsoft Word, the changes we apply count as revisions.
// When editing a document using Aspose.Words, we can begin tracking revisions by
// invoking the document's "StartTrackRevisions" method and stop tracking by using the "StopTrackRevisions" method.
// We can either accept revisions to assimilate them into the document
// or reject them to undo and discard the proposed change.
Assert.assertTrue(doc.hasRevisions());
NodeCollection footnotes = doc.getChildNodes(NodeType.FOOTNOTE, true);
Assert.assertEquals(5, footnotes.getCount());
// Below are five types of revisions that can flag an InlineStory node.
// 1 - An "insert" revision:
// This revision occurs when we insert text while tracking changes.
Footnote footnote = (Footnote) footnotes.get(2);
Assert.assertTrue(footnote.isInsertRevision());
// 2 - A "move from" revision:
// When we highlight text in Microsoft Word, and then drag it to a different place in the document
// while tracking changes, two revisions appear.
// The "move from" revision is a copy of the text originally before we moved it.
footnote = (Footnote) footnotes.get(4);
Assert.assertTrue(footnote.isMoveFromRevision());
// 3 - A "move to" revision:
// The "move to" revision is the text that we moved in its new position in the document.
// "Move from" and "move to" revisions appear in pairs for every move revision we carry out.
// Accepting a move revision deletes the "move from" revision and its text,
// and keeps the text from the "move to" revision.
// Rejecting a move revision conversely keeps the "move from" revision and deletes the "move to" revision.
footnote = (Footnote) footnotes.get(1);
Assert.assertTrue(footnote.isMoveToRevision());
// 4 - A "delete" revision:
// This revision occurs when we delete text while tracking changes. When we delete text like this,
// it will stay in the document as a revision until we either accept the revision,
// which will delete the text for good, or reject the revision, which will keep the text we deleted where it was.
footnote = (Footnote) footnotes.get(3);
Assert.assertTrue(footnote.isDeleteRevision());
true if this object was moved (deleted) in Microsoft Word while change tracking was enabled.public boolean isMoveToRevision()
true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.
Examples:
Shows how to view revision-related properties of InlineStory nodes.
Document doc = new Document(getMyDir() + "Revision footnotes.docx");
// When we edit the document while the "Track Changes" option, found in via Review -> Tracking,
// is turned on in Microsoft Word, the changes we apply count as revisions.
// When editing a document using Aspose.Words, we can begin tracking revisions by
// invoking the document's "StartTrackRevisions" method and stop tracking by using the "StopTrackRevisions" method.
// We can either accept revisions to assimilate them into the document
// or reject them to undo and discard the proposed change.
Assert.assertTrue(doc.hasRevisions());
NodeCollection footnotes = doc.getChildNodes(NodeType.FOOTNOTE, true);
Assert.assertEquals(5, footnotes.getCount());
// Below are five types of revisions that can flag an InlineStory node.
// 1 - An "insert" revision:
// This revision occurs when we insert text while tracking changes.
Footnote footnote = (Footnote) footnotes.get(2);
Assert.assertTrue(footnote.isInsertRevision());
// 2 - A "move from" revision:
// When we highlight text in Microsoft Word, and then drag it to a different place in the document
// while tracking changes, two revisions appear.
// The "move from" revision is a copy of the text originally before we moved it.
footnote = (Footnote) footnotes.get(4);
Assert.assertTrue(footnote.isMoveFromRevision());
// 3 - A "move to" revision:
// The "move to" revision is the text that we moved in its new position in the document.
// "Move from" and "move to" revisions appear in pairs for every move revision we carry out.
// Accepting a move revision deletes the "move from" revision and its text,
// and keeps the text from the "move to" revision.
// Rejecting a move revision conversely keeps the "move from" revision and deletes the "move to" revision.
footnote = (Footnote) footnotes.get(1);
Assert.assertTrue(footnote.isMoveToRevision());
// 4 - A "delete" revision:
// This revision occurs when we delete text while tracking changes. When we delete text like this,
// it will stay in the document as a revision until we either accept the revision,
// which will delete the text for good, or reject the revision, which will keep the text we deleted where it was.
footnote = (Footnote) footnotes.get(3);
Assert.assertTrue(footnote.isDeleteRevision());
true if this object was moved (inserted) in Microsoft Word while change tracking was enabled.public Font getFont()
Examples:
Shows how to insert InlineStory nodes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, null);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
Table table = new Table(doc);
table.ensureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
Assert.assertEquals(footnote.getTables().getCount(), 0);
footnote.appendChild(table);
Assert.assertEquals(footnote.getTables().getCount(), 1);
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.TABLE);
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote.ensureMinimum();
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote.getFont().setName("Arial");
footnote.getFont().setColor(Color.GREEN);
// All inline story nodes have their respective story types.
Assert.assertEquals(footnote.getStoryType(), StoryType.FOOTNOTES);
// A comment is another type of inline story.
Comment comment = (Comment) builder.getCurrentParagraph().appendChild(new Comment(doc, "John Doe", "J. D.", new Date()));
// The parent paragraph of an inline story node will be the one from the main document body.
Assert.assertEquals(doc.getFirstSection().getBody().getFirstParagraph(), comment.getParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
Assert.assertNull(comment.getLastParagraph());
comment.ensureMinimum();
Assert.assertEquals(comment.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder.moveTo(comment.getLastParagraph());
builder.write("My comment.");
Assert.assertEquals(comment.getStoryType(), StoryType.COMMENTS);
doc.save(getArtifactsDir() + "InlineStory.InsertInlineStoryNodes.docx");
Font value.public void ensureMinimum()
Examples:
Shows how to insert InlineStory nodes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Footnote footnote = builder.insertFootnote(FootnoteType.FOOTNOTE, null);
// Table nodes have an "EnsureMinimum()" method that makes sure the table has at least one cell.
Table table = new Table(doc);
table.ensureMinimum();
// We can place a table inside a footnote, which will make it appear at the referencing page's footer.
Assert.assertEquals(footnote.getTables().getCount(), 0);
footnote.appendChild(table);
Assert.assertEquals(footnote.getTables().getCount(), 1);
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.TABLE);
// An InlineStory has an "EnsureMinimum()" method as well, but in this case,
// it makes sure the last child of the node is a paragraph,
// for us to be able to click and write text easily in Microsoft Word.
footnote.ensureMinimum();
Assert.assertEquals(footnote.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Edit the appearance of the anchor, which is the small superscript number
// in the main text that points to the footnote.
footnote.getFont().setName("Arial");
footnote.getFont().setColor(Color.GREEN);
// All inline story nodes have their respective story types.
Assert.assertEquals(footnote.getStoryType(), StoryType.FOOTNOTES);
// A comment is another type of inline story.
Comment comment = (Comment) builder.getCurrentParagraph().appendChild(new Comment(doc, "John Doe", "J. D.", new Date()));
// The parent paragraph of an inline story node will be the one from the main document body.
Assert.assertEquals(doc.getFirstSection().getBody().getFirstParagraph(), comment.getParentParagraph());
// However, the last paragraph is the one from the comment text contents,
// which will be outside the main document body in a speech bubble.
// A comment will not have any child nodes by default,
// so we can apply the EnsureMinimum() method to place a paragraph here as well.
Assert.assertNull(comment.getLastParagraph());
comment.ensureMinimum();
Assert.assertEquals(comment.getLastChild().getNodeType(), NodeType.PARAGRAPH);
// Once we have a paragraph, we can move the builder to do it and write our comment.
builder.moveTo(comment.getLastParagraph());
builder.write("My comment.");
Assert.assertEquals(comment.getStoryType(), StoryType.COMMENTS);
doc.save(getArtifactsDir() + "InlineStory.InsertInlineStoryNodes.docx");
public Paragraph getParentParagraph_IInline()
public DocumentBase getDocument_IInline()
public java.lang.Object getDirectRunAttr(int key)
public java.lang.Object getDirectRunAttr(int key,
int revisionsView)
public java.lang.Object fetchInheritedRunAttr(int fontAttr)
public void setRunAttr(int fontAttr,
java.lang.Object value)
public void removeRunAttr(int key)
public void clearRunAttrs()