/** * Unconditionally clone an InDesign Object. * * @param sourceObj * @return The clone of the object. * @throws Exception */ public InDesignComponent clone(InDesignObject sourceObj) throws Exception { logger.debug( "Cloning object " + sourceObj.getClass().getSimpleName() + " [" + sourceObj.getId() + "]..."); InDesignObject clone = sourceObj.getClass().newInstance(); assignIdAndRegister(clone); // Now remember that we've cloned this source object so we can not // clone it again if we don't want to: Map<String, InDesignObject> cloneMap = getCloneMapForDoc(sourceObj.getDocument()); cloneMap.put(sourceObj.getId(), clone); clone.loadObject(sourceObj, clone.getId()); return clone; }