// Skip insignificant content at the start of the Paragraph.
if (!((i == 0) && !text.hasSignificantContent())) {
text.write(out);
}
} else if (obj instanceof Function) {
Function function = (Function) obj;
if (function instanceof EmbeddedImage) {
EmbeddedImage image = (EmbeddedImage) function;
if (textRecord.document.getLinkableRecord(image.getURI()) == null) {
// If the image is not found in the Document then we try to write the alt text instead.
if ((image.getAlt() != null) && (image.getAlt().getSize() > 0) &&
textRecord.document.isIncludeImageAltText()) {
out.writeString("[");
image.getAlt().write(out);
out.writeString("]");
}
continue;
}
}
if (function instanceof LinkFunction) {
LinkFunction linkFunction = (LinkFunction) function;
linkFunction.setURIResolver(textRecord.document);
}
if (function instanceof LinkEnd && !linkStarted) {
continue;
}
if (function instanceof LinkStart) {
LinkFunction linkFunction = (LinkFunction) function;
boolean brokenLink = !textRecord.document.contains(URIUtil.removeAnchor(linkFunction.getURI()));
if (brokenLink && textRecord.document.isRemoveUnresolvedLinks()) {
linkStarted = false;
continue;
} else {
linkStarted = true;
}
if (textRecord.document.isUseLinkColoring()) {
Color brokenLinkColor = textRecord.document.getUnresolvedLinkColor();
if (brokenLink && (brokenLinkColor != null)) {
// Add a text color function to color the link
TextColor textColor = new TextColor(brokenLinkColor);
// Preceding NUL
out.writeByte(0);
textColor.write(out);
linkColored = true;
} else if (linkColor != null) {
// Add a text color function to color the link
TextColor textColor = new TextColor(linkColor);
// Preceding NUL
out.writeByte(0);
textColor.write(out);
linkColored = true;
}
}
}
if (function instanceof TextColor) {
if (textRecord.document.isUseTextColors()) {
textRecord.currentTextColor = ((TextColor) function).getColor();
} else {
continue;
}
}
out.writeByte(0); // Preceding NUL
function.write(out);
if (function instanceof LinkEnd && linkColored) {
// Preceding NUL
out.writeByte(0);
if (textRecord.currentTextColor != null) {
new TextColor(textRecord.currentTextColor).write(out);