use of org.freeplane.features.styles.StyleString in project freeplane by freeplane.
the class NodeTextBuilder method writeAttributes.
public void writeAttributes(final ITreeWriter writer, final Object userObject, final String tag) {
if (!NodeWriter.shouldWriteSharedContent(writer))
return;
final NodeModel node = (NodeModel) userObject;
final Object data = node.getUserObject();
if (data == null)
return;
final Class<? extends Object> dataClass = data.getClass();
if (dataClass.equals(StyleTranslatedObject.class)) {
writer.addAttribute(NodeTextBuilder.XML_NODE_LOCALIZED_TEXT, ((StyleTranslatedObject) data).getObject().toString());
return;
}
if (dataClass.equals(TranslatedObject.class)) {
writer.addAttribute(NodeTextBuilder.XML_NODE_LOCALIZED_TEXT, ((TranslatedObject) data).getObject().toString());
return;
}
final boolean forceFormatting = Boolean.TRUE.equals(writer.getHint(MapWriter.WriterHint.FORCE_FORMATTING));
if (forceFormatting) {
final String text = TextController.getController().getTransformedTextNoThrow(data, node, data);
if (!HtmlUtils.isHtmlNode(text)) {
writer.addAttribute(NodeTextBuilder.XML_NODE_TEXT, text.replace('\0', ' '));
} else {
node.addExtension(new TransformedXMLExtension(text));
}
} else {
final String text = data.toString();
if (node.getXmlText() == null) {
writer.addAttribute(NodeTextBuilder.XML_NODE_TEXT, text.replace('\0', ' '));
}
if (!(data instanceof String || data instanceof StyleString)) {
writer.addAttribute(XML_NODE_OBJECT, TypeReference.toSpec(data));
}
}
}
Aggregations