From 57c742dbeecf193a19d8e06e3aa37fd89d68cbff Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Wed, 11 Dec 2024 22:45:46 +0100 Subject: [PATCH] Enhance WordList class with detailed XML documentation for private methods related to numbering and list management. --- OfficeIMO.Word/WordList.Private.cs | 41 +++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/OfficeIMO.Word/WordList.Private.cs b/OfficeIMO.Word/WordList.Private.cs index a3a706e..93321ad 100644 --- a/OfficeIMO.Word/WordList.Private.cs +++ b/OfficeIMO.Word/WordList.Private.cs @@ -4,11 +4,18 @@ namespace OfficeIMO.Word; public partial class WordList : WordElement { + /// + /// Retrieves the associated with this list. + /// private AbstractNum GetAbstractNum() { return _document._wordprocessingDocument.MainDocumentPart!.NumberingDefinitionsPart!.Numbering .Elements().FirstOrDefault(a => a.AbstractNumberId.Value == _abstractId); } + /// + /// Gets the next available abstract numbering ID. + /// + /// The numbering definitions. private static int GetNextAbstractNum(Numbering numbering) { var ids = numbering.ChildElements .OfType() @@ -17,6 +24,10 @@ private static int GetNextAbstractNum(Numbering numbering) { return ids.Count > 0 ? ids.Max() + 1 : 0; } + /// + /// Gets the next available numbering instance ID. + /// + /// The numbering definitions. private static int GetNextNumberingInstance(Numbering numbering) { var ids = numbering.ChildElements .OfType() @@ -25,6 +36,12 @@ private static int GetNextNumberingInstance(Numbering numbering) { return ids.Count > 0 ? ids.Max() + 1 : 1; } + /// + /// Gets a numbering property using a selector function. + /// + /// The type of the property. + /// The selector function to extract the property. + /// The default value if the property is not found. private T GetNumberingProperty(Func propertySelector, T defaultValue = default) { var abstractNum = GetAbstractNum(); var level = abstractNum?.Elements().FirstOrDefault(); @@ -37,6 +54,11 @@ private T GetNumberingProperty(Func property return defaultValue; } + /// + /// Sets a numbering property using the specified action. + /// + /// The action to set the property. + /// Indicates whether to apply the property when it is null. private void SetNumberingProperty(Action setProperty, bool applyWhenNull = false) { var abstractNum = GetAbstractNum(); if (abstractNum != null) { @@ -53,7 +75,10 @@ private void SetNumberingProperty(Action setProper } } - + /// + /// Creates the numbering definitions part if it doesn't exist. + /// + /// The Word document. private void CreateNumberingDefinition(WordDocument document) { var numberingDefinitionsPart = document._wordprocessingDocument.MainDocumentPart!.NumberingDefinitionsPart ?? _wordprocessingDocument.MainDocumentPart!.AddNewPart(); if (numberingDefinitionsPart.Numbering == null) { @@ -98,11 +123,21 @@ private void CreateNumberingDefinition(WordDocument document) { } } + /// + /// Creates a default numbering instance. + /// + /// The abstract numbering ID. + /// The numbering instance ID. private NumberingInstance DefaultNumberingInstance(AbstractNumId abstractNumId, int numberId) { var numberingInstance = new NumberingInstance(abstractNumId) { NumberID = numberId }; return numberingInstance; } + /// + /// Creates a numbering instance that restarts numbering after a break. + /// + /// The abstract numbering ID. + /// The numbering instance ID. private NumberingInstance RestartNumberingInstance(AbstractNumId abstractNumId, int numberId) { NumberingInstance numberingInstance1 = new NumberingInstance(abstractNumId) { NumberID = numberId }; @@ -163,6 +198,10 @@ private NumberingInstance RestartNumberingInstance(AbstractNumId abstractNumId, return numberingInstance1; } + /// + /// Adds a list to the document with the specified style. + /// + /// The list style to apply. internal void AddList(WordListStyle style) { CreateNumberingDefinition(_document); var numbering = _document._wordprocessingDocument.MainDocumentPart!.NumberingDefinitionsPart!.Numbering;