Skip to content

Commit d9afe3d

Browse files
committed
clean up code
1 parent 57af34a commit d9afe3d

File tree

2 files changed

+4
-98
lines changed

2 files changed

+4
-98
lines changed

Word/OoxmlTable.cs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ internal WP.Table CreateTable(FF.Table ffTable)
6262
foreach (var ffPara in ffCell.Paragraphs)
6363
{
6464
//CreateParagraph(ffPara));
65-
wpCell.Append(OoxmlParagraph.CreateInstance(_IDs, _numberingPart).CreateParagraph(ffPara));
65+
wpCell.Append(OoxmlParagraph.CreateInstance(_IDs, _numberingPart).
66+
CreateParagraph(ffPara));
6667
}
6768

6869
wpRow.Append(wpCell);
@@ -93,32 +94,13 @@ internal WP.Table UpdateTable(FF.Table ffTable,WP.Table wpTable)
9394
{
9495
var ffCell = ffRow.Cells[j];
9596
var wpCell = wpCells[j];
96-
97-
// Clear existing content
9897
wpCell.RemoveAllChildren<WP.Paragraph>();
99-
// Recreate paragraphs from custom structure
10098
foreach (var para in ffCell.Paragraphs)
10199
{
102-
Console.WriteLine(para.Text);
103-
/**
104-
var wpPara = new WP.Paragraph();
105-
106-
foreach (var run in para.Runs)
107-
{
108-
var wpRun = new WP.Run();
109-
var wpText = new WP.Text(run.Text ?? string.Empty)
110-
{
111-
Space = SpaceProcessingModeValues.Preserve
112-
};
113-
wpRun.Append(wpText);
114-
wpPara.Append(wpRun);
115-
}
116-
**/
117-
wpCell.Append(OoxmlParagraph.CreateInstance(_IDs, _numberingPart).CreateParagraph(para));
100+
wpCell.Append(OoxmlParagraph.CreateInstance(_IDs, _numberingPart).
101+
CreateParagraph(para));
118102
}
119-
//wpRow.Append(wpCell);
120103
}
121-
//wpTable.Append(wpRow);
122104
}
123105
return wpTable;
124106
}

Word/OpenizeWord.cs

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -959,30 +959,13 @@ public void ReplaceText(string search, string replacement, bool useRegex = false
959959
try
960960
{
961961
var updatedElements = new List<IElement>();
962-
963-
// Compile regex pattern once
964962
var regex = useRegex
965963
? new System.Text.RegularExpressions.Regex(search)
966964
: new System.Text.RegularExpressions.Regex(System.Text.RegularExpressions.Regex.Escape(search));
967-
968-
// Local helper for paragraph processing
969-
/**
970-
void ProcessParagraph(Paragraph para)
971-
{
972-
if (regex.IsMatch(para.Text))
973-
{
974-
Console.WriteLine("Match Found");
975-
para.ReplaceText(search, replacement, useRegex);
976-
//updatedElements.Add(para);
977-
}
978-
}
979-
**/
980-
981965
foreach (var element in _lstStructure)
982966
{
983967
if (element is Paragraph para)
984968
{
985-
//ProcessParagraph(para);
986969
if (regex.IsMatch(para.Text))
987970
{
988971
para.ReplaceText(search, replacement, useRegex);
@@ -1002,13 +985,7 @@ void ProcessParagraph(Paragraph para)
1002985
{
1003986
cellPara.ReplaceText(search, replacement, useRegex);
1004987
isMatched = true;
1005-
//updatedElements.Add(para);
1006988
}
1007-
1008-
//ProcessParagraph(cellPara);
1009-
//count++;
1010-
//cell.Paragraphs[count] = cellPara;
1011-
//updatedElements.Add(cellPara);
1012989
}
1013990
}
1014991
}
@@ -1018,8 +995,6 @@ void ProcessParagraph(Paragraph para)
1018995
}
1019996
}
1020997
}
1021-
1022-
// Apply updates in a separate loop
1023998
foreach (var element in updatedElements)
1024999
{
10251000
this.Update(element.ElementId, element);
@@ -1032,57 +1007,6 @@ void ProcessParagraph(Paragraph para)
10321007
}
10331008
}
10341009

1035-
/**
1036-
public void ReplaceText(string search, string replacement, bool useRegex = false)
1037-
{
1038-
var updatedElements = new List<IElement>();
1039-
1040-
// Compile the regex pattern once
1041-
var regex = useRegex
1042-
? new System.Text.RegularExpressions.Regex(search)
1043-
: new System.Text.RegularExpressions.Regex(System.Text.RegularExpressions.Regex.Escape(search));
1044-
1045-
foreach (var element in _lstStructure)
1046-
{
1047-
if (element is Paragraph para)
1048-
{
1049-
var matches = regex.Matches(para.Text);
1050-
if (matches.Count > 0)
1051-
{
1052-
Console.WriteLine("Match Found");
1053-
para.ReplaceText(search, replacement, useRegex);
1054-
updatedElements.Add(para);
1055-
}
1056-
}
1057-
if (element is Table table)
1058-
{
1059-
foreach (var row in table.Rows)
1060-
{
1061-
foreach (var cell in row.Cells)
1062-
{
1063-
foreach (var cellPara in cell.Paragraphs)
1064-
{
1065-
var matches = regex.Matches(cellPara.Text);
1066-
if (matches.Count > 0)
1067-
{
1068-
cellPara.ReplaceText(search, replacement, useRegex);
1069-
updatedElements.Add(cellPara);
1070-
}
1071-
}
1072-
}
1073-
}
1074-
}
1075-
}
1076-
1077-
// Apply updates in a separate loop
1078-
foreach (var element in updatedElements)
1079-
{
1080-
this.Update(element.ElementId, element);
1081-
}
1082-
1083-
}
1084-
**/
1085-
10861010
/// <summary>
10871011
/// Dispose off all managed and unmanaged resources.
10881012
/// </summary>

0 commit comments

Comments
 (0)