Exemplo n.º 1
0
        /**
         * read numbering form an existing package
         */

        internal override void OnDocumentRead()
        {
            NumberingDocument numberingDoc = null;

            XDocument doc = ConvertStreamToXml(GetPackagePart().GetInputStream());

            try
            {
                numberingDoc = NumberingDocument.Parse(doc, NamespaceManager);
                ctNumbering  = numberingDoc.Numbering;
                //get any Nums
                foreach (CT_Num ctNum in ctNumbering.GetNumList())
                {
                    nums.Add(new XWPFNum(ctNum, this));
                }
                foreach (CT_AbstractNum ctAbstractNum in ctNumbering.GetAbstractNumList())
                {
                    abstractNums.Add(new XWPFAbstractNum(ctAbstractNum, this));
                }
            }
            catch (Exception e)
            {
                throw new POIXMLException(e);
            }
        }
Exemplo n.º 2
0
        internal NumberingPart CreateNumberingPart()
        {
            CT_AbstractNum cT_AbstractNum = new CT_AbstractNum();

            cT_AbstractNum.AbstractNumId_Attr = 0;
            cT_AbstractNum.Nsid = new CT_LongHexNumber
            {
                Val_Attr = "00000001"
            };
            cT_AbstractNum.MultiLevelType = new CT_MultiLevelType
            {
                Val_Attr = ST_MultiLevelType.multilevel
            };
            cT_AbstractNum.Tmpl = new CT_LongHexNumber
            {
                Val_Attr = "00000001"
            };
            for (int i = 0; i < 9; i++)
            {
                cT_AbstractNum.Lvl.Add(NumberingLevel(i, WordOpenXmlConstants.Lists.Bulleted.LevelStyle, WordOpenXmlConstants.Lists.Bulleted.BulletTexts[i % WordOpenXmlConstants.Lists.Bulleted.BulletTexts.Length], WordOpenXmlConstants.Lists.Bulleted.BulletFonts[i % WordOpenXmlConstants.Lists.Bulleted.BulletFonts.Length], WordOpenXmlConstants.Lists.Bulleted.LevelJc, "20"));
            }
            CT_Num item = new CT_Num
            {
                NumId_Attr    = 1,
                AbstractNumId = new CT_DecimalNumber
                {
                    Val_Attr = 0
                }
            };
            NumberingPart numberingPart = new NumberingPart();
            CT_Numbering  cT_Numbering  = (CT_Numbering)numberingPart.Root;

            cT_Numbering.AbstractNum.Add(cT_AbstractNum);
            cT_Numbering.Num.Add(item);
            for (int j = 0; j < _numberedListCount; j++)
            {
                CT_AbstractNum cT_AbstractNum2 = NumberedListDefinition(j);
                CT_Num         item2           = new CT_Num
                {
                    NumId_Attr    = 2 + j,
                    AbstractNumId = new CT_DecimalNumber
                    {
                        Val_Attr = cT_AbstractNum2.AbstractNumId_Attr
                    }
                };
                cT_Numbering.AbstractNum.Add(cT_AbstractNum2);
                cT_Numbering.Num.Add(item2);
            }
            return(numberingPart);
        }
Exemplo n.º 3
0
        internal override void OnDocumentRead()
        {
            Stream inputStream = this.GetPackagePart().GetInputStream();

            try
            {
                this.ctNumbering = NumberingDocument.Parse(inputStream).Numbering;
                foreach (CT_Num num in (IEnumerable <CT_Num>) this.ctNumbering.GetNumList())
                {
                    this.nums.Add(new XWPFNum(num, this));
                }
                foreach (CT_AbstractNum abstractNum in (IEnumerable <CT_AbstractNum>) this.ctNumbering.GetAbstractNumList())
                {
                    this.abstractNums.Add(new XWPFAbstractNum(abstractNum, this));
                }
                this.isNew = false;
            }
            catch (Exception ex)
            {
                throw new POIXMLException();
            }
        }
Exemplo n.º 4
0
        /**
         * read numbering form an existing package
         */

        internal override void OnDocumentRead()
        {
            NumberingDocument numberingDoc = null;

            XmlDocument doc = ConvertStreamToXml(GetPackagePart().GetInputStream());

            try {
                numberingDoc = NumberingDocument.Parse(doc, NamespaceManager);
                ctNumbering  = numberingDoc.Numbering;
                //get any Nums
                foreach (CT_Num ctNum in ctNumbering.GetNumList())
                {
                    nums.Add(new XWPFNum(ctNum, this));
                }
                foreach (CT_AbstractNum ctAbstractNum in ctNumbering.GetAbstractNumList())
                {
                    abstractNums.Add(new XWPFAbstractNum(ctAbstractNum, this));
                }
                //isNew = false; //ElectricSquare: The field 'XWPFNumbering.isNew' is assigned but its value is never used
            } catch (Exception e) {
                throw new POIXMLException(e);
            }
        }
Exemplo n.º 5
0
        /**
         * read numbering form an existing package
         */

        internal override void OnDocumentRead()
        {
            NumberingDocument numberingDoc = null;
            Stream            is1;

            is1 = GetPackagePart().GetInputStream();
            try {
                numberingDoc = NumberingDocument.Parse(is1);
                ctNumbering  = numberingDoc.Numbering;
                //get any Nums
                foreach (CT_Num ctNum in ctNumbering.GetNumList())
                {
                    nums.Add(new XWPFNum(ctNum, this));
                }
                foreach (CT_AbstractNum ctAbstractNum in ctNumbering.GetAbstractNumList())
                {
                    abstractNums.Add(new XWPFAbstractNum(ctAbstractNum, this));
                }
                isNew = false;
            } catch (Exception) {
                throw new POIXMLException();
            }
        }
Exemplo n.º 6
0
 /**
  * Sets the ctNumbering
  * @param numbering
  */
 public void SetNumbering(CT_Numbering numbering)
 {
     ctNumbering = numbering;
 }
Exemplo n.º 7
0
        public static NumberingDocument Parse(XDocument doc, XmlNamespaceManager NameSpaceManager)
        {
            CT_Numbering obj = CT_Numbering.Parse(doc.Document.Root, NameSpaceManager);

            return(new NumberingDocument(obj));
        }
Exemplo n.º 8
0
 public NumberingDocument(CT_Numbering numbering)
 {
     this.numbering = numbering;
 }
Exemplo n.º 9
0
 public NumberingDocument()
 {
     numbering = new CT_Numbering();
 }