예제 #1
0
        /**
         * Add a new num with an abstractNumID
         * @return return NumId of the Added num
         */
        public string AddNum(string abstractNumID)
        {
            CT_Num ctNum = this.ctNumbering.AddNewNum();

            ctNum.AddNewAbstractNumId();
            ctNum.abstractNumId.val = (abstractNumID);
            ctNum.numId             = (nums.Count + 1).ToString();
            XWPFNum num = new XWPFNum(ctNum, this);

            nums.Add(num);
            return(ctNum.numId);
        }
예제 #2
0
        public void TestCompareAbstractNum()
        {
            XWPFDocument  doc       = XWPFTestDataSamples.OpenSampleDocument("Numbering.docx");
            XWPFNumbering numbering = doc.GetNumbering();
            int           numId     = 1;

            Assert.IsTrue(numbering.NumExist(numId.ToString()));
            XWPFNum         num                = numbering.GetNum(numId.ToString());
            string          abstrNumId         = num.GetCTNum().abstractNumId.val;
            XWPFAbstractNum abstractNum        = numbering.GetAbstractNum(abstrNumId);
            string          CompareAbstractNum = numbering.GetIdOfAbstractNum(abstractNum);

            Assert.AreEqual(abstrNumId, CompareAbstractNum);
        }
예제 #3
0
        /**
         * return the abstractNumID
         * If the AbstractNumID not exists
         * return null
         * @param       numID
         * @return      abstractNumID
         */
        public string GetAbstractNumID(string numID)
        {
            XWPFNum num = GetNum(numID);

            if (num == null)
            {
                return(null);
            }
            if (num.GetCTNum() == null)
            {
                return(null);
            }
            if (num.GetCTNum().abstractNumId == null)
            {
                return(null);
            }
            return(num.GetCTNum().abstractNumId.val);
        }
예제 #4
0
        public void TestAddNumberingToDoc()
        {
            string abstractNumId = "1";
            string numId         = "1";

            XWPFDocument  docOut    = new XWPFDocument();
            XWPFNumbering numbering = docOut.CreateNumbering();

            numId = numbering.AddNum(abstractNumId);

            XWPFDocument docIn = XWPFTestDataSamples.WriteOutAndReadBack(docOut);

            numbering = docIn.GetNumbering();
            Assert.IsTrue(numbering.NumExist(numId));
            XWPFNum num = numbering.GetNum(numId);

            string CompareAbstractNum = num.GetCTNum().abstractNumId.val;

            Assert.AreEqual(abstractNumId, CompareAbstractNum);
        }