Skip to content

Commit

Permalink
Added method NotesItem.copyToNote() with parameter to rename the item
Browse files Browse the repository at this point in the history
  • Loading branch information
klehmann committed Feb 5, 2019
1 parent a9317a7 commit 95c99af
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
34 changes: 34 additions & 0 deletions domino-jna/src/main/java/com/mindoo/domino/jna/NotesItem.java
Expand Up @@ -676,6 +676,40 @@ public void copyToNote(NotesNote targetNote, boolean overwrite) {
}
}

/**
* Copies this item to another note and renames it.
*
* @param targetNote target note
* @param newItemName name of the item copy
* @param overwrite true to overwrite an existing item in the target note; otherwise, the target note may contain multiple items with the same name
*/
public void copyToNote(NotesNote targetNote, String newItemName, boolean overwrite) {
m_parentNote.checkHandle();
targetNote.checkHandle();

if (overwrite) {
if (targetNote.hasItem(newItemName)) {
targetNote.removeItem(newItemName);
}
}
Memory newItemNameMem = NotesStringUtils.toLMBCS(newItemName, true);

NotesBlockIdStruct.ByValue itemBlockIdByVal = NotesBlockIdStruct.ByValue.newInstance();
itemBlockIdByVal.pool = m_itemBlockId.pool;
itemBlockIdByVal.block = m_itemBlockId.block;

if (PlatformUtils.is64Bit()) {
short result = NotesNativeAPI64.get().NSFItemCopyAndRename(targetNote.getHandle64(),
itemBlockIdByVal, newItemNameMem);
NotesErrorUtils.checkResult(result);
}
else {
short result = NotesNativeAPI32.get().NSFItemCopyAndRename(targetNote.getHandle32(),
itemBlockIdByVal, newItemNameMem);
NotesErrorUtils.checkResult(result);
}
}

/**
* Removes the item from the parent note
*/
Expand Down
Expand Up @@ -404,7 +404,9 @@ public short NSFNoteOpenWithLock(
IntByReference rethNote);

public short NSFItemCopy(int note_handle, NotesBlockIdStruct.ByValue item_blockid);

@UndocumentedAPI
public short NSFItemCopyAndRename (int hNote, NotesBlockIdStruct.ByValue bhItem, Memory pszNewItemName);

public short IDCreateTable (int alignment, IntByReference rethTable);
public short IDDestroyTable(int hTable);
public short IDInsert (int hTable, int id, IntByReference retfInserted);
Expand Down
Expand Up @@ -404,6 +404,9 @@ public short NSFNoteOpenWithLock(
LongByReference rethNote);

public short NSFItemCopy(long note_handle, NotesBlockIdStruct.ByValue item_blockid);
@UndocumentedAPI
public short NSFItemCopyAndRename (long hNote, NotesBlockIdStruct.ByValue bhItem, Memory pszNewItemName);

public short IDCreateTable (int alignment, LongByReference rethTable);
public short IDDestroyTable(long hTable);
public short IDInsert (long hTable, int id, IntByReference retfInserted);
Expand Down
Expand Up @@ -393,6 +393,7 @@ public native short NSFNoteOpenWithLock(int hDB, int NoteID, int LockFlags, int
IntByReference rethLockers, IntByReference retLength, IntByReference rethNote);

public native short NSFItemCopy(int note_handle, NotesBlockIdStruct.ByValue item_blockid);
public native short NSFItemCopyAndRename(int hNote, ByValue bhItem, Memory pszNewItemName);

public native short IDCreateTable (int alignment, IntByReference rethTable);
public native short IDDestroyTable(int hTable);
Expand Down
Expand Up @@ -392,6 +392,8 @@ public native short NSFNoteOpenWithLock(long hDB, int NoteID, int LockFlags, int
LongByReference rethLockers, IntByReference retLength, LongByReference rethNote);

public native short NSFItemCopy(long note_handle, NotesBlockIdStruct.ByValue item_blockid);
public native short NSFItemCopyAndRename(long hNote, ByValue bhItem, Memory pszNewItemName);

public native short IDCreateTable (int alignment, LongByReference rethTable);
public native short IDDestroyTable(long hTable);
public native short IDInsert (long hTable, int id, IntByReference retfInserted);
Expand Down

0 comments on commit 95c99af

Please sign in to comment.