diff --git a/src/main/java/org/jabref/gui/ClipBoardManager.java b/src/main/java/org/jabref/gui/ClipBoardManager.java index 4adaca84236..197f6f85d4a 100644 --- a/src/main/java/org/jabref/gui/ClipBoardManager.java +++ b/src/main/java/org/jabref/gui/ClipBoardManager.java @@ -171,11 +171,7 @@ public void setContent(List entries, BibEntryTypesManager entryTypesMa final ClipboardContent content = new ClipboardContent(); BibEntryWriter writer = new BibEntryWriter(new FieldWriter(preferencesService.getFieldPreferences()), entryTypesManager); StringBuilder builder = new StringBuilder(); - for (BibtexString strConst : stringConstants) { - if (strConst.getParsedSerialization() != null) { - builder.append(strConst.getParsedSerialization()); - } - } + stringConstants.forEach(strConst -> builder.append(strConst.getParsedSerialization() == null ? "" : strConst.getParsedSerialization())); String serializedEntries = writer.serializeAll(entries, BibDatabaseMode.BIBTEX); builder.append(serializedEntries); // BibEntry is not Java serializable. Thus, we need to do the serialization manually diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index acfa2100c9e..230ad5c23e7 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -258,8 +258,7 @@ public void copy() { List selectedEntries = getSelectedEntries(); if (!selectedEntries.isEmpty()) { - List stringConstants = getStringValues(); - + List stringConstants = getUsedStringValues(selectedEntries); try { if (!stringConstants.isEmpty()) { clipBoardManager.setContent(selectedEntries, entryTypesManager, stringConstants); @@ -497,10 +496,7 @@ private Optional findEntry(BibEntry entry) { .findFirst(); } - private List getStringValues() { - return database.getDatabase() - .getStringValues() - .stream() - .toList(); + private List getUsedStringValues(List entries) { + return database.getDatabase().getUsedStrings(entries).stream().toList(); } } diff --git a/src/main/java/org/jabref/model/entry/BibtexString.java b/src/main/java/org/jabref/model/entry/BibtexString.java index d8e83fb6477..3515e0584e9 100644 --- a/src/main/java/org/jabref/model/entry/BibtexString.java +++ b/src/main/java/org/jabref/model/entry/BibtexString.java @@ -158,6 +158,9 @@ public String getUserComments() { public Object clone() { BibtexString clone = new BibtexString(name, content); clone.setId(id); + if (parsedSerialization != null) { + clone.setParsedSerialization(parsedSerialization); + } return clone; }