Example #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
        }
Example #2
0
        public void linesSettingsCantGenerateMultiLevelBullets()
        {
            TildaTextbox tb = multiLevelLineBulletsFixture();

            Microsoft.Office.Core.ParagraphFormat2 pgformat = tb.shape.TextFrame2.TextRange.ParagraphFormat;

            int    fontsize      = (int)(tb.shape.TextFrame2.TextRange.Font.Size * Settings.Scaler());
            double bulletPadding = fontsize / 8;

            float bulletSize = (pgformat.Bullet.RelativeSize * (tb.shape.TextFrame2.TextRange.Font.Size / 4)) * Settings.Scaler();

            double x  = tb.findX();
            double x1 = x + (tb.shape.TextFrame2.TextRange.ParagraphFormat.FirstLineIndent + tb.shape.TextFrame2.TextRange.ParagraphFormat.LeftIndent) * Settings.Scaler();
            double x2 = x + (tb.shape.TextFrame2.TextRange.ParagraphFormat.LeftIndent + bulletPadding) * Settings.Scaler();
            double y  = tb.findY() + (pgformat.SpaceBefore) * Settings.Scaler();
            double y1 = y + bulletPadding;
            double y2 = y1 + fontsize + (pgformat.SpaceAfter) * Settings.Scaler() + bulletPadding;
            double y3 = y2 + fontsize + (pgformat.SpaceAfter) * Settings.Scaler() + bulletPadding;

            String expected = "idsToAnimate = new Array();" +
                              "preso.shapes.push(preso.paper.rect(" + x1 + "," + y + "," + bulletSize + "," + bulletSize + ").attr({'stroke':'#ff0000','fill':'#ff0000'}));" +
                              "preso.shapes.push(preso.paper.text(" + x2 + "," + y1 + ",'Bullet1').attr({'font-size':'24','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));" +
                              "preso.shapes.push(preso.paper.text(" + x2 + "," + y2 + ",'Bullet2').attr({'font-size':'24','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));" +
                              "preso.shapes.push(preso.paper.text(" + x2 + "," + y3 + ",'Bullet3').attr({'font-size':'24','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));";
            String actual = tb.toRaphJS();

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void bulletsAndParagraphsCanBeMixed()
        {
            TildaTextbox tb     = bulletsAndTextFixture();
            String       actual = tb.toRaphJS();

            Assert.AreEqual(2, StringUtil.CountStringOccurrences(actual, "preso.paper.rect"));
        }
Example #4
0
        public void canGenerateMultipleParagraphsWithMultipleLines()
        {
            TildaTextbox tb = multiLineAndParagraphFixture();

            int fontsize = (int)(tb.shape.TextFrame2.TextRange.Font.Size * Settings.Scaler());

            double x = tb.findX();

            Microsoft.Office.Core.ParagraphFormat2 pgformat = tb.shape.TextFrame2.TextRange.ParagraphFormat;
            double y1 = tb.findY() + (pgformat.SpaceBefore) * Settings.Scaler();
            double y2 = y1 + fontsize + (pgformat.SpaceAfter) * Settings.Scaler();
            double y3 = y2 + fontsize + (pgformat.SpaceAfter) * Settings.Scaler();
            double y4 = y3 + fontsize + (pgformat.SpaceAfter + pgformat.SpaceBefore) * Settings.Scaler();
            double y5 = y4 + fontsize + (pgformat.SpaceAfter) * Settings.Scaler();
            double y6 = y5 + fontsize + (pgformat.SpaceAfter) * Settings.Scaler();

            String expected = "idsToAnimate = new Array();" +
                              "preso.shapes.push(preso.paper.text(" + x + "," + y1 + ",'Paragraph1Line1').attr({'font-size':'" + fontsize + "','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));" +
                              "preso.shapes.push(preso.paper.text(" + x + "," + y2 + ",'Line2').attr({'font-size':'" + fontsize + "','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));" +
                              "preso.shapes.push(preso.paper.text(" + x + "," + y3 + ",'Line3').attr({'font-size':'" + fontsize + "','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));" +
                              "idsToAnimate = new Array();" +
                              "preso.shapes.push(preso.paper.text(" + x + "," + y4 + ",'Paragraph2Line3').attr({'font-size':'" + fontsize + "','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));" +
                              "preso.shapes.push(preso.paper.text(" + x + "," + y5 + ",'Line4').attr({'font-size':'" + fontsize + "','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));" +
                              "preso.shapes.push(preso.paper.text(" + x + "," + y6 + ",'Line5').attr({'font-size':'" + fontsize + "','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));";

            String actual = tb.toRaphJS();

            Assert.AreEqual(expected, actual);
        }
Example #5
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!
        }
Example #6
0
        public void TildaTextboxConstructorTest()
        {
            PowerPoint.Shape shape = new MockShape();
            int          id        = 15;
            TildaTextbox target    = new TildaTextbox(shape, id);

            Assert.AreEqual(shape, target.shape);
            Assert.AreEqual(id, target.id);
        }
Example #7
0
        public void numberedBulletsPossible()
        {
            TildaTextbox tb = numberedBulletsFixture();

            Microsoft.Office.Core.ParagraphFormat2 pgformat = tb.shape.TextFrame2.TextRange.ParagraphFormat;
            //not testing position, just want 1. and 2. to appear
            String actual = tb.toRaphJS();

            Assert.AreEqual(true, actual.Contains(",'1.')"));
            Assert.AreEqual(true, actual.Contains(",'2.')"));
        }
Example #8
0
        public void textCanBeBottomAligned()
        {
            TildaTextbox tb     = bottomAnchorFixture();
            String       actual = tb.toRaphJS();
            //essentially they should be in the reverse order, the rest of the positioning is tested elsewhere
            int first  = actual.IndexOf("This is Line the 3rd");
            int second = actual.IndexOf("Line2");
            int third  = actual.IndexOf("Line1");

            Assert.AreEqual(true, first < second);
            Assert.AreEqual(true, second < third);
        }
Example #9
0
        public void canGenerateOneParagraph()
        {
            TildaTextbox tb       = oneSentenceFixture();
            int          fontsize = (int)(tb.shape.TextFrame2.TextRange.Font.Size * Settings.Scaler());
            //no need to check these functions, but we will be adding values to them
            double x = tb.findX();
            double y = tb.findY();

            // offsetting text
            y += (tb.shape.TextFrame2.TextRange.ParagraphFormat.SpaceBefore) * Settings.Scaler();

            String expected = "idsToAnimate = new Array();" +
                              "preso.shapes.push(preso.paper.text(" + x + "," + y + ",'Paragraph1').attr("
                              + "{'font-size':'" + fontsize + "','fill':'#ff0000','font-family':'Verdana','transformation':'r0','text-anchor': 'start'}));";

            String actual = tb.toRaphJS();

            Assert.AreEqual(expected, actual);
        }
Example #10
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
        }
Example #11
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());
        }
Example #12
0
        public void numberedBulletStylesWorkPossible()
        {
            TildaTextbox tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletAlphaLCParenBoth);
            String       actual = tb.toRaphJS();

            Assert.AreEqual(true, actual.Contains(",'(a)')"));
            Assert.AreEqual(true, actual.Contains(",'(b)')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletAlphaLCParenRight);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'a)')"));
            Assert.AreEqual(true, actual.Contains(",'b)')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletAlphaLCPeriod);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'a.')"));
            Assert.AreEqual(true, actual.Contains(",'b.')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletAlphaUCParenBoth);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'(A)')"));
            Assert.AreEqual(true, actual.Contains(",'(B)')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletAlphaUCParenRight);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'A)')"));
            Assert.AreEqual(true, actual.Contains(",'B)')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletAlphaUCPeriod);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'A.')"));
            Assert.AreEqual(true, actual.Contains(",'B.')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletArabicDBPeriod);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'1.')"));
            Assert.AreEqual(true, actual.Contains(",'2.')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletArabicDBPlain);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'1.')"));
            Assert.AreEqual(true, actual.Contains(",'2.')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletArabicParenBoth);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'(1)')"));
            Assert.AreEqual(true, actual.Contains(",'(2)')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletArabicParenRight);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'1)')"));
            Assert.AreEqual(true, actual.Contains(",'2)')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletArabicPeriod);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'1.')"));
            Assert.AreEqual(true, actual.Contains(",'2.')"));

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletArabicPlain);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'1.')"));
            Assert.AreEqual(true, actual.Contains(",'2.')"));

            //else, just one test, but basically all other options should follow:

            tb     = numberedBulletsFixture(Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletCircleNumDBPlain);
            actual = tb.toRaphJS();
            Assert.AreEqual(true, actual.Contains(",'1.')"));
            Assert.AreEqual(true, actual.Contains(",'2.')"));
        }