/** * Generate the footnote reference (link) that should be inserted at the location of the macro, and should point to * the actual footnote at the end of the document. * * @param counter the current footnote counter * @return the generated reference element, displayed as {@code (superscript(link(footnote index)))} */ private Block createFootnoteReferenceBlock(int counter) { Block result = new WordBlock(String.valueOf(counter)); DocumentResourceReference reference = new DocumentResourceReference(null); reference.setAnchor(FOOTNOTE_ID_PREFIX + counter); result = new LinkBlock(Collections.singletonList(result), reference, false); result = new FormatBlock(Collections.singletonList(result), Format.SUPERSCRIPT); result.setParameter(ID_ATTRIBUTE_NAME, FOOTNOTE_REFERENCE_ID_PREFIX + counter); result.setParameter(CLASS_ATTRIBUTE_NAME, "footnoteRef"); return result; }
/** * Create a new toc list item based on section title. * * @param headerBlock the {@link HeaderBlock}. * @return the new list item block. */ private ListItemBlock createTocEntry(HeaderBlock headerBlock, String documentReference) { // Create the link to target the header anchor DocumentResourceReference reference = new DocumentResourceReference(documentReference); reference.setAnchor(headerBlock.getId()); LinkBlock linkBlock = new LinkBlock(this.tocBlockFilter.generateLabel(headerBlock), reference, false); return new ListItemBlock(Collections.singletonList(linkBlock)); }
/** * Construct a Document Link reference out of the passed content. * * @param content the string containing the Document link reference * @return the parsed Link Object corresponding to the Document link reference */ private ResourceReference parseDocumentLink(StringBuffer content) { String queryString = null; String text = parseElementAfterString(content, SEPARATOR_QUERYSTRING); if (text != null) { queryString = removeEscapesFromExtraParts(text); } String anchor = null; text = parseElementAfterString(content, SEPARATOR_ANCHOR); if (text != null) { anchor = removeEscapesFromExtraParts(text); } DocumentResourceReference reference = new DocumentResourceReference(removeEscapesFromReferencePart(content.toString())); reference.setTyped(false); reference.setQueryString(queryString); reference.setAnchor(anchor); return reference; }
reference.setAnchor(FOOTNOTE_REFERENCE_ID_PREFIX + counter); result = new LinkBlock(Collections.singletonList(result), reference, false); result.setParameter(ID_ATTRIBUTE_NAME, FOOTNOTE_ID_PREFIX + counter);