Search in sources :

Example 1 with RichTextNavigator

use of org.openntf.domino.RichTextNavigator in project org.openntf.domino by OpenNTF.

the class RichTextItem method replaceAttachment.

@Override
public EmbeddedObject replaceAttachment(final String filename, final String sourcePath) {
    // System.out.println("TEMP DEBUG replacing filename " + filename + " from source at " + sourcePath);
    EmbeddedObject result = null;
    RichTextNavigator navigator = this.createNavigator();
    EmbeddedObject eo = (EmbeddedObject) navigator.getFirstElement(RTELEM_TYPE_FILEATTACHMENT);
    boolean replaced = false;
    while (eo != null) {
        if (filename.equals(eo.getSource())) {
            // System.out.println("TEMP DEBUG Found matching embeddedobject for name " + filename);
            beginInsert(eo, true);
            // $NON-NLS-1$ //$NON-NLS-2$
            result = embedObject(org.openntf.domino.EmbeddedObject.Type.EMBED_ATTACHMENT.getValue(), "", sourcePath, "");
            endInsert();
            eo.remove();
            replaced = true;
            break;
        }
        eo = (EmbeddedObject) navigator.getNextElement(RTELEM_TYPE_FILEATTACHMENT);
    }
    if (!replaced) {
        // $NON-NLS-1$ //$NON-NLS-2$
        result = embedObject(org.openntf.domino.EmbeddedObject.Type.EMBED_ATTACHMENT.getValue(), "", sourcePath, "");
    }
    return result;
}
Also used : EmbeddedObject(org.openntf.domino.EmbeddedObject) RichTextNavigator(org.openntf.domino.RichTextNavigator)

Example 2 with RichTextNavigator

use of org.openntf.domino.RichTextNavigator in project org.openntf.domino by OpenNTF.

the class RichTextItem method removeAttachment.

@Override
public boolean removeAttachment(final String filename) {
    boolean result = false;
    RichTextNavigator navigator = this.createNavigator();
    EmbeddedObject eo = (EmbeddedObject) navigator.getFirstElement(RTELEM_TYPE_FILEATTACHMENT);
    while (eo != null) {
        if (filename.equals(eo.getSource())) {
            eo.remove();
            result = true;
            break;
        }
        eo = (EmbeddedObject) navigator.getNextElement(RTELEM_TYPE_FILEATTACHMENT);
    }
    return result;
}
Also used : EmbeddedObject(org.openntf.domino.EmbeddedObject) RichTextNavigator(org.openntf.domino.RichTextNavigator)

Aggregations

EmbeddedObject (org.openntf.domino.EmbeddedObject)2 RichTextNavigator (org.openntf.domino.RichTextNavigator)2