Ejemplo n.º 1
0
        /// <summary>
        /// attach an annotation describing this failure to the object. *Does Not* remove previous annotations! Generally call RemoveObsoleteAnnotations first.
        /// </summary>
        /// <remarks> I say it does not remove previous annotations because I haven't thought about how much smarts
        ///  it would take to only remove once associated with this particular failure. So I am stipulating for now that
        ///  the caller should first remove all of the kinds of indications which it might create.</remarks>
        /// <returns></returns>
        public ICmBaseAnnotation MakeAnnotation()
        {
            var annotation = m_cache.ServiceLocator.GetInstance <ICmBaseAnnotationFactory>().Create();

            m_cache.LanguageProject.AnnotationsOC.Add(annotation);
            annotation.CompDetails = m_xmlDescription;

            annotation.TextOA = m_cache.ServiceLocator.GetInstance <IStTextFactory>().Create();
            var paraBldr = new StTxtParaBldr(m_cache);

            //review: I have no idea what this has to be.
            paraBldr.ParaStyleName = "Paragraph";
            //todo: this pretends that the default analysis writing system is also the user
            // interface 1.  but I don't really know what's the right thing to do.
            paraBldr.AppendRun(m_explanation,
                               StyleUtils.CharStyleTextProps(null,
                                                             m_cache.DefaultAnalWs));
            paraBldr.CreateParagraph(annotation.TextOA);

            annotation.BeginObjectRA = m_object;
            annotation.Flid          = m_flid;
            annotation.CompDetails   = m_xmlDescription;
            annotation.SourceRA      = m_cache.LanguageProject.ConstraintCheckerAgent;
            return(annotation);
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates an empty paragraph with the given paragraph style and writing system.
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="owner"></param>
        /// <param name="paraStyle"></param>
        /// <param name="ws"></param>
        /// ------------------------------------------------------------------------------------
        public static void CreateEmptyPara(LcmCache cache, IStText owner, string paraStyle, int ws)
        {
            var bldr = new StTxtParaBldr(cache);

            bldr.ParaStyleName = paraStyle;
            bldr.AppendRun(String.Empty, StyleUtils.CharStyleTextProps(null, ws));
            bldr.CreateParagraph(owner);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void MoveNext_SpacesInVerses_ChapterNumberSeparate()
        {
            IScrSection sectionCur = AddSectionToMockedBook(m_genesis);

            // Create a section head for this section
            AddSectionHeadParaToSection(sectionCur, "My aching head!", ScrStyleNames.SectionHead);

            StTxtParaBldr paraBldr = new StTxtParaBldr(Cache);

            paraBldr.ParaStyleName = ScrStyleNames.NormalParagraph;
            paraBldr.AppendRun("1", StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("Verse One. ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.AppendRun("2", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun(" Verse Two. ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.AppendRun("3", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("Verse Three.",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            paraBldr.AppendRun("4", StyleUtils.CharStyleTextProps(ScrStyleNames.VerseNumber,
                                                                  Cache.DefaultVernWs));
            paraBldr.AppendRun("     ",
                               StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            IScrTxtPara para = (IScrTxtPara)paraBldr.CreateParagraph(sectionCur.ContentOA);

            using (ScrVerseSet verseSet = new ScrVerseSet(para))
            {
                // Iterate through the verses in the paragraph
                ScrVerse verse;

                Assert.IsTrue(verseSet.MoveNext());
                verse = verseSet.Current;
                Assert.AreEqual("1", verse.Text.Text);
                Assert.AreEqual(01001001, verse.StartRef);
                Assert.AreEqual(01001001, verse.EndRef);

                Assert.IsTrue(verseSet.MoveNext());
                verse = verseSet.Current;
                Assert.AreEqual("Verse One. ", verse.Text.Text);
                Assert.AreEqual(01001001, verse.StartRef);
                Assert.AreEqual(01001001, verse.EndRef);

                Assert.IsTrue(verseSet.MoveNext());
                verse = verseSet.Current;
                Assert.AreEqual("2 Verse Two. ", verse.Text.Text);
                Assert.AreEqual(01001002, verse.StartRef);
                Assert.AreEqual(01001002, verse.EndRef);

                Assert.IsTrue(verseSet.MoveNext());
                verse = verseSet.Current;
                Assert.AreEqual("3Verse Three.", verse.Text.Text);
                Assert.AreEqual(01001003, verse.StartRef);
                Assert.AreEqual(01001003, verse.EndRef);

                Assert.IsTrue(verseSet.MoveNext());
                verse = verseSet.Current;
                Assert.AreEqual("4     ", verse.Text.Text);
                Assert.AreEqual(01001004, verse.StartRef);
                Assert.AreEqual(01001004, verse.EndRef);

                Assert.IsFalse(verseSet.MoveNext());
            }
        }