public void DisableCompareBtn()
        {
            // Add Revelation, archive it and then remove it.
            int hvoTitle;

            Assert.IsNull(ScrBook.FindBookByID(m_cache, 66),
                          "Revelation should not be in the database. Restore the clean version of TestLangProj.");
            IScrBook        revelation = ScrBook.CreateNewScrBook(66, m_scr, out hvoTitle);
            ITsPropsFactory propFact   = TsPropsFactoryClass.Create();
            ITsTextProps    ttp        = propFact.MakeProps(ScrStyleNames.NormalParagraph, m_cache.DefaultVernWs, 0);

            ScrSection.CreateScrSection(revelation, 0, "Text for section", ttp, false);
            AddArchive("Revelation Archive", new List <int>(new int[] { revelation.Hvo }));
            m_scr.ScriptureBooksOS.Remove(m_scr.ScriptureBooksOS[3]);

            DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(m_cache);
            TreeView tree = dlg.ArchiveTree;

            // Select the archive node that was just added.
            tree.SelectedNode = tree.Nodes[0];
            dlg.SimulateSelectEvent();

            // Check to make sure the Compare to Current Version button is disabled
            Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled");

            // Select a book node.
            tree.SelectedNode = tree.Nodes[0].Nodes[0];
            dlg.SimulateSelectEvent();

            // Check to make sure the Diff button is still disabled if we select Philemon
            // after it is removed from the DB.
            Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled,
                           "The Compare to Current Version button should still");
        }
예제 #2
0
        public void ConvertChapterVerseNumbersTest_EmptyChapterNumber()
        {
            CheckDisposed();

            // Add paragraph with empty chapter number run.
            StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(m_exodus.SectionsOS[0].Hvo,
                                                                              ScrStyleNames.ChapterNumber);
            ITsPropsFactory propFact         = TsPropsFactoryClass.Create();
            ITsTextProps    ttpChapterNumber = propFact.MakeProps(ScrStyleNames.ChapterNumber,
                                                                  (int)InMemoryFdoCache.s_wsHvos.Fr, 0);
            ITsStrBldr bldr = para.Contents.UnderlyingTsString.GetBldr();

            bldr.SetProperties(0, 0, ttpChapterNumber);
            para.Contents.UnderlyingTsString = bldr.GetString();

            ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true);

            char bengaliZero = '\u09e6';
            char bengaliNine = (char)((int)bengaliZero + 9);

            // test arabic->bengali when there is a paragraph with an empty chapter number run.
            // It should complete without crashing.
            ScriptDigitConversionTest(bengaliZero, bengaliNine, dlg);
            // test bengali->arabic
            ScriptDigitConversionTest('0', '9', dlg);
        }
예제 #3
0
 public ITsString WsLabel(FdoCache cache)
 {
     if (m_tssWsLabel == null)
     {
         ITsPropsFactory tpf   = TsPropsFactoryClass.Create();
         ITsTextProps    ttp   = tpf.MakeProps("Language Code", cache.DefaultUserWs, 0);
         ITsStrFactory   tsf   = TsStrFactoryClass.Create();
         string          label = null;
         if (m_ws == LangProject.kwsFirstAnal)
         {
             label = ITextStrings.ksBstAn;
         }
         else if (m_ws == LangProject.kwsVernInParagraph)
         {
             label = ITextStrings.ksBaselineAbbr;
         }
         else
         {
             LgWritingSystem wsAnalysis = new LgWritingSystem(cache, m_ws);
             label = wsAnalysis.Abbr.UserDefaultWritingSystem;
         }
         m_tssWsLabel = tsf.MakeStringWithPropsRgch(label, label.Length, ttp);
     }
     return(m_tssWsLabel);
 }
예제 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the text from clipboard.
        /// </summary>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public ITsString CallGetTextFromClipboard()
        {
            CheckDisposed();

            ITsPropsFactory propsFact = TsPropsFactoryClass.Create();

            return(base.GetTextFromClipboard(null, false, propsFact.MakeProps("bla", 0, 0)));
        }
예제 #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds a run of text to the specified translation
        /// </summary>
        /// <param name="trans">The translation where the run of text will be appended.</param>
        /// <param name="btWS">The writing system of the back translation</param>
        /// <param name="runWS">The writing system of the run</param>
        /// <param name="runText">The run text.</param>
        /// <param name="runStyleName">Name of the run style.</param>
        /// ------------------------------------------------------------------------------------
        protected void AddRunToMockedTrans(ICmTranslation trans, int btWS, int runWS, string runText, string runStyleName)
        {
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    runProps = propFact.MakeProps(runStyleName, runWS, 0);
            ITsStrBldr      bldr     = trans.Translation.get_String(btWS).GetBldr();

            bldr.Replace(bldr.Length, bldr.Length, runText, runProps);
            trans.Translation.set_String(btWS, bldr.GetString());
        }
예제 #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds a run of text to the specified paragraph
        /// </summary>
        /// <param name="para"></param>
        /// <param name="runText"></param>
        /// <param name="ws"></param>
        /// ------------------------------------------------------------------------------------
        public void AddRunToMockedPara(IStTxtPara para, string runText, int ws)
        {
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    runStyle = propFact.MakeProps(null, ws, 0);
            ITsStrBldr      bldr     = para.Contents.GetBldr();

            bldr.Replace(bldr.Length, bldr.Length, runText, runStyle);
            para.Contents = bldr.GetString();
        }
예제 #7
0
        public static ITsString WsLabel(FdoCache cache, int ws)
        {
            ITsPropsFactory  tpf   = TsPropsFactoryClass.Create();
            ITsTextProps     ttp   = tpf.MakeProps("Language Code", cache.DefaultUserWs, 0);
            ILgWritingSystem wsObj = LgWritingSystem.CreateFromDBObject(cache, ws);
            ITsStrFactory    tsf   = TsStrFactoryClass.Create();
            string           sAbbr = wsObj.Abbr.UserDefaultWritingSystem;

            return(tsf.MakeStringWithPropsRgch(sAbbr, sAbbr.Length, ttp));
        }
예제 #8
0
        public void NullStringDiffersFromTsString()
        {
            ITsStrBldr      strBldr   = TsStrBldrClass.Create();
            ITsPropsFactory propsFact = TsPropsFactoryClass.Create();

            strBldr.Replace(0, 0, "Test", propsFact.MakeProps(null, 5, 0));
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(strBldr.GetString(), null,
                                                            out s));
            Assert.AreEqual("TsStrings differ." + Environment.NewLine + "\tExpected <Test>, but was <null>.", s,
                            "Got incorrect explanation of difference");
        }
예제 #9
0
        public void UserPromptChangeWSWhenPasting()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();

            Options.ShowEmptyParagraphPromptsSetting = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("IsCompositionInProgress", false);
            DynamicMock vwsel       = new DynamicMock(typeof(IVwSelection));
            IVwRootBox  mockRootbox = (IVwRootBox)rootb.MockInstance;

            vwsel.SetupResult("RootBox", mockRootbox);
            vwsel.SetupResult("CLevels", 4, typeof(bool));
            vwsel.Ignore("AllTextSelInfo");
#if DEBUG
            vwsel.SetupResult("IsValid", true);
#endif

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache,
                                               m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox);

            // set up the text to paste - will be TE2ST with vernacular WS
            int             ws       = m_inMemoryCache.Cache.DefaultVernWs;
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, ws, 0);
            ITsStrBldr      bldr     = TsStrBldrClass.Create();
            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssVal = bldr.GetString();

            // Now simulate the user pasting over the user prompt
            stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo,
                            SimpleRootSite.kTagUserPrompt, 0, tssVal);

            // verify that the text is in the paragraph, that there is no longer a user
            // prompt, and that the ws changed but the character formatting survives.
            bldr = tssVal.GetBldr();
            bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString);

            m_vwenvMock.Verify();
        }
예제 #10
0
        public void PasteParagraphsWithSameStyle()
        {
            // Add a title to the root object
            int           hvoTitle      = m_cache.MakeNewObject(SimpleRootsiteTestsConstants.kclsidStText, m_hvoRoot, SimpleRootsiteTestsConstants.kflidDocTitle, -2);
            int           hvoTitlePara1 = m_cache.MakeNewObject(SimpleRootsiteTestsConstants.kclsidStTxtPara, hvoTitle, SimpleRootsiteTestsConstants.kflidTextParas, 0);
            ITsStrFactory tsStrFactory  = TsStrFactoryClass.Create();

            m_cache.CacheStringProp(hvoTitlePara1, SimpleRootsiteTestsConstants.kflidParaContents,
                                    tsStrFactory.MakeString("The First Book of the Law given by Moses", m_wsEng));
            ITsPropsFactory fact = TsPropsFactoryClass.Create();

            m_cache.SetUnknown(hvoTitlePara1, SimpleRootsiteTestsConstants.kflidParaProperties, fact.MakeProps("Title", m_wsEng, 0));

            int    hvoTitlePara2      = m_cache.MakeNewObject(SimpleRootsiteTestsConstants.kclsidStTxtPara, hvoTitle, SimpleRootsiteTestsConstants.kflidTextParas, 1);
            string secondParaContents = "and Aaron";

            m_cache.CacheStringProp(hvoTitlePara2, SimpleRootsiteTestsConstants.kflidParaContents,
                                    tsStrFactory.MakeString(secondParaContents, m_wsEng));
            m_cache.SetUnknown(hvoTitlePara2, SimpleRootsiteTestsConstants.kflidParaProperties, fact.MakeProps("Title", m_wsEng, 0));

            ShowForm(SimpleViewVc.DisplayType.kTitle |
                     SimpleViewVc.DisplayType.kUseParaProperties |
                     SimpleViewVc.DisplayType.kOnlyDisplayContentsOnce);

            // Make a selection from the top of the view to the bottom.
            IVwSelection sel0 = m_basicView.RootBox.MakeSimpleSel(true, false, false, false);
            IVwSelection sel1 = m_basicView.RootBox.MakeSimpleSel(false, false, false, false);

            m_basicView.RootBox.MakeRangeSelection(sel0, sel1, true);

            // Copy the selection and then paste it at the start of the view.
            Assert.IsTrue(m_basicView.EditingHelper.CopySelection());
            // Install a simple selection at the start of the view.
            m_basicView.RootBox.MakeSimpleSel(true, true, false, true);

            // This is a legal paste.
            m_basicView.EditingHelper.PasteClipboard();

            // We expect the contents to change.
            Assert.AreEqual(4, m_cache.get_VecSize(hvoTitle, SimpleRootsiteTestsConstants.kflidTextParas));
            Assert.AreEqual(hvoTitlePara2 + 1, m_cache.get_VecItem(hvoTitle, SimpleRootsiteTestsConstants.kflidTextParas, 0));
            Assert.AreEqual(hvoTitlePara2 + 2, m_cache.get_VecItem(hvoTitle, SimpleRootsiteTestsConstants.kflidTextParas, 1));
            Assert.AreEqual(hvoTitlePara1, m_cache.get_VecItem(hvoTitle, SimpleRootsiteTestsConstants.kflidTextParas, 2));
            Assert.AreEqual(hvoTitlePara2, m_cache.get_VecItem(hvoTitle, SimpleRootsiteTestsConstants.kflidTextParas, 3));

            Assert.IsNotNull(m_basicView.RequestedSelectionAtEndOfUow);
            // WANTTESTPORT: (Common) FWR-1649 Check properties of RequestedSelectionAtEndOfUow
        }
예제 #11
0
        public void TsStringsDifferByText()
        {
            ITsStrBldr      strBldr   = TsStrBldrClass.Create();
            ITsPropsFactory propsFact = TsPropsFactoryClass.Create();
            ITsTextProps    props     = propsFact.MakeProps(null, 5, 0);

            strBldr.Replace(0, 0, "Test", props);
            ITsString tssExpected = strBldr.GetString();

            strBldr.Replace(0, 4, "Crud", props);
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsString text differs." + Environment.NewLine + "\tExpected <Test>, but was <Crud>.", s,
                "Got incorrect explanation of difference");
        }
예제 #12
0
        public void TsStringsDifferByRunCount()
        {
            ITsStrBldr      strBldr   = TsStrBldrClass.Create();
            ITsPropsFactory propsFact = TsPropsFactoryClass.Create();

            strBldr.Replace(0, 0, "Bad Test", propsFact.MakeProps(null, 5, 0));
            ITsString tssExpected = strBldr.GetString();

            strBldr.Replace(0, 3, "Bad", propsFact.MakeProps("Bogus", 5, 0));
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                string.Format("TsStrings have different number of runs.{0}\tExpected 1 runs, but was 2 runs.{0}\t" +
                              "Expected run 1:<Bad Test>, but was:<Bad>{0}\t" +
                              "Expected run 2:<>, but was:< Test>", Environment.NewLine), s,
                "Got incorrect explanation of difference");
        }
예제 #13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            if (DialogResult == DialogResult.Cancel)
            {
                return;
            }

            FdoOwningSequence <IStPara> oldParas = m_error.ResolutionOA.ParagraphsOS;

            ITsString[] newParas = m_text.Paragraphs;

            // If there are fewer paragraphs in the new comment, then remove from the end
            // of the old comment the number paragraphs that is the difference between
            // the number of old and new paragraphs.
            if (newParas.Length < oldParas.Count)
            {
                for (int i = oldParas.Count - 1; i >= newParas.Length; i--)
                {
                    oldParas.RemoveAt(i);
                }
            }

            for (int i = 0; i < newParas.Length; i++)
            {
                if (i < oldParas.Count)
                {
                    // Reuse the old paragraph.
                    ((StTxtPara)oldParas[i]).Contents.UnderlyingTsString = newParas[i];
                }
                else
                {
                    // Create a new paragraph
                    StTxtPara newStPara = new StTxtPara();
                    oldParas.Append(newStPara);
                    newStPara.Contents.UnderlyingTsString = newParas[i];
                    ITsPropsFactory tspf = TsPropsFactoryClass.Create();
                    newStPara.StyleRules = tspf.MakeProps(ScrStyleNames.Remark, m_text.CurrentWs, 0);
                }
            }
        }
        public void PasteParagraphsWithDifferentStyles()
        {
            // Add a title to the root object
            int           hvoTitle      = m_cache.MakeNewObject(kclsidStText, m_hvoRoot, kflidDocTitle, -2);
            int           hvoTitlePara1 = m_cache.MakeNewObject(kclsidStTxtPara, hvoTitle, kflidTextParas, 0);
            ITsStrFactory tsStrFactory  = TsStrFactoryClass.Create();

            m_cache.CacheStringProp(hvoTitlePara1, kflidParaContents,
                                    tsStrFactory.MakeString("The First Book of the Law given by Moses", m_wsEng));
            ITsPropsFactory fact = TsPropsFactoryClass.Create();

            m_cache.SetUnknown(hvoTitlePara1, kflidParaProperties, fact.MakeProps("Title", m_wsEng, 0));

            int    hvoTitlePara2      = m_cache.MakeNewObject(kclsidStTxtPara, hvoTitle, kflidTextParas, 1);
            string secondParaContents = "and Aaron";

            m_cache.CacheStringProp(hvoTitlePara2, kflidParaContents,
                                    tsStrFactory.MakeString(secondParaContents, m_wsEng));
            m_cache.SetUnknown(hvoTitlePara2, kflidParaProperties, fact.MakeProps("Conclusion", m_wsEng, 0));

            ShowForm(SimpleViewVc.DisplayType.kTitle |
                     SimpleViewVc.DisplayType.kUseParaProperties |
                     SimpleViewVc.DisplayType.kOnlyDisplayContentsOnce);

            // Make a selection from the top of the view to the bottom.
            IVwSelection sel0 = m_basicView.RootBox.MakeSimpleSel(true, false, false, false);
            IVwSelection sel1 = m_basicView.RootBox.MakeSimpleSel(false, false, false, false);

            m_basicView.RootBox.MakeRangeSelection(sel0, sel1, true);

            // Copy the selection and then paste it at the start of the view.
            Assert.IsTrue(m_basicView.EditingHelper.CopySelection());
            // Install a simple selection at the start of the view.
            m_basicView.RootBox.MakeSimpleSel(true, true, false, true);

            // This is an illegal paste, so the paste will fail.
            m_basicView.EditingHelper.PasteClipboard();

            // We expect the contents to remain unchanged.
            Assert.AreEqual(2, m_cache.get_VecSize(hvoTitle, kflidTextParas));
            Assert.IsNull(m_basicView.RequestedSelectionAtEndOfUow);
        }
예제 #15
0
        /// <summary>
        /// Add to the current display (a paragraph should be open) a label followed by colon, in the standard style,
        /// that identifies a particular writing system from the current list.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="iws"></param>
        public void AddWsLabel(IVwEnv vwenv, int iws)
        {
            CheckDisposed();

            if (m_tssColon == null)
            {
                ITsStrFactory tsf = TsStrFactoryClass.Create();
                m_tssColon = tsf.MakeString(": ", m_lp.Cache.DefaultUserWs);
            }
            if (m_ttpLabelStyle == null)
            {
                ITsPropsFactory tpf = TsPropsFactoryClass.Create();
                // Get a ttp invoking the style "Language Code" style for the writing system
                // which corresponds to the user's environment.
                m_ttpLabelStyle = tpf.MakeProps("Language Code", m_lp.Cache.DefaultUserWs, 0);
            }
            vwenv.Props = m_ttpLabelStyle;
            vwenv.OpenSpan();
            vwenv.AddString(AnalysisWsLabels[iws]);
            vwenv.AddString(m_tssColon);
            vwenv.CloseSpan();
        }
예제 #16
0
        public void ConvertChapterVerseNumbersTest_EmptyChapterNumber()
        {
            // Add paragraph with empty chapter number run.
            IStTxtPara      para             = AddParaToMockedSectionContent(m_exodus.SectionsOS[0], ScrStyleNames.ChapterNumber);
            ITsPropsFactory propFact         = TsPropsFactoryClass.Create();
            ITsTextProps    ttpChapterNumber = propFact.MakeProps(ScrStyleNames.ChapterNumber,
                                                                  Cache.ServiceLocator.WritingSystemManager.GetWsFromStr("fr"), 0);
            ITsStrBldr bldr = para.Contents.GetBldr();

            bldr.SetProperties(0, 0, ttpChapterNumber);
            para.Contents = bldr.GetString();

            using (ScriptureProperties dlg = new ScriptureProperties(Cache, m_stylesheet, null, true, null))
            {
                char bengaliZero = '\u09e6';
                char bengaliNine = (char)((int)bengaliZero + 9);

                // test arabic->bengali when there is a paragraph with an empty chapter number run.
                // It should complete without crashing.
                ScriptDigitConversionTest(bengaliZero, bengaliNine, dlg);
                // test bengali->arabic
                ScriptDigitConversionTest('0', '9', dlg);
            }
        }
예제 #17
0
        public void UpdateUserPrompt_NormalBT_Pasting()
        {
            // Set up section head with an empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddSectionHeadParaToSection(section, "", ScrStyleNames.SectionHead);

            int          defAnalWs = Cache.DefaultAnalWs;
            IVwRootBox   rootb;
            IVwSelection vwsel;
            IVwRootSite  rootsite;

            SetUpResultsForUpdateUserPromptTests(5, "TE2ST", out rootb, out vwsel, out rootsite);

            DummyTeStVc stVc = new DummyTeStVc(Cache, defAnalWs, rootb);
            // set up the text to paste - will be TE2ST with vernacular WS
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, defAnalWs, 0);

            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, defAnalWs, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssPasted = bldr.GetString();

            // Now simulate the user pasting over the user prompt
            ICmTranslation bt = para.GetOrCreateBT();

            stVc.UpdateProp(vwsel, bt.Hvo, SimpleRootSite.kTagUserPrompt, CmTranslationTags.kflidTranslation, tssPasted);

            // Verify that the text is in the paragraph and that the character formatting survives.
            AssertEx.AreTsStringsEqual(tssPasted, bt.Translation.get_String(defAnalWs));

            m_vwenvMock.VerifyAllExpectations();
            VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, defAnalWs, 5, CmTranslationTags.kflidTranslation, "TE2ST");
        }
예제 #18
0
        /// <summary>
        /// Parse the text in hvoPara.Contents[vc.DestWs] and make words
        /// </summary>
        /// <param name="hvoPara"></param>
        public void Parse(int hvoPara)
        {
            ITsString tssSrc = m_sda.get_MultiStringAlt(hvoPara, ViewSampleVc.ktagParaContents, m_vc.DestWs);
            WordMaker wm = new WordMaker(tssSrc, m_wsf);
            int       ichMin, ichLim;
            int       cbundle = m_sda.get_VecSize(hvoPara, ViewSampleVc.ktagParaBundles);

            // Clean it out. This wouldn't normally be appropriate for an owning property, but we can get away
            // with it for a non-database cache.
            if (cbundle != 0)
            {
                m_sda.Replace(hvoPara, ViewSampleVc.ktagParaBundles, 0, cbundle, new int[0], 0);
            }
            int             ibundle = 0;
            ITsPropsFactory tpf     = (ITsPropsFactory) new FwKernelLib.TsPropsFactoryClass();
            ITsTextProps    ttp     = tpf.MakeProps(null, m_vc.SourceWs, 0);

            for (ITsString tssWord = wm.NextWord(out ichMin, out ichLim); tssWord != null;
                 tssWord = wm.NextWord(out ichMin, out ichLim))
            {
                // 4 is an arbitrary classid; this kind of cache does nothing with it.
                int hvoBundle = m_sda.MakeNewObject(4, hvoPara, ViewSampleVc.ktagParaBundles, ibundle);
                ibundle++;
                m_sda.SetString(hvoBundle, ViewSampleVc.ktagBundleBase, tssWord);
                ITsStrBldr tsb = tssWord.GetBldr();
                tsb.Replace(0, 0, "idiom(", ttp);
                tsb.Replace(tsb.get_Length(), tsb.get_Length(), ")", ttp);
                m_sda.SetString(hvoBundle, ViewSampleVc.ktagBundleIdiom, tsb.GetString());

                tsb = tssWord.GetBldr();
                tsb.Replace(0, 0, "ling(", ttp);
                tsb.Replace(tsb.get_Length(), tsb.get_Length(), ")", ttp);
                m_sda.SetString(hvoBundle, ViewSampleVc.ktagBundleLing, tsb.GetString());
            }
            m_sda.PropChanged(null, (int)FwViews.PropChangeType.kpctNotifyAll, hvoPara, ViewSampleVc.ktagParaBundles, 0, ibundle, cbundle);
        }
예제 #19
0
        public void DisableCompareBtn()
        {
            // Add Revelation, archive it and then remove it.
            IStText title;

            Assert.IsNull(m_scr.FindBook(66),
                          "Revelation should not be in the database. Restore the clean version of TestLangProj.");
            IScrBook        revelation = Cache.ServiceLocator.GetInstance <IScrBookFactory>().Create(66, out title);
            ITsPropsFactory propFact   = TsPropsFactoryClass.Create();
            ITsTextProps    ttp        = propFact.MakeProps(ScrStyleNames.NormalParagraph, Cache.DefaultVernWs, 0);

            Cache.ServiceLocator.GetInstance <IScrSectionFactory>().CreateScrSection(revelation, 0, "Text for section", ttp, false);
            AddArchive("Revelation Archive", new List <IScrBook>(new IScrBook[] { revelation }));
            m_scr.ScriptureBooksOS.Remove(revelation);

            using (DummySavedVersionsDialog dlg = new DummySavedVersionsDialog(Cache))
            {
                TreeView tree = dlg.ArchiveTree;

                // Select the archive node that was just added.
                tree.SelectedNode = tree.Nodes[0];
                dlg.SimulateSelectEvent();

                // Check to make sure the Compare to Current Version button is disabled
                Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled, "The Compare to Current Version button should be disabled");

                TreeNode revNode = null;
                TreeNode phmNode = null;
                foreach (TreeNode node in tree.Nodes)
                {
                    if (node.Nodes.Count > 0 && node.Nodes[0].Tag is IScrBook)
                    {
                        if (((IScrBook)node.Nodes[0].Tag).CanonicalNum == 66)
                        {
                            revNode = node.Nodes[0];
                        }
                        if (((IScrBook)node.Nodes[0].Tag).CanonicalNum == 57)
                        {
                            phmNode = node.Nodes[0];
                        }
                    }
                }
                Assert.IsNotNull(revNode, "there should be an archive where the first book is Revelation");
                Assert.IsNotNull(phmNode, "there should be an archive where the first book is Philemon");
                // Select a book node for Revelation.
                tree.SelectedNode = revNode;
                dlg.SimulateSelectEvent();

                // Check to make sure the Diff button is still disabled if we select Revelation
                // after it is removed from the DB.
                Assert.IsTrue(tree.SelectedNode.Tag is IScrBook);
                var bookId = ((IScrBook)tree.SelectedNode.Tag).CanonicalNum;
                Assert.AreEqual(66, bookId);
                Assert.IsNull(m_scr.FindBook(bookId));
                Assert.IsFalse(dlg.ComparetoCurrentVersionBtn.Enabled,
                               "The Compare to Current Version button should still be disabled.");

                // However, the diff button should be enabled if we select Philemon in the second archive
                // since it is in our database.
                tree.SelectedNode = phmNode;
                // selecting Philemon
                dlg.SimulateSelectEvent();
                Assert.IsTrue(dlg.ComparetoCurrentVersionBtn.Enabled,
                              "The Compare to Current Version button should be enabled when Philemon is selected.");
            }
        }
예제 #20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This is the main interesting method of displaying objects and fragments of them.
        /// Scripture Footnotes are displayed by displaying each footnote's reference and text.
        /// The text is displayed using the standard view constructor for StText.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// ------------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case (int)FootnoteFrags.kfrScripture:
            {
                vwenv.NoteDependency(new int[] { m_cache.LangProject.TranslatedScriptureOAHvo },
                                     new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, 1);
                vwenv.AddLazyVecItems(BooksTag, this, (int)FootnoteFrags.kfrBook);
                break;
            }

            case (int)FootnoteFrags.kfrRootInPageSeq:
            {
                int tag = DummyVirtualHandler.InstallDummyHandler(m_cache.VwCacheDaAccessor,
                                                                  "Scripture", "FootnotesOnPage",
                                                                  (int)CellarModuleDefns.kcptReferenceSequence).Tag;
                // Get the list of footnotes to display
                int[] hvos = m_cache.GetVectorProperty(hvo, tag, true);
                if (hvos.Length > 0)
                {
                    int ownerHvo = m_cache.GetOwnerOfObject(hvos[0]);
                    // The ownerHvo should be the HVO of the book
                    vwenv.NoteDependency(new int[] { ownerHvo },
                                         new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes }, 1);
                }
                vwenv.AddObjVec(tag, this, (int)FootnoteFrags.kfrAllFootnotesWithinPagePara);
                break;
            }

            case (int)FootnoteFrags.kfrFootnoteWithinPagePara:
            {
                // Note a dependency on the footnote options so that the footnote will
                // be refreshed when these are changed.
                int[] depHvos = { hvo };
                int[] depTags = { StFootnote.ktagFootnoteOptions };
                vwenv.NoteDependency(depHvos, depTags, 1);

                // Insert the marker and reference
                vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteMarker);
                vwenv.AddObj(hvo, this, (int)StTextFrags.kfrFootnoteReference);

                // Insert (we hope only one) paragraph contents.
                vwenv.AddObjVecItems((int)StText.StTextTags.kflidParagraphs, this,
                                     (int)FootnoteFrags.kfrFootnoteParaWithinPagePara);
                break;
            }

            case (int)FootnoteFrags.kfrFootnoteParaWithinPagePara:
            {
                if (!InsertParaContentsUserPrompt(vwenv, hvo))
                {
                    // Display the text paragraph contents, or its user prompt.
                    vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null);
                }
                break;
            }

            case (int)FootnoteFrags.kfrBook:
            {
                vwenv.OpenDiv();
                vwenv.AddObjVecItems((int)ScrBook.ScrBookTags.kflidFootnotes, this,
                                     (int)StTextFrags.kfrFootnote);
                vwenv.CloseDiv();
                break;
            }

            case (int)StTextFrags.kfrFootnoteMarker:
            {
                ScrFootnote footnote = new ScrFootnote(Cache, hvo);
                if (footnote.DisplayFootnoteMarker)
                {
                    DisplayFootnoteMarker(vwenv, footnote);
                }
                break;
            }

            case (int)StTextFrags.kfrFootnoteReference:
            {
                ITsStrFactory   tsStrFactory = TsStrFactoryClass.Create();
                ITsPropsFactory tpf          = TsPropsFactoryClass.Create();
                ITsTextProps    ttp          = tpf.MakeProps(ScrStyleNames.FootnoteTargetRef, m_wsDefault, 0);

                ScrFootnote footnote    = new ScrFootnote(m_cache, hvo);
                string      footnoteRef = footnote.GetReference(m_wsDefault);
                ITsString   tssRef      = tsStrFactory.MakeStringWithPropsRgch(footnoteRef,
                                                                               footnoteRef.Length, ttp);
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvEnum,
                                      (int)TptEditable.ktptNotEditable);
                vwenv.AddString(tssRef);
                break;
            }

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }