Exemple #1
0
        public void TestRichText()
        {
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sheet   = wb.CreateSheet() as XSSFSheet;
            XSSFDrawing  Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

            XSSFTextBox        shape = Drawing.CreateTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4)) as XSSFTextBox;
            XSSFRichTextString rt    = new XSSFRichTextString("Test String");

            XSSFFont font = wb.CreateFont() as XSSFFont;

            font.SetColor(new XSSFColor(Color.FromArgb(0, 128, 128)));
            font.IsItalic  = (true);
            font.IsBold    = (true);
            font.Underline = FontUnderlineType.Single;
            rt.ApplyFont(font);

            shape.SetText(rt);

            CT_TextParagraph pr = shape.GetCTShape().txBody.p[0];

            Assert.AreEqual(1, pr.SizeOfRArray());

            CT_TextCharacterProperties rPr = pr.r[0].rPr;

            Assert.AreEqual(true, rPr.b);
            Assert.AreEqual(true, rPr.i);
            Assert.AreEqual(ST_TextUnderlineType.sng, rPr.u);
            Assert.IsTrue(Arrays.Equals(
                              new byte[] { 0, (byte)128, (byte)128 },
                              rPr.solidFill.srgbClr.val));
            Assert.IsNotNull(XSSFTestDataSamples.WriteOutAndReadBack(wb));
        }
Exemple #2
0
        public void TestBug56835CellComment()
        {
            XSSFWorkbook wb = new XSSFWorkbook();

            try
            {
                XSSFSheet   sheet   = wb.CreateSheet() as XSSFSheet;
                XSSFDrawing Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

                // first comment works
                IClientAnchor anchor  = new XSSFClientAnchor(1, 1, 2, 2, 3, 3, 4, 4);
                XSSFComment   comment = Drawing.CreateCellComment(anchor) as XSSFComment;
                Assert.IsNotNull(comment);

                try
                {
                    Drawing.CreateCellComment(anchor);
                    Assert.Fail("Should fail if we try to add the same comment for the same cell");
                }
                catch (ArgumentException)
                {
                    // expected
                }
            }
            finally
            {
                wb.Close();
            }
        }
Exemple #3
0
        public void TestReadAnchors()
        {
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sheet   = wb.CreateSheet() as XSSFSheet;
            XSSFDrawing  Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

            XSSFClientAnchor anchor1 = new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4);
            XSSFShape        shape1  = Drawing.CreateTextbox(anchor1) as XSSFShape;

            Assert.IsNotNull(shape1);

            XSSFClientAnchor anchor2 = new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 5);
            XSSFShape        shape2  = Drawing.CreateTextbox(anchor2) as XSSFShape;

            Assert.IsNotNull(shape2);

            int pictureIndex         = wb.AddPicture(new byte[] { }, XSSFWorkbook.PICTURE_TYPE_PNG);
            XSSFClientAnchor anchor3 = new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 6);
            XSSFShape        shape3  = Drawing.CreatePicture(anchor3, pictureIndex) as XSSFShape;

            Assert.IsNotNull(shape3);

            wb      = XSSFTestDataSamples.WriteOutAndReadBack(wb) as XSSFWorkbook;
            sheet   = wb.GetSheetAt(0) as XSSFSheet;
            Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;
            List <XSSFShape> shapes = Drawing.GetShapes();

            Assert.AreEqual(3, shapes.Count);
            Assert.AreEqual(shapes[0].GetAnchor(), anchor1);
            Assert.AreEqual(shapes[1].GetAnchor(), anchor2);
            Assert.AreEqual(shapes[2].GetAnchor(), anchor3);

            Assert.IsNotNull(XSSFTestDataSamples.WriteOutAndReadBack(wb));
        }
        public void Test53568()
        {
            XSSFWorkbook           wb       = XSSFTestDataSamples.OpenSampleWorkbook("53568.xlsx");
            List <XSSFPictureData> pictures = wb.GetAllPictures() as List <XSSFPictureData>;

            Assert.IsNotNull(pictures);
            Assert.AreEqual(4, pictures.Count);

            XSSFSheet        sheet1  = wb.GetSheetAt(0) as XSSFSheet;
            List <XSSFShape> shapes1 = (sheet1.CreateDrawingPatriarch() as XSSFDrawing).GetShapes();

            Assert.IsNotNull(shapes1);
            Assert.AreEqual(5, shapes1.Count);

            for (int i = 0; i < wb.NumberOfSheets; i++)
            {
                XSSFSheet   sheet   = wb.GetSheetAt(i) as XSSFSheet;
                XSSFDrawing Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;
                foreach (XSSFShape shape in Drawing.GetShapes())
                {
                    if (shape is XSSFPicture)
                    {
                        XSSFPicture     pic     = (XSSFPicture)shape;
                        XSSFPictureData picData = pic.PictureData as XSSFPictureData;
                        Assert.IsNotNull(picData);
                    }
                }
            }
        }
Exemple #5
0
        public void Create()
        {
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sheet   = (XSSFSheet)wb.CreateSheet();
            XSSFDrawing  drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch();

            byte[] jpegData = Encoding.UTF8.GetBytes("test jpeg data");

            IList pictures = wb.GetAllPictures();

            Assert.AreEqual(0, pictures.Count);

            int jpegIdx = wb.AddPicture(jpegData, PictureType.JPEG);

            Assert.AreEqual(1, pictures.Count);
            Assert.AreEqual("jpeg", ((XSSFPictureData)pictures[jpegIdx]).SuggestFileExtension());
            Assert.IsTrue(Arrays.Equals(jpegData, ((XSSFPictureData)pictures[jpegIdx]).Data));

            XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 10, 30);

            Assert.AreEqual(AnchorType.MoveAndResize, (AnchorType)anchor.AnchorType);
            anchor.AnchorType = AnchorType.DontMoveAndResize;
            Assert.AreEqual(AnchorType.DontMoveAndResize, (AnchorType)anchor.AnchorType);

            XSSFPicture shape = (XSSFPicture)drawing.CreatePicture(anchor, jpegIdx);

            Assert.IsTrue(anchor.Equals(shape.GetAnchor()));
            Assert.IsNotNull(shape.PictureData);
            Assert.IsTrue(Arrays.Equals(jpegData, shape.PictureData.Data));

            CT_TwoCellAnchor ctShapeHolder = (CT_TwoCellAnchor)drawing.GetCTDrawing().CellAnchors[0];

            // STEditAs.ABSOLUTE corresponds to ClientAnchor.DONT_MOVE_AND_RESIZE
            Assert.AreEqual(ST_EditAs.absolute, ctShapeHolder.editAs);
        }
        public void TestNew()
        {
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sheet   = (XSSFSheet)wb.CreateSheet();
            XSSFDrawing  Drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch();

            byte[] jpegData = Encoding.UTF8.GetBytes("test jpeg data");
            byte[] wmfData  = Encoding.UTF8.GetBytes("test wmf data");
            byte[] pngData  = Encoding.UTF8.GetBytes("test png data");

            IList pictures = wb.GetAllPictures();

            Assert.AreEqual(0, pictures.Count);

            int jpegIdx = wb.AddPicture(jpegData, PictureType.JPEG);

            Assert.AreEqual(1, pictures.Count);
            Assert.AreEqual("jpeg", ((XSSFPictureData)pictures[jpegIdx]).SuggestFileExtension());
            Assert.IsTrue(Arrays.Equals(jpegData, ((XSSFPictureData)pictures[jpegIdx]).Data));

            int wmfIdx = wb.AddPicture(wmfData, PictureType.WMF);

            Assert.AreEqual(2, pictures.Count);
            Assert.AreEqual("wmf", ((XSSFPictureData)pictures[wmfIdx]).SuggestFileExtension());
            Assert.IsTrue(Arrays.Equals(wmfData, ((XSSFPictureData)pictures[wmfIdx]).Data));

            int pngIdx = wb.AddPicture(pngData, PictureType.PNG);

            Assert.AreEqual(3, pictures.Count);
            Assert.AreEqual("png", ((XSSFPictureData)pictures[pngIdx]).SuggestFileExtension());
            Assert.IsTrue(Arrays.Equals(pngData, ((XSSFPictureData)pictures[pngIdx]).Data));

            //TODO finish usermodel API for XSSFPicture
            XSSFPicture p1 = (XSSFPicture)Drawing.CreatePicture(new XSSFClientAnchor(), jpegIdx);

            Assert.IsNotNull(p1);
            XSSFPicture p2 = (XSSFPicture)Drawing.CreatePicture(new XSSFClientAnchor(), wmfIdx);

            Assert.IsNotNull(p1);
            XSSFPicture p3 = (XSSFPicture)Drawing.CreatePicture(new XSSFClientAnchor(), pngIdx);

            Assert.IsNotNull(p1);

            //check that the Added pictures are accessible After write
            wb = (XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(wb);
            IList pictures2 = wb.GetAllPictures();

            Assert.AreEqual(3, pictures2.Count);

            Assert.AreEqual("jpeg", ((XSSFPictureData)pictures2[jpegIdx]).SuggestFileExtension());
            Assert.IsTrue(Arrays.Equals(jpegData, ((XSSFPictureData)pictures2[jpegIdx]).Data));

            Assert.AreEqual("wmf", ((XSSFPictureData)pictures2[wmfIdx]).SuggestFileExtension());
            Assert.IsTrue(Arrays.Equals(wmfData, ((XSSFPictureData)pictures2[wmfIdx]).Data));

            Assert.AreEqual("png", ((XSSFPictureData)pictures2[pngIdx]).SuggestFileExtension());
            Assert.IsTrue(Arrays.Equals(pngData, ((XSSFPictureData)pictures2[pngIdx]).Data));
        }
Exemple #7
0
        public void Resize()
        {
            XSSFWorkbook     wb     = XSSFITestDataProvider.instance.OpenSampleWorkbook("resize_Compare.xlsx") as XSSFWorkbook;
            XSSFDrawing      dp     = wb.GetSheetAt(0).CreateDrawingPatriarch() as XSSFDrawing;
            List <XSSFShape> pics   = dp.GetShapes();
            XSSFPicture      inpPic = (XSSFPicture)pics[(0)];
            XSSFPicture      cmpPic = (XSSFPicture)pics[(0)];

            BaseTestResize(inpPic, cmpPic, 2.0, 2.0);
            wb.Close();
        }
Exemple #8
0
        public void TestMultipleDrawings()
        {
            XSSFWorkbook wb = new XSSFWorkbook();

            for (int i = 0; i < 3; i++)
            {
                XSSFSheet   sheet   = (XSSFSheet)wb.CreateSheet();
                XSSFDrawing drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch();
                Assert.IsNotNull(drawing);
            }
            OPCPackage pkg = wb.Package;

            Assert.AreEqual(3, pkg.GetPartsByContentType(XSSFRelation.DRAWINGS.ContentType).Count);
            Assert.IsNotNull(XSSFTestDataSamples.WriteOutAndReadBack(wb));
        }
Exemple #9
0
        public void multiRelationShips()
        {
            XSSFWorkbook wb = new XSSFWorkbook();

            byte[] pic1Data = Encoding.UTF8.GetBytes("test jpeg data");
            byte[] pic2Data = Encoding.UTF8.GetBytes("test png data");

            List <XSSFPictureData> pictures = wb.GetAllPictures() as List <XSSFPictureData>;

            Assert.AreEqual(0, pictures.Count);

            int pic1 = wb.AddPicture(pic1Data, XSSFWorkbook.PICTURE_TYPE_JPEG);
            int pic2 = wb.AddPicture(pic2Data, XSSFWorkbook.PICTURE_TYPE_PNG);

            XSSFSheet   sheet1   = wb.CreateSheet() as XSSFSheet;
            XSSFDrawing drawing1 = sheet1.CreateDrawingPatriarch() as XSSFDrawing;
            XSSFPicture shape1   = drawing1.CreatePicture(new XSSFClientAnchor(), pic1) as XSSFPicture;
            XSSFPicture shape2   = drawing1.CreatePicture(new XSSFClientAnchor(), pic2) as XSSFPicture;

            XSSFSheet   sheet2   = wb.CreateSheet() as XSSFSheet;
            XSSFDrawing drawing2 = sheet2.CreateDrawingPatriarch() as XSSFDrawing;
            XSSFPicture shape3   = drawing2.CreatePicture(new XSSFClientAnchor(), pic2) as XSSFPicture;
            XSSFPicture shape4   = drawing2.CreatePicture(new XSSFClientAnchor(), pic1) as XSSFPicture;

            Assert.AreEqual(2, pictures.Count);

            wb       = XSSFTestDataSamples.WriteOutAndReadBack(wb) as XSSFWorkbook;
            pictures = wb.GetAllPictures() as List <XSSFPictureData>;
            Assert.AreEqual(2, pictures.Count);

            sheet1   = wb.GetSheetAt(0) as XSSFSheet;
            drawing1 = sheet1.CreateDrawingPatriarch() as XSSFDrawing;
            XSSFPicture shape11 = (XSSFPicture)drawing1.GetShapes()[0];

            Assert.IsTrue(Arrays.Equals(shape1.PictureData.Data, shape11.PictureData.Data));
            XSSFPicture shape22 = (XSSFPicture)drawing1.GetShapes()[1];

            Assert.IsTrue(Arrays.Equals(shape2.PictureData.Data, shape22.PictureData.Data));

            sheet2   = wb.GetSheetAt(1) as XSSFSheet;
            drawing2 = sheet2.CreateDrawingPatriarch() as XSSFDrawing;
            XSSFPicture shape33 = (XSSFPicture)drawing2.GetShapes()[0];

            Assert.IsTrue(Arrays.Equals(shape3.PictureData.Data, shape33.PictureData.Data));
            XSSFPicture shape44 = (XSSFPicture)drawing2.GetShapes()[1];

            Assert.IsTrue(Arrays.Equals(shape4.PictureData.Data, shape44.PictureData.Data));
        }
Exemple #10
0
        public void TestGetChartAxisBug57362()
        {
            //Load existing excel with some chart on it having primary and secondary axis.
            IWorkbook   workbook = XSSFTestDataSamples.OpenSampleWorkbook("57362.xlsx");
            ISheet      sh       = workbook.GetSheetAt(0);
            XSSFSheet   xsh      = (XSSFSheet)sh;
            XSSFDrawing Drawing  = xsh.CreateDrawingPatriarch() as XSSFDrawing;
            XSSFChart   chart    = Drawing.GetCharts()[(0)];

            List <IChartAxis> axisList = chart.GetAxis();

            Assert.AreEqual(4, axisList.Count);
            Assert.IsNotNull(axisList[(0)]);
            Assert.IsNotNull(axisList[(1)]);
            Assert.IsNotNull(axisList[(2)]);
            Assert.IsNotNull(axisList[(3)]);
        }
Exemple #11
0
        protected internal XSSFSimpleShape(XSSFDrawing Drawing, CT_Shape ctShape)
        {
            this.drawing = Drawing;
            this.ctShape = ctShape;

            _paragraphs = new List <XSSFTextParagraph>();

            // Initialize any existing paragraphs - this will be the default body paragraph in a new shape,
            // or existing paragraphs that have been loaded from the file
            Npoi.Core.OpenXmlFormats.Dml.Spreadsheet.CT_TextBody body = ctShape.txBody;
            if (body != null)
            {
                for (int i = 0; i < body.SizeOfPArray(); i++)
                {
                    _paragraphs.Add(new XSSFTextParagraph(body.GetPArray(i), ctShape));
                }
            }
        }
Exemple #12
0
        public void TestAddChartsToNewWorkbook()
        {
            XSSFWorkbook     wb = new XSSFWorkbook();
            XSSFSheet        s1 = (XSSFSheet)wb.CreateSheet();
            XSSFDrawing      d1 = (XSSFDrawing)s1.CreateDrawingPatriarch();
            XSSFClientAnchor a1 = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 10, 30);
            XSSFChart        c1 = (XSSFChart)d1.CreateChart(a1);

            Assert.AreEqual(1, d1.GetCharts().Count);

            Assert.IsNotNull(c1.GetGraphicFrame());
            Assert.IsNotNull(c1.GetOrCreateLegend());

            XSSFClientAnchor a2 = new XSSFClientAnchor(0, 0, 0, 0, 1, 11, 10, 60);
            XSSFChart        c2 = (XSSFChart)d1.CreateChart(a2);

            Assert.IsNotNull(c2);
            Assert.AreEqual(2, d1.GetCharts().Count);
            Assert.IsNotNull(XSSFTestDataSamples.WriteOutAndReadBack(wb));
        }
Exemple #13
0
        public void IncrementShapeId()
        {
            XSSFWorkbook wb      = new XSSFWorkbook();
            XSSFSheet    sheet   = (XSSFSheet)wb.CreateSheet();
            XSSFDrawing  drawing = (XSSFDrawing)sheet.CreateDrawingPatriarch();

            XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 10, 30);

            byte[] jpegData = Encoding.UTF8.GetBytes("picture1");
            int    jpegIdx  = wb.AddPicture(jpegData, PictureType.JPEG);

            XSSFPicture shape1 = (XSSFPicture)drawing.CreatePicture(anchor, jpegIdx);

            Assert.AreEqual((uint)1, shape1.GetCTPicture().nvPicPr.cNvPr.id);

            jpegData = Encoding.UTF8.GetBytes("picture2");
            jpegIdx  = wb.AddPicture(jpegData, PictureType.JPEG);
            XSSFPicture shape2 = (XSSFPicture)drawing.CreatePicture(anchor, jpegIdx);

            Assert.AreEqual((uint)2, shape2.GetCTPicture().nvPicPr.cNvPr.id);
        }
Exemple #14
0
        public void TestXSSFSimpleShapeCausesNPE56514()
        {
            XSSFWorkbook     wb      = XSSFTestDataSamples.OpenSampleWorkbook("56514.xlsx");
            XSSFSheet        sheet   = wb.GetSheetAt(0) as XSSFSheet;
            XSSFDrawing      Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;
            List <XSSFShape> shapes  = Drawing.GetShapes();

            Assert.AreEqual(4, shapes.Count);

            wb = XSSFTestDataSamples.WriteOutAndReadBack(wb) as XSSFWorkbook;

            shapes = Drawing.GetShapes();
            Assert.AreEqual(4, shapes.Count);

            /*        OutputStream stream = new FileOutputStream(new File("C:\\temp\\56514.xlsx"));
             *      try {
             *          wb.Write(stream);
             *      } finally {
             *          stream.Close();
             *      }*/
        }
Exemple #15
0
        public void TestClone()
        {
            XSSFWorkbook wb     = XSSFTestDataSamples.OpenSampleWorkbook("WithDrawing.xlsx");
            XSSFSheet    sheet1 = wb.GetSheetAt(0) as XSSFSheet;

            XSSFSheet sheet2 = wb.CloneSheet(0) as XSSFSheet;

            //the source sheet has one relationship and it is XSSFDrawing
            List <POIXMLDocumentPart> rels1 = sheet1.GetRelations();

            Assert.AreEqual(1, rels1.Count);
            Assert.IsTrue(rels1[(0)] is XSSFDrawing);

            List <POIXMLDocumentPart> rels2 = sheet2.GetRelations();

            Assert.AreEqual(1, rels2.Count);
            Assert.IsTrue(rels2[(0)] is XSSFDrawing);

            XSSFDrawing drawing1 = (XSSFDrawing)rels1[0];
            XSSFDrawing drawing2 = (XSSFDrawing)rels2[0];

            Assert.AreNotSame(drawing1, drawing2);  // Drawing2 is a clone of Drawing1

            List <XSSFShape> shapes1 = drawing1.GetShapes();
            List <XSSFShape> shapes2 = drawing2.GetShapes();

            Assert.AreEqual(shapes1.Count, shapes2.Count);

            for (int i = 0; i < shapes1.Count; i++)
            {
                XSSFShape sh1 = (XSSFShape)shapes1[(i)];
                XSSFShape sh2 = (XSSFShape)shapes2[i];

                Assert.IsTrue(sh1.GetType() == sh2.GetType());
                Assert.AreEqual(sh1.GetShapeProperties().ToString(), sh2.GetShapeProperties().ToString());
            }

            Assert.IsNotNull(XSSFTestDataSamples.WriteOutAndReadBack(wb));
        }
Exemple #16
0
        public void TestRead()
        {
            XSSFWorkbook wb    = XSSFTestDataSamples.OpenSampleWorkbook("WithDrawing.xlsx");
            XSSFSheet    sheet = (XSSFSheet)wb.GetSheetAt(0);
            //the sheet has one relationship and it is XSSFDrawing
            List <POIXMLDocumentPart> rels = sheet.GetRelations();

            Assert.AreEqual(1, rels.Count);
            Assert.IsTrue(rels[0] is XSSFDrawing);

            XSSFDrawing drawing = (XSSFDrawing)rels[0];

            //sheet.CreateDrawingPatriarch() should return the same instance of XSSFDrawing
            Assert.AreSame(drawing, sheet.CreateDrawingPatriarch());
            String drawingId = drawing.GetPackageRelationship().Id;

            //there should be a relation to this Drawing in the worksheet
            Assert.IsTrue(sheet.GetCTWorksheet().IsSetDrawing());
            Assert.AreEqual(drawingId, sheet.GetCTWorksheet().drawing.id);


            List <XSSFShape> shapes = drawing.GetShapes();

            Assert.AreEqual(6, shapes.Count);

            Assert.IsTrue(shapes[(0)] is XSSFPicture);
            Assert.IsTrue(shapes[(1)] is XSSFPicture);
            Assert.IsTrue(shapes[(2)] is XSSFPicture);
            Assert.IsTrue(shapes[(3)] is XSSFPicture);
            Assert.IsTrue(shapes[(4)] is XSSFSimpleShape);
            Assert.IsTrue(shapes[(5)] is XSSFPicture);

            foreach (XSSFShape sh in shapes)
            {
                Assert.IsNotNull(sh.GetAnchor());
            }
            Assert.IsNotNull(XSSFTestDataSamples.WriteOutAndReadBack(wb));
        }
Exemple #17
0
        public void XSSFTextParagraph_()
        {
            XSSFWorkbook wb = new XSSFWorkbook();

            try
            {
                XSSFSheet   sheet   = wb.CreateSheet() as XSSFSheet;
                XSSFDrawing Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

                XSSFTextBox        shape = Drawing.CreateTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4)) as XSSFTextBox;
                XSSFRichTextString rt    = new XSSFRichTextString("Test String");

                XSSFFont font  = wb.CreateFont() as XSSFFont;
                Color    color = Color.FromArgb(0, 255, 255);
                font.SetColor(new XSSFColor(color));
                font.FontName = (/*setter*/ "Arial");
                rt.ApplyFont(font);

                shape.SetText(rt);

                List <XSSFTextParagraph> paras = shape.TextParagraphs;
                Assert.AreEqual(1, paras.Count);

                XSSFTextParagraph text = paras[(0)];
                Assert.AreEqual("Test String", text.Text);

                Assert.IsFalse(text.IsBullet);
                Assert.IsNotNull(text.GetXmlObject());
                Assert.AreEqual(shape.GetCTShape(), text.ParentShape);
                Assert.IsNotNull(text.GetEnumerator());
                Assert.IsNotNull(text.AddLineBreak());

                Assert.IsNotNull(text.TextRuns);
                Assert.AreEqual(2, text.TextRuns.Count);
                text.AddNewTextRun();
                Assert.AreEqual(3, text.TextRuns.Count);

                Assert.AreEqual(TextAlign.LEFT, text.TextAlign);
                text.TextAlign = TextAlign.None;
                Assert.AreEqual(TextAlign.LEFT, text.TextAlign);
                text.TextAlign = (/*setter*/ TextAlign.CENTER);
                Assert.AreEqual(TextAlign.CENTER, text.TextAlign);
                text.TextAlign = (/*setter*/ TextAlign.RIGHT);
                Assert.AreEqual(TextAlign.RIGHT, text.TextAlign);
                text.TextAlign = TextAlign.None;
                Assert.AreEqual(TextAlign.LEFT, text.TextAlign);

                text.TextFontAlign = (/*setter*/ TextFontAlign.BASELINE);
                Assert.AreEqual(TextFontAlign.BASELINE, text.TextFontAlign);
                text.TextFontAlign = (/*setter*/ TextFontAlign.BOTTOM);
                Assert.AreEqual(TextFontAlign.BOTTOM, text.TextFontAlign);
                text.TextFontAlign = TextFontAlign.None;
                Assert.AreEqual(TextFontAlign.BASELINE, text.TextFontAlign);
                text.TextFontAlign = TextFontAlign.None;
                Assert.AreEqual(TextFontAlign.BASELINE, text.TextFontAlign);

                Assert.IsNull(text.BulletFont);
                text.BulletFont = (/*setter*/ "Arial");
                Assert.AreEqual("Arial", text.BulletFont);

                Assert.IsNull(text.BulletCharacter);
                text.BulletCharacter = (/*setter*/ ".");
                Assert.AreEqual(".", text.BulletCharacter);

                //Assert.IsNull(text.BulletFontColor);
                Assert.AreEqual(Color.Empty, text.BulletFontColor);
                text.BulletFontColor = (/*setter*/ color);
                Assert.AreEqual(color, text.BulletFontColor);

                Assert.AreEqual(100.0, text.BulletFontSize, 0.01);
                text.BulletFontSize = (/*setter*/ 1.0);
                Assert.AreEqual(1.0, text.BulletFontSize, 0.01);
                text.BulletFontSize = (/*setter*/ 1.0);
                Assert.AreEqual(1.0, text.BulletFontSize, 0.01);
                text.BulletFontSize = (/*setter*/ -9.0);
                Assert.AreEqual(-9.0, text.BulletFontSize, 0.01);
                text.BulletFontSize = (/*setter*/ -9.0);
                Assert.AreEqual(-9.0, text.BulletFontSize, 0.01);
                text.BulletFontSize = (/*setter*/ 1.0);
                Assert.AreEqual(1.0, text.BulletFontSize, 0.01);
                text.BulletFontSize = (/*setter*/ -9.0);
                Assert.AreEqual(-9.0, text.BulletFontSize, 0.01);

                Assert.AreEqual(0.0, text.Indent, 0.01);
                text.Indent = (/*setter*/ 2.0);
                Assert.AreEqual(2.0, text.Indent, 0.01);
                text.Indent = (/*setter*/ -1.0);
                Assert.AreEqual(0.0, text.Indent, 0.01);
                text.Indent = (/*setter*/ -1.0);
                Assert.AreEqual(0.0, text.Indent, 0.01);

                Assert.AreEqual(0.0, text.LeftMargin, 0.01);
                text.LeftMargin = (/*setter*/ 3.0);
                Assert.AreEqual(3.0, text.LeftMargin, 0.01);
                text.LeftMargin = (/*setter*/ -1.0);
                Assert.AreEqual(0.0, text.LeftMargin, 0.01);
                text.LeftMargin = (/*setter*/ -1.0);
                Assert.AreEqual(0.0, text.LeftMargin, 0.01);

                Assert.AreEqual(0.0, text.RightMargin, 0.01);
                text.RightMargin = (/*setter*/ 4.5);
                Assert.AreEqual(4.5, text.RightMargin, 0.01);
                text.RightMargin = (/*setter*/ -1.0);
                Assert.AreEqual(0.0, text.RightMargin, 0.01);
                text.RightMargin = (/*setter*/ -1.0);
                Assert.AreEqual(0.0, text.RightMargin, 0.01);

                Assert.AreEqual(0.0, text.DefaultTabSize, 0.01);

                Assert.AreEqual(0.0, text.GetTabStop(0), 0.01);
                text.AddTabStop(3.14);
                Assert.AreEqual(3.14, text.GetTabStop(0), 0.01);

                Assert.AreEqual(100.0, text.LineSpacing, 0.01);
                text.LineSpacing = (/*setter*/ 3.15);
                Assert.AreEqual(3.15, text.LineSpacing, 0.01);
                text.LineSpacing = (/*setter*/ -2.13);
                Assert.AreEqual(-2.13, text.LineSpacing, 0.01);

                Assert.AreEqual(0.0, text.SpaceBefore, 0.01);
                text.SpaceBefore = (/*setter*/ 3.17);
                Assert.AreEqual(3.17, text.SpaceBefore, 0.01);
                text.SpaceBefore = (/*setter*/ -4.7);
                Assert.AreEqual(-4.7, text.SpaceBefore, 0.01);

                Assert.AreEqual(0.0, text.SpaceAfter, 0.01);
                text.SpaceAfter = (/*setter*/ 6.17);
                Assert.AreEqual(6.17, text.SpaceAfter, 0.01);
                text.SpaceAfter = (/*setter*/ -8.17);
                Assert.AreEqual(-8.17, text.SpaceAfter, 0.01);

                Assert.AreEqual(0, text.Level);
                text.Level = (/*setter*/ 1);
                Assert.AreEqual(1, text.Level);
                text.Level = (/*setter*/ 4);
                Assert.AreEqual(4, text.Level);

                Assert.IsTrue(text.IsBullet);
                Assert.IsFalse(text.IsBulletAutoNumber);
                text.IsBullet = (false);
                text.IsBullet = (false);
                Assert.IsFalse(text.IsBullet);
                Assert.IsFalse(text.IsBulletAutoNumber);
                text.IsBullet = (true);
                Assert.IsTrue(text.IsBullet);
                Assert.IsFalse(text.IsBulletAutoNumber);
                Assert.AreEqual(0, text.BulletAutoNumberStart);
                Assert.AreEqual(ListAutoNumber.ARABIC_PLAIN, text.BulletAutoNumberScheme);

                text.IsBullet = (false);
                Assert.IsFalse(text.IsBullet);
                text.SetBullet(ListAutoNumber.CIRCLE_NUM_DB_PLAIN);
                Assert.IsTrue(text.IsBullet);
                Assert.IsTrue(text.IsBulletAutoNumber);

                //Assert.AreEqual(0, text.BulletAutoNumberStart);
                //This value should be 1, see CT_TextAutonumberBullet.startAt, default value is 1;
                Assert.AreEqual(1, text.BulletAutoNumberStart);


                Assert.AreEqual(ListAutoNumber.CIRCLE_NUM_DB_PLAIN, text.BulletAutoNumberScheme);
                text.IsBullet = (false);
                Assert.IsFalse(text.IsBullet);
                Assert.IsFalse(text.IsBulletAutoNumber);
                text.SetBullet(ListAutoNumber.CIRCLE_NUM_WD_BLACK_PLAIN, 10);
                Assert.IsTrue(text.IsBullet);
                Assert.IsTrue(text.IsBulletAutoNumber);
                Assert.AreEqual(10, text.BulletAutoNumberStart);
                Assert.AreEqual(ListAutoNumber.CIRCLE_NUM_WD_BLACK_PLAIN, text.BulletAutoNumberScheme);


                Assert.IsNotNull(text.ToString());

                new XSSFTextParagraph(text.GetXmlObject(), shape.GetCTShape());
            }
            finally
            {
                wb.Close();
            }
        }
        public void TestXSSFTextParagraph()
        {
            XSSFWorkbook wb = new XSSFWorkbook();

            try
            {
                XSSFSheet   sheet   = wb.CreateSheet() as XSSFSheet;
                XSSFDrawing Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

                XSSFTextBox shape = Drawing.CreateTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4)) as XSSFTextBox;

                XSSFRichTextString rt = new XSSFRichTextString("Test String");

                XSSFFont font  = wb.CreateFont() as XSSFFont;
                Color    color = Color.FromArgb(0, 255, 255);
                font.SetColor(new XSSFColor(color));
                font.FontName = (/*setter*/ "Arial");
                rt.ApplyFont(font);

                shape.SetText(/*setter*/ rt);

                Assert.IsNotNull(shape.GetCTShape());
                Assert.IsNotNull(shape.GetEnumerator());
                Assert.IsNotNull(XSSFSimpleShape.GetPrototype());

                foreach (ListAutoNumber nr in Enum.GetValues(typeof(ListAutoNumber)))
                {
                    shape.TextParagraphs[(0)].SetBullet(nr);
                    Assert.IsNotNull(shape.Text);
                }

                shape.TextParagraphs[(0)].IsBullet = (false);
                Assert.IsNotNull(shape.Text);

                shape.SetText("testtext");
                Assert.AreEqual("testtext", shape.Text);

                shape.SetText(new XSSFRichTextString());
                //Assert.AreEqual("null", shape.Text);
                Assert.AreEqual(string.Empty, shape.Text);

                shape.AddNewTextParagraph();
                shape.AddNewTextParagraph("test-other-text");
                shape.AddNewTextParagraph(new XSSFRichTextString("rtstring"));
                shape.AddNewTextParagraph(new XSSFRichTextString());
                //Assert.AreEqual("null\n\ntest-other-text\nrtstring\nnull", shape.Text);
                Assert.AreEqual("test-other-text\nrtstring\n", shape.Text);

                Assert.AreEqual(TextHorizontalOverflow.OVERFLOW, shape.TextHorizontalOverflow);
                shape.TextHorizontalOverflow = (/*setter*/ TextHorizontalOverflow.CLIP);
                Assert.AreEqual(TextHorizontalOverflow.CLIP, shape.TextHorizontalOverflow);
                shape.TextHorizontalOverflow = (/*setter*/ TextHorizontalOverflow.OVERFLOW);
                Assert.AreEqual(TextHorizontalOverflow.OVERFLOW, shape.TextHorizontalOverflow);
                shape.TextHorizontalOverflow = TextHorizontalOverflow.None;
                Assert.AreEqual(TextHorizontalOverflow.OVERFLOW, shape.TextHorizontalOverflow);
                shape.TextHorizontalOverflow = TextHorizontalOverflow.None;
                Assert.AreEqual(TextHorizontalOverflow.OVERFLOW, shape.TextHorizontalOverflow);

                Assert.AreEqual(TextVerticalOverflow.OVERFLOW, shape.TextVerticalOverflow);
                shape.TextVerticalOverflow = (/*setter*/ TextVerticalOverflow.CLIP);
                Assert.AreEqual(TextVerticalOverflow.CLIP, shape.TextVerticalOverflow);
                shape.TextVerticalOverflow = (/*setter*/ TextVerticalOverflow.OVERFLOW);
                Assert.AreEqual(TextVerticalOverflow.OVERFLOW, shape.TextVerticalOverflow);
                shape.TextVerticalOverflow = TextVerticalOverflow.None;
                Assert.AreEqual(TextVerticalOverflow.OVERFLOW, shape.TextVerticalOverflow);
                shape.TextVerticalOverflow = TextVerticalOverflow.None;
                Assert.AreEqual(TextVerticalOverflow.OVERFLOW, shape.TextVerticalOverflow);

                Assert.AreEqual(VerticalAlignment.Top, shape.VerticalAlignment);
                shape.VerticalAlignment = VerticalAlignment.Bottom;
                Assert.AreEqual(VerticalAlignment.Bottom, shape.VerticalAlignment);
                shape.VerticalAlignment = VerticalAlignment.Top;
                Assert.AreEqual(VerticalAlignment.Top, shape.VerticalAlignment);
                shape.VerticalAlignment = VerticalAlignment.None;
                Assert.AreEqual(VerticalAlignment.Top, shape.VerticalAlignment);
                shape.VerticalAlignment = VerticalAlignment.None;
                Assert.AreEqual(VerticalAlignment.Top, shape.VerticalAlignment);

                Assert.AreEqual(TextDirection.HORIZONTAL, shape.TextDirection);
                shape.TextDirection = (/*setter*/ TextDirection.STACKED);
                Assert.AreEqual(TextDirection.STACKED, shape.TextDirection);
                shape.TextDirection = (/*setter*/ TextDirection.HORIZONTAL);
                Assert.AreEqual(TextDirection.HORIZONTAL, shape.TextDirection);
                shape.TextDirection = (/*setter*/ TextDirection.None);
                Assert.AreEqual(TextDirection.HORIZONTAL, shape.TextDirection);
                shape.TextDirection = (/*setter*/ TextDirection.None);
                Assert.AreEqual(TextDirection.HORIZONTAL, shape.TextDirection);

                Assert.AreEqual(3.6, shape.BottomInset, 0.01);
                shape.BottomInset = (/*setter*/ 12.32);
                Assert.AreEqual(12.32, shape.BottomInset, 0.01);
                shape.BottomInset = (/*setter*/ -1);
                Assert.AreEqual(3.6, shape.BottomInset, 0.01);
                shape.BottomInset = (/*setter*/ -1);
                Assert.AreEqual(3.6, shape.BottomInset, 0.01);

                Assert.AreEqual(3.6, shape.LeftInset, 0.01);
                shape.LeftInset = (/*setter*/ 12.31);
                Assert.AreEqual(12.31, shape.LeftInset, 0.01);
                shape.LeftInset = (/*setter*/ -1);
                Assert.AreEqual(3.6, shape.LeftInset, 0.01);
                shape.LeftInset = (/*setter*/ -1);
                Assert.AreEqual(3.6, shape.LeftInset, 0.01);

                Assert.AreEqual(3.6, shape.RightInset, 0.01);
                shape.RightInset = (/*setter*/ 13.31);
                Assert.AreEqual(13.31, shape.RightInset, 0.01);
                shape.RightInset = (/*setter*/ -1);
                Assert.AreEqual(3.6, shape.RightInset, 0.01);
                shape.RightInset = (/*setter*/ -1);
                Assert.AreEqual(3.6, shape.RightInset, 0.01);

                Assert.AreEqual(3.6, shape.TopInset, 0.01);
                shape.TopInset = (/*setter*/ 23.31);
                Assert.AreEqual(23.31, shape.TopInset, 0.01);
                shape.TopInset = (/*setter*/ -1);
                Assert.AreEqual(3.6, shape.TopInset, 0.01);
                shape.TopInset = (/*setter*/ -1);
                Assert.AreEqual(3.6, shape.TopInset, 0.01);

                Assert.IsTrue(shape.WordWrap);
                shape.WordWrap = (/*setter*/ false);
                Assert.IsFalse(shape.WordWrap);
                shape.WordWrap = (/*setter*/ true);
                Assert.IsTrue(shape.WordWrap);

                Assert.AreEqual(TextAutofit.NORMAL, shape.TextAutofit);
                shape.TextAutofit = (/*setter*/ TextAutofit.NORMAL);
                Assert.AreEqual(TextAutofit.NORMAL, shape.TextAutofit);
                shape.TextAutofit = (/*setter*/ TextAutofit.SHAPE);
                Assert.AreEqual(TextAutofit.SHAPE, shape.TextAutofit);
                shape.TextAutofit = (/*setter*/ TextAutofit.NONE);
                Assert.AreEqual(TextAutofit.NONE, shape.TextAutofit);

                Assert.AreEqual(5, shape.ShapeType);
                shape.ShapeType = (/*setter*/ 23);
                Assert.AreEqual(23, shape.ShapeType);

                // TODO: should this be supported?
                //            shape.ShapeType=(/*setter*/-1);
                //            Assert.AreEqual(-1, shape.ShapeType);
                //            shape.ShapeType=(/*setter*/-1);
                //            Assert.AreEqual(-1, shape.ShapeType);

                Assert.IsNotNull(shape.GetShapeProperties());
            }
            finally
            {
                wb.Close();
            }
        }
Exemple #19
0
        public void TestNew()
        {
            XSSFWorkbook wb    = new XSSFWorkbook();
            XSSFSheet    sheet = (XSSFSheet)wb.CreateSheet();
            //multiple calls of CreateDrawingPatriarch should return the same instance of XSSFDrawing
            XSSFDrawing dr1 = (XSSFDrawing)sheet.CreateDrawingPatriarch();
            XSSFDrawing dr2 = (XSSFDrawing)sheet.CreateDrawingPatriarch();

            Assert.AreSame(dr1, dr2);

            List <POIXMLDocumentPart> rels = sheet.GetRelations();

            Assert.AreEqual(1, rels.Count);
            Assert.IsTrue(rels[0] is XSSFDrawing);

            XSSFDrawing drawing   = (XSSFDrawing)rels[0];
            String      drawingId = drawing.GetPackageRelationship().Id;

            //there should be a relation to this Drawing in the worksheet
            Assert.IsTrue(sheet.GetCTWorksheet().IsSetDrawing());
            Assert.AreEqual(drawingId, sheet.GetCTWorksheet().drawing.id);

            //XSSFClientAnchor anchor = new XSSFClientAnchor();

            XSSFConnector c1 = drawing.CreateConnector(new XSSFClientAnchor(0, 0, 0, 0, 0, 0, 2, 2));

            c1.LineWidth = 2.5;
            c1.LineStyle = SS.UserModel.LineStyle.DashDotSys;

            XSSFShapeGroup c2 = drawing.CreateGroup(new XSSFClientAnchor(0, 0, 0, 0, 0, 0, 5, 5));

            Assert.IsNotNull(c2);

            XSSFSimpleShape c3 = drawing.CreateSimpleShape(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4));

            c3.SetText(new XSSFRichTextString("Test String"));
            c3.SetFillColor(128, 128, 128);

            XSSFTextBox        c4 = (XSSFTextBox)drawing.CreateTextbox(new XSSFClientAnchor(0, 0, 0, 0, 4, 4, 5, 6));
            XSSFRichTextString rt = new XSSFRichTextString("Test String");

            rt.ApplyFont(0, 5, wb.CreateFont());
            rt.ApplyFont(5, 6, wb.CreateFont());
            c4.SetText(rt);

            c4.IsNoFill = (true);

            Assert.AreEqual(4, drawing.GetCTDrawing().SizeOfTwoCellAnchorArray());

            List <XSSFShape> shapes = drawing.GetShapes();

            Assert.AreEqual(4, shapes.Count);
            Assert.IsTrue(shapes[(0)] is XSSFConnector);
            Assert.IsTrue(shapes[(1)] is XSSFShapeGroup);
            Assert.IsTrue(shapes[(2)] is XSSFSimpleShape);
            Assert.IsTrue(shapes[(3)] is XSSFSimpleShape);

            // Save and re-load it
            wb    = XSSFTestDataSamples.WriteOutAndReadBack(wb) as XSSFWorkbook;
            sheet = wb.GetSheetAt(0) as XSSFSheet;

            // Check
            dr1 = sheet.CreateDrawingPatriarch() as XSSFDrawing;
            CT_Drawing ctDrawing = dr1.GetCTDrawing();

            // Connector, shapes and text boxes are all two cell anchors
            Assert.AreEqual(0, ctDrawing.SizeOfAbsoluteAnchorArray());
            Assert.AreEqual(0, ctDrawing.SizeOfOneCellAnchorArray());
            Assert.AreEqual(4, ctDrawing.SizeOfTwoCellAnchorArray());

            shapes = dr1.GetShapes();
            Assert.AreEqual(4, shapes.Count);
            Assert.IsTrue(shapes[0] is XSSFConnector);
            Assert.IsTrue(shapes[1] is XSSFShapeGroup);
            Assert.IsTrue(shapes[2] is XSSFSimpleShape);
            Assert.IsTrue(shapes[3] is XSSFSimpleShape); //

            // Ensure it got the right namespaces
            //String xml = ctDrawing.ToString();
            //Assert.IsTrue(xml.Contains("xmlns:xdr=\"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing\""));
            //Assert.IsTrue(xml.Contains("xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\""));

            Assert.IsNotNull(XSSFTestDataSamples.WriteOutAndReadBack(wb));
        }
Exemple #20
0
 /**
  * Construct a new XSSFConnector object.
  *
  * @param Drawing the XSSFDrawing that owns this shape
  * @param ctShape the shape bean that holds all the shape properties
  */
 public XSSFConnector(XSSFDrawing drawing, CT_Connector ctShape)
 {
     this.drawing = drawing;
     this.ctShape = ctShape;
 }
Exemple #21
0
 internal XSSFTextBox(XSSFDrawing drawing, CT_Shape ctShape)
     : base(drawing, ctShape)
 {
 }
Exemple #22
0
        /**
         * Construct a new XSSFGraphicFrame object.
         *
         * @param Drawing the XSSFDrawing that owns this frame
         * @param ctGraphicFrame the XML bean that stores this frame content
         */


        public XSSFGraphicFrame(XSSFDrawing Drawing, CT_GraphicalObjectFrame ctGraphicFrame)
        {
            this.drawing      = Drawing;
            this.graphicFrame = ctGraphicFrame;
        }
Exemple #23
0
        public void TestXSSFTextParagraph()
        {
            XSSFWorkbook wb = new XSSFWorkbook();

            try
            {
                XSSFSheet   sheet   = wb.CreateSheet() as XSSFSheet;
                XSSFDrawing Drawing = sheet.CreateDrawingPatriarch() as XSSFDrawing;

                XSSFTextBox shape = Drawing.CreateTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4)) as XSSFTextBox;

                XSSFTextParagraph para    = shape.AddNewTextParagraph();
                para.AddNewTextRun().Text = ("Line 1");

                List <XSSFTextRun> Runs = para.TextRuns;
                Assert.AreEqual(1, Runs.Count);
                XSSFTextRun run = Runs[0];
                Assert.AreEqual("Line 1", run.Text);

                //Assert.IsNotNull(run.ParentParagraph);
                //Assert.IsNotNull(run.XmlObject);
                Assert.IsNotNull(run.GetRPr());

                Assert.AreEqual(Color.FromArgb(0, 0, 0), run.FontColor);

                Color color = Color.FromArgb(0, 255, 255);
                run.FontColor = (/*setter*/ color);
                Assert.AreEqual(color, run.FontColor);

                Assert.AreEqual(11.0, run.FontSize, 0.01);
                run.FontSize = (/*setter*/ 12.32);
                Assert.AreEqual(12.32, run.FontSize, 0.01);
                run.FontSize = (/*setter*/ -1.0);
                Assert.AreEqual(11.0, run.FontSize, 0.01);
                run.FontSize = (/*setter*/ -1.0);
                Assert.AreEqual(11.0, run.FontSize, 0.01);
                try
                {
                    run.FontSize = (/*setter*/ 0.9);
                    Assert.Fail("Should fail");
                }
                catch (ArgumentException e)
                {
                    Assert.IsTrue(e.Message.Contains("0.9"));
                }
                Assert.AreEqual(11.0, run.FontSize, 0.01);

                Assert.AreEqual(0.0, run.CharacterSpacing, 0.01);
                run.CharacterSpacing = (/*setter*/ 12.31);
                Assert.AreEqual(12.31, run.CharacterSpacing, 0.01);
                run.CharacterSpacing = (/*setter*/ 0.0);
                Assert.AreEqual(0.0, run.CharacterSpacing, 0.01);
                run.CharacterSpacing = (/*setter*/ 0.0);
                Assert.AreEqual(0.0, run.CharacterSpacing, 0.01);

                Assert.AreEqual("Calibri", run.FontFamily);
                run.SetFontFamily("Arial", (byte)1, (byte)1, false);
                Assert.AreEqual("Arial", run.FontFamily);
                run.SetFontFamily("Arial", unchecked ((byte)-1), (byte)1, false);
                Assert.AreEqual("Arial", run.FontFamily);
                run.SetFontFamily("Arial", (byte)1, unchecked ((byte)-1), false);
                Assert.AreEqual("Arial", run.FontFamily);
                run.SetFontFamily("Arial", (byte)1, (byte)1, true);
                Assert.AreEqual("Arial", run.FontFamily);
                run.SetFontFamily(null, (byte)1, (byte)1, false);
                Assert.AreEqual("Calibri", run.FontFamily);
                run.SetFontFamily(null, (byte)1, (byte)1, false);
                Assert.AreEqual("Calibri", run.FontFamily);

                run.SetFont("Arial");
                Assert.AreEqual("Arial", run.FontFamily);

                Assert.AreEqual((byte)0, run.PitchAndFamily);
                run.SetFont(null);
                Assert.AreEqual((byte)0, run.PitchAndFamily);

                Assert.IsFalse(run.IsStrikethrough);
                run.IsStrikethrough = (/*setter*/ true);
                Assert.IsTrue(run.IsStrikethrough);
                run.IsStrikethrough = (/*setter*/ false);
                Assert.IsFalse(run.IsStrikethrough);

                Assert.IsFalse(run.IsSuperscript);
                run.IsSuperscript = (/*setter*/ true);
                Assert.IsTrue(run.IsSuperscript);
                run.IsSuperscript = (/*setter*/ false);
                Assert.IsFalse(run.IsSuperscript);

                Assert.IsFalse(run.IsSubscript);
                run.IsSubscript = (/*setter*/ true);
                Assert.IsTrue(run.IsSubscript);
                run.IsSubscript = (/*setter*/ false);
                Assert.IsFalse(run.IsSubscript);

                Assert.AreEqual(TextCap.NONE, run.TextCap);

                Assert.IsFalse(run.IsBold);
                run.IsBold = (/*setter*/ true);
                Assert.IsTrue(run.IsBold);
                run.IsBold = (/*setter*/ false);
                Assert.IsFalse(run.IsBold);

                Assert.IsFalse(run.IsItalic);
                run.IsItalic = (/*setter*/ true);
                Assert.IsTrue(run.IsItalic);
                run.IsItalic = (/*setter*/ false);
                Assert.IsFalse(run.IsItalic);

                Assert.IsFalse(run.IsUnderline);
                run.IsUnderline = (/*setter*/ true);
                Assert.IsTrue(run.IsUnderline);
                run.IsUnderline = (/*setter*/ false);
                Assert.IsFalse(run.IsUnderline);

                Assert.IsNotNull(run.ToString());
            }
            finally
            {
                wb.Close();
            }
        }
Exemple #24
0
        /**
         * Returns a prototype that is used to construct new shapes
         *
         * @return a prototype that is used to construct new shapes
         */

        public XSSFPicture(XSSFDrawing drawing, XElement ctPicture)
        {
            this.drawing   = drawing;
            this.ctPicture = CT_Picture.Parse(ctPicture, POIXMLDocumentPart.NamespaceManager);
        }
Exemple #25
0
        /**
         * Construct a new XSSFPicture object. This constructor is called from
         *  {@link XSSFDrawing#CreatePicture(XSSFClientAnchor, int)}
         *
         * @param Drawing the XSSFDrawing that owns this picture
         */

        public XSSFPicture(XSSFDrawing drawing, CT_Picture ctPicture)
        {
            this.drawing   = drawing;
            this.ctPicture = ctPicture;
        }
Exemple #26
0
        /**
         * Construct a new XSSFSimpleShape object.
         *
         * @param Drawing the XSSFDrawing that owns this shape
         * @param ctGroup the XML bean that stores this group content
         */

        public XSSFShapeGroup(XSSFDrawing drawing, CT_GroupShape ctGroup)
        {
            this.drawing = drawing;
            this.ctGroup = ctGroup;
        }