Пример #1
0
        public void findXTest()
        {
            PowerPoint.Shape shape = new MockShape();
            int            id      = 15;
            MockTextRange2 tr      = (MockTextRange2)shape.TextFrame2.TextRange;

            shape.Left  = 7f;
            shape.Width = 100f;
            shape.TextFrame2.MarginLeft  = 1.1f;
            shape.TextFrame2.MarginRight = 1.2f;
            TildaTextbox target = new TildaTextbox(shape, id);

            //left aligned
            shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignLeft;
            Assert.AreEqual((shape.Left + shape.TextFrame2.MarginLeft) * Settings.Scaler(), target.findX(), .001);

            //right aligned
            shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignRight;
            Assert.AreEqual((shape.Left + shape.Width - shape.TextFrame2.MarginRight) * Settings.Scaler(), target.findX(), .001);

            //centered
            shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignCenter;
            Assert.AreEqual((shape.Width / 2 + shape.Left + shape.TextFrame2.MarginLeft) * Settings.Scaler(), target.findX(), .001);

            //dont care otherwise
        }
Пример #2
0
        public void findYTest()
        {
            PowerPoint.Shape shape = new MockShape();
            int            id      = 15;
            MockTextRange2 tr      = (MockTextRange2)shape.TextFrame2.TextRange;

            shape.Top = 5f;
            shape.TextFrame2.MarginTop    = 3.2f;
            shape.TextFrame2.MarginBottom = 4.2f;
            shape.Height = 100f;
            TildaTextbox target = new TildaTextbox(shape, id);

            //bottom aligned
            shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorBottom;
            Assert.AreEqual((shape.Top + shape.Height - shape.TextFrame2.MarginBottom) * Settings.Scaler(), target.findY(), .001);

            //baseline aligned
            shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorBottomBaseLine;
            Assert.AreEqual((shape.Top + shape.Height) * Settings.Scaler(), target.findY(), .001);

            //top aligned
            shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorTop;
            Assert.AreEqual((shape.Top + shape.TextFrame2.MarginTop) * Settings.Scaler(), target.findY(), .001);

            //top baseline aligned
            shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorTopBaseline;
            Assert.AreEqual((shape.Top) * Settings.Scaler(), target.findY(), .001);

            //middle
            shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorMiddle;
            Assert.AreEqual((shape.Height / 2 + shape.TextFrame2.MarginTop + shape.Top) * Settings.Scaler(), target.findY(), .001);


            //otherwise don't care!
        }
Пример #3
0
        public void fontPositionTest()
        {
            PowerPoint.Shape shape = new MockShape();
            int            id      = 15;
            MockTextRange2 tr      = (MockTextRange2)shape.TextFrame2.TextRange;
            TildaTextbox   target  = new TildaTextbox(shape, id);

            //left aligned
            shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignLeft;
            Assert.AreEqual("'text-anchor': 'start'", target.fontPosition());

            //center aligned
            shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignCenter;
            Assert.AreEqual("'text-anchor': 'middle'", target.fontPosition());

            //right aligned
            shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignRight;
            Assert.AreEqual("'text-anchor': 'end'", target.fontPosition());

            //otherwise don't care
        }
Пример #4
0
        public void fontStyleTest()
        {
            int    redRGB = 16711680;
            string redHex = "#ff0000";

            PowerPoint.Shape shape = new MockShape();
            int            id      = 15;
            MockTextRange2 tr      = (MockTextRange2)shape.TextFrame2.TextRange;

            tr.Font.Name = "Verdana";
            tr.Font.Size = 12f;
            tr.Font.Fill.ForeColor.RGB = redRGB;
            TildaTextbox target = new TildaTextbox(shape, id);

            String expected = "'font-size':'" + Settings.Scaler() * tr.Font.Size + "','fill':'" + redHex + "'";

            //No bold or italic
            Assert.AreEqual(expected + ",'font-family':'" + tr.Font.Name + "'", target.fontStyle());

            //Italic only
            tr.Font.Italic = Microsoft.Office.Core.MsoTriState.msoCTrue;
            Assert.AreEqual(expected + ",'font-family':'" + tr.Font.Name + " italic'", target.fontStyle());
            tr.Font.Italic = Microsoft.Office.Core.MsoTriState.msoTrue;
            Assert.AreEqual(expected + ",'font-family':'" + tr.Font.Name + " italic'", target.fontStyle());

            //Bold only
            tr.Font.Italic = Microsoft.Office.Core.MsoTriState.msoFalse;
            tr.Font.Bold   = Microsoft.Office.Core.MsoTriState.msoTrue;
            Assert.AreEqual(expected + ",'font-weight':'bold','font-family':'" + tr.Font.Name + "'", target.fontStyle());
            tr.Font.Bold = Microsoft.Office.Core.MsoTriState.msoCTrue;
            Assert.AreEqual(expected + ",'font-weight':'bold','font-family':'" + tr.Font.Name + "'", target.fontStyle());

            //Bold and Italic
            tr.Font.Italic = Microsoft.Office.Core.MsoTriState.msoCTrue;
            Assert.AreEqual(expected + ",'font-weight':'bold','font-family':'" + tr.Font.Name + " italic'", target.fontStyle());
        }