Esempio n. 1
0
 /**
  * set the color for the font in Standard Alpha Red Green Blue color value
  *
  * @param color - color to use
  */
 public void SetColor(XSSFColor color)
 {
     if (color == null)
     {
         _ctFont.SetColorArray(null);
     }
     else
     {
         Spreadsheet.CT_Color ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.AddNewColor() : _ctFont.GetColorArray(0);
         ctColor.SetRgb(color.RGB);
     }
 }
Esempio n. 2
0
        public void TestRgbColor()
        {
            CT_Font  ctFont = new CT_Font();
            CT_Color color  = ctFont.AddNewColor();

            //Integer.toHexString(0xFFFFFF).getBytes() = [102, 102, 102, 102, 102, 102]
            color.SetRgb(Encoding.ASCII.GetBytes("ffffff"));
            ctFont.SetColorArray(0, color);

            XSSFFont xssfFont = new XSSFFont(ctFont);

            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[0], xssfFont.GetXSSFColor().RGB[0]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[1], xssfFont.GetXSSFColor().RGB[1]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[2], xssfFont.GetXSSFColor().RGB[2]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[3], xssfFont.GetXSSFColor().RGB[3]);

            xssfFont.Color = ((short)23);

            byte[] bytes = Encoding.ASCII.GetBytes(HexDump.ToHex(0xF1F1F1));
            color.rgb = (bytes);

            XSSFColor newColor = new XSSFColor(color);

            xssfFont.SetColor(newColor);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[2], newColor.RGB[2]);

            CollectionAssert.AreEqual(bytes, xssfFont.GetXSSFColor().RGB);
            Assert.AreEqual(0, xssfFont.Color);
        }
Esempio n. 3
0
        public void TestColor()
        {
            CT_Font  ctFont = new CT_Font();
            CT_Color color  = ctFont.AddNewColor();

            color.indexed = (uint)(XSSFFont.DEFAULT_FONT_COLOR);
            ctFont.SetColorArray(0, color);

            XSSFFont xssfFont = new XSSFFont(ctFont);

            Assert.AreEqual(IndexedColors.Black.Index, xssfFont.Color);

            xssfFont.Color = IndexedColors.Red.Index;
            Assert.AreEqual((uint)IndexedColors.Red.Index, ctFont.GetColorArray(0).indexed);
        }
Esempio n. 4
0
        public void TestThemeColor()
        {
            CT_Font  ctFont = new CT_Font();
            CT_Color color  = ctFont.AddNewColor();

            color.theme          = (1);
            color.themeSpecified = true;
            ctFont.SetColorArray(0, color);

            XSSFFont xssfFont = new XSSFFont(ctFont);

            Assert.AreEqual((short)ctFont.GetColorArray(0).theme, xssfFont.GetThemeColor());

            xssfFont.SetThemeColor(IndexedColors.Red.Index);
            Assert.AreEqual((uint)IndexedColors.Red.Index, ctFont.GetColorArray(0).theme);
        }
Esempio n. 5
0
        public void TestRgbColor()
        {
            CT_Font  ctFont = new CT_Font();
            CT_Color color  = ctFont.AddNewColor();

            //Integer.toHexString(0xFFFFFF).getBytes() = [102, 102, 102, 102, 102, 102]
            color.SetRgb(Encoding.ASCII.GetBytes("ffffff"));
            ctFont.SetColorArray(0, color);

            XSSFFont xssfFont = new XSSFFont(ctFont);

            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[0], xssfFont.GetXSSFColor().GetRgb()[0]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[1], xssfFont.GetXSSFColor().GetRgb()[1]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[2], xssfFont.GetXSSFColor().GetRgb()[2]);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[3], xssfFont.GetXSSFColor().GetRgb()[3]);

            //Integer.toHexString(0xF1F1F1).getBytes() = [102, 49, 102, 49, 102, 49]
            color.SetRgb(Encoding.ASCII.GetBytes("f1f1f1"));
            XSSFColor newColor = new XSSFColor(color);

            xssfFont.SetColor(newColor);
            Assert.AreEqual(ctFont.GetColorArray(0).GetRgb()[2], newColor.GetRgb()[2]);
        }
Esempio n. 6
0
        /**
         *
         * CTRPrElt --> CTFont adapter
         */
        protected static CT_Font ToCTFont(CT_RPrElt pr)
        {
            CT_Font ctFont = new CT_Font();

            if (pr.SizeOfBArray() > 0)
            {
                ctFont.AddNewB().val = (pr.GetBArray(0).val);
            }
            if (pr.SizeOfUArray() > 0)
            {
                ctFont.AddNewU().val = (pr.GetUArray(0).val);
            }
            if (pr.SizeOfIArray() > 0)
            {
                ctFont.AddNewI().val = (pr.GetIArray(0).val);
            }
            if (pr.SizeOfColorArray() > 0)
            {
                CT_Color c1 = pr.GetColorArray(0);
                CT_Color c2 = ctFont.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.GetRgb());
                    c2.rgbSpecified = true;
                }
                if (c1.IsSetTheme())
                {
                    c2.theme          = (c1.theme);
                    c2.themeSpecified = true;
                }
                if (c1.IsSetTint())
                {
                    c2.tint          = (c1.tint);
                    c2.tintSpecified = true;
                }
            }

            if (pr.SizeOfSzArray() > 0)
            {
                ctFont.AddNewSz().val = (pr.GetSzArray(0).val);
            }
            if (pr.SizeOfRFontArray() > 0)
            {
                ctFont.AddNewName().val = (pr.GetRFontArray(0).val);
            }
            if (pr.SizeOfFamilyArray() > 0)
            {
                ctFont.AddNewFamily().val = (pr.GetFamilyArray(0).val);
            }
            if (pr.sizeOfSchemeArray() > 0)
            {
                ctFont.AddNewScheme().val = (pr.GetSchemeArray(0).val);
            }
            if (pr.sizeOfCharsetArray() > 0)
            {
                ctFont.AddNewCharset().val = (pr.GetCharsetArray(0).val);
            }
            if (pr.sizeOfCondenseArray() > 0)
            {
                ctFont.AddNewCondense().val = (pr.GetCondenseArray(0).val);
            }
            if (pr.sizeOfExtendArray() > 0)
            {
                ctFont.AddNewExtend().val = (pr.GetExtendArray(0).val);
            }
            if (pr.sizeOfVertAlignArray() > 0)
            {
                ctFont.AddNewVertAlign().val = (pr.GetVertAlignArray(0).val);
            }
            if (pr.sizeOfOutlineArray() > 0)
            {
                ctFont.AddNewOutline().val = (pr.GetOutlineArray(0).val);
            }
            if (pr.sizeOfShadowArray() > 0)
            {
                ctFont.AddNewShadow().val = (pr.GetShadowArray(0).val);
            }
            if (pr.sizeOfStrikeArray() > 0)
            {
                ctFont.AddNewStrike().val = (pr.GetStrikeArray(0).val);
            }

            return(ctFont);
        }