Beispiel #1
0
        /**
         * Returns numbering format for this paragraph, eg bullet or
         *  lowerLetter.
         * Returns null if this paragraph does not have numeric style.
         */
        public String GetNumFmt()
        {
            string        numID     = GetNumID();
            XWPFNumbering numbering = document.GetNumbering();

            if (numID != null && numbering != null)
            {
                XWPFNum num = numbering.GetNum(numID);
                if (num != null)
                {
                    string         ilvl          = GetNumIlvl();
                    string         abstractNumId = num.GetCTNum().abstractNumId.val;
                    CT_AbstractNum anum          = numbering.GetAbstractNum(abstractNumId).GetAbstractNum();
                    CT_Lvl         level         = null;
                    for (int i = 0; i < anum.lvl.Count; i++)
                    {
                        CT_Lvl lvl = anum.lvl[i];
                        if (lvl.ilvl.Equals(ilvl))
                        {
                            level = lvl;
                            break;
                        }
                    }
                    if (level != null)
                    {
                        return(level.numFmt.val.ToString());
                    }
                }
            }
            return(null);
        }
Beispiel #2
0
        public void TestOverrideList()
        {
            XWPFDocument  doc       = XWPFTestDataSamples.OpenSampleDocument("NumberingWOverrides.docx");
            XWPFParagraph p         = doc.Paragraphs[(4)];
            XWPFNumbering numbering = doc.GetNumbering();
            CT_Num        ctNum     = numbering.GetNum(p.GetNumID()).GetCTNum();

            Assert.AreEqual(9, ctNum.SizeOfLvlOverrideArray());
            CT_NumLvl ctNumLvl = ctNum.GetLvlOverrideArray(0);

            Assert.AreEqual("upperLetter", ctNumLvl.lvl.numFmt.val.ToString());
        }
Beispiel #3
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);
        }
Beispiel #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);
        }
Beispiel #5
0
        public void TestOverrideList()
        {
            //TODO: for now the try/catch block ensures loading/inclusion of CTNumLevel
            //for down stream Processing.
            //Ideally, we should find files that actually use overrides and test against those.
            //Use XWPFParagraph's GetNumStartOverride() in the actual tests

            XWPFDocument  doc = XWPFTestDataSamples.OpenSampleDocument("Numbering.docx");
            XWPFParagraph p = doc.Paragraphs[(18)]; XWPFNumbering numbering = doc.CreateNumbering();
            bool          ex = false;

            Assert.IsNull(p.GetNumStartOverride());
            try
            {
                numbering.GetNum(p.GetNumID()).GetCTNum().GetLvlOverrideArray(1);
            }
            catch (ArgumentOutOfRangeException e)
            {
                ex = true;
            }
            Assert.IsTrue(ex);
        }