|
|
|
|
|
|
|
|
PackagePart mainPart;
|
|
|
PackagePart mainPart;
|
|
|
public PackagePart PackagePart { get { return mainPart; } set { mainPart = value; } }
|
|
|
public PackagePart PackagePart { get { return mainPart; } set { mainPart = value; } }
|
|
|
|
|
|
|
|
|
|
|
|
// The Append family of functions use this List to apply style.
|
|
|
internal List<XElement> runs;
|
|
|
internal List<XElement> runs;
|
|
|
|
|
|
|
|
|
// This paragraphs text alignment
|
|
|
// This paragraphs text alignment
|
|
|
private Alignment alignment;
|
|
|
private Alignment alignment;
|
|
|
|
|
|
|
|
|
// A lookup for the runs in this paragraph
|
|
|
|
|
|
public Dictionary<int, Run> runLookup = new Dictionary<int, Run>();
|
|
|
|
|
|
|
|
|
|
|
|
internal int startIndex, endIndex;
|
|
|
internal int startIndex, endIndex;
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
|
this.startIndex = startIndex;
|
|
|
this.startIndex = startIndex;
|
|
|
this.endIndex = startIndex + GetElementTextLength(xml);
|
|
|
this.endIndex = startIndex + GetElementTextLength(xml);
|
|
|
|
|
|
|
|
|
BuildRunLookup(xml);
|
|
|
|
|
|
RebuildDocProperties();
|
|
|
RebuildDocProperties();
|
|
|
|
|
|
|
|
|
#region It's possible that a Paragraph may have pStyle references
|
|
|
#region It's possible that a Paragraph may have pStyle references
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (run == null)
|
|
|
if (run == null)
|
|
|
return AppendHyperlink(h);
|
|
|
return AppendHyperlink(h);
|
|
|
|
|
|
|
|
|
else
|
|
|
else
|
|
|
{
|
|
|
{
|
|
|
// The parent of this Run
|
|
|
// The parent of this Run
|
|
|
|
|
|
|
|
|
XElement link = h.Xml;
|
|
|
XElement link = h.Xml;
|
|
|
|
|
|
|
|
|
// Replace the origional run
|
|
|
// Replace the origional run
|
|
|
run.Xml.ReplaceWith ( splitRun[0], link, splitRun[1] );
|
|
|
|
|
|
|
|
|
run.Xml.ReplaceWith( splitRun[0], link, splitRun[1] );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// Rebuild the run lookup for this paragraph
|
|
|
|
|
|
runLookup.Clear();
|
|
|
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
|
|
|
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
else
|
|
|
{
|
|
|
{
|
|
|
runLookup.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
if (Xml.Parent.Name.LocalName == "tc")
|
|
|
if (Xml.Parent.Name.LocalName == "tc")
|
|
|
Xml.Value = string.Empty;
|
|
|
Xml.Value = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove this paragraph from the document
|
|
|
// Remove this paragraph from the document
|
|
|
Xml.Remove();
|
|
|
Xml.Remove();
|
|
|
Xml = null;
|
|
|
Xml = null;
|
|
|
|
|
|
|
|
|
runLookup = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal void BuildRunLookup(XElement p)
|
|
|
|
|
|
{
|
|
|
|
|
|
runLookup.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
List<XElement> runs = new List<XElement>();
|
|
|
|
|
|
p.Flatten("r", runs);
|
|
|
|
|
|
|
|
|
|
|
|
int startIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// Loop through each run in this paragraph
|
|
|
|
|
|
foreach (XElement run in runs)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Only add runs which contain text
|
|
|
|
|
|
if (GetElementTextLength(run) > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Run r = new Run(Document, run, startIndex);
|
|
|
|
|
|
runLookup.Add(r.EndIndex, r);
|
|
|
|
|
|
startIndex = r.EndIndex;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
);
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// Rebuild the run lookup for this paragraph
|
|
|
|
|
|
runLookup.Clear();
|
|
|
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
return picture;
|
|
|
return picture;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
List<XElement> newRuns = HelperFunctions.FormatInput(value, null);
|
|
|
List<XElement> newRuns = HelperFunctions.FormatInput(value, null);
|
|
|
Xml.Add(newRuns);
|
|
|
Xml.Add(newRuns);
|
|
|
|
|
|
|
|
|
runLookup.Clear();
|
|
|
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<XElement> newRuns = HelperFunctions.FormatInput(value, formatting.Xml);
|
|
|
List<XElement> newRuns = HelperFunctions.FormatInput(value, formatting.Xml);
|
|
|
Xml.Add(newRuns);
|
|
|
Xml.Add(newRuns);
|
|
|
|
|
|
|
|
|
runLookup.Clear();
|
|
|
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// Rebuild the run lookup for this paragraph
|
|
|
|
|
|
runLookup.Clear();
|
|
|
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Xml.Add(newRuns);
|
|
|
Xml.Add(newRuns);
|
|
|
|
|
|
|
|
|
this.runs = Xml.Elements(XName.Get("r", DocX.w.NamespaceName)).Reverse().Take(newRuns.Count()).ToList();
|
|
|
this.runs = Xml.Elements(XName.Get("r", DocX.w.NamespaceName)).Reverse().Take(newRuns.Count()).ToList();
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
return this;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Xml.Elements().Last().SetAttributeValue(DocX.r + "id", rel.Id);
|
|
|
Xml.Elements().Last().SetAttributeValue(DocX.r + "id", rel.Id);
|
|
|
|
|
|
|
|
|
this.runs = Xml.Elements().Last().Elements(XName.Get("r", DocX.w.NamespaceName)).ToList();
|
|
|
this.runs = Xml.Elements().Last().Elements(XName.Get("r", DocX.w.NamespaceName)).ToList();
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
return this;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
a_id.SetValue(rel.Id);
|
|
|
a_id.SetValue(rel.Id);
|
|
|
|
|
|
|
|
|
this.runs = Xml.Elements(XName.Get("r", DocX.w.NamespaceName)).Reverse().Take(p.Xml.Elements(XName.Get("r", DocX.w.NamespaceName)).Count()).ToList();
|
|
|
this.runs = Xml.Elements(XName.Get("r", DocX.w.NamespaceName)).Reverse().Take(p.Xml.Elements(XName.Get("r", DocX.w.NamespaceName)).Count()).ToList();
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
return this;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
XElement last = rPr.Elements().Last();
|
|
|
XElement last = rPr.Elements().Last();
|
|
|
last.Add(content);
|
|
|
last.Add(content);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), underlineColor.ToHex());
|
|
|
u.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), underlineColor.ToHex());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
return this;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
while (processed < count);
|
|
|
while (processed < count);
|
|
|
|
|
|
|
|
|
// Rebuild the run lookup
|
|
|
|
|
|
runLookup.Clear();
|
|
|
|
|
|
BuildRunLookup(Xml);
|
|
|
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
HelperFunctions.RenumberIDs(Document);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|