update 20251210
This commit is contained in:
@@ -568,10 +568,60 @@ namespace DOCGEN.Klassen
|
||||
{
|
||||
try
|
||||
{
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
bookmarkNavigator.MoveToBookmark(apivalue.Tag);
|
||||
//bookmarkNavigator.InsertText(dv.Value.ToString());
|
||||
bookmarkNavigator.ReplaceBookmarkContent(apivalue.Value, true);
|
||||
if (apivalue.Type == "Checkbox")
|
||||
{
|
||||
CheckboxCount = 0;
|
||||
CheckboxNr = Convert.ToInt32(apivalue.Value);
|
||||
|
||||
foreach (WSection section in document.Sections)
|
||||
{
|
||||
//Accesses the Body of section where all the contents in document are apart
|
||||
WTextBody sectionBody = section.Body;
|
||||
IterateTextBody(sectionBody);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (apivalue.Type == "Absatz")
|
||||
{
|
||||
if (apivalue.Value != "Ja")
|
||||
{
|
||||
apivalue.Value = "";
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
bookmarkNavigator.MoveToBookmark(apivalue.Tag);
|
||||
bookmarkNavigator.ReplaceBookmarkContent(apivalue.Value, true);
|
||||
Bookmark bookmark = document.Bookmarks.FindByName(apivalue.Tag + "Inhalt");
|
||||
document.Bookmarks.Remove(bookmark);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (apivalue.Value.Contains("</i>"))
|
||||
{
|
||||
string leftpart = apivalue.Value.Substring(0, apivalue.Value.IndexOf("<i>"));
|
||||
string rightparr = apivalue.Value.Substring(apivalue.Value.IndexOf("</i>"), apivalue.Value.Length - apivalue.Value.IndexOf("</i>") - 4);
|
||||
string middle = apivalue.Value.Substring(apivalue.Value.IndexOf("<i>") + 3, apivalue.Value.IndexOf("</i>") - apivalue.Value.IndexOf("<i>") - 3);
|
||||
BookmarksNavigator bn = new BookmarksNavigator(document);
|
||||
bn.MoveToBookmark(apivalue.Tag);
|
||||
apivalue.Value = apivalue.Value.Replace("<i>", "");
|
||||
apivalue.Value = apivalue.Value.Replace("</i>", "");
|
||||
bn.ReplaceBookmarkContent(apivalue.Value, true);
|
||||
TextSelection textSelection = document.Find(middle, false, true);
|
||||
WTextRange text = textSelection.GetAsOneRange();
|
||||
text.CharacterFormat.Italic = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// WTextRange text = textSelection.GetAsOneRange();
|
||||
//apivalue.Value = apivalue.Value & char(11) & "Hallo";
|
||||
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);
|
||||
bookmarkNavigator.MoveToBookmark(apivalue.Tag);
|
||||
bookmarkNavigator.ReplaceBookmarkContent(apivalue.Value, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@@ -774,7 +824,77 @@ namespace DOCGEN.Klassen
|
||||
|
||||
return Convert.ToBase64String(imageArray);
|
||||
}
|
||||
private static int CheckboxNr = 0;
|
||||
private static int CheckboxCount = 0;
|
||||
private static void IterateTextBody(WTextBody textBody)
|
||||
{
|
||||
//Iterates through each of the child items of WTextBody
|
||||
for (int i = 0; i < textBody.ChildEntities.Count; i++)
|
||||
{
|
||||
//IEntity is the basic unit in DocIO DOM.
|
||||
//Accesses the body items (should be either paragraph, table or block content control) as IEntity
|
||||
IEntity bodyItemEntity = textBody.ChildEntities[i];
|
||||
//A Text body has 3 types of elements - Paragraph, Table and Block Content Control
|
||||
//Decides the element type by using EntityType
|
||||
switch (bodyItemEntity.EntityType)
|
||||
{
|
||||
case EntityType.Paragraph:
|
||||
WParagraph paragraph = bodyItemEntity as WParagraph;
|
||||
//Processes the paragraph contents
|
||||
//Iterates through the paragraph's DOM
|
||||
IterateParagraph(paragraph.Items);
|
||||
break;
|
||||
case EntityType.Table:
|
||||
//Table is a collection of rows and cells
|
||||
//Iterates through table's DOM
|
||||
IterateTable(bodyItemEntity as WTable);
|
||||
break;
|
||||
case EntityType.BlockContentControl:
|
||||
BlockContentControl blockContentControl = bodyItemEntity as BlockContentControl;
|
||||
//Iterates to the body items of Block Content Control.
|
||||
IterateTextBody(blockContentControl.TextBody);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void IterateTable(WTable table)
|
||||
{
|
||||
//Iterates the row collection in a table
|
||||
foreach (WTableRow row in table.Rows)
|
||||
{
|
||||
//Iterates the cell collection in a table row
|
||||
foreach (WTableCell cell in row.Cells)
|
||||
{
|
||||
//Table cell is derived from (also a) TextBody
|
||||
//Reusing the code meant for iterating TextBody
|
||||
IterateTextBody(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void IterateParagraph(ParagraphItemCollection paraItems)
|
||||
{
|
||||
for (int i = 0; i < paraItems.Count; i++)
|
||||
{
|
||||
Entity entity = paraItems[i];
|
||||
//A paragraph can have child elements such as text, image, hyperlink, symbols, etc.,
|
||||
//Decides the element type by using EntityType
|
||||
if (entity is WCheckBox)
|
||||
{
|
||||
WCheckBox checkbox = entity as WCheckBox;
|
||||
//Modifies check box properties
|
||||
CheckboxCount = CheckboxCount + 1;
|
||||
if (CheckboxCount == CheckboxNr)
|
||||
{
|
||||
checkbox.Checked = true;
|
||||
//checkbox.SizeType = CheckBoxSizeType.Exactly;
|
||||
|
||||
}
|
||||
//if (!checkbox.Checked)
|
||||
// checkbox.Checked = true;
|
||||
//checkbox.SizeType = CheckBoxSizeType.Exactly;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void set_list(ref WordDocument document)
|
||||
{
|
||||
Regex regex = new Regex("<ul>(.*?)</ul>");
|
||||
|
||||
Reference in New Issue
Block a user