SVN-Revision: r751
This commit is contained in:
wyf
2025-06-17 09:07:24 +00:00
parent 9442efc5ac
commit 0fcd6b53b0
+44 -39
View File
@@ -144,7 +144,7 @@ namespace Lskj.AutoCreatWord
TextSelection endSelection = document3.FindString("{" + moduleId + ":end}", false, true);
if (startSelection != null && endSelection != null)
{
if (moduleId.Equals("yw", StringComparison.OrdinalIgnoreCase) || i == 0)
if (moduleId.Equals("yw", StringComparison.OrdinalIgnoreCase))
{
Paragraph lastBreakParagraph = null;
DocumentObject lastBreak = null;
@@ -168,10 +168,6 @@ namespace Lskj.AutoCreatWord
lastBreakParagraph.ChildObjects.Remove(lastBreak);
}
}
if (i == 0 && document.LastSection.Paragraphs.Count > 0)
{
//document.LastSection.Paragraphs[document.LastSection.Paragraphs.Count - 1].AppendBreak(BreakType.PageBreak);
}
Section section = startSelection.GetAsOneRange().OwnerParagraph.OwnerTextBody.Owner as Section;
if (section.PageSetup.Orientation != document.LastSection.PageSetup.Orientation)
{
@@ -202,8 +198,9 @@ namespace Lskj.AutoCreatWord
}
if (isCopying)
{
DocumentObject documentObject = obj.Clone();
//将内容添加到可替换模板
mainSection.Body.ChildObjects.Add(obj.Clone());
mainSection.Body.ChildObjects.Add(documentObject);
}
}
}
@@ -497,26 +494,26 @@ namespace Lskj.AutoCreatWord
{
if (tableCell.Paragraphs.Count == 0)
{
if (disMergeDic.ContainsKey(table))
{
disMergeDic[table].Add(tableRow.Cells.IndexOf(tableCell));
}
else
{
disMergeDic.Add(table, new List<int>() { tableRow.Cells.IndexOf(tableCell) });
}
//if (disMergeDic.ContainsKey(table))
//{
// disMergeDic[table].Add(tableRow.Cells.IndexOf(tableCell));
//}
//else
//{
// disMergeDic.Add(table, new List<int>() { tableRow.Cells.IndexOf(tableCell) });
//}
continue;
}
if (string.IsNullOrEmpty(tableCell.Paragraphs[0].Text))
{
if (disMergeDic.ContainsKey(table))
{
disMergeDic[table].Add(tableRow.Cells.IndexOf(tableCell));
}
else
{
disMergeDic.Add(table, new List<int>() { tableRow.Cells.IndexOf(tableCell) });
}
//if (disMergeDic.ContainsKey(table))
//{
// disMergeDic[table].Add(tableRow.Cells.IndexOf(tableCell));
//}
//else
//{
// disMergeDic.Add(table, new List<int>() { tableRow.Cells.IndexOf(tableCell) });
//}
continue;
}
if (Regex.IsMatch(tableCell.Paragraphs[0].Text, pattern, RegexOptions.IgnoreCase) || Regex.IsMatch(tableCell.Paragraphs[0].Text, pattern1, RegexOptions.IgnoreCase))
@@ -773,7 +770,11 @@ namespace Lskj.AutoCreatWord
TableCell newCell2 = new TableCell(document);
// 设置单元格宽度为原行宽度的一半
newCell1.SetCellWidth(50, CellWidthType.Percentage);
newCell1.CellFormat.BackColor = item.Cells[0].CellFormat.BackColor;
newCell1.CellFormat.VerticalAlignment = item.Cells[0].CellFormat.VerticalAlignment;
newCell2.SetCellWidth(50, CellWidthType.Percentage);
newCell2.CellFormat.BackColor = item.Cells[0].CellFormat.BackColor;
newCell2.CellFormat.VerticalAlignment = item.Cells[0].CellFormat.VerticalAlignment;
newRow.Cells.Clear();
// 将两个新的单元格添加到行中
newRow.Cells.Add(newCell1);
@@ -934,26 +935,26 @@ namespace Lskj.AutoCreatWord
{
if (tableCell.Paragraphs.Count == 0)
{
if (disMergeDic.ContainsKey(table))
{
disMergeDic[table].Add(tableRow.Cells.IndexOf(tableCell));
}
else
{
disMergeDic.Add(table, new List<int>() { tableRow.Cells.IndexOf(tableCell) });
}
//if (disMergeDic.ContainsKey(table))
//{
// disMergeDic[table].Add(tableRow.Cells.IndexOf(tableCell));
//}
//else
//{
// disMergeDic.Add(table, new List<int>() { tableRow.Cells.IndexOf(tableCell) });
//}
continue;
}
if (string.IsNullOrEmpty(tableCell.Paragraphs[0].Text))
{
if (disMergeDic.ContainsKey(table))
{
disMergeDic[table].Add(tableRow.Cells.IndexOf(tableCell));
}
else
{
disMergeDic.Add(table, new List<int>() { tableRow.Cells.IndexOf(tableCell) });
}
//if (disMergeDic.ContainsKey(table))
//{
// disMergeDic[table].Add(tableRow.Cells.IndexOf(tableCell));
//}
//else
//{
// disMergeDic.Add(table, new List<int>() { tableRow.Cells.IndexOf(tableCell) });
//}
continue;
}
if (Regex.IsMatch(tableCell.Paragraphs[0].Text, pattern, RegexOptions.IgnoreCase) || Regex.IsMatch(tableCell.Paragraphs[0].Text, pattern1, RegexOptions.IgnoreCase))
@@ -1215,7 +1216,11 @@ namespace Lskj.AutoCreatWord
TableCell newCell1 = new TableCell(document);
TableCell newCell2 = new TableCell(document);
newCell1.SetCellWidth(50, CellWidthType.Percentage);
newCell1.CellFormat.BackColor = item.Cells[0].CellFormat.BackColor;
newCell1.CellFormat.VerticalAlignment = item.Cells[0].CellFormat.VerticalAlignment;
newCell2.SetCellWidth(50, CellWidthType.Percentage);
newCell2.CellFormat.BackColor = item.Cells[0].CellFormat.BackColor;
newCell2.CellFormat.VerticalAlignment = item.Cells[0].CellFormat.VerticalAlignment;
newRow.Cells.Clear();
// 将两个新的单元格添加到行中
newRow.Cells.Add(newCell1);
@@ -1593,7 +1598,7 @@ namespace Lskj.AutoCreatWord
private static void CpoyHeaderFooter(Section sourceSection, Section targetSection, HeaderFooterType headerFooterType)
{
HeaderFooter headerFooter = sourceSection.HeadersFooters[headerFooterType];
if (headerFooter != null && headerFooter.ChildObjects != null)
if (headerFooter != null && headerFooter.ChildObjects != null && headerFooter.ChildObjects.Count > 0)
{
targetSection.HeadersFooters[headerFooterType].LinkToPrevious = false;
targetSection.HeadersFooters[headerFooterType].ChildObjects.Clear();