update 20260308
This commit is contained in:
@@ -1718,6 +1718,11 @@ namespace DOCGEN.Klassen
|
||||
set_font_bold(ref document);
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
set_list(ref document);
|
||||
}
|
||||
catch { }
|
||||
//document.UpdateDocumentFields();
|
||||
//document.UpdateAlternateChunks();
|
||||
|
||||
@@ -1822,8 +1827,45 @@ namespace DOCGEN.Klassen
|
||||
}
|
||||
public static void set_list(ref WordDocument document)
|
||||
{
|
||||
Regex regex = new Regex("<ul>(.*?)</ul>");
|
||||
Regex regex = new Regex("<li>(.*?)</li>");
|
||||
TextSelection[] matches = document.FindAll(regex);
|
||||
foreach (TextSelection match in matches)
|
||||
{
|
||||
// Get the entire text range of the matched content.
|
||||
WTextRange textRange = match.GetAsOneRange();
|
||||
|
||||
// Extract the full text of the match.
|
||||
string fullText = textRange.Text;
|
||||
|
||||
// Define the length of the opening tag <b>.
|
||||
int startTagLength = "ul>".Length;
|
||||
int endTagIndex = fullText.LastIndexOf("</ul");
|
||||
|
||||
// Extract the opening tag, bold text, and closing tag as separate strings.
|
||||
string startTag = fullText.Substring(0, startTagLength);
|
||||
string boldText = fullText.Substring(startTagLength, endTagIndex - startTagLength);
|
||||
string endTag = fullText.Substring(endTagIndex);
|
||||
|
||||
// Create new text ranges for each part (opening tag, bold text, and closing tag).
|
||||
WTextRange startTextRange = CreateTextRange(textRange, startTag);
|
||||
WTextRange boldTextRange = CreateTextRange(textRange, boldText);
|
||||
WTextRange endTextRange = CreateTextRange(textRange, endTag);
|
||||
|
||||
// Apply bold formatting to the text range containing the bold text.
|
||||
//boldTextRange.CharacterFormat.Bold = true;
|
||||
WParagraph paragraph = textRange.OwnerParagraph;
|
||||
|
||||
// Get the index of the original text range within the paragraph.
|
||||
int index = paragraph.ChildEntities.IndexOf(textRange);
|
||||
|
||||
// Remove the original text range from the paragraph.
|
||||
paragraph.ChildEntities.RemoveAt(index);
|
||||
paragraph.ListFormat.ApplyDefBulletStyle();
|
||||
|
||||
// Insert the new text ranges (in order: closing tag, bold text, opening tag) into the paragraph.
|
||||
// paragraph.ChildEntities.Insert(index, endTextRange);
|
||||
paragraph.ChildEntities.Insert(index, boldTextRange);
|
||||
}
|
||||
}
|
||||
public static void set_font_bold(ref WordDocument document)
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user