Exemplo n.º 1
0
        /**
         * Copy font attributes from CTFont bean into CTRPrElt bean
         */
        private void SetRunAttributes(CT_Font ctFont, CT_RPrElt pr)
        {
            if (ctFont.SizeOfBArray() > 0)
            {
                pr.AddNewB().val = (ctFont.GetBArray(0).val);
            }
            if (ctFont.sizeOfUArray() > 0)
            {
                pr.AddNewU().val = (ctFont.GetUArray(0).val);
            }
            if (ctFont.sizeOfIArray() > 0)
            {
                pr.AddNewI().val = (ctFont.GetIArray(0).val);
            }
            if (ctFont.sizeOfColorArray() > 0)
            {
                CT_Color c1 = ctFont.GetColorArray(0);
                CT_Color c2 = pr.AddNewColor();
                if (c1.IsSetAuto())
                {
                    c2.auto          = (c1.auto);
                    c2.autoSpecified = true;
                }
                if (c1.IsSetIndexed())
                {
                    c2.indexed          = (c1.indexed);
                    c2.indexedSpecified = true;
                }
                if (c1.IsSetRgb())
                {
                    c2.SetRgb(c1.rgb);
                    c2.rgbSpecified = true;
                }
                if (c1.IsSetTheme())
                {
                    c2.theme          = (c1.theme);
                    c2.themeSpecified = true;
                }
                if (c1.IsSetTint())
                {
                    c2.tint          = (c1.tint);
                    c2.tintSpecified = true;
                }
            }

            if (ctFont.sizeOfSzArray() > 0)
            {
                pr.AddNewSz().val = (ctFont.GetSzArray(0).val);
            }
            if (ctFont.sizeOfNameArray() > 0)
            {
                pr.AddNewRFont().val = (ctFont.name.val);
            }
            if (ctFont.sizeOfFamilyArray() > 0)
            {
                pr.AddNewFamily().val = (ctFont.GetFamilyArray(0).val);
            }
            if (ctFont.sizeOfSchemeArray() > 0)
            {
                pr.AddNewScheme().val = (ctFont.GetSchemeArray(0).val);
            }
            if (ctFont.sizeOfCharsetArray() > 0)
            {
                pr.AddNewCharset().val = (ctFont.GetCharsetArray(0).val);
            }
            if (ctFont.sizeOfCondenseArray() > 0)
            {
                pr.AddNewCondense().val = (ctFont.GetCondenseArray(0).val);
            }
            if (ctFont.sizeOfExtendArray() > 0)
            {
                pr.AddNewExtend().val = (ctFont.GetExtendArray(0).val);
            }
            if (ctFont.sizeOfVertAlignArray() > 0)
            {
                pr.AddNewVertAlign().val = (ctFont.GetVertAlignArray(0).val);
            }
            if (ctFont.sizeOfOutlineArray() > 0)
            {
                pr.AddNewOutline().val = (ctFont.GetOutlineArray(0).val);
            }
            if (ctFont.sizeOfShadowArray() > 0)
            {
                pr.AddNewShadow().val = (ctFont.GetShadowArray(0).val);
            }
            if (ctFont.sizeOfStrikeArray() > 0)
            {
                pr.AddNewStrike().val = (ctFont.GetStrikeArray(0).val);
            }
        }
Exemplo n.º 2
0
        public void TestCreateNew()
        {
            SharedStringsTable sst = new SharedStringsTable();

            CT_Rst st;
            int    idx;

            // Check defaults
            Assert.IsNotNull(sst.Items);
            Assert.AreEqual(0, sst.Items.Count);
            Assert.AreEqual(0, sst.Count);
            Assert.AreEqual(0, sst.UniqueCount);

            st   = new CT_Rst();
            st.t = ("Hello, World!");

            idx = sst.AddEntry(st);
            Assert.AreEqual(0, idx);
            Assert.AreEqual(1, sst.Count);
            Assert.AreEqual(1, sst.UniqueCount);

            //add the same entry again
            idx = sst.AddEntry(st);
            Assert.AreEqual(0, idx);
            Assert.AreEqual(2, sst.Count);
            Assert.AreEqual(1, sst.UniqueCount);

            //and again
            idx = sst.AddEntry(st);
            Assert.AreEqual(0, idx);
            Assert.AreEqual(3, sst.Count);
            Assert.AreEqual(1, sst.UniqueCount);

            st   = new CT_Rst();
            st.t = ("Second string");

            idx = sst.AddEntry(st);
            Assert.AreEqual(1, idx);
            Assert.AreEqual(4, sst.Count);
            Assert.AreEqual(2, sst.UniqueCount);

            //add the same entry again
            idx = sst.AddEntry(st);
            Assert.AreEqual(1, idx);
            Assert.AreEqual(5, sst.Count);
            Assert.AreEqual(2, sst.UniqueCount);

            st = new CT_Rst();
            CT_RElt   r  = st.AddNewR();
            CT_RPrElt pr = r.AddNewRPr();

            pr.AddNewColor().SetRgb(new byte[] { (byte)0xFF, 0, 0 }); //red
            pr.AddNewI().val = (true);                                //bold
            pr.AddNewB().val = (true);                                //italic
            r.t = ("Second string");

            idx = sst.AddEntry(st);
            Assert.AreEqual(2, idx);
            Assert.AreEqual(6, sst.Count);
            Assert.AreEqual(3, sst.UniqueCount);

            idx = sst.AddEntry(st);
            Assert.AreEqual(2, idx);
            Assert.AreEqual(7, sst.Count);
            Assert.AreEqual(3, sst.UniqueCount);

            //OK. the sst table is Filled, check the contents
            Assert.AreEqual(3, sst.Items.Count);
            Assert.AreEqual("Hello, World!", new XSSFRichTextString(sst.GetEntryAt(0)).ToString());
            Assert.AreEqual("Second string", new XSSFRichTextString(sst.GetEntryAt(1)).ToString());
            Assert.AreEqual("Second string", new XSSFRichTextString(sst.GetEntryAt(2)).ToString());
        }
Exemplo n.º 3
0
 private void SetRunAttributes(CT_Font ctFont, CT_RPrElt pr)
 {
     if (ctFont.sizeOfBArray() > 0)
     {
         pr.AddNewB().val = ctFont.GetBArray(0).val;
     }
     if (ctFont.sizeOfUArray() > 0)
     {
         pr.AddNewU().val = ctFont.GetUArray(0).val;
     }
     if (ctFont.sizeOfIArray() > 0)
     {
         pr.AddNewI().val = ctFont.GetIArray(0).val;
     }
     if (ctFont.sizeOfColorArray() > 0)
     {
         CT_Color colorArray = ctFont.GetColorArray(0);
         CT_Color ctColor    = pr.AddNewColor();
         if (colorArray.IsSetAuto())
         {
             ctColor.auto          = colorArray.auto;
             ctColor.autoSpecified = true;
         }
         if (colorArray.IsSetIndexed())
         {
             ctColor.indexed          = colorArray.indexed;
             ctColor.indexedSpecified = true;
         }
         if (colorArray.IsSetRgb())
         {
             ctColor.SetRgb(colorArray.rgb);
             ctColor.rgbSpecified = true;
         }
         if (colorArray.IsSetTheme())
         {
             ctColor.theme          = colorArray.theme;
             ctColor.themeSpecified = true;
         }
         if (colorArray.IsSetTint())
         {
             ctColor.tint          = colorArray.tint;
             ctColor.tintSpecified = true;
         }
     }
     if (ctFont.sizeOfSzArray() > 0)
     {
         pr.AddNewSz().val = ctFont.GetSzArray(0).val;
     }
     if (ctFont.sizeOfNameArray() > 0)
     {
         pr.AddNewRFont().val = ctFont.GetNameArray(0).val;
     }
     if (ctFont.sizeOfFamilyArray() > 0)
     {
         pr.AddNewFamily().val = ctFont.GetFamilyArray(0).val;
     }
     if (ctFont.sizeOfSchemeArray() > 0)
     {
         pr.AddNewScheme().val = ctFont.GetSchemeArray(0).val;
     }
     if (ctFont.sizeOfCharsetArray() > 0)
     {
         pr.AddNewCharset().val = ctFont.GetCharsetArray(0).val;
     }
     if (ctFont.sizeOfCondenseArray() > 0)
     {
         pr.AddNewCondense().val = ctFont.GetCondenseArray(0).val;
     }
     if (ctFont.sizeOfExtendArray() > 0)
     {
         pr.AddNewExtend().val = ctFont.GetExtendArray(0).val;
     }
     if (ctFont.sizeOfVertAlignArray() > 0)
     {
         pr.AddNewVertAlign().val = ctFont.GetVertAlignArray(0).val;
     }
     if (ctFont.sizeOfOutlineArray() > 0)
     {
         pr.AddNewOutline().val = ctFont.GetOutlineArray(0).val;
     }
     if (ctFont.sizeOfShadowArray() > 0)
     {
         pr.AddNewShadow().val = ctFont.GetShadowArray(0).val;
     }
     if (ctFont.sizeOfStrikeArray() <= 0)
     {
         return;
     }
     pr.AddNewStrike().val = ctFont.GetStrikeArray(0).val;
 }