Paragraph alignment changed after deleting text of a subsequent bookmark

Hello,

with Aspose.Words 23.01 (and 22.12) the paragraph alignment (center) changes (center -> left) when deleting the content of a subsequent bookmark.

Document doc = new Document("c:\\tmp\\open_document.docx");
Bookmark currentBookmark = doc.Range.Bookmarks[bookmarkName: "PACK_RETURN_P"];
currentBookmark.Text = string.Empty;
doc.Save("c:\\tmp\\saved_document.docx");

Can you please have a look: Aspose.Words.23.01-DeleteBookmarkText-AlignmentCenterToLeft.zip (78.2 KB)

Thanks and best regards,
Marco

@MarcoFrank1 The behavior is expected. If you take a look at the document structure:

You will notice that the bookmark end is after the second paragraph end. When you remove content of the bookmark whole two paragraphs are removed. The remaining content of the first paragraph is prepended to the next available paragraph and the bookmark is move to the inline level:

Hello,

the problem did not occur with older Aspose.Words versions (e.g. 20.12). The behavior in Micrsoft-Word is the same as in older Aspose.Words versions.

BookmarkTextDeletion.png (2.9 KB)
RunStillWithinParagraph.PNG (40.9 KB)
RunWithinParagraphAndBeforeBookmark.PNG (6.4 KB)

Putting the existing “run” under a different “paragraph” is a mistake in my opinion

Can you please look at this again.

Thanks & regards,
Marco

@MarcoFrank1 The behavior has been changed in 21.10 version of Aspose.Words according to WORDSNET-19767.
Here is the analysis of MS Word and Aspose.Words behaviour:

MS Word behavior is cumbersome and depends as on a feature (e.g. simple typing or Find/Replace) as on MS Word version. Aspose.Words has behavior different than in MS Word:

# Bookmark New text Word 2019 behavior when using Delete/typing Word 2019 behavior with Find/Replace Aspose.Words (old) behavior
1 The customer’s bookmark None The paragraph 1 is deleted. The paragraph 2 preserves its properties. Same as using Delete/typing The text of the paragraph 2 is moved into the paragraph 1. The paragraph 2 is deleted.
2 The customer’s bookmark Non-empty Text of the paragraph 1 is replaced with the new text. The paragraph 1 preserves its properties including paragraph break char. The paragraph 2 preserves its properties. The paragraph 1 is deleted. The new text is inserted into the paragraph 2 and has run properties of the paragraph 1. The paragraph 2 preserves its properties. The paragraphs are joined. The result paragraph has properties of the paragraph 1. The new text has run properties of the paragraph 1.
3 Bookmark covers part of the paragraph 1 and part of the paragraph 2 None The bookmarked text is removed. The paragraphs are not joined and keep their properties. The paragraph break char of the paragraph 1 has run properties of the paragraph 2. The paragraphs are joined. The result paragraph has properties of the paragraph 2. The result paragraph has properties of the paragraph 1.
4 Bookmark covers part of the paragraph 1 and part of the paragraph 2 Non-empty The paragraphs are joined. The result paragraph has properties of the paragraph 1 (paragraph 2 in MS Word 2003), but paragraph break char has properties of the paragraph 2. The new text has run properties of the paragraph 1. The paragraphs are joined. The result paragraph has properties of the paragraph 2. The new text has run properties of the paragraph 1. The paragraphs are joined. The result paragraph has properties of the paragraph 1, including paragraph break char properties. The new text has run properties of the paragraph 1.
5 Bookmark includes the entire paragraph 1 and part of the paragraph 2 None The paragraph 1 is removed. The paragraph 2 keeps its properties. Same as using Delete/typing The result paragraph has properties of the paragraph 1.
6 Bookmark includes the entire paragraph 1 and part of the paragraph 2 Non-empty The paragraph 1 is removed. The paragraph 2 keeps its properties. The new text has run properties of the paragraph 1. Same as using Delete/typing The paragraphs are joined. The result paragraph has properties of the paragraph 1. The new text has run properties of the paragraph 1.

After discussion, it was decided to use “Word 2019 behavior with Find/Replace” since this behavior is closer to MS Word.