/// <summary> /// Create bullet numbering part /// </summary> public void CreateBulletNumberingPart(MainDocumentPart mainPart, string bulletChar = "-") { NumberingDefinitionsPart numberingPart = mainPart.AddNewPart <NumberingDefinitionsPart>("NDPBullet"); Numbering element = new Numbering( new AbstractNum( new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = bulletChar } ) { LevelIndex = 0 } ) { AbstractNumberId = 1 }, new NumberingInstance( new AbstractNumId() { Val = 1 } ) { NumberID = 1 }); element.Save(numberingPart); }
/// <summary> /// Creates a list instace be creating a (nonabstract) numbering instance. This is an element with a unique number (which is returned) /// that refers to the abstract numbering definition. /// </summary> /// <param name="renderer">The renderer.</param> /// <returns>The unique identifer. Is used afterwards in the list.</returns> public int AddNonabstractNumberId(OpenXMLRenderer renderer) { var _wordDocument = renderer._wordDocument; NumberingDefinitionsPart numberingPart = _wordDocument.MainDocumentPart.NumberingDefinitionsPart; var abstractNumberId = _currentAbstractNumberingDefinition.AbstractNumberId; // Insert an NumberingInstance into the numbering part numbering list. The order seems to matter or it will not pass the // Open XML SDK Productity Tools validation test. AbstractNum comes first and then NumberingInstance and we want to // insert this AFTER the last NumberingInstance and AFTER all the AbstractNum entries or we will get a validation error. var numberId = numberingPart.Numbering.Elements <NumberingInstance>().Count() + 1; var numberingInstance1 = new NumberingInstance() { NumberID = numberId }; var abstractNumId1 = new AbstractNumId() { Val = abstractNumberId }; numberingInstance1.Append(abstractNumId1); if (numberId == 1) { numberingPart.Numbering.Append(numberingInstance1); } else { var lastNumberingInstance = numberingPart.Numbering.Elements <NumberingInstance>().Last(); numberingPart.Numbering.InsertAfter(numberingInstance1, lastNumberingInstance); } return(numberId); }
public ParagraphParser( MainDocumentPart mainDocumentPart, DocxNumberingManager numberingManager) { _mainDocumentPart = mainDocumentPart; _numberingDefinitionsPart = _mainDocumentPart.NumberingDefinitionsPart; _numberingManager = numberingManager; PrepareNumbering(); }
private static NumberingDefinitionsPart GetNumberingDefinitionsPart(WordprocessingDocument doc) { NumberingDefinitionsPart numPart = doc.MainDocumentPart.NumberingDefinitionsPart; if (numPart == null) { numPart = doc.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>(); numPart.Numbering = new Numbering(); } return(numPart); }
public void Print(string name, IEnumerable <string> data, string testDate, string qsId) { WordprocessingDocument doc = null; try { doc = WordprocessingDocument.Create(name, DocumentFormat.OpenXml.WordprocessingDocumentType.Document); } catch (OpenXmlPackageException) { return; } catch (System.IO.IOException) { return; } this.testDate = testDate; questSheetId = qsId; MainDocumentPart mainPart = doc.AddMainDocumentPart(); NumberingDefinitionsPart numberingDefinitionsPart = mainPart.AddNewPart <NumberingDefinitionsPart>("rId1"); CreateNumberingDefinitionsPartContent(numberingDefinitionsPart); FooterPart footerPart1 = mainPart.AddNewPart <FooterPart>("rId7"); GenerateFooterPartContent(footerPart1); mainPart.Document = new Document(); Body body = doc.MainDocumentPart.Document.AppendChild(new Body()); body.Append(Create1stSection()); body.Append(Create2ndSection()); int i = 3; foreach (string s in data) { ++i; if (i < 4) { body.AppendChild(CreateParagraph(s, 1)); } else { body.AppendChild(CreateParagraph(s, 0)); i = -1; } } body.Append(new Paragraph()); body.Append(CreateLastSection()); body.Append(CreateSectionProperties()); doc.Close(); }
public int InsertNewNumbering() { int result = this.m_NumberingCounter++; NumberingDefinitionsPart numberingPart = this.m_Document.MainDocumentPart.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = this.m_Document.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>("NumberingDefinitionsPart"); } Numbering element = new Numbering( new AbstractNum( new Level() { LevelIndex = 0, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Bullet }, LevelText = new LevelText() { Val = "" } } ) { AbstractNumberId = m_NumberingCounter, MultiLevelType = new MultiLevelType() { Val = MultiLevelValues.HybridMultilevel }, }, new NumberingInstance() { NumberID = result, AbstractNumId = new AbstractNumId() { Val = m_NumberingCounter } } ); numberingPart.Numbering = element; element.Save(numberingPart); return(result); }
internal static Numbering CreateNumbering(NumberingDefinitionsPart numberingDefinitionsPart) { //For now do not add bullet and numbered list when there are already numberings defined. //Otherwise the orgiginal numbering will not work. var element = new Numbering(); if (numberingDefinitionsPart != null) { element.Load(numberingDefinitionsPart); } else { var abstractNumberId = element.ChildElements.OfType <AbstractNum>().Count(); element.Append(CreateBulletList(abstractNumberId)); element.Append(CreateNumberedList(abstractNumberId + 1)); } return(element); }
public override MemoryStream CreateDocument(IEnumerable <IResumeSection> resumeSections, ResumeData data) { var memoryStream = new MemoryStream(); using (var wordDocument = WordprocessingDocument.Create(memoryStream, WordprocessingDocumentType.Document)) { mainDocumentPart = wordDocument.AddMainDocumentPart(); // set document settings var documentSettingsPart = mainDocumentPart.AddNewPart <DocumentSettingsPart>(); documentSettingsPart.Settings = new Settings(new EvenAndOddHeaders()); // set headers and footers var wordBrandingHelper = new WordBranding(mainDocumentPart); wordBrandingHelper.AddHeadersAndFooters(); styleDefinitionsPart = mainDocumentPart.AddNewPart <StyleDefinitionsPart>(); GenerateStyleDefinitions(styleDefinitionsPart); numberingDefinitionsPart = mainDocumentPart.AddNewPart <NumberingDefinitionsPart>(); numberingDefinitionsPart.Numbering = new Numbering(); mainDocumentPart.Document = new Document(); body = mainDocumentPart.Document.AppendChild(new Body()); base.RenderElements(resumeSections, data); // apply sections to the document - sections must describe what headers and footers are present body.AppendChild(wordBrandingHelper.CreateSections()); // add numbering instances to the numbering sections. Must be all abstract first, followed by all numbering instances. // hence it is moved out up here. numberingDefinitionsPart.Numbering.Append(abstractNumberingInstances); numberingDefinitionsPart.Numbering.Append(numberingInstances); } memoryStream.Position = 0; return(memoryStream); }
public void SetNumberingFromDocument(string stylesFile) { XDocument numbering = WordDocUtilities.ExtractNumberingPart(stylesFile); // Get the Styles part for this document. NumberingDefinitionsPart part = WordDocument.MainDocumentPart.NumberingDefinitionsPart; Numbering root = new Numbering(numbering.ToString()); // If the Styles part does not exist, add it. if (part == null) { WordDocUtilities.AddNumberingPartToPackage(WordDocument, root); } else { root.Save(part); } }
//..................................................................... /// <summary> /// /// </summary> public void TestDocx( ) { using (this.wordocument = WordprocessingDocument.Create( this.GetDocxName( ), WordprocessingDocumentType.Document)) { MainDocumentPart mainDocxPart = wordocument.AddMainDocumentPart( ); //............................................. //DocumentSettingsPart settingsPART = mainDocxPart.AddNewPart<DocumentSettingsPart>( "rId3" ); //GenerateSettingsPart( settingsPART ); //DocumentSettingsPart settingsPART = mainDocxPart.AddNewPart<DocumentSettingsPart>( "rId3" ); //OpenDocxSettingsPart.Generate( settingsPART ); //............................................. //StylesWithEffectsPart stylesWithEffectsPart1 = mainDocxPart.AddNewPart<StylesWithEffectsPart>( "rId2" ); //GenerateStylesWithEffectsPart1Content( stylesWithEffectsPart1 ); //............................................. NumberingDefinitionsPart numberingPART = mainDocxPart.AddNewPart <NumberingDefinitionsPart>("rId4"); OpenDocxNumbering.Generate(numberingPART); //NumberingDefinitionsPart numberingPART = mainDocxPart.AddNewPart<NumberingDefinitionsPart>( "rId4" ); //GenerateNumberingDefinitionsPart1Content( numberingPART ); //............................................. //StyleDefinitionsPart stylePART = mainDocxPart.AddNewPart<StyleDefinitionsPart>( "rId1" ); //GenerateStyleDefinitionsPart1Content( stylePART ); StyleDefinitionsPart stylePART = mainDocxPart.AddNewPart <StyleDefinitionsPart>("rId1"); OpenDocxStylesPart.Generate(stylePART); //............................................. mainDocxPart.Document = this.GenerateDocument( ); mainDocxPart.Document.Save( ); } return; }
/// <summary> /// Adds the abstract numbering definition. The abstract numbering definition can be thought of as the list class, which can have multiple instances. /// In this definition the styles of the different list levels will be defined, but here we add the definitions part only. /// The level definitions will be added to this on demand later. /// </summary> /// <param name="renderer">The renderer.</param> /// <returns>The abstract numbering definition.</returns> private AbstractNum AddAbstractNumberingDefinition(OpenXMLRenderer renderer) { var _wordDocument = renderer._wordDocument; // Introduce bulleted numbering in case it will be needed at some point NumberingDefinitionsPart numberingPart = _wordDocument.MainDocumentPart.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = _wordDocument.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>("NumberingDefinitionsPart001"); var element = new Numbering(); element.Save(numberingPart); } // Insert an AbstractNum into the numbering part numbering list. // The order seems to matter or it will not pass the // Open XML SDK Productity Tools validation test. // AbstractNum comes first and then NumberingInstance and we want to // insert this AFTER the last AbstractNum and BEFORE the first NumberingInstance or we will get a validation error. var abstractNumberId = numberingPart.Numbering.Elements <AbstractNum>().Count() + 1; var abstractNum1 = new AbstractNum() { AbstractNumberId = abstractNumberId }; abstractNum1.AppendChild(new MultiLevelType() { Val = MultiLevelValues.HybridMultilevel }); if (abstractNumberId == 1) { numberingPart.Numbering.Append(abstractNum1); } else { AbstractNum lastAbstractNum = numberingPart.Numbering.Elements <AbstractNum>().Last(); numberingPart.Numbering.InsertAfter(abstractNum1, lastAbstractNum); } return(abstractNum1); }
public static string RetrieveListItem(WordprocessingDocument wordDoc, XElement paragraph, string bulletReplacementString) { string pt = paragraph.Elements(W.r).Elements(W.t).Select(e => e.Value) .StringConcatenate(); NumberingDefinitionsPart numberingDefinitionsPart = wordDoc.MainDocumentPart.NumberingDefinitionsPart; if (numberingDefinitionsPart == null) { return(null); } StyleDefinitionsPart styleDefinitionsPart = wordDoc.MainDocumentPart .StyleDefinitionsPart; if (styleDefinitionsPart == null) { return(null); } XDocument numbering = numberingDefinitionsPart.GetXDocument(); XDocument styles = styleDefinitionsPart.GetXDocument(); ListItemInfo listItemInfo = GetListItemInfo(numbering, styles, paragraph); if (listItemInfo.IsListItem) { string lvlText = (string)listItemInfo.Lvl.Elements(W.lvlText) .Attributes(W.val).FirstOrDefault(); int[] levelNumbers = GetLevelNumbers(numbering, styles, paragraph); paragraph.AddAnnotation(new LevelNumbers() { LevelNumbersArray = levelNumbers }); string listItem = FormatListItem(listItemInfo.Lvl, levelNumbers, lvlText, bulletReplacementString); return(listItem); } return(null); }
private void NumberingPart(MainDocumentPart mainDocumentPart) { NumberingDefinitionsPart numberingPart = mainDocumentPart.AddNewPart <NumberingDefinitionsPart>("defaultNumberingDefinition"); Numbering element = new Numbering( new AbstractNum( new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "🎈" } ) { LevelIndex = 0 } ) { AbstractNumberId = 1 }, new NumberingInstance( new AbstractNumId() { Val = 1 } ) { NumberID = 1 }); element.Save(numberingPart); }
private void SaveNumberDefinitions() { if (abstractNumList != null && numberingInstanceList != null) { if (mainPart.NumberingDefinitionsPart == null) { NumberingDefinitionsPart numberingPart = mainPart.AddNewPart <NumberingDefinitionsPart>("numberingDefinitionsPart"); } Numbering numbering = new Numbering(); foreach (var abstractNum in abstractNumList) { numbering.Append(abstractNum.Value); } foreach (var numberingInstance in numberingInstanceList) { numbering.Append(numberingInstance.Value); } mainPart.NumberingDefinitionsPart.Numbering = numbering; } }
public static void ProcessTranslate(WordprocessingDocument wordprocessingDocument, MainDocumentPart m) { int begintag = 0; int endtag = 0; int listcount = 1; while (begintag < txtPatentlist.Count()) { endtag = GetInterval(begintag); if (txtPatentlist[begintag][0] == "img") { InsertAPicture(wordprocessingDocument, m, txtPatentlist[begintag][1]); } //else if (txtPatentlist[begintag][0] == "br") //{ // WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(document, true); // Body body = wordprocessingDocument.MainDocumentPart.Document.Body; // Paragraph para = new Paragraph(); // Run run = para.AppendChild(new Run()); // run.Append(new Break()); // body.AppendChild(para); // wordprocessingDocument.MainDocumentPart.Document.Save(); // wordprocessingDocument.Close(); //} else if (txtPatentlist[begintag].Contains("table")) { int trindex = txtPatentlist[begintag].IndexOf("tr") + 1; int colcount = Int32.Parse(txtPatentlist[begintag][trindex]); int rowcount = (endtag - begintag) / colcount; CreateTable(wordprocessingDocument, colcount, rowcount, begintag); } else if (txtPatentlist[begintag].Contains("ul")) { //WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(document, true); //MainDocumentPart m = wordprocessingDocument.MainDocumentPart; //Body body = m.Document.Body; NumberingDefinitionsPart numberingPart = m.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = m.AddNewPart <NumberingDefinitionsPart>(); } Numbering element = new Numbering( new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.Multilevel }, new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "●" } ) { LevelIndex = 0 }, new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "o" } ) { LevelIndex = 1 }, new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "■" } ) { LevelIndex = 2 } ) { AbstractNumberId = 1 }, new NumberingInstance( new AbstractNumId() { Val = 1 } ) { NumberID = 1 } ); element.Save(numberingPart); bool isenter = false; for (; begintag < endtag; begintag++) { if (txtPatentlist[begintag][0] == "br") { begintag++; isenter = true; } int level = -1; string content = txtPatentlist[begintag][0]; foreach (string s in txtPatentlist[begintag]) { if (s == "ul") { level += 1; } } AppendListItem(wordprocessingDocument, content, level, listcount, 0, isenter); wordprocessingDocument.MainDocumentPart.Document.Save(); isenter = false; } listcount++; //wordprocessingDocument.Close(); } else if (txtPatentlist[begintag].Contains("pre")) { //WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(document, true); //Body body = wordprocessingDocument.MainDocumentPart.Document.Body; Paragraph para = new Paragraph(); ParagraphProperties paraProperties = new ParagraphProperties(); ParagraphBorders paraBorders = new ParagraphBorders(); TopBorder top = new TopBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)9U, Space = (UInt32Value)5U }; BottomBorder bottom = new BottomBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)9U, Space = (UInt32Value)5U }; LeftBorder left = new LeftBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)9U, Space = (UInt32Value)5U }; RightBorder right = new RightBorder() { Val = BorderValues.Single, Color = "auto", Size = (UInt32Value)9U, Space = (UInt32Value)5U }; paraBorders.Append(bottom); paraBorders.Append(top); paraBorders.Append(left); paraBorders.Append(right); paraProperties.Append(paraBorders); para.Append(paraProperties); Run run = para.AppendChild(new Run()); string t = txtPatentlist[begintag][0]; string[] s = t.Split('\n'); foreach (string str in s) { if (str.Contains(" ")) { run.Append(new TabChar()); } run.AppendChild(new Text(str)); run.Append(new Break()); } body.AppendChild(para); wordprocessingDocument.MainDocumentPart.Document.Save(); //wordprocessingDocument.Close(); } else if (txtPatentlist[begintag].Contains("h1")) { SetTitle(begintag, endtag, 1.ToString(), wordprocessingDocument); //string path = @"demo.docx"; //CreateWordDocumentUsingMSWordStyles(begintag, endtag, path, "E:\\Microsoft Office\\Office16\\2052\\QuickStyles\\Default.dotx"); } else if (txtPatentlist[begintag].Contains("h2")) { SetTitle2(begintag, endtag, 2.ToString(), wordprocessingDocument); } else if (txtPatentlist[begintag].Contains("h3")) { SetTitle3(begintag, endtag, 3.ToString(), wordprocessingDocument); } else { //WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Open(document, true); //Body body = wordprocessingDocument.MainDocumentPart.Document.Body; Paragraph para = body.AppendChild(new Paragraph()); for (; begintag < endtag; begintag++) { Run run = para.AppendChild(new Run()); if (txtPatentlist[begintag][0] == "br") { run.Append(new Break()); begintag++; } if (txtPatentlist[begintag][0] != "endtag") { Text t = new Text(ToHexString(txtPatentlist[begintag][0])); t.Space = t.Space = new EnumValue <SpaceProcessingModeValues>(SpaceProcessingModeValues.Preserve); run.AppendChild(t); } foreach (string tag in txtPatentlist[begintag]) { switch (tag) { case "b": SetBoldFont(run, wordprocessingDocument); break; case "u": SetItalic(run, wordprocessingDocument); break; case "strong": SetBoldFont(run, wordprocessingDocument); break; default: break; } } } //wordprocessingDocument.Close(); } begintag = endtag + 1; } m.Document.Body = body; wordprocessingDocument.MainDocumentPart.Document.Save(); wordprocessingDocument.Close(); }
/// <summary> /// Transforms a document into a html file /// </summary> /// <param name="packing">Whether save results to a package or not</param> /// <param name="resourcesPackageName">Name of output package</param> /// <param name="htmlOutputName">Name of the output html file</param> /// <param name="outputPath">Path where the files should be placed</param> /// <param name="xslFilePath">Xslt file to use to perform transformation</param> public override void TransformToHtml(bool packing, string resourcesPackageName, string htmlOutputName, string outputPath, string xslFilePath, XsltArgumentList arguments = null) { try { Package htmlPackage = null; StreamWriter htmlWriter = null; /* * // Creates an xmlReader to get the xml of the main document part * XmlReader xmlReader = * XmlReader.Create(parentDocument.Document.MainDocumentPart.GetStream(FileMode.Open, FileAccess.Read)); */ // Load document and important related parts, like the styles XmlDocument mainDoc = new XmlDocument(); mainDoc.Load(parentDocument.Document.MainDocumentPart.GetStream()); XmlNamespaceManager nsm = createNameSpaceManager(mainDoc.NameTable); XmlNode docNode = mainDoc.SelectSingleNode("./w:document", nsm); StyleDefinitionsPart styles = parentDocument.Document.MainDocumentPart.StyleDefinitionsPart; if (styles != null) { LoadRelatedPart(mainDoc, docNode, styles.GetStream()); } NumberingDefinitionsPart numbering = parentDocument.Document.MainDocumentPart.NumberingDefinitionsPart; if (numbering != null) { LoadRelatedPart(mainDoc, docNode, numbering.GetStream()); } ThemePart theme = parentDocument.Document.MainDocumentPart.ThemePart; if (theme != null) { LoadRelatedPart(mainDoc, docNode, theme.GetStream()); } FontTablePart fontTable = parentDocument.Document.MainDocumentPart.FontTablePart; if (fontTable != null) { LoadRelatedPart(mainDoc, docNode, fontTable.GetStream()); } if (packing) { // New package that will contain the html file, with the images htmlPackage = Package.Open(outputPath + @"\" + resourcesPackageName, FileMode.Create); } else { // Create the directory where images will be stored Directory.CreateDirectory(outputPath + @"\images\"); } HandleNumberedLists(mainDoc, nsm); HandleImages(mainDoc, nsm, packing, outputPath, htmlPackage); HandleLinks(mainDoc, nsm); XslCompiledTransform OpenXmlTransformer = new XslCompiledTransform(); OpenXmlTransformer.Load(xslFilePath); // The Transform method apply the xslt transformation to convert the XML to HTML StringWriter strWriterHtml = new StringWriter(); // Manage the mapping of paragraphs with specific style templates to elements OpenXmlTransformer.Transform(mainDoc, arguments, strWriterHtml); string strHtml = strWriterHtml.ToString(); // Closes the package if created if (packing) { // Finally, creates the html file inside the html package Uri uri = null; if (htmlOutputName == string.Empty) { uri = new Uri("/inputFileName.html", UriKind.Relative); } else { uri = new Uri("/" + htmlOutputName, UriKind.Relative); } PackagePart htmlPart = htmlPackage.CreatePart(uri, "text/html"); htmlWriter = new StreamWriter(htmlPart.GetStream()); htmlWriter.Write(strHtml); htmlWriter.Close(); htmlPackage.Close(); } else { // Writes the html file htmlWriter = File.CreateText(outputPath + @"\" + htmlOutputName); htmlWriter.Write(strHtml); htmlWriter.Close(); } } catch (XsltCompileException) { throw new Exception("Invalid XSLT"); } catch (XsltException) { throw new Exception("Invalid XSLT"); } }
private void CreateParts(WordprocessingDocument document) { DocxBase.CurrentTitle = DocxServiceProvinceRes.Title; ExtendedFilePropertiesPart extendedFilePropertiesPart1 = document.AddNewPart <ExtendedFilePropertiesPart>("rId3"); DocxBase.GenerateExtendedFilePropertiesPart1Content(extendedFilePropertiesPart1); MainDocumentPart mainDocumentPart1 = document.AddMainDocumentPart(); GenerateMainDocumentPart1Content(mainDocumentPart1); FontTablePart fontTablePart1 = mainDocumentPart1.AddNewPart <FontTablePart>("rId13"); DocxBase.GenerateFontTablePart1Content(fontTablePart1); StyleDefinitionsPart styleDefinitionsPart1 = mainDocumentPart1.AddNewPart <StyleDefinitionsPart>("rId3"); DocxBase.GenerateStyleDefinitionsPart1Content(styleDefinitionsPart1); EndnotesPart endnotesPart1 = mainDocumentPart1.AddNewPart <EndnotesPart>("rId7"); DocxBase.GenerateEndnotesPart1Content(endnotesPart1); FooterPart footerPart1 = mainDocumentPart1.AddNewPart <FooterPart>("rId12"); DocxBase.GenerateFooterPart1Content(footerPart1); NumberingDefinitionsPart numberingDefinitionsPart1 = mainDocumentPart1.AddNewPart <NumberingDefinitionsPart>("rId2"); DocxBase.GenerateNumberingDefinitionsPart1Content(numberingDefinitionsPart1); CustomXmlPart customXmlPart1 = mainDocumentPart1.AddNewPart <CustomXmlPart>("application/xml", "rId1"); DocxBase.GenerateCustomXmlPart1Content(customXmlPart1); CustomXmlPropertiesPart customXmlPropertiesPart1 = customXmlPart1.AddNewPart <CustomXmlPropertiesPart>("rId1"); DocxBase.GenerateCustomXmlPropertiesPart1Content(customXmlPropertiesPart1); FootnotesPart footnotesPart1 = mainDocumentPart1.AddNewPart <FootnotesPart>("rId6"); DocxBase.GenerateFootnotesPart1Content(footnotesPart1); HeaderPart headerPart1 = mainDocumentPart1.AddNewPart <HeaderPart>("rId11"); DocxBase.GenerateHeaderPart1Content(headerPart1); WebSettingsPart webSettingsPart1 = mainDocumentPart1.AddNewPart <WebSettingsPart>("rId5"); DocxBase.GenerateWebSettingsPart1Content(webSettingsPart1); //ChartPart chartPart1 = mainDocumentPart1.AddNewPart<ChartPart>("rId10"); //DocxBase.GenerateChartPart1Content(chartPart1); //EmbeddedPackagePart embeddedPackagePart1 = chartPart1.AddNewPart<EmbeddedPackagePart>("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "rId3"); //DocxBase.GenerateEmbeddedPackagePart1Content(embeddedPackagePart1); //ChartColorStylePart chartColorStylePart1 = chartPart1.AddNewPart<ChartColorStylePart>("rId2"); //DocxBase.GenerateChartColorStylePart1Content(chartColorStylePart1); //ChartStylePart chartStylePart1 = chartPart1.AddNewPart<ChartStylePart>("rId1"); //DocxBase.GenerateChartStylePart1Content(chartStylePart1); DocumentSettingsPart documentSettingsPart1 = mainDocumentPart1.AddNewPart <DocumentSettingsPart>("rId4"); DocxBase.GenerateDocumentSettingsPart1Content(documentSettingsPart1); //ChartPart chartPart2 = mainDocumentPart1.AddNewPart<ChartPart>("rId9"); //DocxBase.GenerateChartPart2Content(chartPart2); //EmbeddedPackagePart embeddedPackagePart2 = chartPart2.AddNewPart<EmbeddedPackagePart>("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "rId3"); //DocxBase.GenerateEmbeddedPackagePart2Content(embeddedPackagePart2); //ChartColorStylePart chartColorStylePart2 = chartPart2.AddNewPart<ChartColorStylePart>("rId2"); //DocxBase.GenerateChartColorStylePart2Content(chartColorStylePart2); //ChartStylePart chartStylePart2 = chartPart2.AddNewPart<ChartStylePart>("rId1"); //DocxBase.GenerateChartStylePart2Content(chartStylePart2); ThemePart themePart1 = mainDocumentPart1.AddNewPart <ThemePart>("rId14"); DocxBase.GenerateThemePart1Content(themePart1); foreach (UsedHyperlink usedHyperlink in DocxBase.UsedHyperlinkList) { mainDocumentPart1.AddHyperlinkRelationship(new System.Uri(usedHyperlink.URL, System.UriKind.Absolute), true, usedHyperlink.Id.ToString()); } DocxBase.SetPackageProperties(document); }
private void SetupStyles() { WordprocessingCommentsPart commentsPart = AddTemplatePart <WordprocessingCommentsPart>(this.document, CommentsStyleResource); EndnotesPart endNotesPart = AddTemplatePart <EndnotesPart>(this.document, EndNotesStyleResource); FontTablePart fontTablePart = AddTemplatePart <FontTablePart>(this.document, FontsTableStyleResource); FootnotesPart footnotesPart = AddTemplatePart <FootnotesPart>(this.document, FootNotesStyleResource); HeaderPart headerPart = AddTemplatePart <HeaderPart>(this.document, HeaderStyleResource); DocumentSettingsPart settingsPart = AddTemplatePart <DocumentSettingsPart>(this.document, SettingsStyleResource); StyleDefinitionsPart styles = AddTemplatePart <StyleDefinitionsPart>(this.document, StylesStyleResource); StylesWithEffectsPart stylesWithEffectsPart = AddTemplatePart <StylesWithEffectsPart>(this.document, StylesWithEffectsStyleResource); WebSettingsPart webSettingsPart = AddTemplatePart <WebSettingsPart>(this.document, WebSettingsStyleResource); ThemePart themePart = AddTemplatePart <ThemePart>(this.document, ThemeStyleResource); NumberingDefinitionsPart numberingPart = AddTemplatePart <NumberingDefinitionsPart>(this.document, NumberingStyleResource); // Initialize the comments manager with the comments part this.commentManager = new CommentManager(commentsPart.Comments); // Initialize the footer string footerTitle = this.implementationGuide.GetDisplayName(); DateTime footerDate = this.implementationGuide.PublishDate != null ? this.implementationGuide.PublishDate.Value : DateTime.Now; string footerDateString = footerDate.ToString("m"); FooterPart newFooterPart = this.document.MainDocumentPart.AddNewPart <FooterPart>(); Footer newFooter = new Footer(); Paragraph pFooter = new Paragraph( new ParagraphProperties( new ParagraphStyleId() { Val = "Footer" })); pFooter.Append( new Run( new Text(footerTitle)), new Run( new TabChar(), new Text(footerDateString) { Space = SpaceProcessingModeValues.Preserve }), new Run( new TabChar(), new Text("Page ") { Space = SpaceProcessingModeValues.Preserve }), new Run( new FieldChar() { FieldCharType = FieldCharValues.Begin }), new Run( new FieldCode(" PAGE ") { Space = SpaceProcessingModeValues.Preserve }), new Run( new FieldChar() { FieldCharType = FieldCharValues.Separate }), new Run( new RunProperties( new NoProof()), new Text("54")), new Run( new FieldChar() { FieldCharType = FieldCharValues.End })); newFooter.Append(pFooter); newFooterPart.Footer = newFooter; // Add numbering for templates foreach (Template cTemplate in this.templates) { NumberingInstance ni = new NumberingInstance( new AbstractNumId() { Val = 3 }) { NumberID = GenerationConstants.BASE_TEMPLATE_INDEX + (int)cTemplate.Id }; for (int i = 0; i < 9; i++) { ni.Append(new LevelOverride( new StartOverrideNumberingValue() { Val = 1 }) { LevelIndex = i }); } numberingPart.Numbering.Append(ni); } }
public static void GenerateNumberingDefinitionsPart1Content(NumberingDefinitionsPart numberingDefinitionsPart1) { Numbering numbering1 = new Numbering() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 w16se w16cid wp14" } }; numbering1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); numbering1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex"); numbering1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex"); numbering1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex"); numbering1.AddNamespaceDeclaration("cx3", "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex"); numbering1.AddNamespaceDeclaration("cx4", "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex"); numbering1.AddNamespaceDeclaration("cx5", "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex"); numbering1.AddNamespaceDeclaration("cx6", "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex"); numbering1.AddNamespaceDeclaration("cx7", "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex"); numbering1.AddNamespaceDeclaration("cx8", "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex"); numbering1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); numbering1.AddNamespaceDeclaration("aink", "http://schemas.microsoft.com/office/drawing/2016/ink"); numbering1.AddNamespaceDeclaration("am3d", "http://schemas.microsoft.com/office/drawing/2017/model3d"); numbering1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); numbering1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); numbering1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); numbering1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); numbering1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); numbering1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); numbering1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); numbering1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); numbering1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); numbering1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml"); numbering1.AddNamespaceDeclaration("w16cid", "http://schemas.microsoft.com/office/word/2016/wordml/cid"); numbering1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex"); numbering1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); numbering1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); numbering1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); numbering1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); AbstractNum abstractNum1 = new AbstractNum() { AbstractNumberId = 0 }; abstractNum1.SetAttribute(new OpenXmlAttribute("w15", "restartNumberingAfterBreak", "http://schemas.microsoft.com/office/word/2012/wordml", "0")); Nsid nsid1 = new Nsid() { Val = "1FFE17EE" }; MultiLevelType multiLevelType1 = new MultiLevelType() { Val = MultiLevelValues.HybridMultilevel }; TemplateCode templateCode1 = new TemplateCode() { Val = "65746D14" }; Level level1 = new Level() { LevelIndex = 0, TemplateCode = "04260001" }; StartNumberingValue startNumberingValue1 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat1 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText1 = new LevelText() { Val = "·" }; LevelJustification levelJustification1 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties1 = new PreviousParagraphProperties(); Indentation indentation2 = new Indentation() { Start = "720", Hanging = "360" }; previousParagraphProperties1.Append(indentation2); NumberingSymbolRunProperties numberingSymbolRunProperties1 = new NumberingSymbolRunProperties(); RunFonts runFonts2 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol" }; numberingSymbolRunProperties1.Append(runFonts2); level1.Append(startNumberingValue1); level1.Append(numberingFormat1); level1.Append(levelText1); level1.Append(levelJustification1); level1.Append(previousParagraphProperties1); level1.Append(numberingSymbolRunProperties1); Level level2 = new Level() { LevelIndex = 1, TemplateCode = "04260003", Tentative = true }; StartNumberingValue startNumberingValue2 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat2 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText2 = new LevelText() { Val = "o" }; LevelJustification levelJustification2 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties2 = new PreviousParagraphProperties(); Indentation indentation3 = new Indentation() { Start = "1440", Hanging = "360" }; previousParagraphProperties2.Append(indentation3); NumberingSymbolRunProperties numberingSymbolRunProperties2 = new NumberingSymbolRunProperties(); RunFonts runFonts3 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" }; numberingSymbolRunProperties2.Append(runFonts3); level2.Append(startNumberingValue2); level2.Append(numberingFormat2); level2.Append(levelText2); level2.Append(levelJustification2); level2.Append(previousParagraphProperties2); level2.Append(numberingSymbolRunProperties2); Level level3 = new Level() { LevelIndex = 2, TemplateCode = "04260005", Tentative = true }; StartNumberingValue startNumberingValue3 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat3 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText3 = new LevelText() { Val = "§" }; LevelJustification levelJustification3 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties3 = new PreviousParagraphProperties(); Indentation indentation4 = new Indentation() { Start = "2160", Hanging = "360" }; previousParagraphProperties3.Append(indentation4); NumberingSymbolRunProperties numberingSymbolRunProperties3 = new NumberingSymbolRunProperties(); RunFonts runFonts4 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties3.Append(runFonts4); level3.Append(startNumberingValue3); level3.Append(numberingFormat3); level3.Append(levelText3); level3.Append(levelJustification3); level3.Append(previousParagraphProperties3); level3.Append(numberingSymbolRunProperties3); Level level4 = new Level() { LevelIndex = 3, TemplateCode = "04260001", Tentative = true }; StartNumberingValue startNumberingValue4 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat4 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText4 = new LevelText() { Val = "·" }; LevelJustification levelJustification4 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties4 = new PreviousParagraphProperties(); Indentation indentation5 = new Indentation() { Start = "2880", Hanging = "360" }; previousParagraphProperties4.Append(indentation5); NumberingSymbolRunProperties numberingSymbolRunProperties4 = new NumberingSymbolRunProperties(); RunFonts runFonts5 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol" }; numberingSymbolRunProperties4.Append(runFonts5); level4.Append(startNumberingValue4); level4.Append(numberingFormat4); level4.Append(levelText4); level4.Append(levelJustification4); level4.Append(previousParagraphProperties4); level4.Append(numberingSymbolRunProperties4); Level level5 = new Level() { LevelIndex = 4, TemplateCode = "04260003", Tentative = true }; StartNumberingValue startNumberingValue5 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat5 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText5 = new LevelText() { Val = "o" }; LevelJustification levelJustification5 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties5 = new PreviousParagraphProperties(); Indentation indentation6 = new Indentation() { Start = "3600", Hanging = "360" }; previousParagraphProperties5.Append(indentation6); NumberingSymbolRunProperties numberingSymbolRunProperties5 = new NumberingSymbolRunProperties(); RunFonts runFonts6 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" }; numberingSymbolRunProperties5.Append(runFonts6); level5.Append(startNumberingValue5); level5.Append(numberingFormat5); level5.Append(levelText5); level5.Append(levelJustification5); level5.Append(previousParagraphProperties5); level5.Append(numberingSymbolRunProperties5); Level level6 = new Level() { LevelIndex = 5, TemplateCode = "04260005", Tentative = true }; StartNumberingValue startNumberingValue6 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat6 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText6 = new LevelText() { Val = "§" }; LevelJustification levelJustification6 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties6 = new PreviousParagraphProperties(); Indentation indentation7 = new Indentation() { Start = "4320", Hanging = "360" }; previousParagraphProperties6.Append(indentation7); NumberingSymbolRunProperties numberingSymbolRunProperties6 = new NumberingSymbolRunProperties(); RunFonts runFonts7 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties6.Append(runFonts7); level6.Append(startNumberingValue6); level6.Append(numberingFormat6); level6.Append(levelText6); level6.Append(levelJustification6); level6.Append(previousParagraphProperties6); level6.Append(numberingSymbolRunProperties6); Level level7 = new Level() { LevelIndex = 6, TemplateCode = "04260001", Tentative = true }; StartNumberingValue startNumberingValue7 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat7 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText7 = new LevelText() { Val = "·" }; LevelJustification levelJustification7 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties7 = new PreviousParagraphProperties(); Indentation indentation8 = new Indentation() { Start = "5040", Hanging = "360" }; previousParagraphProperties7.Append(indentation8); NumberingSymbolRunProperties numberingSymbolRunProperties7 = new NumberingSymbolRunProperties(); RunFonts runFonts8 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol" }; numberingSymbolRunProperties7.Append(runFonts8); level7.Append(startNumberingValue7); level7.Append(numberingFormat7); level7.Append(levelText7); level7.Append(levelJustification7); level7.Append(previousParagraphProperties7); level7.Append(numberingSymbolRunProperties7); Level level8 = new Level() { LevelIndex = 7, TemplateCode = "04260003", Tentative = true }; StartNumberingValue startNumberingValue8 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat8 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText8 = new LevelText() { Val = "o" }; LevelJustification levelJustification8 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties8 = new PreviousParagraphProperties(); Indentation indentation9 = new Indentation() { Start = "5760", Hanging = "360" }; previousParagraphProperties8.Append(indentation9); NumberingSymbolRunProperties numberingSymbolRunProperties8 = new NumberingSymbolRunProperties(); RunFonts runFonts9 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" }; numberingSymbolRunProperties8.Append(runFonts9); level8.Append(startNumberingValue8); level8.Append(numberingFormat8); level8.Append(levelText8); level8.Append(levelJustification8); level8.Append(previousParagraphProperties8); level8.Append(numberingSymbolRunProperties8); Level level9 = new Level() { LevelIndex = 8, TemplateCode = "04260005", Tentative = true }; StartNumberingValue startNumberingValue9 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat9 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText9 = new LevelText() { Val = "§" }; LevelJustification levelJustification9 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties9 = new PreviousParagraphProperties(); Indentation indentation10 = new Indentation() { Start = "6480", Hanging = "360" }; previousParagraphProperties9.Append(indentation10); NumberingSymbolRunProperties numberingSymbolRunProperties9 = new NumberingSymbolRunProperties(); RunFonts runFonts10 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties9.Append(runFonts10); level9.Append(startNumberingValue9); level9.Append(numberingFormat9); level9.Append(levelText9); level9.Append(levelJustification9); level9.Append(previousParagraphProperties9); level9.Append(numberingSymbolRunProperties9); abstractNum1.Append(nsid1); abstractNum1.Append(multiLevelType1); abstractNum1.Append(templateCode1); abstractNum1.Append(level1); abstractNum1.Append(level2); abstractNum1.Append(level3); abstractNum1.Append(level4); abstractNum1.Append(level5); abstractNum1.Append(level6); abstractNum1.Append(level7); abstractNum1.Append(level8); abstractNum1.Append(level9); NumberingInstance numberingInstance1 = new NumberingInstance() { NumberID = 1 }; AbstractNumId abstractNumId1 = new AbstractNumId() { Val = 0 }; numberingInstance1.Append(abstractNumId1); numbering1.Append(abstractNum1); numbering1.Append(numberingInstance1); numberingDefinitionsPart1.Numbering = numbering1; }
public int CreateBulletList() { NumberingDefinitionsPart numberingPart = wdMainDocumentPart.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = wdMainDocumentPart.AddNewPart <NumberingDefinitionsPart>(); Numbering element = new Numbering(); element.Save(numberingPart); } // Insert an AbstractNum into the numbering part numbering list. The order seems to matter or it will not pass the // Open XML SDK Productity Tools validation test. AbstractNum comes first and then NumberingInstance and we want to // insert this AFTER the last AbstractNum and BEFORE the first NumberingInstance or we will get a validation error. var abstractNumberId = numberingPart.Numbering.Elements <AbstractNum>().Count() + 1; var lvls = new List <Level>(); for (int i = 0; i < 6; i++) { var abstractLevel = new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "" }, new ParagraphProperties() { Indentation = new Indentation() { Left = (720 * (i + 1)).ToString(), Hanging = "360" } }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "Symbol", HighAnsi = "Symbol" } }) { LevelIndex = i }; lvls.Add(abstractLevel); } var abstractNum1 = new AbstractNum(lvls) { AbstractNumberId = abstractNumberId }; if (abstractNumberId == 1) { numberingPart.Numbering.Append(abstractNum1); } else { AbstractNum lastAbstractNum = numberingPart.Numbering.Elements <AbstractNum>().Last(); numberingPart.Numbering.InsertAfter(abstractNum1, lastAbstractNum); } // Insert an NumberingInstance into the numbering part numbering list. The order seems to matter or it will not pass the // Open XML SDK Productity Tools validation test. AbstractNum comes first and then NumberingInstance and we want to // insert this AFTER the last NumberingInstance and AFTER all the AbstractNum entries or we will get a validation error. var numberId = numberingPart.Numbering.Elements <NumberingInstance>().Count() + 1; NumberingInstance numberingInstance1 = new NumberingInstance() { NumberID = numberId }; AbstractNumId abstractNumId1 = new AbstractNumId() { Val = abstractNumberId }; numberingInstance1.Append(abstractNumId1); if (numberId == 1) { numberingPart.Numbering.Append(numberingInstance1); } else { var lastNumberingInstance = numberingPart.Numbering.Elements <NumberingInstance>().Last(); numberingPart.Numbering.InsertAfter(numberingInstance1, lastNumberingInstance); } return(numberId); }
public IActionResult AddList() { using (var stream = new MemoryStream()) { using (var wordDocument = WordprocessingDocument.Create(stream, WordprocessingDocumentType.Document, true)) { wordDocument.AddMainDocumentPart(); var document = new Document(); var body = new Body(); var spacing = new SpacingBetweenLines() { After = "0" }; var indentation = new Indentation() { Left = "5", Hanging = "360" }; var numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 1 }, //ordered list new NumberingId() { Val = 2 } //ordered list ); var paragraphProperties = new ParagraphProperties(numberingProperties, spacing, indentation); paragraphProperties.ParagraphStyleId = new ParagraphStyleId() { Val = "ListParagraph" }; var paragraph0 = new Paragraph(new Run(new Text("Ordered List."))); var paragraph1 = new Paragraph(); paragraph1.ParagraphProperties = new ParagraphProperties(paragraphProperties.OuterXml); paragraph1.Append(new Run(new Text("Soccer"))); Paragraph paragraph2 = new Paragraph(); paragraph2.ParagraphProperties = new ParagraphProperties(paragraphProperties.OuterXml); paragraph2.Append(new Run(new Text("Basketball"))); Paragraph paragraph3 = new Paragraph(); paragraph3.ParagraphProperties = new ParagraphProperties(paragraphProperties.OuterXml); paragraph3.Append(new Run(new Text("Tennis"))); body.Append(paragraph0); body.Append(paragraph1); body.Append(paragraph2); body.Append(paragraph3); ///////////////////////////// NumberingDefinitionsPart numberingPart = wordDocument.MainDocumentPart.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = wordDocument.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>("NumberingDefinitionsPart001"); } //var numberingPart = wordDocument.MainDocumentPart.AddNewPart<NumberingDefinitionsPart>("NumberingDefinitionsPart001"); //unique ID var numbering = new Numbering( new AbstractNum( new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "·" } //♦ ) { LevelIndex = 0 } ) { AbstractNumberId = 1 }, new NumberingInstance( new AbstractNumId() { Val = 1 } ) { NumberID = 1 }); numbering.Save(numberingPart); var spacing2 = new SpacingBetweenLines() { After = "5" }; var indentation2 = new Indentation() { Left = "5", Hanging = "360" }; var numberingProperties2 = new NumberingProperties( new NumberingLevelReference() { Val = 0 }, //unordered list new NumberingId() { Val = 1 } //unordered list ); var paragraphProperties2 = new ParagraphProperties(numberingProperties2, spacing2, indentation2); paragraphProperties2.ParagraphStyleId = new ParagraphStyleId() { Val = "ListParagraph" }; var paragraph20 = new Paragraph(new Run(new Text("Unordered List."))); body.Append(paragraph20); var countryList = new List <string>() { "Mexico", "Czech Republic", "Nicaragua", "Italy" }; foreach (var item in countryList) { var paragraph2n = new Paragraph(); paragraph2n.ParagraphProperties = new ParagraphProperties(paragraphProperties2.OuterXml); paragraph2n.Append(new Run(new Text(item))); body.Append(paragraph2n); } document.Append(body); wordDocument.MainDocumentPart.Document = document; wordDocument.Close(); } return(File(stream.ToArray(), docxMIMEType, "Word Document List Example.docx")); } }
private void AppendList( WordprocessingDocument wordDoc, List <ListText> arr) { NumberingDefinitionsPart numberingPart = wordDoc.MainDocumentPart.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = wordDoc.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>( "NumberingDefinitionsPart1"); Numbering element = new Numbering(); element.Save(numberingPart); } var abstractNumberId = numberingPart.Numbering.Elements <AbstractNum>().Count() + 1; var abstractLevel = new Level( new NumberingFormat() { Val = NumberFormatValues.UpperRoman }, new LevelText() { Val = "%1." }, new StartNumberingValue() { Val = 1, }, new RunProperties() { Italic = new Italic() { Val = OnOffValue.FromBoolean(true) }, FontSize = new FontSize() { Val = 26.ToString(), }, Bold = new Bold() { }, }) { LevelIndex = 0 }; var abstractLevel1 = new Level( new NumberingFormat() { Val = NumberFormatValues.Decimal }, new LevelText() { Val = "%2." }, new StartNumberingValue() { Val = 1, }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "GOST type B", HighAnsi = "GOST type B", ComplexScript = "GOST type B" }, Italic = new Italic() { Val = OnOffValue.FromBoolean(true) }, FontSize = new FontSize() { Val = 26.ToString(), } }) { LevelIndex = 1 }; var abstractLevel2 = new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "–" }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "Calibri", HighAnsi = "Calibri", ComplexScript = "Calibri" }, }) { LevelIndex = 2 }; var abstractLevel3 = new Level( new LevelSuffix() { Val = LevelSuffixValues.Space }) { LevelIndex = 3 }; var abstractLevel4 = new Level( new LevelSuffix() { Val = LevelSuffixValues.Space }) { LevelIndex = 4 }; var abstractLevel5 = new Level( new LevelSuffix() { Val = LevelSuffixValues.Space }) { LevelIndex = 5 }; var abstractLevel6 = new Level( new LevelSuffix() { Val = LevelSuffixValues.Space }) { LevelIndex = 6 }; var abstractNum = new AbstractNum( abstractLevel, abstractLevel1, abstractLevel2, abstractLevel3, abstractLevel4, abstractLevel5, abstractLevel6) { AbstractNumberId = abstractNumberId }; if (abstractNumberId == 1) { numberingPart.Numbering.Append(abstractNum); } else { AbstractNum lastAbstractNum = numberingPart.Numbering.Elements <AbstractNum>().Last(); numberingPart.Numbering.InsertAfter(abstractNum, lastAbstractNum); } var numberId = numberingPart.Numbering.Elements <NumberingInstance>().Count() + 1; NumberingInstance numberingInstance = new NumberingInstance() { NumberID = numberId }; AbstractNumId abstractNumId = new AbstractNumId() { Val = abstractNumberId }; numberingInstance.Append(abstractNumId); if (numberId == 1) { numberingPart.Numbering.Append(numberingInstance); } else { var lastNumberingInstance = numberingPart.Numbering.Elements <NumberingInstance>().Last(); numberingPart.Numbering.InsertAfter(numberingInstance, lastNumberingInstance); } Body body = wordDoc.MainDocumentPart.Document.Body; for (var i = 0; i < arr.Count(); i++) { var spacingBetweenLines = new SpacingBetweenLines() { After = "120", Line = "240" }; var indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "1160" }; NumberingProperties numberingProperties; if (arr[i].LevelNum == 0) { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = numberId }); indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "720" }; } else if (arr[i].LevelNum == 1) { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 1 }, new NumberingId() { Val = numberId }); } else if (arr[i].LevelNum == 2) { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 2 }, new NumberingId() { Val = numberId }); } else if (arr[i].LevelNum == 3) { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 3 }, new NumberingId() { Val = numberId }); indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "640" }; } else if (arr[i].LevelNum == 4) { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 4 }, new NumberingId() { Val = numberId }); indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "1080" }; } else if (arr[i].LevelNum == 5) { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 5 }, new NumberingId() { Val = numberId }); indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "1800" }; } else { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 6 }, new NumberingId() { Val = numberId }); indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "2400" }; } var paragraphProperties = new ParagraphProperties( numberingProperties, spacingBetweenLines, indentation); var newPara = new Paragraph(paragraphProperties); if (arr[i].WithSuperscript) { var split = arr[i].Text.Split('^'); if (split.Count() > 1) { for (int k = 0; k < split.Count(); k++) { if (k > 0) { newPara.AppendChild( Word.GetTextElement(split[k][0].ToString(), 26, false, true)); } if (k == 0) { newPara.AppendChild(Word.GetTextElement(split[k], 26)); } else if (split[k].Length > 1) { newPara.AppendChild( Word.GetTextElement(split[k].Substring(1), 26)); } } } else { newPara.AppendChild( Word.GetTextElement(arr[i].Text, 26, false, false, arr[i].IsBold)); } } else { newPara.AppendChild( Word.GetTextElement(arr[i].Text, 26, false, false, arr[i].IsBold)); } body.AppendChild(newPara); } }
public void AddNestedBulletList(List <Run> runList) { // Introduce bulleted numbering in case it will be needed at some point NumberingDefinitionsPart numberingPart = _document.MainDocumentPart.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = _document.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>("NumberingDefinitionsPart002"); Numbering element = new Numbering(); element.Save(numberingPart); } // Insert an AbstractNum into the numbering part numbering list. The order seems to matter or it will not pass the // Open XML SDK Productity Tools validation test. AbstractNum comes first and then NumberingInstance and we want to // insert this AFTER the last AbstractNum and BEFORE the first NumberingInstance or we will get a validation error. var abstractNumberId = numberingPart.Numbering.Elements <AbstractNum>().Count() + 1; var abstractLevel = new Level(new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "o" }) { LevelIndex = 1 }; var abstractNum1 = new AbstractNum(abstractLevel) { AbstractNumberId = abstractNumberId }; if (abstractNumberId == 1) { numberingPart.Numbering.Append(abstractNum1); } else { AbstractNum lastAbstractNum = numberingPart.Numbering.Elements <AbstractNum>().Last(); numberingPart.Numbering.InsertAfter(abstractNum1, lastAbstractNum); } // Insert an NumberingInstance into the numbering part numbering list. The order seems to matter or it will not pass the // Open XML SDK Productity Tools validation test. AbstractNum comes first and then NumberingInstance and we want to // insert this AFTER the last NumberingInstance and AFTER all the AbstractNum entries or we will get a validation error. var numberId = numberingPart.Numbering.Elements <NumberingInstance>().Count() + 1; NumberingInstance numberingInstance1 = new NumberingInstance() { NumberID = numberId }; AbstractNumId abstractNumId1 = new AbstractNumId() { Val = abstractNumberId }; numberingInstance1.Append(abstractNumId1); if (numberId == 1) { numberingPart.Numbering.Append(numberingInstance1); } else { var lastNumberingInstance = numberingPart.Numbering.Elements <NumberingInstance>().Last(); numberingPart.Numbering.InsertAfter(numberingInstance1, lastNumberingInstance); } foreach (Run runItem in runList) { // Create items for paragraph properties var numberingProperties = new NumberingProperties(new NumberingLevelReference() { Val = 1 }, new NumberingId() { Val = numberId }); var spacingBetweenLines1 = new SpacingBetweenLines() { After = "0" }; // Get rid of space between bullets var indentation = new Indentation() { Left = "1440", Hanging = "360" }; // correct indentation ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties(); RunFonts runFonts1 = new RunFonts() { Ascii = "Symbol", HighAnsi = "Symbol" }; paragraphMarkRunProperties1.Append(runFonts1); // create paragraph properties var paragraphProperties = new ParagraphProperties(numberingProperties, spacingBetweenLines1, indentation, paragraphMarkRunProperties1); // Create paragraph var newPara = new Paragraph(paragraphProperties); // Add run to the paragraph newPara.AppendChild(runItem); ApplyStyleToParagraph(DocumentStyles.Text, newPara); // Add one bullet item to the body DocumentBody.AppendChild(newPara); } }
/// <summary> /// Add a Numbering part to the package, we are adding 2 numbering formats + a bullet format /// </summary> private void AddNumberingPartToPackage() { NumberingDefinitionsPart numberingPart = m_DocumentPart.AddNewPart <NumberingDefinitionsPart>("gxNumberingPart"); NumberingPart.GenerateNumberingDefinitionsPart1Content(numberingPart); }
private void InitNumberingIds() { NumberingDefinitionsPart numberingPart = mainPart.NumberingDefinitionsPart; int absNumIdRef = 0; // Ensure the numbering.xml file exists or any numbering or bullets list will results // in simple numbering list (1. 2. 3...) if (numberingPart == null) { numberingPart = numberingPart = mainPart.AddNewPart <NumberingDefinitionsPart>(); } if (mainPart.NumberingDefinitionsPart.Numbering == null) { new Numbering().Save(numberingPart); } else { // The absNumIdRef Id is a required field and should be unique. We will loop through the existing Numbering definition // to retrieve the highest Id and reconstruct our own list definition template. foreach (var abs in numberingPart.Numbering.Elements <AbstractNum>()) { if (abs.AbstractNumberId.HasValue && abs.AbstractNumberId > absNumIdRef) { absNumIdRef = abs.AbstractNumberId; } } absNumIdRef++; } // This minimal numbering definition has been inspired by the documentation OfficeXMLMarkupExplained_en.docx // http://www.microsoft.com/downloads/details.aspx?FamilyID=6f264d0b-23e8-43fe-9f82-9ab627e5eaa3&displaylang=en DocumentFormat.OpenXml.OpenXmlElement[] absNumChildren = new [] { //8 kinds of abstractnum + 1 multi-level. new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Decimal }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Bullet }, LevelIndex = 0, LevelText = new LevelText() { Val = "•" }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 1 }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Bullet }, LevelIndex = 0, LevelText = new LevelText() { Val = "▪" }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 2 }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Bullet }, LevelIndex = 0, LevelText = new LevelText() { Val = "o" }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 3 }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.UpperLetter }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 4 }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.LowerLetter }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 5 }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.UpperRoman }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 6 }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.LowerRoman }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 7 } }; // this is not documented but MS Word needs that all the AbstractNum are stored consecutively. // Otherwise, it will apply the "NoList" style to the existing ListInstances. // This is the reason why I insert all the items after the last AbstractNum. int lastAbsNumIndex = 0; if (absNumIdRef > 0) { lastAbsNumIndex = numberingPart.Numbering.ChildElements.Count - 1; for (; lastAbsNumIndex >= 0; lastAbsNumIndex--) { if (numberingPart.Numbering.ChildElements[lastAbsNumIndex] is AbstractNum) { break; } } } for (int i = 0; i < absNumChildren.Length; i++) { numberingPart.Numbering.InsertAt(absNumChildren[i], i + lastAbsNumIndex); } // initializes the lookup knonwAbsNumIds = new Dictionary <String, Int32>() { { "disc", absNumIdRef + 1 }, { "square", absNumIdRef + 2 }, { "circle", absNumIdRef + 3 }, { "upper-alpha", absNumIdRef + 4 }, { "lower-alpha", absNumIdRef + 5 }, { "upper-roman", absNumIdRef + 6 }, { "lower-roman", absNumIdRef + 7 }, { "decimal", absNumIdRef } }; // compute the next list instance ID seed. We start at 1 because 0 has a special meaning: // The w:numId can contain a value of 0, which is a special value that indicates that numbering was removed // at this level of the style hierarchy. While processing this markup, if the w:val='0', // the paragraph does not have a list item (http://msdn.microsoft.com/en-us/library/ee922775(office.14).aspx) nextInstanceID = 1; foreach (NumberingInstance inst in numberingPart.Numbering.Elements <NumberingInstance>()) { if (inst.NumberID.Value > nextInstanceID) { nextInstanceID = inst.NumberID; } } numInstances.Push(nextInstanceID); numberingPart.Numbering.Save(); }
private void InitNumberingIds() { NumberingDefinitionsPart numberingPart = mainPart.NumberingDefinitionsPart; int absNumIdRef = 0; // Ensure the numbering.xml file exists or any numbering or bullets list will results // in simple numbering list (1. 2. 3...) if (numberingPart == null) { numberingPart = numberingPart = mainPart.AddNewPart <NumberingDefinitionsPart>(); } if (mainPart.NumberingDefinitionsPart.Numbering == null) { new Numbering().Save(numberingPart); } else { // The absNumIdRef Id is a required field and should be unique. We will loop through the existing Numbering definition // to retrieve the highest Id and reconstruct our own list definition template. foreach (var abs in numberingPart.Numbering.Elements <AbstractNum>()) { if (abs.AbstractNumberId.HasValue && abs.AbstractNumberId > absNumIdRef) { absNumIdRef = abs.AbstractNumberId; } } absNumIdRef++; } // This minimal numbering definition has been inspired by the documentation OfficeXMLMarkupExplained_en.docx // http://www.microsoft.com/downloads/details.aspx?FamilyID=6f264d0b-23e8-43fe-9f82-9ab627e5eaa3&displaylang=en AbstractNum[] absNumChildren = new [] { //8 kinds of abstractnum + 1 multi-level. new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Decimal }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = "decimal" } }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Bullet }, LevelIndex = 0, LevelText = new LevelText() { Val = "•" }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 1, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = "disc" } }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Bullet }, LevelIndex = 0, LevelText = new LevelText() { Val = "▪" }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 2, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = "square" } }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Bullet }, LevelIndex = 0, LevelText = new LevelText() { Val = "o" }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 3, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = "circle" } }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.UpperLetter }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 4, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = "upper-alpha" } }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.LowerLetter }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 5, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = "lower-alpha" } }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.UpperRoman }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 6, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = "upper-roman" } }, new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.LowerRoman }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." }, PreviousParagraphProperties = new PreviousParagraphProperties { Indentation = new Indentation() { Left = "420", Hanging = "360" } } } ) { AbstractNumberId = absNumIdRef + 7, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = "lower-roman" } }, // decimal-heading-multi // WARNING: only use this for headings new AbstractNum( new MultiLevelType() { Val = MultiLevelValues.SingleLevel }, new Level { StartNumberingValue = new StartNumberingValue() { Val = 1 }, NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.Decimal }, LevelIndex = 0, LevelText = new LevelText() { Val = "%1." } } ) { AbstractNumberId = absNumIdRef + 8, AbstractNumDefinitionName = new AbstractNumDefinitionName() { Val = HEADING_NUMBERING_NAME } } }; // Check if we have already initialized our abstract nums // if that is the case, we should not add them again. // This supports a use-case where the HtmlConverter is called multiple times // on document generation, and needs to continue existing lists bool addNewAbstractNums = false; IEnumerable <AbstractNum> existingAbstractNums = numberingPart.Numbering.ChildElements.Where(e => e != null && e is AbstractNum).Cast <AbstractNum>(); if (existingAbstractNums.Count() >= absNumChildren.Length) // means we might have added our own already { foreach (var abstractNum in absNumChildren) { // Check if we can find this in the existing document addNewAbstractNums = addNewAbstractNums || !existingAbstractNums.Any(a => a.AbstractNumDefinitionName != null && a.AbstractNumDefinitionName.Val.Value == abstractNum.AbstractNumDefinitionName.Val.Value); } } else { addNewAbstractNums = true; } if (addNewAbstractNums) { // this is not documented but MS Word needs that all the AbstractNum are stored consecutively. // Otherwise, it will apply the "NoList" style to the existing ListInstances. // This is the reason why I insert all the items after the last AbstractNum. int lastAbsNumIndex = 0; if (absNumIdRef > 0) { lastAbsNumIndex = numberingPart.Numbering.ChildElements.Count - 1; for (; lastAbsNumIndex >= 0; lastAbsNumIndex--) { if (numberingPart.Numbering.ChildElements[lastAbsNumIndex] is AbstractNum) { break; } } } for (int i = 0; i < absNumChildren.Length; i++) { numberingPart.Numbering.InsertAt(absNumChildren[i], i + lastAbsNumIndex); } knownAbsNumIds = absNumChildren .ToDictionary(a => a.AbstractNumDefinitionName.Val.Value, a => a.AbstractNumberId.Value); } else { knownAbsNumIds = existingAbstractNums .Where(a => a.AbstractNumDefinitionName != null && a.AbstractNumDefinitionName.Val != null) .ToDictionary(a => a.AbstractNumDefinitionName.Val.Value, a => a.AbstractNumberId.Value); } // compute the next list instance ID seed. We start at 1 because 0 has a special meaning: // The w:numId can contain a value of 0, which is a special value that indicates that numbering was removed // at this level of the style hierarchy. While processing this markup, if the w:val='0', // the paragraph does not have a list item (http://msdn.microsoft.com/en-us/library/ee922775(office.14).aspx) nextInstanceID = 1; foreach (NumberingInstance inst in numberingPart.Numbering.Elements <NumberingInstance>()) { if (inst.NumberID.Value > nextInstanceID) { nextInstanceID = inst.NumberID; } } numInstances.Push(new KeyValuePair <int, int>(nextInstanceID, -1)); numberingPart.Numbering.Save(); }
private void AppendList( WordprocessingDocument wordDoc, IEnumerable <MarkGeneralDataPoint> markGeneralDataPoints, MarkOperatingConditions markOperatingConditions) { NumberingDefinitionsPart numberingPart = wordDoc.MainDocumentPart.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = wordDoc.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>( "NumberingDefinitionsPart1"); Numbering element = new Numbering(); element.Save(numberingPart); } var abstractNumberId = numberingPart.Numbering.Elements <AbstractNum>().Count() + 1; var abstractLevel = new Level( new NumberingFormat() { Val = NumberFormatValues.Decimal }, new LevelText() { Val = "%1" }, new StartNumberingValue() { Val = 1, }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "GOST type B", HighAnsi = "GOST type B", ComplexScript = "GOST type B" }, Italic = new Italic() { Val = OnOffValue.FromBoolean(true) }, FontSize = new FontSize() { Val = 26.ToString(), } }) { LevelIndex = 0 }; var abstractLevel2 = new Level( new NumberingFormat() { Val = NumberFormatValues.Decimal }, new LevelText() { Val = "%1.%2" }, new StartNumberingValue() { Val = 1, }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "GOST type B", HighAnsi = "GOST type B", ComplexScript = "GOST type B" }, Italic = new Italic() { Val = OnOffValue.FromBoolean(true) }, FontSize = new FontSize() { Val = 26.ToString(), } }) { LevelIndex = 1 }; var abstractLevel3 = new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "–" }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "Calibri", HighAnsi = "Calibri", ComplexScript = "Calibri" }, }) { LevelIndex = 2 }; var abstractLevel4 = new Level( new LevelSuffix() { Val = LevelSuffixValues.Space }) { LevelIndex = 3 }; var abstractNum = new AbstractNum( abstractLevel, abstractLevel2, abstractLevel3, abstractLevel4) { AbstractNumberId = abstractNumberId }; if (abstractNumberId == 1) { numberingPart.Numbering.Append(abstractNum); } else { AbstractNum lastAbstractNum = numberingPart.Numbering.Elements <AbstractNum>().Last(); numberingPart.Numbering.InsertAfter(abstractNum, lastAbstractNum); } var numberId = numberingPart.Numbering.Elements <NumberingInstance>().Count() + 1; NumberingInstance numberingInstance = new NumberingInstance() { NumberID = numberId }; AbstractNumId abstractNumId = new AbstractNumId() { Val = abstractNumberId }; numberingInstance.Append(abstractNumId); if (numberId == 1) { numberingPart.Numbering.Append(numberingInstance); } else { var lastNumberingInstance = numberingPart.Numbering.Elements <NumberingInstance>().Last(); numberingPart.Numbering.InsertAfter(numberingInstance, lastNumberingInstance); } Body body = wordDoc.MainDocumentPart.Document.Body; var markGeneralDataPointsList = markGeneralDataPoints.ToList(); for (var i = 0; i < markGeneralDataPoints.Count(); i++) { var item = markGeneralDataPointsList[i]; var spacingBetweenLines = new SpacingBetweenLines() { After = "120", Line = "240" }; var indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "720" }; NumberingProperties numberingProperties; var pointText = item.Text; if (item.OrderNum == 1) { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = numberId }); } else if (item.Text[0] == '#' && item.Text[1] == ' ') { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 1 }, new NumberingId() { Val = numberId }); pointText = pointText.Substring(2) + "."; } else if (item.Text[0] == '-' && item.Text[1] == ' ') { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 2 }, new NumberingId() { Val = numberId }); if (i == 0) { pointText = pointText.Substring(2) + "."; } else if (markGeneralDataPointsList[i - 1].OrderNum == 1) { pointText = pointText.Substring(2) + "."; } else if (markGeneralDataPointsList[i - 1].Text[0] == '#' && markGeneralDataPointsList[i - 1].Text[1] == ' ') { pointText = pointText.Substring(2) + "."; } else { pointText = pointText.Substring(2) + ";"; } } else { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 3 }, new NumberingId() { Val = numberId }); pointText = pointText + "."; indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "640" }; } var paragraphProperties = new ParagraphProperties( numberingProperties, spacingBetweenLines, indentation); var newPara = new Paragraph(paragraphProperties); if (item.Section.Id == 7) { if (pointText.Contains("коэффициент надежности по ответственности")) { pointText = pointText.Replace("{}", markOperatingConditions.SafetyCoeff.ToString()); } else if (pointText.Contains("степень агрессивного воздействия среды")) { pointText = pointText.Replace("{}", markOperatingConditions.EnvAggressiveness.Name); } else if (pointText.Contains("расчетная температура эксплуатации")) { pointText = pointText.Replace("{}", $"{(markOperatingConditions.Temperature < 0 ? ("минус " + -markOperatingConditions.Temperature) : markOperatingConditions.Temperature)}"); } } if (pointText.Contains('^')) { var split = pointText.Split('^'); if (split.Count() > 1) { for (int k = 0; k < split.Count(); k++) { if (k > 0) { newPara.AppendChild(Word.GetTextElement(split[k][0].ToString(), 26, false, true)); } if (k == 0) { newPara.AppendChild(Word.GetTextElement(split[k], 26)); } else if (split[k].Length > 1) { newPara.AppendChild(Word.GetTextElement(split[k].Substring(1), 26)); } } } else { newPara.AppendChild(Word.GetTextElement(pointText, 26)); } } else { newPara.AppendChild(Word.GetTextElement(pointText, 26)); } body.PrependChild(newPara); } }
public string Save(ITest test, string path) { try { using (WordprocessingDocument doc = WordprocessingDocument.Create( path, DocumentFormat.OpenXml.WordprocessingDocumentType.Document)) { //Doc structure mainPart = doc.AddMainDocumentPart(); mainPart.Document = new Document(); body = mainPart.Document.AppendChild(new Body()); NumberingDefinitionsPart numberingPart = mainPart.AddNewPart <NumberingDefinitionsPart>("numberpart1"); Numbering element = new Numbering( new AbstractNum( new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "·" }) { LevelIndex = 0 }) { AbstractNumberId = 1 }, new NumberingInstance( new AbstractNumId() { Val = 1 }) { NumberID = 1 }); element.Save(numberingPart); foreach (var question in test.Questions) { Paragraph para = body.AppendChild(new Paragraph()); var info = new StringBuilder(question.QuestionAnswer.GetQuestionTaskInfo()); info.Append(" ("); info.Append(question.QuestionAnswer.QuestionScore); info.Append(" баллов)"); Run run = para.AppendChild(new Run()); run.PrependChild(GetStyle(true)); run.AppendChild(new Text(info.ToString())); run = para.AppendChild(new Run()); run.PrependChild(GetStyle(false)); run.AppendChild(new Break()); run.AppendChild(new Text(question.QuestionInfo.GetShortDescription())); question.QuestionAnswer.ToWord(this as IWordAnswerPrinter); } } } catch (Exception e) { return(e.Message); } return(null); }
public static void AppendList( WordprocessingDocument wordDoc, IEnumerable <MarkGeneralDataPoint> markGeneralDataPoints) { NumberingDefinitionsPart numberingPart = wordDoc.MainDocumentPart.NumberingDefinitionsPart; if (numberingPart == null) { numberingPart = wordDoc.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>( "NumberingDefinitionsPart1"); Numbering element = new Numbering(); element.Save(numberingPart); } var abstractNumberId = numberingPart.Numbering.Elements <AbstractNum>().Count() + 1; var abstractLevel = new Level( new NumberingFormat() { Val = NumberFormatValues.Decimal }, new LevelText() { Val = "%1" }, new StartNumberingValue() { Val = 1, }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "GOST type B", HighAnsi = "GOST type B", ComplexScript = "GOST type B" }, Italic = new Italic() { Val = OnOffValue.FromBoolean(true) }, FontSize = new FontSize() { Val = 26.ToString(), } }) { LevelIndex = 0 }; var abstractLevel2 = new Level( new NumberingFormat() { Val = NumberFormatValues.Decimal }, new LevelText() { Val = "%1.%2" }, new StartNumberingValue() { Val = 1, }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "GOST type B", HighAnsi = "GOST type B", ComplexScript = "GOST type B" }, Italic = new Italic() { Val = OnOffValue.FromBoolean(true) }, FontSize = new FontSize() { Val = 26.ToString(), } }) { LevelIndex = 1 }; var abstractLevel3 = new Level( new NumberingFormat() { Val = NumberFormatValues.Bullet }, new LevelText() { Val = "–" }, new RunProperties() { RunFonts = new RunFonts() { Ascii = "Calibri", HighAnsi = "Calibri", ComplexScript = "Calibri" }, }) { LevelIndex = 2 }; var abstractLevel4 = new Level( new LevelSuffix() { Val = LevelSuffixValues.Space }) { LevelIndex = 3 }; var abstractNum = new AbstractNum( abstractLevel, abstractLevel2, abstractLevel3, abstractLevel4) { AbstractNumberId = abstractNumberId }; if (abstractNumberId == 1) { numberingPart.Numbering.Append(abstractNum); } else { AbstractNum lastAbstractNum = numberingPart.Numbering.Elements <AbstractNum>().Last(); numberingPart.Numbering.InsertAfter(abstractNum, lastAbstractNum); } var numberId = numberingPart.Numbering.Elements <NumberingInstance>().Count() + 1; NumberingInstance numberingInstance = new NumberingInstance() { NumberID = numberId }; AbstractNumId abstractNumId = new AbstractNumId() { Val = abstractNumberId }; numberingInstance.Append(abstractNumId); if (numberId == 1) { numberingPart.Numbering.Append(numberingInstance); } else { var lastNumberingInstance = numberingPart.Numbering.Elements <NumberingInstance>().Last(); numberingPart.Numbering.InsertAfter(numberingInstance, lastNumberingInstance); } Body body = wordDoc.MainDocumentPart.Document.Body; var markGeneralDataPointsList = markGeneralDataPoints.ToList(); for (var i = 0; i < markGeneralDataPoints.Count(); i++) { var item = markGeneralDataPointsList[i]; var spacingBetweenLines = new SpacingBetweenLines() { After = "120", Line = "240" }; var indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "720" }; NumberingProperties numberingProperties; var pointText = item.Text; if (item.OrderNum == 1) { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 0 }, new NumberingId() { Val = numberId }); } else if (item.Text[0] == '#' && item.Text[1] == ' ') { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 1 }, new NumberingId() { Val = numberId }); pointText = pointText.Substring(2) + "."; } else if (item.Text[0] == '-' && item.Text[1] == ' ') { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 2 }, new NumberingId() { Val = numberId }); if (i == 0) { pointText = pointText.Substring(2) + "."; } else if (markGeneralDataPointsList[i - 1].OrderNum == 1) { pointText = pointText.Substring(2) + "."; } else if (markGeneralDataPointsList[i - 1].Text[0] == '#' && markGeneralDataPointsList[i - 1].Text[1] == ' ') { pointText = pointText.Substring(2) + "."; } else { pointText = pointText.Substring(2) + ";"; } } else { numberingProperties = new NumberingProperties( new NumberingLevelReference() { Val = 3 }, new NumberingId() { Val = numberId }); pointText = pointText + "."; indentation = new Indentation() { Left = "360", Right = "360", FirstLine = "640" }; } var paragraphProperties = new ParagraphProperties( numberingProperties, spacingBetweenLines, indentation); var newPara = new Paragraph(paragraphProperties); if (pointText.Contains('^')) { var split = pointText.Split('^'); if (split.Count() > 1) { for (int k = 0; k < split.Count(); k++) { if (k > 0) { newPara.AppendChild(GetWordTextElement(split[k][0].ToString(), 26, false, true)); } if (k == 0) { newPara.AppendChild(GetWordTextElement(split[k], 26)); } else if (split[k].Length > 1) { newPara.AppendChild(GetWordTextElement(split[k].Substring(1), 26)); } } } else { newPara.AppendChild(GetWordTextElement(pointText, 26)); } } else { newPara.AppendChild(GetWordTextElement(pointText, 26)); } // if (pointText.Contains('^')) // { // var split = pointText.Split("^2"); // if (split.Count() > 1) // { // for (int k = 0; k < split.Count(); k++) // { // if (k > 0) // { // newPara.AppendChild(GetWordTextElement("2", 26, false, true)); // } // newPara.AppendChild(GetWordTextElement(split[k], 26)); // } // // var split2 = s.Split("^3"); // // if (s.Count() > 1) // // { // // } // } // else // { // split = pointText.Split("^3"); // if (split.Count() > 1) // { // for (int k = 0; k < split.Count(); k++) // { // if (k > 0) // { // newPara.AppendChild(GetWordTextElement("3", 26, false, true)); // } // newPara.AppendChild(GetWordTextElement(split[k], 26)); // } // } // else // newPara.AppendChild(GetWordTextElement(pointText, 26)); // } // } // else // newPara.AppendChild(GetWordTextElement(pointText, 26)); body.PrependChild(newPara); } }
// Generates content of numberingDefinitionsPart1. internal static void GenerateNumberingDefinitionsPart1Content(NumberingDefinitionsPart numberingDefinitionsPart1) { Numbering numbering1 = new Numbering() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 w15 w16se w16cid w16 w16cex wp14" } }; numbering1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"); numbering1.AddNamespaceDeclaration("cx", "http://schemas.microsoft.com/office/drawing/2014/chartex"); numbering1.AddNamespaceDeclaration("cx1", "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex"); numbering1.AddNamespaceDeclaration("cx2", "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex"); numbering1.AddNamespaceDeclaration("cx3", "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex"); numbering1.AddNamespaceDeclaration("cx4", "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex"); numbering1.AddNamespaceDeclaration("cx5", "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex"); numbering1.AddNamespaceDeclaration("cx6", "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex"); numbering1.AddNamespaceDeclaration("cx7", "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex"); numbering1.AddNamespaceDeclaration("cx8", "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex"); numbering1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); numbering1.AddNamespaceDeclaration("aink", "http://schemas.microsoft.com/office/drawing/2016/ink"); numbering1.AddNamespaceDeclaration("am3d", "http://schemas.microsoft.com/office/drawing/2017/model3d"); numbering1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office"); numbering1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); numbering1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"); numbering1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml"); numbering1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"); numbering1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"); numbering1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word"); numbering1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main"); numbering1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml"); numbering1.AddNamespaceDeclaration("w15", "http://schemas.microsoft.com/office/word/2012/wordml"); numbering1.AddNamespaceDeclaration("w16cex", "http://schemas.microsoft.com/office/word/2018/wordml/cex"); numbering1.AddNamespaceDeclaration("w16cid", "http://schemas.microsoft.com/office/word/2016/wordml/cid"); numbering1.AddNamespaceDeclaration("w16", "http://schemas.microsoft.com/office/word/2018/wordml"); numbering1.AddNamespaceDeclaration("w16se", "http://schemas.microsoft.com/office/word/2015/wordml/symex"); numbering1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"); numbering1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk"); numbering1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml"); numbering1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"); AbstractNum abstractNum1 = new AbstractNum() { AbstractNumberId = 0 }; abstractNum1.SetAttribute(new OpenXmlAttribute("w15", "restartNumberingAfterBreak", "http://schemas.microsoft.com/office/word/2012/wordml", "0")); Nsid nsid1 = new Nsid() { Val = "3D494EF0" }; MultiLevelType multiLevelType1 = new MultiLevelType() { Val = MultiLevelValues.HybridMultilevel }; TemplateCode templateCode1 = new TemplateCode() { Val = "3A6EFE6E" }; Level level1 = new Level() { LevelIndex = 0, TemplateCode = "380A0001" }; StartNumberingValue startNumberingValue1 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat1 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText1 = new LevelText() { Val = "·" }; LevelJustification levelJustification1 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties1 = new PreviousParagraphProperties(); Indentation indentation2 = new Indentation() { Start = "720", Hanging = "360" }; previousParagraphProperties1.Append(indentation2); NumberingSymbolRunProperties numberingSymbolRunProperties1 = new NumberingSymbolRunProperties(); RunFonts runFonts2 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol" }; numberingSymbolRunProperties1.Append(runFonts2); level1.Append(startNumberingValue1); level1.Append(numberingFormat1); level1.Append(levelText1); level1.Append(levelJustification1); level1.Append(previousParagraphProperties1); level1.Append(numberingSymbolRunProperties1); Level level2 = new Level() { LevelIndex = 1, TemplateCode = "380A0003", Tentative = true }; StartNumberingValue startNumberingValue2 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat2 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText2 = new LevelText() { Val = "o" }; LevelJustification levelJustification2 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties2 = new PreviousParagraphProperties(); Indentation indentation3 = new Indentation() { Start = "1440", Hanging = "360" }; previousParagraphProperties2.Append(indentation3); NumberingSymbolRunProperties numberingSymbolRunProperties2 = new NumberingSymbolRunProperties(); RunFonts runFonts3 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" }; numberingSymbolRunProperties2.Append(runFonts3); level2.Append(startNumberingValue2); level2.Append(numberingFormat2); level2.Append(levelText2); level2.Append(levelJustification2); level2.Append(previousParagraphProperties2); level2.Append(numberingSymbolRunProperties2); Level level3 = new Level() { LevelIndex = 2, TemplateCode = "380A0005", Tentative = true }; StartNumberingValue startNumberingValue3 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat3 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText3 = new LevelText() { Val = "§" }; LevelJustification levelJustification3 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties3 = new PreviousParagraphProperties(); Indentation indentation4 = new Indentation() { Start = "2160", Hanging = "360" }; previousParagraphProperties3.Append(indentation4); NumberingSymbolRunProperties numberingSymbolRunProperties3 = new NumberingSymbolRunProperties(); RunFonts runFonts4 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties3.Append(runFonts4); level3.Append(startNumberingValue3); level3.Append(numberingFormat3); level3.Append(levelText3); level3.Append(levelJustification3); level3.Append(previousParagraphProperties3); level3.Append(numberingSymbolRunProperties3); Level level4 = new Level() { LevelIndex = 3, TemplateCode = "380A0001", Tentative = true }; StartNumberingValue startNumberingValue4 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat4 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText4 = new LevelText() { Val = "·" }; LevelJustification levelJustification4 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties4 = new PreviousParagraphProperties(); Indentation indentation5 = new Indentation() { Start = "2880", Hanging = "360" }; previousParagraphProperties4.Append(indentation5); NumberingSymbolRunProperties numberingSymbolRunProperties4 = new NumberingSymbolRunProperties(); RunFonts runFonts5 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol" }; numberingSymbolRunProperties4.Append(runFonts5); level4.Append(startNumberingValue4); level4.Append(numberingFormat4); level4.Append(levelText4); level4.Append(levelJustification4); level4.Append(previousParagraphProperties4); level4.Append(numberingSymbolRunProperties4); Level level5 = new Level() { LevelIndex = 4, TemplateCode = "380A0003", Tentative = true }; StartNumberingValue startNumberingValue5 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat5 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText5 = new LevelText() { Val = "o" }; LevelJustification levelJustification5 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties5 = new PreviousParagraphProperties(); Indentation indentation6 = new Indentation() { Start = "3600", Hanging = "360" }; previousParagraphProperties5.Append(indentation6); NumberingSymbolRunProperties numberingSymbolRunProperties5 = new NumberingSymbolRunProperties(); RunFonts runFonts6 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" }; numberingSymbolRunProperties5.Append(runFonts6); level5.Append(startNumberingValue5); level5.Append(numberingFormat5); level5.Append(levelText5); level5.Append(levelJustification5); level5.Append(previousParagraphProperties5); level5.Append(numberingSymbolRunProperties5); Level level6 = new Level() { LevelIndex = 5, TemplateCode = "380A0005", Tentative = true }; StartNumberingValue startNumberingValue6 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat6 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText6 = new LevelText() { Val = "§" }; LevelJustification levelJustification6 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties6 = new PreviousParagraphProperties(); Indentation indentation7 = new Indentation() { Start = "4320", Hanging = "360" }; previousParagraphProperties6.Append(indentation7); NumberingSymbolRunProperties numberingSymbolRunProperties6 = new NumberingSymbolRunProperties(); RunFonts runFonts7 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties6.Append(runFonts7); level6.Append(startNumberingValue6); level6.Append(numberingFormat6); level6.Append(levelText6); level6.Append(levelJustification6); level6.Append(previousParagraphProperties6); level6.Append(numberingSymbolRunProperties6); Level level7 = new Level() { LevelIndex = 6, TemplateCode = "380A0001", Tentative = true }; StartNumberingValue startNumberingValue7 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat7 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText7 = new LevelText() { Val = "·" }; LevelJustification levelJustification7 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties7 = new PreviousParagraphProperties(); Indentation indentation8 = new Indentation() { Start = "5040", Hanging = "360" }; previousParagraphProperties7.Append(indentation8); NumberingSymbolRunProperties numberingSymbolRunProperties7 = new NumberingSymbolRunProperties(); RunFonts runFonts8 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol" }; numberingSymbolRunProperties7.Append(runFonts8); level7.Append(startNumberingValue7); level7.Append(numberingFormat7); level7.Append(levelText7); level7.Append(levelJustification7); level7.Append(previousParagraphProperties7); level7.Append(numberingSymbolRunProperties7); Level level8 = new Level() { LevelIndex = 7, TemplateCode = "380A0003", Tentative = true }; StartNumberingValue startNumberingValue8 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat8 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText8 = new LevelText() { Val = "o" }; LevelJustification levelJustification8 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties8 = new PreviousParagraphProperties(); Indentation indentation9 = new Indentation() { Start = "5760", Hanging = "360" }; previousParagraphProperties8.Append(indentation9); NumberingSymbolRunProperties numberingSymbolRunProperties8 = new NumberingSymbolRunProperties(); RunFonts runFonts9 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" }; numberingSymbolRunProperties8.Append(runFonts9); level8.Append(startNumberingValue8); level8.Append(numberingFormat8); level8.Append(levelText8); level8.Append(levelJustification8); level8.Append(previousParagraphProperties8); level8.Append(numberingSymbolRunProperties8); Level level9 = new Level() { LevelIndex = 8, TemplateCode = "380A0005", Tentative = true }; StartNumberingValue startNumberingValue9 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat9 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText9 = new LevelText() { Val = "§" }; LevelJustification levelJustification9 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties9 = new PreviousParagraphProperties(); Indentation indentation10 = new Indentation() { Start = "6480", Hanging = "360" }; previousParagraphProperties9.Append(indentation10); NumberingSymbolRunProperties numberingSymbolRunProperties9 = new NumberingSymbolRunProperties(); RunFonts runFonts10 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties9.Append(runFonts10); level9.Append(startNumberingValue9); level9.Append(numberingFormat9); level9.Append(levelText9); level9.Append(levelJustification9); level9.Append(previousParagraphProperties9); level9.Append(numberingSymbolRunProperties9); abstractNum1.Append(nsid1); abstractNum1.Append(multiLevelType1); abstractNum1.Append(templateCode1); abstractNum1.Append(level1); abstractNum1.Append(level2); abstractNum1.Append(level3); abstractNum1.Append(level4); abstractNum1.Append(level5); abstractNum1.Append(level6); abstractNum1.Append(level7); abstractNum1.Append(level8); abstractNum1.Append(level9); AbstractNum abstractNum2 = new AbstractNum() { AbstractNumberId = 1 }; abstractNum2.SetAttribute(new OpenXmlAttribute("w15", "restartNumberingAfterBreak", "http://schemas.microsoft.com/office/word/2012/wordml", "0")); Nsid nsid2 = new Nsid() { Val = "47DE622F" }; MultiLevelType multiLevelType2 = new MultiLevelType() { Val = MultiLevelValues.HybridMultilevel }; TemplateCode templateCode2 = new TemplateCode() { Val = "7C9283E6" }; Level level10 = new Level() { LevelIndex = 0, TemplateCode = "380A000F" }; StartNumberingValue startNumberingValue10 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat10 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; LevelText levelText10 = new LevelText() { Val = "%1." }; LevelJustification levelJustification10 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties10 = new PreviousParagraphProperties(); Indentation indentation11 = new Indentation() { Start = "720", Hanging = "360" }; previousParagraphProperties10.Append(indentation11); NumberingSymbolRunProperties numberingSymbolRunProperties10 = new NumberingSymbolRunProperties(); RunFonts runFonts11 = new RunFonts() { Hint = FontTypeHintValues.Default }; numberingSymbolRunProperties10.Append(runFonts11); level10.Append(startNumberingValue10); level10.Append(numberingFormat10); level10.Append(levelText10); level10.Append(levelJustification10); level10.Append(previousParagraphProperties10); level10.Append(numberingSymbolRunProperties10); Level level11 = new Level() { LevelIndex = 1, TemplateCode = "380A000F" }; StartNumberingValue startNumberingValue11 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat11 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; LevelText levelText11 = new LevelText() { Val = "%2." }; LevelJustification levelJustification11 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties11 = new PreviousParagraphProperties(); Indentation indentation12 = new Indentation() { Start = "1440", Hanging = "360" }; previousParagraphProperties11.Append(indentation12); NumberingSymbolRunProperties numberingSymbolRunProperties11 = new NumberingSymbolRunProperties(); RunFonts runFonts12 = new RunFonts() { Hint = FontTypeHintValues.Default }; numberingSymbolRunProperties11.Append(runFonts12); level11.Append(startNumberingValue11); level11.Append(numberingFormat11); level11.Append(levelText11); level11.Append(levelJustification11); level11.Append(previousParagraphProperties11); level11.Append(numberingSymbolRunProperties11); Level level12 = new Level() { LevelIndex = 2, TemplateCode = "380A0005" }; StartNumberingValue startNumberingValue12 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat12 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText12 = new LevelText() { Val = "§" }; LevelJustification levelJustification12 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties12 = new PreviousParagraphProperties(); Indentation indentation13 = new Indentation() { Start = "2160", Hanging = "360" }; previousParagraphProperties12.Append(indentation13); NumberingSymbolRunProperties numberingSymbolRunProperties12 = new NumberingSymbolRunProperties(); RunFonts runFonts13 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties12.Append(runFonts13); level12.Append(startNumberingValue12); level12.Append(numberingFormat12); level12.Append(levelText12); level12.Append(levelJustification12); level12.Append(previousParagraphProperties12); level12.Append(numberingSymbolRunProperties12); Level level13 = new Level() { LevelIndex = 3, TemplateCode = "380A0001" }; StartNumberingValue startNumberingValue13 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat13 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText13 = new LevelText() { Val = "·" }; LevelJustification levelJustification13 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties13 = new PreviousParagraphProperties(); Indentation indentation14 = new Indentation() { Start = "2880", Hanging = "360" }; previousParagraphProperties13.Append(indentation14); NumberingSymbolRunProperties numberingSymbolRunProperties13 = new NumberingSymbolRunProperties(); RunFonts runFonts14 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol" }; numberingSymbolRunProperties13.Append(runFonts14); level13.Append(startNumberingValue13); level13.Append(numberingFormat13); level13.Append(levelText13); level13.Append(levelJustification13); level13.Append(previousParagraphProperties13); level13.Append(numberingSymbolRunProperties13); Level level14 = new Level() { LevelIndex = 4, TemplateCode = "380A0003", Tentative = true }; StartNumberingValue startNumberingValue14 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat14 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText14 = new LevelText() { Val = "o" }; LevelJustification levelJustification14 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties14 = new PreviousParagraphProperties(); Indentation indentation15 = new Indentation() { Start = "3600", Hanging = "360" }; previousParagraphProperties14.Append(indentation15); NumberingSymbolRunProperties numberingSymbolRunProperties14 = new NumberingSymbolRunProperties(); RunFonts runFonts15 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" }; numberingSymbolRunProperties14.Append(runFonts15); level14.Append(startNumberingValue14); level14.Append(numberingFormat14); level14.Append(levelText14); level14.Append(levelJustification14); level14.Append(previousParagraphProperties14); level14.Append(numberingSymbolRunProperties14); Level level15 = new Level() { LevelIndex = 5, TemplateCode = "380A0005", Tentative = true }; StartNumberingValue startNumberingValue15 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat15 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText15 = new LevelText() { Val = "§" }; LevelJustification levelJustification15 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties15 = new PreviousParagraphProperties(); Indentation indentation16 = new Indentation() { Start = "4320", Hanging = "360" }; previousParagraphProperties15.Append(indentation16); NumberingSymbolRunProperties numberingSymbolRunProperties15 = new NumberingSymbolRunProperties(); RunFonts runFonts16 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties15.Append(runFonts16); level15.Append(startNumberingValue15); level15.Append(numberingFormat15); level15.Append(levelText15); level15.Append(levelJustification15); level15.Append(previousParagraphProperties15); level15.Append(numberingSymbolRunProperties15); Level level16 = new Level() { LevelIndex = 6, TemplateCode = "380A0001", Tentative = true }; StartNumberingValue startNumberingValue16 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat16 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText16 = new LevelText() { Val = "·" }; LevelJustification levelJustification16 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties16 = new PreviousParagraphProperties(); Indentation indentation17 = new Indentation() { Start = "5040", Hanging = "360" }; previousParagraphProperties16.Append(indentation17); NumberingSymbolRunProperties numberingSymbolRunProperties16 = new NumberingSymbolRunProperties(); RunFonts runFonts17 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Symbol", HighAnsi = "Symbol" }; numberingSymbolRunProperties16.Append(runFonts17); level16.Append(startNumberingValue16); level16.Append(numberingFormat16); level16.Append(levelText16); level16.Append(levelJustification16); level16.Append(previousParagraphProperties16); level16.Append(numberingSymbolRunProperties16); Level level17 = new Level() { LevelIndex = 7, TemplateCode = "380A0003", Tentative = true }; StartNumberingValue startNumberingValue17 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat17 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText17 = new LevelText() { Val = "o" }; LevelJustification levelJustification17 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties17 = new PreviousParagraphProperties(); Indentation indentation18 = new Indentation() { Start = "5760", Hanging = "360" }; previousParagraphProperties17.Append(indentation18); NumberingSymbolRunProperties numberingSymbolRunProperties17 = new NumberingSymbolRunProperties(); RunFonts runFonts18 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Courier New", HighAnsi = "Courier New", ComplexScript = "Courier New" }; numberingSymbolRunProperties17.Append(runFonts18); level17.Append(startNumberingValue17); level17.Append(numberingFormat17); level17.Append(levelText17); level17.Append(levelJustification17); level17.Append(previousParagraphProperties17); level17.Append(numberingSymbolRunProperties17); Level level18 = new Level() { LevelIndex = 8, TemplateCode = "380A0005", Tentative = true }; StartNumberingValue startNumberingValue18 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat18 = new NumberingFormat() { Val = NumberFormatValues.Bullet }; LevelText levelText18 = new LevelText() { Val = "§" }; LevelJustification levelJustification18 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties18 = new PreviousParagraphProperties(); Indentation indentation19 = new Indentation() { Start = "6480", Hanging = "360" }; previousParagraphProperties18.Append(indentation19); NumberingSymbolRunProperties numberingSymbolRunProperties18 = new NumberingSymbolRunProperties(); RunFonts runFonts19 = new RunFonts() { Hint = FontTypeHintValues.Default, Ascii = "Wingdings", HighAnsi = "Wingdings" }; numberingSymbolRunProperties18.Append(runFonts19); level18.Append(startNumberingValue18); level18.Append(numberingFormat18); level18.Append(levelText18); level18.Append(levelJustification18); level18.Append(previousParagraphProperties18); level18.Append(numberingSymbolRunProperties18); abstractNum2.Append(nsid2); abstractNum2.Append(multiLevelType2); abstractNum2.Append(templateCode2); abstractNum2.Append(level10); abstractNum2.Append(level11); abstractNum2.Append(level12); abstractNum2.Append(level13); abstractNum2.Append(level14); abstractNum2.Append(level15); abstractNum2.Append(level16); abstractNum2.Append(level17); abstractNum2.Append(level18); AbstractNum abstractNum3 = new AbstractNum() { AbstractNumberId = 2 }; abstractNum3.SetAttribute(new OpenXmlAttribute("w15", "restartNumberingAfterBreak", "http://schemas.microsoft.com/office/word/2012/wordml", "0")); Nsid nsid3 = new Nsid() { Val = "4F9A041C" }; MultiLevelType multiLevelType3 = new MultiLevelType() { Val = MultiLevelValues.HybridMultilevel }; TemplateCode templateCode3 = new TemplateCode() { Val = "A1C80EC8" }; Level level19 = new Level() { LevelIndex = 0, TemplateCode = "380A000F" }; StartNumberingValue startNumberingValue19 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat19 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; LevelText levelText19 = new LevelText() { Val = "%1." }; LevelJustification levelJustification19 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties19 = new PreviousParagraphProperties(); Indentation indentation20 = new Indentation() { Start = "720", Hanging = "360" }; previousParagraphProperties19.Append(indentation20); level19.Append(startNumberingValue19); level19.Append(numberingFormat19); level19.Append(levelText19); level19.Append(levelJustification19); level19.Append(previousParagraphProperties19); Level level20 = new Level() { LevelIndex = 1, TemplateCode = "380A0019" }; StartNumberingValue startNumberingValue20 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat20 = new NumberingFormat() { Val = NumberFormatValues.LowerLetter }; LevelText levelText20 = new LevelText() { Val = "%2." }; LevelJustification levelJustification20 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties20 = new PreviousParagraphProperties(); Indentation indentation21 = new Indentation() { Start = "1440", Hanging = "360" }; previousParagraphProperties20.Append(indentation21); level20.Append(startNumberingValue20); level20.Append(numberingFormat20); level20.Append(levelText20); level20.Append(levelJustification20); level20.Append(previousParagraphProperties20); Level level21 = new Level() { LevelIndex = 2, TemplateCode = "380A001B", Tentative = true }; StartNumberingValue startNumberingValue21 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat21 = new NumberingFormat() { Val = NumberFormatValues.LowerRoman }; LevelText levelText21 = new LevelText() { Val = "%3." }; LevelJustification levelJustification21 = new LevelJustification() { Val = LevelJustificationValues.Right }; PreviousParagraphProperties previousParagraphProperties21 = new PreviousParagraphProperties(); Indentation indentation22 = new Indentation() { Start = "2160", Hanging = "180" }; previousParagraphProperties21.Append(indentation22); level21.Append(startNumberingValue21); level21.Append(numberingFormat21); level21.Append(levelText21); level21.Append(levelJustification21); level21.Append(previousParagraphProperties21); Level level22 = new Level() { LevelIndex = 3, TemplateCode = "380A000F", Tentative = true }; StartNumberingValue startNumberingValue22 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat22 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; LevelText levelText22 = new LevelText() { Val = "%4." }; LevelJustification levelJustification22 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties22 = new PreviousParagraphProperties(); Indentation indentation23 = new Indentation() { Start = "2880", Hanging = "360" }; previousParagraphProperties22.Append(indentation23); level22.Append(startNumberingValue22); level22.Append(numberingFormat22); level22.Append(levelText22); level22.Append(levelJustification22); level22.Append(previousParagraphProperties22); Level level23 = new Level() { LevelIndex = 4, TemplateCode = "380A0019", Tentative = true }; StartNumberingValue startNumberingValue23 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat23 = new NumberingFormat() { Val = NumberFormatValues.LowerLetter }; LevelText levelText23 = new LevelText() { Val = "%5." }; LevelJustification levelJustification23 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties23 = new PreviousParagraphProperties(); Indentation indentation24 = new Indentation() { Start = "3600", Hanging = "360" }; previousParagraphProperties23.Append(indentation24); level23.Append(startNumberingValue23); level23.Append(numberingFormat23); level23.Append(levelText23); level23.Append(levelJustification23); level23.Append(previousParagraphProperties23); Level level24 = new Level() { LevelIndex = 5, TemplateCode = "380A001B", Tentative = true }; StartNumberingValue startNumberingValue24 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat24 = new NumberingFormat() { Val = NumberFormatValues.LowerRoman }; LevelText levelText24 = new LevelText() { Val = "%6." }; LevelJustification levelJustification24 = new LevelJustification() { Val = LevelJustificationValues.Right }; PreviousParagraphProperties previousParagraphProperties24 = new PreviousParagraphProperties(); Indentation indentation25 = new Indentation() { Start = "4320", Hanging = "180" }; previousParagraphProperties24.Append(indentation25); level24.Append(startNumberingValue24); level24.Append(numberingFormat24); level24.Append(levelText24); level24.Append(levelJustification24); level24.Append(previousParagraphProperties24); Level level25 = new Level() { LevelIndex = 6, TemplateCode = "380A000F", Tentative = true }; StartNumberingValue startNumberingValue25 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat25 = new NumberingFormat() { Val = NumberFormatValues.Decimal }; LevelText levelText25 = new LevelText() { Val = "%7." }; LevelJustification levelJustification25 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties25 = new PreviousParagraphProperties(); Indentation indentation26 = new Indentation() { Start = "5040", Hanging = "360" }; previousParagraphProperties25.Append(indentation26); level25.Append(startNumberingValue25); level25.Append(numberingFormat25); level25.Append(levelText25); level25.Append(levelJustification25); level25.Append(previousParagraphProperties25); Level level26 = new Level() { LevelIndex = 7, TemplateCode = "380A0019", Tentative = true }; StartNumberingValue startNumberingValue26 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat26 = new NumberingFormat() { Val = NumberFormatValues.LowerLetter }; LevelText levelText26 = new LevelText() { Val = "%8." }; LevelJustification levelJustification26 = new LevelJustification() { Val = LevelJustificationValues.Left }; PreviousParagraphProperties previousParagraphProperties26 = new PreviousParagraphProperties(); Indentation indentation27 = new Indentation() { Start = "5760", Hanging = "360" }; previousParagraphProperties26.Append(indentation27); level26.Append(startNumberingValue26); level26.Append(numberingFormat26); level26.Append(levelText26); level26.Append(levelJustification26); level26.Append(previousParagraphProperties26); Level level27 = new Level() { LevelIndex = 8, TemplateCode = "380A001B", Tentative = true }; StartNumberingValue startNumberingValue27 = new StartNumberingValue() { Val = 1 }; NumberingFormat numberingFormat27 = new NumberingFormat() { Val = NumberFormatValues.LowerRoman }; LevelText levelText27 = new LevelText() { Val = "%9." }; LevelJustification levelJustification27 = new LevelJustification() { Val = LevelJustificationValues.Right }; PreviousParagraphProperties previousParagraphProperties27 = new PreviousParagraphProperties(); Indentation indentation28 = new Indentation() { Start = "6480", Hanging = "180" }; previousParagraphProperties27.Append(indentation28); level27.Append(startNumberingValue27); level27.Append(numberingFormat27); level27.Append(levelText27); level27.Append(levelJustification27); level27.Append(previousParagraphProperties27); abstractNum3.Append(nsid3); abstractNum3.Append(multiLevelType3); abstractNum3.Append(templateCode3); abstractNum3.Append(level19); abstractNum3.Append(level20); abstractNum3.Append(level21); abstractNum3.Append(level22); abstractNum3.Append(level23); abstractNum3.Append(level24); abstractNum3.Append(level25); abstractNum3.Append(level26); abstractNum3.Append(level27); NumberingInstance numberingInstance1 = new NumberingInstance() { NumberID = 1 }; AbstractNumId abstractNumId1 = new AbstractNumId() { Val = 2 }; numberingInstance1.Append(abstractNumId1); NumberingInstance numberingInstance2 = new NumberingInstance() { NumberID = 2 }; AbstractNumId abstractNumId2 = new AbstractNumId() { Val = 1 }; numberingInstance2.Append(abstractNumId2); NumberingInstance numberingInstance3 = new NumberingInstance() { NumberID = 3 }; AbstractNumId abstractNumId3 = new AbstractNumId() { Val = 0 }; numberingInstance3.Append(abstractNumId3); numbering1.Append(abstractNum1); numbering1.Append(abstractNum2); numbering1.Append(abstractNum3); numbering1.Append(numberingInstance1); numbering1.Append(numberingInstance2); numbering1.Append(numberingInstance3); numberingDefinitionsPart1.Numbering = numbering1; }