private void CreateBorderGroups ContentSection contentSection ContentE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
private void CreateBorderGroups(ContentSection contentSection)
{
ContentElement body = (ContentElement)((List<IContentElement>) contentSection.Section.Contents)[0];
List<IContentElement> newContent = new List<IContentElement>();
ContentElement borderGroup=new ContentElement(null,this,contentSection.Section,new List<IContentElement>(),AreaContentType.Group,AreaLayout.Block.Instance);
ContentElement previous = null;
MsStyle previouStyle = null;
foreach (IContentElement paragraph in body.Contents)
{
CreateRunBorderGroups(paragraph);
if(((IXmlElement)paragraph).Name.LocalName.Code==XmlTags.p)
{
if(previous!=null)
{
if (previouStyle != null && ((MsElement)((ContentElement)paragraph).Source).MsStyle !=null&&
previouStyle.BelongsToSameGroup(((MsElement)((ContentElement)paragraph).Source).MsStyle))
{
if (previous.ContentType == AreaContentType.Group)
{
((ContentElement)paragraph).MoveTo(previous);
}
else
{
previous.MoveTo(borderGroup);
previouStyle = ((MsElement) previous.Source).style;
((ContentElement)paragraph).MoveTo(borderGroup);
previous = borderGroup;
borderGroup = new ContentElement(null, this, contentSection.Section, new List<IContentElement>(), AreaContentType.Group, AreaLayout.Block.Instance);
}
}
else
{
newContent.Add(previous);
previous = (ContentElement)paragraph; ;
previouStyle = ((MsElement)((ContentElement)paragraph).Source).MsStyle;
}
}
else
{
previouStyle = ((MsElement) ((ContentElement) paragraph).Source).MsStyle;
previous = (ContentElement)paragraph;
}
}
else
{
newContent.Add (paragraph);
}
}
newContent.Add(previous);
body.Contents.Clear();
foreach (ContentElement element in newContent)
{
element.MoveTo(body);
}
}