Example #1
0
 /// <summary>
 /// Create another Group Under this Group.
 /// </summary>
 /// <param name="anchor">the position of the new Group.</param>
 /// <returns>the Group</returns>
 public HSSFShapeGroup CreateGroup(HSSFChildAnchor anchor)
 {
     HSSFShapeGroup group = new HSSFShapeGroup(this, anchor);
     group.Anchor = anchor;
     shapes.Add(group);
     return group;
 }
Example #2
0
 /// <summary>
 /// Create a new simple shape Under this Group.
 /// </summary>
 /// <param name="anchor">the position of the shape.</param>
 /// <returns>the shape</returns>
 public HSSFSimpleShape CreateShape(HSSFChildAnchor anchor)
 {
     HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);
     shape.Anchor = anchor;
     shapes.Add(shape);
     return shape;
 }
Example #3
0
 /// <summary>
 /// Create a new textbox Under this Group.
 /// </summary>
 /// <param name="anchor">the position of the shape.</param>
 /// <returns>the textbox</returns>
 public HSSFTextbox CreateTextbox(HSSFChildAnchor anchor)
 {
     HSSFTextbox shape = new HSSFTextbox(this, anchor);
     shape.Anchor = anchor;
     shapes.Add(shape);
     return shape;
 }
Example #4
0
        public HSSFShapeGroup(EscherContainerRecord spgrContainer, ObjRecord objRecord)
            : base(spgrContainer, objRecord)
        {
            // read internal and external coordinates from spgrContainer
            EscherContainerRecord spContainer = spgrContainer.ChildContainers[0];

            _spgrRecord = (EscherSpgrRecord)spContainer.GetChild(0);
            foreach (EscherRecord ch in spContainer.ChildRecords)
            {
                switch (ch.RecordId)
                {
                case EscherSpgrRecord.RECORD_ID:
                    break;

                case EscherClientAnchorRecord.RECORD_ID:
                    anchor = new HSSFClientAnchor((EscherClientAnchorRecord)ch);
                    break;

                case EscherChildAnchorRecord.RECORD_ID:
                    anchor = new HSSFChildAnchor((EscherChildAnchorRecord)ch);
                    break;

                default:
                    break;
                }
            }
        }
Example #5
0
        /// <summary>
        /// Creates a polygon
        /// </summary>
        /// <param name="anchor">the client anchor describes how this Group Is attached
        /// to the sheet.</param>
        /// <returns>the newly Created shape.</returns>
        public HSSFPolygon CreatePolygon(HSSFChildAnchor anchor)
        {
            HSSFPolygon shape = new HSSFPolygon(this, anchor);

            shape.Anchor = anchor;
            shapes.Add(shape);
            return(shape);
        }
Example #6
0
        /// <summary>
        /// Create another Group Under this Group.
        /// </summary>
        /// <param name="anchor">the position of the new Group.</param>
        /// <returns>the Group</returns>
        public HSSFShapeGroup CreateGroup(HSSFChildAnchor anchor)
        {
            HSSFShapeGroup group = new HSSFShapeGroup(this, anchor);

            group.Anchor = anchor;
            shapes.Add(group);
            return(group);
        }
Example #7
0
        /// <summary>
        /// Create a new simple shape Under this Group.
        /// </summary>
        /// <param name="anchor">the position of the shape.</param>
        /// <returns>the shape</returns>
        public HSSFSimpleShape CreateShape(HSSFChildAnchor anchor)
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);

            shape.Anchor = anchor;
            shapes.Add(shape);
            return(shape);
        }
Example #8
0
        /// <summary>
        /// Create a new textbox Under this Group.
        /// </summary>
        /// <param name="anchor">the position of the shape.</param>
        /// <returns>the textbox</returns>
        public HSSFTextbox CreateTextbox(HSSFChildAnchor anchor)
        {
            HSSFTextbox shape = new HSSFTextbox(this, anchor);

            shape.Anchor = anchor;
            shapes.Add(shape);
            return(shape);
        }
Example #9
0
        /// <summary>
        /// Creates a picture.
        /// </summary>
        /// <param name="anchor">the client anchor describes how this Group Is attached
        /// to the sheet.</param>
        /// <param name="pictureIndex">Index of the picture.</param>
        /// <returns>the newly Created shape.</returns>
        public HSSFPicture CreatePicture(HSSFChildAnchor anchor, int pictureIndex)
        {
            HSSFPicture shape = new HSSFPicture(this, anchor);

            shape.Anchor       = anchor;
            shape.PictureIndex = pictureIndex;
            shapes.Add(shape);
            return(shape);
        }
Example #10
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (obj == this)
            {
                return(true);
            }
            if (obj.GetType() != GetType())
            {
                return(false);
            }
            HSSFChildAnchor anchor = (HSSFChildAnchor)obj;

            return(anchor.Dx1 == Dx1 && anchor.Dx2 == Dx2 && anchor.Dy1 == Dy1 &&
                   anchor.Dy2 == Dy2);
        }
Example #11
0
        /// <summary>
        /// Create a new simple shape Under this Group.
        /// </summary>
        /// <param name="anchor">the position of the shape.</param>
        /// <returns>the shape</returns>
        public HSSFSimpleShape CreateShape(HSSFChildAnchor anchor)
        {
            HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);

            shape.Parent = this;
            shape.Anchor = anchor;
            shapes.Add(shape);
            OnCreate(shape);
            EscherSpRecord sp = (EscherSpRecord)shape.GetEscherContainer().GetChildById(EscherSpRecord.RECORD_ID);

            if (shape.Anchor.IsHorizontallyFlipped)
            {
                sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ);
            }
            if (shape.Anchor.IsVerticallyFlipped)
            {
                sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPVERT);
            }
            return(shape);
        }
Example #12
0
 public HSSFShapeGroup(EscherContainerRecord spgrContainer, ObjRecord objRecord)
     : base(spgrContainer, objRecord)
 {
     // read internal and external coordinates from spgrContainer
     EscherContainerRecord spContainer = spgrContainer.ChildContainers[0];
     _spgrRecord = (EscherSpgrRecord)spContainer.GetChild(0);
     foreach (EscherRecord ch in spContainer.ChildRecords)
     {
         switch (ch.RecordId)
         {
             case EscherSpgrRecord.RECORD_ID:
                 break;
             case EscherClientAnchorRecord.RECORD_ID:
                 anchor = new HSSFClientAnchor((EscherClientAnchorRecord)ch);
                 break;
             case EscherChildAnchorRecord.RECORD_ID:
                 anchor = new HSSFChildAnchor((EscherChildAnchorRecord)ch);
                 break;
         }
     }
 }
Example #13
0
        public void TestDefaultValues()
        {
            HSSFClientAnchor clientAnchor = new HSSFClientAnchor();
            Assert.AreEqual(clientAnchor.AnchorType, 0);
            Assert.AreEqual(clientAnchor.Col1, 0);
            Assert.AreEqual(clientAnchor.Col2, 0);
            Assert.AreEqual(clientAnchor.Dx1, 0);
            Assert.AreEqual(clientAnchor.Dx2, 0);
            Assert.AreEqual(clientAnchor.Dy1, 0);
            Assert.AreEqual(clientAnchor.Dy2, 0);
            Assert.AreEqual(clientAnchor.Row1, 0);
            Assert.AreEqual(clientAnchor.Row2, 0);

            clientAnchor = new HSSFClientAnchor(new EscherClientAnchorRecord());
            Assert.AreEqual(clientAnchor.AnchorType, 0);
            Assert.AreEqual(clientAnchor.Col1, 0);
            Assert.AreEqual(clientAnchor.Col2, 0);
            Assert.AreEqual(clientAnchor.Dx1, 0);
            Assert.AreEqual(clientAnchor.Dx2, 0);
            Assert.AreEqual(clientAnchor.Dy1, 0);
            Assert.AreEqual(clientAnchor.Dy2, 0);
            Assert.AreEqual(clientAnchor.Row1, 0);
            Assert.AreEqual(clientAnchor.Row2, 0);

            HSSFChildAnchor childAnchor = new HSSFChildAnchor();
            Assert.AreEqual(childAnchor.Dx1, 0);
            Assert.AreEqual(childAnchor.Dx2, 0);
            Assert.AreEqual(childAnchor.Dy1, 0);
            Assert.AreEqual(childAnchor.Dy2, 0);

            childAnchor = new HSSFChildAnchor(new EscherChildAnchorRecord());
            Assert.AreEqual(childAnchor.Dx1, 0);
            Assert.AreEqual(childAnchor.Dx2, 0);
            Assert.AreEqual(childAnchor.Dy1, 0);
            Assert.AreEqual(childAnchor.Dy2, 0);
        }
Example #14
0
 /// <summary>
 /// Creates a polygon
 /// </summary>
 /// <param name="anchor">the client anchor describes how this Group Is attached
 /// to the sheet.</param>
 /// <returns>the newly Created shape.</returns>
 public HSSFPolygon CreatePolygon(HSSFChildAnchor anchor)
 {
     HSSFPolygon shape = new HSSFPolygon(this, anchor);
     shape.Anchor = anchor;
     shapes.Add(shape);
     return shape;
 }
Example #15
0
        public void TestChildAnchorFromScratch()
        {
            HSSFChildAnchor anchor = new HSSFChildAnchor();
            EscherChildAnchorRecord escher = (EscherChildAnchorRecord)HSSFTestHelper.GetEscherAnchor(anchor);
            anchor.SetAnchor(11, 12, 13, 14);

            Assert.AreEqual(anchor.Dx1, 11);
            Assert.AreEqual(escher.Dx1, 11);
            Assert.AreEqual(anchor.Dx2, 13);
            Assert.AreEqual(escher.Dx2, 13);
            Assert.AreEqual(anchor.Dy1, 12);
            Assert.AreEqual(escher.Dy1, 12);
            Assert.AreEqual(anchor.Dy2, 14);
            Assert.AreEqual(escher.Dy2, 14);

            anchor.Dx1=(115);
            Assert.AreEqual(anchor.Dx1, 115);
            Assert.AreEqual(escher.Dx1, 115);
            anchor.Dx2=(116);
            Assert.AreEqual(anchor.Dx2, 116);
            Assert.AreEqual(escher.Dx2, 116);
            anchor.Dy1=(117);
            Assert.AreEqual(anchor.Dy1, 117);
            Assert.AreEqual(escher.Dy1, 117);
            anchor.Dy2=(118);
            Assert.AreEqual(anchor.Dy2, 118);
            Assert.AreEqual(escher.Dy2, 118);
        }
Example #16
0
        public void TestEqualsToSelf()
        {
            HSSFClientAnchor clientAnchor = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7);
            Assert.AreEqual(clientAnchor, clientAnchor);

            HSSFChildAnchor childAnchor = new HSSFChildAnchor(0, 1, 2, 3);
            Assert.AreEqual(childAnchor, childAnchor);
        }
Example #17
0
        public void TestPassIncompatibleTypeIsFalse()
        {
            HSSFClientAnchor clientAnchor = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7);
            Assert.AreNotSame(clientAnchor, "wrongType");

            HSSFChildAnchor childAnchor = new HSSFChildAnchor(0, 1, 2, 3);
            Assert.AreNotSame(childAnchor, "wrongType");
        }
Example #18
0
 /// <summary>
 /// Creates a picture.
 /// </summary>
 /// <param name="anchor">the client anchor describes how this Group Is attached
 /// to the sheet.</param>
 /// <param name="pictureIndex">Index of the picture.</param>
 /// <returns>the newly Created shape.</returns>
 public HSSFPicture CreatePicture(HSSFChildAnchor anchor, int pictureIndex)
 {
     HSSFPicture shape = new HSSFPicture(this, anchor);
     shape.Anchor = anchor;
     shape.PictureIndex=pictureIndex;
     shapes.Add(shape);
     return shape;
 }
Example #19
0
        public void TestModify()
        {
            HSSFWorkbook wb = new HSSFWorkbook();

            // create a sheet with a text box
            HSSFSheet sheet = wb.CreateSheet() as HSSFSheet;
            HSSFPatriarch patriarch = sheet.CreateDrawingPatriarch() as HSSFPatriarch;

            HSSFShapeGroup group1 = patriarch.CreateGroup(new
                    HSSFClientAnchor(0, 0, 0, 0,
                    (short)0, 0, (short)15, 25));
            group1.SetCoordinates(0, 0, 792, 612);

            HSSFTextbox textbox1 = group1.CreateTextbox(new
                    HSSFChildAnchor(100, 100, 300, 300));
            HSSFRichTextString rt1 = new HSSFRichTextString("Hello, World!");
            textbox1.String = rt1;

            // Write, read back and check that our text box is there
            wb = HSSFTestDataSamples.WriteOutAndReadBack(wb);
            sheet = wb.GetSheetAt(0) as HSSFSheet;
            patriarch = sheet.DrawingPatriarch as HSSFPatriarch;
            Assert.AreEqual(1, patriarch.Children.Count);

            group1 = (HSSFShapeGroup)patriarch.Children[(0)];
            Assert.AreEqual(1, group1.Children.Count);
            textbox1 = (HSSFTextbox)group1.Children[(0)];
            Assert.AreEqual("Hello, World!", textbox1.String.String);

            // modify anchor
            Assert.AreEqual(new HSSFChildAnchor(100, 100, 300, 300),
                    textbox1.Anchor);
            HSSFChildAnchor newAnchor = new HSSFChildAnchor(200, 200, 400, 400);
            textbox1.Anchor = newAnchor;
            // modify text
            textbox1.String = new HSSFRichTextString("Hello, World! (modified)");

            // add a new text box
            HSSFTextbox textbox2 = group1.CreateTextbox(new
                    HSSFChildAnchor(400, 400, 600, 600));
            HSSFRichTextString rt2 = new HSSFRichTextString("Hello, World-2");
            textbox2.String = rt2;
            Assert.AreEqual(2, group1.Children.Count);

            wb = HSSFTestDataSamples.WriteOutAndReadBack(wb);
            sheet = wb.GetSheetAt(0) as HSSFSheet;
            patriarch = sheet.DrawingPatriarch as HSSFPatriarch;
            Assert.AreEqual(1, patriarch.Children.Count);

            group1 = (HSSFShapeGroup)patriarch.Children[(0)];
            Assert.AreEqual(2, group1.Children.Count);
            textbox1 = (HSSFTextbox)group1.Children[(0)];
            Assert.AreEqual("Hello, World! (modified)",
                    textbox1.String.String);
            Assert.AreEqual(new HSSFChildAnchor(200, 200, 400, 400),
                    textbox1.Anchor);

            textbox2 = (HSSFTextbox)group1.Children[(1)];
            Assert.AreEqual("Hello, World-2", textbox2.String.String);
            Assert.AreEqual(new HSSFChildAnchor(400, 400, 600, 600),
                    textbox2.Anchor);

            wb = HSSFTestDataSamples.WriteOutAndReadBack(wb);
            sheet = wb.GetSheetAt(0) as HSSFSheet;
            patriarch = sheet.DrawingPatriarch as HSSFPatriarch;
            group1 = (HSSFShapeGroup)patriarch.Children[(0)];
            textbox1 = (HSSFTextbox)group1.Children[(0)];
            textbox2 = (HSSFTextbox)group1.Children[(1)];
            HSSFTextbox textbox3 = group1.CreateTextbox(new
                    HSSFChildAnchor(400, 200, 600, 400));
            HSSFRichTextString rt3 = new HSSFRichTextString("Hello, World-3");
            textbox3.String = rt3;
        }
Example #20
0
 /// <summary>
 /// Creates a picture.
 /// </summary>
 /// <param name="anchor">the client anchor describes how this Group Is attached
 /// to the sheet.</param>
 /// <param name="pictureIndex">Index of the picture.</param>
 /// <returns>the newly Created shape.</returns>
 public HSSFPicture CreatePicture(HSSFChildAnchor anchor, int pictureIndex)
 {
     HSSFPicture shape = new HSSFPicture(this, anchor);
     shape.Parent = this;
     shape.Anchor = anchor;
     shape.PictureIndex=pictureIndex;
     shapes.Add(shape);
     OnCreate(shape);
     EscherSpRecord sp = (EscherSpRecord)shape.GetEscherContainer().GetChildById(EscherSpRecord.RECORD_ID);
     if (shape.Anchor.IsHorizontallyFlipped)
     {
         sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPHORIZ);
     }
     if (shape.Anchor.IsVerticallyFlipped)
     {
         sp.Flags = (sp.Flags | EscherSpRecord.FLAG_FLIPVERT);
     }
     return shape;
 }
Example #21
0
        public void TestNullReferenceIsFalse()
        {
            HSSFClientAnchor clientAnchor = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7);
            Assert.IsFalse(clientAnchor.Equals(null), "Passing null to equals should return false");

            HSSFChildAnchor childAnchor = new HSSFChildAnchor(0, 1, 2, 3);
            Assert.IsFalse(childAnchor.Equals(null), "Passing null to equals should return false");
        }
Example #22
0
        public void TestEqualsIsReflexiveIsSymmetric()
        {
            HSSFClientAnchor clientAnchor1 = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7);
            HSSFClientAnchor clientAnchor2 = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7);

            Assert.IsTrue(clientAnchor1.Equals(clientAnchor2));
            Assert.IsTrue(clientAnchor1.Equals(clientAnchor2));

            HSSFChildAnchor childAnchor1 = new HSSFChildAnchor(0, 1, 2, 3);
            HSSFChildAnchor childAnchor2 = new HSSFChildAnchor(0, 1, 2, 3);

            Assert.IsTrue(childAnchor1.Equals(childAnchor2));
            Assert.IsTrue(childAnchor2.Equals(childAnchor1));
        }
Example #23
0
        public void TestChildAnchorFromEscher()
        {
            EscherChildAnchorRecord escher = new EscherChildAnchorRecord();
            escher.Dx1=((short)15);
            escher.Dx2=((short)16);
            escher.Dy1=((short)17);
            escher.Dy2=((short)18);

            HSSFChildAnchor anchor = new HSSFChildAnchor(escher);
            Assert.AreEqual(anchor.Dx1, 15);
            Assert.AreEqual(escher.Dx1, 15);
            Assert.AreEqual(anchor.Dx2, 16);
            Assert.AreEqual(escher.Dx2, 16);
            Assert.AreEqual(anchor.Dy1, 17);
            Assert.AreEqual(escher.Dy1, 17);
            Assert.AreEqual(anchor.Dy2, 18);
            Assert.AreEqual(escher.Dy2, 18);
        }
Example #24
0
        public void TestEqualsValues()
        {
            HSSFClientAnchor clientAnchor1 = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7);
            HSSFClientAnchor clientAnchor2 = new HSSFClientAnchor(0, 1, 2, 3, (short)4, 5, (short)6, 7);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.Dx1=(10);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.Dx1=(0);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.Dy1=(10);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.Dy1=(1);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.Dx2=(10);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.Dx2=(2);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.Dy2=(10);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.Dy2=(3);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.Col1=(10);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.Col1=(4);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.Row1=(10);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.Row1=(5);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.Col2=(10);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.Col2=(6);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.Row2=(10);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.Row2=(7);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            clientAnchor2.AnchorType = (AnchorType)(3);
            Assert.AreNotSame(clientAnchor1, clientAnchor2);
            clientAnchor2.AnchorType=(0);
            Assert.AreEqual(clientAnchor1, clientAnchor2);

            HSSFChildAnchor childAnchor1 = new HSSFChildAnchor(0, 1, 2, 3);
            HSSFChildAnchor childAnchor2 = new HSSFChildAnchor(0, 1, 2, 3);

            childAnchor1.Dx1=(10);
            Assert.AreNotSame(childAnchor1, childAnchor2);
            childAnchor1.Dx1=(0);
            Assert.AreEqual(childAnchor1, childAnchor2);

            childAnchor2.Dy1=(10);
            Assert.AreNotSame(childAnchor1, childAnchor2);
            childAnchor2.Dy1=(1);
            Assert.AreEqual(childAnchor1, childAnchor2);

            childAnchor2.Dx2=(10);
            Assert.AreNotSame(childAnchor1, childAnchor2);
            childAnchor2.Dx2=(2);
            Assert.AreEqual(childAnchor1, childAnchor2);

            childAnchor2.Dy2=(10);
            Assert.AreNotSame(childAnchor1, childAnchor2);
            childAnchor2.Dy2=(3);
            Assert.AreEqual(childAnchor1, childAnchor2);
        }
Example #25
0
        public void testFlipped()
        {
            HSSFChildAnchor child = new HSSFChildAnchor(2, 2, 1, 1);
            Assert.AreEqual(child.IsHorizontallyFlipped, true);
            Assert.AreEqual(child.IsVerticallyFlipped, true);
            Assert.AreEqual(child.Dx1, 1);
            Assert.AreEqual(child.Dx2, 2);
            Assert.AreEqual(child.Dy1, 1);
            Assert.AreEqual(child.Dy2, 2);

            child = new HSSFChildAnchor(3, 3, 4, 4);
            Assert.AreEqual(child.IsHorizontallyFlipped, false);
            Assert.AreEqual(child.IsVerticallyFlipped, false);
            Assert.AreEqual(child.Dx1, 3);
            Assert.AreEqual(child.Dx2, 4);
            Assert.AreEqual(child.Dy1, 3);
            Assert.AreEqual(child.Dy2, 4);

            HSSFClientAnchor client = new HSSFClientAnchor(1, 1, 1, 1, (short)4, 4, (short)3, 3);
            Assert.AreEqual(client.IsVerticallyFlipped, true);
            Assert.AreEqual(client.IsHorizontallyFlipped, true);
            Assert.AreEqual(client.Col1, 3);
            Assert.AreEqual(client.Col2, 4);
            Assert.AreEqual(client.Row1, 3);
            Assert.AreEqual(client.Row2, 4);

            client = new HSSFClientAnchor(1, 1, 1, 1, (short)5, 5, (short)6, 6);
            Assert.AreEqual(client.IsVerticallyFlipped, false);
            Assert.AreEqual(client.IsHorizontallyFlipped, false);
            Assert.AreEqual(client.Col1, 5);
            Assert.AreEqual(client.Col2, 6);
            Assert.AreEqual(client.Row1, 5);
            Assert.AreEqual(client.Row2, 6);
        }