示例#1
0
        public void CreateTwoParagraphs()
        {
            // Build First IStTxtPara
            IParaStylePropsProxy proxy = new DummyProxy("MyParaStyle");

            m_bldr.ParaStylePropsProxy = proxy;
            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary);

            m_bldr.AppendRun("Para 1", textProps);
            int        iPara = m_text.ParagraphsOS.Count;
            IStTxtPara para1 = m_bldr.CreateParagraph(m_text, iPara);

            // verify paragraph 1
            AssertEx.RunIsCorrect(para1.Contents, 0, "Para 1", null,
                                  m_wsArbitrary);

            // Build Second IStTxtPara -- Builder should have been cleared
            textProps = StyleUtils.CharStyleTextProps("BringBrangBrung", m_wsArbitrary);
            m_bldr.AppendRun("Para 2", textProps);
            IStTxtPara para2 = m_bldr.CreateParagraph(m_text, iPara + 1);

            Assert.AreEqual(m_text.ParagraphsOS[iPara], para1);
            Assert.AreEqual(m_text.ParagraphsOS[iPara + 1], para2);

            // Re-verify paragraph 1
            AssertEx.RunIsCorrect(para1.Contents, 0, "Para 1", null, m_wsArbitrary);
            // verify paragraph 2
            AssertEx.RunIsCorrect(para2.Contents, 0, "Para 2", "BringBrangBrung", m_wsArbitrary);
        }
示例#2
0
        public void CreateParagraphEmpty()
        {
            // create an IStTxtPara
            IParaStylePropsProxy proxy = new DummyProxy("EmptyPara");

            m_bldr.ParaStylePropsProxy = proxy;
            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary);

            m_bldr.AppendRun(string.Empty, textProps);
            Assert.AreEqual(0, m_bldr.Length);
            IStTxtPara para = m_bldr.CreateParagraph(m_text, 1);

            // verify paragraph's state
            Assert.IsNotNull(para);
            Assert.AreEqual(proxy.StyleId, para.StyleName);
            Assert.AreEqual(1, para.Contents.RunCount);
            Assert.IsNull(para.Contents.Text);
        }
示例#3
0
        public void TrimTrailingSpaceWithNoSpaceAtEnd()
        {
            // Build an IStTxtPara
            IParaStylePropsProxy proxy = new DummyProxy("Whatever");

            m_bldr.ParaStylePropsProxy = proxy;
            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary);

            m_bldr.AppendRun("My run", textProps);
            Assert.AreEqual(6, m_bldr.Length);
            // Attempt to trim the space off the end -- nothing should happen.
            m_bldr.TrimTrailingSpaceInPara();
            Assert.AreEqual(6, m_bldr.Length);
            IStTxtPara para = m_bldr.CreateParagraph(m_text, 1);

            // verify paragraph contents
            AssertEx.RunIsCorrect(para.Contents, 0, "My run", null,
                                  m_wsArbitrary);
        }
示例#4
0
        public void TrimTrailingSpaceWithTwoSpacesAtEnd()
        {
            // create an IStTxtPara
            IParaStylePropsProxy proxy = new DummyProxy("Whatever");

            m_bldr.ParaStylePropsProxy = proxy;
            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary);

            m_bldr.AppendRun("My run  ", textProps);
            Assert.AreEqual(8, m_bldr.Length);
            // trim one of the spaces off the end
            m_bldr.TrimTrailingSpaceInPara();
            Assert.AreEqual(7, m_bldr.Length);
            IStTxtPara para = m_bldr.CreateParagraph(m_text, 1);

            // verify paragraph contents
            AssertEx.RunIsCorrect(para.Contents, 0, "My run ", null,
                                  m_wsArbitrary);
        }
示例#5
0
        public void AppendRunWithNamedCharStyle()
        {
            // create an IStTxtPara
            IParaStylePropsProxy proxy = new DummyProxy("Whatever");

            m_bldr.ParaStylePropsProxy = proxy;
            ITsTextProps textProps =
                StyleUtils.CharStyleTextProps("George's Favorite Char Style", m_wsArbitrary);

            m_bldr.AppendRun("My run", textProps);

            IStTxtPara para = m_bldr.CreateParagraph(m_text, 1);

            // verify paragraph's state
            Assert.IsNotNull(para);
            Assert.AreEqual(proxy.StyleId, para.StyleName);
            AssertEx.RunIsCorrect(para.Contents, 0, "My run", "George's Favorite Char Style",
                                  m_wsArbitrary);
            // Builder should now be cleared
            Assert.AreEqual(0, m_bldr.Length);
        }
示例#6
0
        public void AppendParagraph()
        {
            // Build an IStTxtPara
            IParaStylePropsProxy proxy = new DummyProxy("Para Meister");

            m_bldr.ParaStylePropsProxy = proxy;
            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary);

            m_bldr.AppendRun("Run 1", textProps);

            int        iPara = m_text.ParagraphsOS.Count;
            IStTxtPara para  = m_bldr.CreateParagraph(m_text);

            // verify paragraph's state
            Assert.IsNotNull(para);
            Assert.AreEqual(proxy.StyleId, para.StyleName);
            AssertEx.RunIsCorrect(para.Contents, 0, "Run 1", null,
                                  m_wsArbitrary);
            Assert.AreEqual(para.Hvo, m_text.ParagraphsOS[iPara].Hvo);
            // Builder should now be cleared
            Assert.AreEqual(0, m_bldr.Length);
        }
示例#7
0
        public void AppendTwoRuns_WithAndWithoutNamedCharStyles()
        {
            // Build an IStTxtPara
            IParaStylePropsProxy proxy = new DummyProxy("Para Meister");

            m_bldr.ParaStylePropsProxy = proxy;
            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null, m_wsArbitrary);

            m_bldr.AppendRun("Run 1 ", textProps);
            textProps = StyleUtils.CharStyleTextProps("Italic Run", m_wsArbitrary);
            // verify its length
            Assert.AreEqual(6, m_bldr.Length);
            // add another run
            m_bldr.AppendRun("Run 2", textProps);
            IStTxtPara para = m_bldr.CreateParagraph(m_text, 1);

            // verify paragraph's state
            Assert.IsNotNull(para);
            Assert.AreEqual(proxy.StyleId, para.StyleName);
            AssertEx.RunIsCorrect(para.Contents, 0, "Run 1 ", null, m_wsArbitrary);
            AssertEx.RunIsCorrect(para.Contents, 1, "Run 2", "Italic Run", m_wsArbitrary);
            // Builder should now be cleared
            Assert.AreEqual(0, m_bldr.Length);
        }