/// <summary>
/// Sets the outline style.
/// </summary>
/// <param name="outlineLevel">The outline level.</param>
/// <param name="numFormat">The num format.</param>
/// <param name="document">The text document.</param>
public void SetOutlineStyle(int outlineLevel, string numFormat, TextDocument document)
{
try
{
XmlNode outlineStyleNode = null;
foreach (IStyle iStyle in document.CommonStyles)
{
if (iStyle.Node.Name == "text:outline-style")
{
outlineStyleNode = iStyle.Node;
}
}
// XmlNode outlineStyleNode = this.Styles.SelectSingleNode(
// "//text:outline-style",
// document.NamespaceManager);
XmlNode outlineLevelNode = null;
if (outlineStyleNode != null)
{
outlineLevelNode = outlineStyleNode.SelectSingleNode(
"text:outline-level-style[@text:level='" + outlineLevel.ToString() + "']",
document.NamespaceManager);
}
if (outlineLevelNode != null)
{
XmlNode numberFormatNode = outlineLevelNode.SelectSingleNode(
"@style:num-format", document.NamespaceManager);
if (numberFormatNode != null)
{
numberFormatNode.InnerText = numFormat;
}
XmlAttribute xa = document.CreateAttribute(
"num-suffix", "style");
xa.InnerText = ".";
outlineLevelNode.Attributes.Append(xa);
if (outlineLevel > 1)
{
xa = document.CreateAttribute(
"display-levels", "text");
xa.InnerText = outlineLevel.ToString();
outlineLevelNode.Attributes.Append(xa);
}
}
}
catch (Exception ex)
{
throw;
}
}