com.aspose.words
Class FindReplaceDirection

java.lang.Object
    extended by com.aspose.words.FindReplaceDirection

public class FindReplaceDirection 
extends java.lang.Object

Utility class containing constants. Specifies direction for replace operations.

Example:

Shows how to insert content of one document into another during a customized find and replace operation.
public void insertDocumentAtReplace() throws Exception {
    Document mainDoc = new Document(getMyDir() + "InsertDocument1.doc");

    FindReplaceOptions options = new FindReplaceOptions();
    options.setDirection(FindReplaceDirection.BACKWARD);
    options.setReplacingCallback(new InsertDocumentAtReplaceHandler());

    mainDoc.getRange().replace(Pattern.compile("\\[MY_DOCUMENT\\]"), "", options);
    mainDoc.save(getArtifactsDir() + "InsertDocumentAtReplace.doc");
}

private class InsertDocumentAtReplaceHandler implements IReplacingCallback {
    public int replacing(final ReplacingArgs args) throws Exception {
        Document subDoc = new Document(getMyDir() + "InsertDocument2.doc");

        // Insert a document after the paragraph, containing the match text.
        Paragraph para = (Paragraph) args.getMatchNode().getParentNode();
        insertDocument(para, subDoc);

        // Remove the paragraph with the match text.
        para.remove();

        return ReplaceAction.SKIP;
    }
}

Field Summary
static final intFORWARD = 0
           Matched items are replaced from first to last.
static final intBACKWARD = 1
           Matched items are replaced from last back to first.
 

Field Detail

FORWARD = 0

public static final int FORWARD
Matched items are replaced from first to last.

BACKWARD = 1

public static final int BACKWARD
Matched items are replaced from last back to first.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.