Esempio n. 1
0
        public void TestPolygonPoints()
        {
            HSSFWorkbook  wb        = new HSSFWorkbook();
            HSSFSheet     sh        = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch;

            HSSFPolygon polygon = patriarch.CreatePolygon(new HSSFClientAnchor());

            polygon.SetPolygonDrawArea(100, 100);
            polygon.SetPoints(new int[] { 0, 90, 50, 90 }, new int[] { 5, 5, 44, 88 });

            PolygonShape polygonShape = HSSFTestModelHelper.CreatePolygonShape(0, polygon);

            EscherArrayProperty verticesProp1 = polygon.GetOptRecord().Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty;
            EscherArrayProperty verticesProp2 = ((EscherOptRecord)polygonShape.SpContainer.GetChildById(EscherOptRecord.RECORD_ID))
                                                .Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty;

            Assert.AreEqual(verticesProp1.NumberOfElementsInArray, verticesProp2.NumberOfElementsInArray);
            Assert.AreEqual(verticesProp1.ToXml(""), verticesProp2.ToXml(""));

            polygon.SetPoints(new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 });
            Assert.IsTrue(Arrays.Equals(polygon.XPoints, new int[] { 1, 2, 3 }));
            Assert.IsTrue(Arrays.Equals(polygon.YPoints, new int[] { 4, 5, 6 }));

            polygonShape  = HSSFTestModelHelper.CreatePolygonShape(0, polygon);
            verticesProp1 = polygon.GetOptRecord().Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty;
            verticesProp2 = ((EscherOptRecord)polygonShape.SpContainer.GetChildById(EscherOptRecord.RECORD_ID))
                            .Lookup(EscherProperties.GEOMETRY__VERTICES) as EscherArrayProperty;

            Assert.AreEqual(verticesProp1.NumberOfElementsInArray, verticesProp2.NumberOfElementsInArray);
            Assert.AreEqual(verticesProp1.ToXml(""), verticesProp2.ToXml(""));
        }
Esempio n. 2
0
        public void TestFindComments()
        {
            HSSFWorkbook  wb        = new HSSFWorkbook();
            HSSFSheet     sh        = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch;

            HSSFComment comment = patriarch.CreateCellComment(new HSSFClientAnchor()) as HSSFComment;
            HSSFRow     row     = sh.CreateRow(5) as HSSFRow;
            HSSFCell    cell    = row.CreateCell(4) as HSSFCell;

            cell.CellComment = (comment);

            HSSFTestModelHelper.CreateCommentShape(0, comment);

            Assert.IsNotNull(sh.FindCellComment(5, 4));
            Assert.IsNull(sh.FindCellComment(5, 5));

            HSSFWorkbook wbBack = HSSFTestDataSamples.WriteOutAndReadBack(wb);

            sh = wbBack.GetSheetAt(0) as HSSFSheet;

            Assert.IsNotNull(sh.FindCellComment(5, 4));
            Assert.IsNull(sh.FindCellComment(5, 5));

            wb.Close();
            wbBack.Close();
        }
Esempio n. 3
0
        public void TestResultEqualsToAbstractShape()
        {
            HSSFWorkbook  wb           = new HSSFWorkbook();
            HSSFSheet     sh           = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch    = sh.CreateDrawingPatriarch() as HSSFPatriarch;
            HSSFTextbox   textbox      = patriarch.CreateTextbox(new HSSFClientAnchor()) as HSSFTextbox;
            TextboxShape  textboxShape = HSSFTestModelHelper.CreateTextboxShape(1025, textbox);

            Assert.AreEqual(textbox.GetEscherContainer().ChildRecords.Count, 5);
            Assert.AreEqual(textboxShape.SpContainer.ChildRecords.Count, 5);

            //sp record
            byte[] expected = textboxShape.SpContainer.GetChild(0).Serialize();
            byte[] actual   = textbox.GetEscherContainer().GetChild(0).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = textboxShape.SpContainer.GetChild(2).Serialize();
            actual   = textbox.GetEscherContainer().GetChild(2).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = textboxShape.SpContainer.GetChild(3).Serialize();
            actual   = textbox.GetEscherContainer().GetChild(3).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = textboxShape.SpContainer.GetChild(4).Serialize();
            actual   = textbox.GetEscherContainer().GetChild(4).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            ObjRecord obj      = textbox.GetObjRecord();
            ObjRecord objShape = textboxShape.ObjRecord;

            expected = obj.Serialize();
            actual   = objShape.Serialize();

            TextObjectRecord tor      = textbox.GetTextObjectRecord();
            TextObjectRecord torShape = textboxShape.TextObjectRecord;

            expected = tor.Serialize();
            actual   = torShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));
        }
Esempio n. 4
0
        public void TestResultEqualsToAbstractShape()
        {
            HSSFWorkbook  wb        = new HSSFWorkbook();
            HSSFSheet     sh        = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch;

            HSSFPolygon polygon = patriarch.CreatePolygon(new HSSFClientAnchor());

            polygon.SetPolygonDrawArea(100, 100);
            polygon.SetPoints(new int[] { 0, 90, 50 }, new int[] { 5, 5, 44 });
            PolygonShape polygonShape = HSSFTestModelHelper.CreatePolygonShape(1024, polygon);

            polygon.ShapeId = (1024);

            Assert.AreEqual(polygon.GetEscherContainer().ChildRecords.Count, 4);
            Assert.AreEqual(polygonShape.SpContainer.ChildRecords.Count, 4);

            //sp record
            byte[] expected = polygonShape.SpContainer.GetChild(0).Serialize();
            byte[] actual   = polygon.GetEscherContainer().GetChild(0).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = polygonShape.SpContainer.GetChild(2).Serialize();
            actual   = polygon.GetEscherContainer().GetChild(2).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = polygonShape.SpContainer.GetChild(3).Serialize();
            actual   = polygon.GetEscherContainer().GetChild(3).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            ObjRecord obj      = polygon.GetObjRecord();
            ObjRecord objShape = polygonShape.ObjRecord;

            expected = obj.Serialize();
            actual   = objShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));
        }
Esempio n. 5
0
        public void TestResultEqualsToAbstractShape()
        {
            HSSFWorkbook  wb        = new HSSFWorkbook();
            HSSFSheet     sh        = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch = sh.CreateDrawingPatriarch() as HSSFPatriarch;

            HSSFComment comment = patriarch.CreateCellComment(new HSSFClientAnchor()) as HSSFComment;
            HSSFRow     row     = sh.CreateRow(0) as HSSFRow;
            HSSFCell    cell    = row.CreateCell(0) as HSSFCell;

            cell.CellComment = (comment);

            CommentShape commentShape = HSSFTestModelHelper.CreateCommentShape(1025, comment);

            Assert.AreEqual(comment.GetEscherContainer().ChildRecords.Count, 5);
            Assert.AreEqual(commentShape.SpContainer.ChildRecords.Count, 5);

            //sp record
            byte[] expected = commentShape.SpContainer.GetChild(0).Serialize();
            byte[] actual   = comment.GetEscherContainer().GetChild(0).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(2).Serialize();
            actual   = comment.GetEscherContainer().GetChild(2).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(3).Serialize();
            actual   = comment.GetEscherContainer().GetChild(3).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            expected = commentShape.SpContainer.GetChild(4).Serialize();
            actual   = comment.GetEscherContainer().GetChild(4).Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            ObjRecord obj      = comment.GetObjRecord();
            ObjRecord objShape = commentShape.ObjRecord;

            expected = obj.Serialize();
            actual   = objShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            //assertArrayEquals(expected, actual);


            TextObjectRecord tor      = comment.GetTextObjectRecord();
            TextObjectRecord torShape = commentShape.TextObjectRecord;

            expected = tor.Serialize();
            actual   = torShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            NoteRecord note      = comment.NoteRecord;
            NoteRecord noteShape = commentShape.NoteRecord;

            expected = note.Serialize();
            actual   = noteShape.Serialize();

            Assert.AreEqual(expected.Length, actual.Length);
            Assert.IsTrue(Arrays.Equals(expected, actual));

            wb.Close();
        }