Example #1
0
        // Creates an Numbering instance and adds its children.
        public static DocumentFormat.OpenXml.Wordprocessing.Numbering GenerateNumbering()
        {
            DocumentFormat.OpenXml.Wordprocessing.Numbering numberingPart = new DocumentFormat.OpenXml.Wordprocessing.Numbering()
            {
                MCAttributes = new MarkupCompatibilityAttributes()
                {
                    Ignorable = "w14 wp14"
                }
            };
            numberingPart.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            numberingPart.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            numberingPart.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            numberingPart.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            numberingPart.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            numberingPart.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            numberingPart.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            numberingPart.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            numberingPart.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            numberingPart.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            numberingPart.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            numberingPart.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            numberingPart.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            numberingPart.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            numberingPart.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            numberingPart.Append(GenerateAbstractNum10());
            numberingPart.Append(GenerateAbstractNum18());
            numberingPart.Append(GenerateNumberingInstance7());
            numberingPart.Append(GenerateNumberingInstance8());

            return(numberingPart);
        }
Example #2
0
 public void Initialize()
 {
     _wpDoc     = NumberingSample3.BuildDoc();
     _numbering = _wpDoc.MainDocumentPart.NumberingDefinitionsPart.Numbering;
     _styles    = _wpDoc.MainDocumentPart.StyleDefinitionsPart.Styles;
     _instance  = new NumberingProvider(_numbering, _styles);
 }
Example #3
0
 public static DocumentFormat.OpenXml.Wordprocessing.Numbering GenerateNumbering()
 {
     DocumentFormat.OpenXml.Wordprocessing.Numbering num = new DocumentFormat.OpenXml.Wordprocessing.Numbering();
     num.Append(GenerateAbstractNum());
     num.Append(GenerateNumberingInstance());
     return(num);
 }
Example #4
0
 public NumberingProvider(
     DocumentFormat.OpenXml.Wordprocessing.Numbering numbering,
     Styles styles)
 {
     _styles    = styles;
     _numbering = numbering;
 }
Example #5
0
 private void SetMembersFromWpDoc()
 {
     _numbering  = _wpDoc.MainDocumentPart.NumberingDefinitionsPart?.Numbering;
     _body       = _wpDoc.MainDocumentPart.Document.Body;
     _styles     = _wpDoc.MainDocumentPart.StyleDefinitionsPart.Styles;
     _nconfCache = new ConfigCache(_numbering, _styles, new ConfigFactory());
 }
Example #6
0
 public ConfigCache(
     DocumentFormat.OpenXml.Wordprocessing.Numbering numbering,
     DocumentFormat.OpenXml.Wordprocessing.Styles styles,
     IConfigFactory numberingConfigFac)
 {
     _numbering = numbering;
     _styles    = styles;
     _numberingConfigFactory = numberingConfigFac;
 }
Example #7
0
        public NumberingMapper(WordprocessingDocument wpDoc)
        {
            _body = wpDoc.MainDocumentPart.Document.Body;
            _numbering = wpDoc.MainDocumentPart.NumberingDefinitionsPart?.Numbering;
            _styles = wpDoc.MainDocumentPart.StyleDefinitionsPart.Styles;

            if (_numbering != null)
            {
                Initialize();
            }
        }
Example #8
0
        public StyleHelper(WordprocessingDocument doc)
        {
            if (doc != null)
            {
                this.doc = doc;
                if (this.doc.MainDocumentPart.StyleDefinitionsPart != null)
                {
                    this.docDefaults = this.doc.MainDocumentPart.StyleDefinitionsPart.Styles.Descendants <Word.DocDefaults>().FirstOrDefault();
                    this.styles      = this.doc.MainDocumentPart.StyleDefinitionsPart.Styles.Descendants <Word.Style>();
                }
                this.sections = this.doc.MainDocumentPart.Document.Body.Descendants <Word.SectionProperties>().ToList();
                if (this.doc.MainDocumentPart.ThemePart != null)
                {
                    this.theme = this.doc.MainDocumentPart.ThemePart;
                }
                if (this.doc.MainDocumentPart.NumberingDefinitionsPart != null &&
                    this.doc.MainDocumentPart.NumberingDefinitionsPart.Numbering != null)
                {
                    this.numbering = this.doc.MainDocumentPart.NumberingDefinitionsPart.Numbering;

                    // set all ilevel's start value for all abstractNums
                    foreach (Word.AbstractNum an in this.numbering.Descendants <Word.AbstractNum>())
                    {
                        int abstractNumId = an.AbstractNumberId.Value;
                        foreach (Word.Level lvl in an.Descendants <Word.Level>())
                        {
                            if (lvl.LevelIndex != null && lvl.StartNumberingValue != null)
                            {
                                this.nc.SetStart(abstractNumId, lvl.LevelIndex.Value, lvl.StartNumberingValue.Val);
                            }
                        }
                    }
                }
                if (this.doc.MainDocumentPart.HyperlinkRelationships != null)
                {
                    this.hyperlinkRelationships = this.doc.MainDocumentPart.HyperlinkRelationships;
                }
                if (this.doc.MainDocumentPart.DocumentSettingsPart != null &&
                    this.doc.MainDocumentPart.DocumentSettingsPart.Settings != null)
                {
                    Word.Compatibility compat = this.doc.MainDocumentPart.DocumentSettingsPart.Settings.Descendants <Word.Compatibility>().FirstOrDefault();
                    if (compat != null && compat.BalanceSingleByteDoubleByteWidth != null)
                    {
                        this.balanceSingleByteDoubleByteWidth = StyleHelper.GetToggleProperty(compat.BalanceSingleByteDoubleByteWidth);
                    }
                }
            }
        }