Exemplo n.º 1
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            if (m_cache != null)
            {
                IVwCacheDa cda = m_cache.MainCacheAccessor as IVwCacheDa;
                cda.CacheVecProp(m_cache.LangProject.Hvo, m_fakeFlid, null, 0);
                cda     = null;
                m_cache = null;
            }
            m_fwTextBoxBottomMsg = null;
            m_mediator           = null;
            if (m_tsf != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_tsf);
            }
            m_tsf = null;

            base.Dispose(disposing);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Extra cleanup that fieldworks doesn't do correctly.
        /// </summary>
        public void Dispose()
        {
            // StructureMapService doesn't close this
            ITsStrFactory tsf = TsStrFactoryClass.Create();

            Marshal.FinalReleaseComObject(tsf);
        }
Exemplo n.º 3
0
        public void FindNextMissingBtFootnoteMarker_BtSectionHeadToContent()
        {
            IScrSection section = m_exodus.SectionsOS[1];

            ITsStrFactory strfact     = TsStrFactoryClass.Create();
            IStTxtPara    contentPara = section.ContentOA[0];
            ITsStrBldr    strBldr     = contentPara.Contents.GetBldr();
            IStFootnote   foot        = m_exodus.InsertFootnoteAt(0, strBldr, 7);

            contentPara.Contents = strBldr.GetString();
            IScrTxtPara footPara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle(
                foot, ScrStyleNames.NormalFootnoteParagraph);

            footPara.Contents = strfact.MakeString("This is footnote text for footnote", Cache.DefaultVernWs);

            ICmTranslation trans = contentPara.GetOrCreateBT();

            m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading, 0, 1, 0);

            m_draftView.CallNextMissingBtFootnoteMarker();

            SelectionHelper helper = m_draftView.EditingHelper.CurrentSelection;

            Assert.AreEqual(2, helper.IchAnchor, "IP should be after chapter and verse number.");
            Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(1, m_draftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_draftView.ParagraphIndex);
            Assert.AreEqual(ScrSectionTags.kflidContent,
                            m_draftView.EditingHelper.CurrentSelection.LevelInfo[2].tag);
            Assert.IsTrue(m_draftView.TeEditingHelper.IsBackTranslation);
        }
Exemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a blank dummy footnote. Used when a footnote object is missing.
        /// Note: This does not insert an ORC into the paragraph. The caller is fixing the ORC
        /// with a missing object.
        /// </summary>
        /// <param name="owner">The owner to which we will add a footnote.</param>
        /// <param name="iFootnote">The 0-based index where the footnote will be inserted in the
        /// owner.</param>
        /// <param name="paraContents">The paragraph string where the ORC is being fixed.</param>
        /// <param name="iRun">The 0-based index of the run from which we will get the writing
        /// system used in the footnote.</param>
        /// <returns>a blank general footnote</returns>
        /// ------------------------------------------------------------------------------------
        protected override StFootnote CreateBlankDummyFootnoteNoRecursion(ICmObject owner,
                                                                          int iFootnote, ITsString paraContents, int iRun)
        {
            if (!(owner is IScrBook))
            {
                return(base.CreateBlankDummyFootnoteNoRecursion(owner, iFootnote, paraContents, iRun));
            }

            // get the writing system of the existing ORC run
            int nDummy;
            int ws = paraContents.get_Properties(iRun).GetIntPropValues(
                (int)FwTextPropType.ktptWs, out nDummy);

            //  Make a dummy blank footnote
            IScripture scr         = m_cache.LangProject.TranslatedScriptureOA;
            string     sMarker     = scr.GeneralFootnoteMarker;
            StFootnote newFootnote = ScrFootnote.CreateFootnoteInScrBook((IScrBook)owner, iFootnote, ref sMarker,
                                                                         m_cache, ws);

            // Create an empty footnote paragraph with properties with default style and writing system.
            StTxtPara footnotePara = new StTxtPara();

            newFootnote.ParagraphsOS.Append(footnotePara);
            footnotePara.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph);
            // Insert an empty run into the footnote paragraph in order to set the
            // default writing system.
            ITsStrFactory strFactory = TsStrFactoryClass.Create();

            footnotePara.Contents.UnderlyingTsString =
                strFactory.MakeString(string.Empty, m_cache.DefaultVernWs);

            return(newFootnote);
        }
        public override void TestSetup()
        {
            base.TestSetup();

            m_vc       = new StVc();
            m_vc.Cache = Cache;

            m_pattern    = VwPatternClass.Create();
            m_strFactory = TsStrFactoryClass.Create();

            m_pattern.Pattern = m_strFactory.MakeString("a", Cache.DefaultVernWs);
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;

            IScrBook genesis = AddBookWithTwoSections(1, "Genesis");

            m_section = genesis.SectionsOS[0];
            // Add paragraphs (because we use an StVc in the test we add them all to the same section)
            m_para1 = AddParaToMockedSectionContent(m_section,
                                                    ScrStyleNames.NormalParagraph);
            AddRunToMockedPara(m_para1,
                               "This is some text so that we can test the find functionality.", null);
            m_para2 = AddParaToMockedSectionContent(m_section,
                                                    ScrStyleNames.NormalParagraph);
            AddRunToMockedPara(m_para2,
                               "Some more text so that we can test the find and replace functionality.", null);
            m_para3 = AddParaToMockedSectionContent(
                m_section, ScrStyleNames.NormalParagraph);
            AddRunToMockedPara(m_para3,
                               "This purugruph doesn't contuin the first letter of the ulphubet.", null);
        }
        public void LeadingPunctuation()
        {
            ITsStrFactory tsf   = TsStrFactoryClass.Create();
            string        test1 = "?This is a question with special punctuation?";
            ITsString     tss   = tsf.MakeString(test1, m_wsEn);

            m_para.Contents = tss;
            List <int> results;
            var        segments = m_pp.CollectSegments(tss, out results);

            VerifyBreaks(new int[] { test1.Length - 1 }, results, "leading QM");
            Assert.AreEqual(1, segments.Count);
            VerifySegment(segments[0], 0, test1.Length, m_para, "leading QM");

            // Now try leading punctuation following a verse number.
            ITsStrBldr bldr  = tss.GetBldr();
            string     verse = "5 ";

            bldr.Replace(0, 0, verse, null);
            bldr.SetStrPropValue(0, 1, (int)FwTextPropType.ktptNamedStyle,
                                 ScrStyleNames.VerseNumber);
            ITsString tssMultiV = bldr.GetString();

            m_para.Contents = tssMultiV;
            segments        = m_pp.CollectSegments(tssMultiV, out results);
            VerifyBreaks(new int[] { verse.Length, tssMultiV.Length - 1 },
                         results, "leading verse and QM");
            Assert.AreEqual(2, segments.Count);
            VerifySegment(segments[0], 0, verse.Length, m_para, "first seg of leading verse and QM");
            VerifySegment(segments[1], verse.Length, tssMultiV.Length, m_para, "second seg of leading verse and QM");
        }
Exemplo n.º 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds paragraphs to the database
        /// </summary>
        /// <param name="ws"></param>
        /// <param name="firstPara"></param>
        /// <param name="secondPara"></param>
        /// ------------------------------------------------------------------------------------
        private void AddParagraphs(int ws, string firstPara, string secondPara)
        {
            int           hvoPara1 = m_hvoPara++;
            int           hvoPara2 = m_hvoPara++;
            int           hvoText1 = m_hvoText++;
            int           hvoText2 = m_hvoText++;
            ITsStrFactory tsf      = TsStrFactoryClass.Create();
            ITsString     tsString = tsf.MakeString(firstPara, ws);
            IVwCacheDa    cda      = Cache.VwCacheDaAccessor;

            cda.CacheStringProp(hvoPara1, (int)StTxtPara.StTxtParaTags.kflidContents,
                                tsString);
            tsString = tsf.MakeString(secondPara, ws);
            cda.CacheStringProp(hvoPara2, (int)StTxtPara.StTxtParaTags.kflidContents,
                                tsString);

            // Now make each of them the paragraphs of an StText.
            int[] hvoParas = { hvoPara1 };
            cda.CacheVecProp(hvoText1, (int)StText.StTextTags.kflidParagraphs, hvoParas,
                             1);
            hvoParas[0] = hvoPara2;
            cda.CacheVecProp(hvoText2, (int)StText.StTextTags.kflidParagraphs, hvoParas,
                             1);

            // And the StTexts to the contents of a dummy property.
            AddVecProp(new int[] { hvoText1, hvoText2 });
        }
 public void MySetup()
 {
     Setup();
     m_tsf   = TsStrFactoryClass.Create();
     m_wsEng = m_wsf.GetWsFromStr("en");
     m_wsFrn = m_wsf.GetWsFromStr("fr");
 }
Exemplo n.º 9
0
		public void MySetup()
		{
			Setup();
			m_tsf = TsStrFactoryClass.Create();
			m_wsEng = m_wsf.GetWsFromStr("en");
			m_wsFrn = m_wsf.GetWsFromStr("fr");
		}
Exemplo n.º 10
0
        public TitleContentsVc(FdoCache cache)
        {
            int           wsUser = cache.DefaultUserWs;
            ITsStrFactory tsf    = TsStrFactoryClass.Create();

            m_tssTitle = tsf.MakeString(ITextStrings.ksTitle, wsUser);
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            tpb.SetIntPropValues((int)FwTextPropType.ktptBold,
                                 (int)FwTextPropVar.ktpvEnum,
                                 (int)FwTextToggleVal.kttvForceOn);
            m_ttpBold = tpb.GetTextProps();
            tpb       = TsPropsBldrClass.Create();
            // Set some padding all around.
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTop,
                                 (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadBottom,
                                 (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadLeading,
                                 (int)FwTextPropVar.ktpvMilliPoint, 3000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTrailing,
                                 (int)FwTextPropVar.ktpvMilliPoint, 3000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptMarginTrailing,
                                 (int)FwTextPropVar.ktpvMilliPoint, 11000); // 10000 clips right border.
            m_ttpDataCellProps = tpb.GetTextProps();

            m_vtagStTextTitle = cache.MetaDataCacheAccessor.GetFieldId("StText", "Title", false);

            // Set up the array of writing systems we will display for title.
            SetupWritingSystemsForTitle(cache);
        }
Exemplo n.º 11
0
        public void FixOrcsWithoutProps_OrphanedFootnoteAndValidPicture()
        {
            CheckDisposed();

            IScrBook  exodus = CreateExodusData();
            StTxtPara para   = AddPara(exodus.SectionsOS[2]);

            AddVerse(para, 2, 3, "ORC is here, you see, my friend.");

            // Update the paragraph contents to include the picture
            ITsStrBldr    tsStrBldr = para.Contents.UnderlyingTsString.GetBldr();
            ITsStrFactory factory   = TsStrFactoryClass.Create();
            CmPicture     pict      = new CmPicture(Cache, "c:\\junk.jpg",
                                                    factory.MakeString("Test picture", Cache.DefaultVernWs),
                                                    StringUtils.LocalPictures);

            Assert.IsNotNull(pict);
            pict.InsertOwningORCIntoPara(tsStrBldr, 11, 0);
            para.Contents.UnderlyingTsString = tsStrBldr.GetString();

            // Update the paragraph contents to include the (orphaned) footnote marker
            CreateFootnote(exodus, 1, 0, 1, 19, ScrStyleNames.CrossRefFootnoteParagraph, true);

            TeScrInitializer scrInit = new TestTeScrInitializer(Cache);
            List <string>    report  = (List <string>)ReflectionHelper.GetResult(scrInit, "FixOrcsWithoutProps");

            VerifyNoOrphanedFootnotes();
            VerifyResourceForFixedOrphans();

            Assert.AreEqual(1, report.Count);
            Assert.AreEqual("EXO 1:2 - Deleted corrupted footnote marker or picture anchor", report[0]);

            Assert.AreEqual(0, exodus.FootnotesOS.Count);
        }
Exemplo n.º 12
0
        public void FixOrcsWithoutProps_OrcForMissingObject()
        {
            CheckDisposed();

            IScrBook  exodus = CreateExodusData();
            StTxtPara para   = AddPara(exodus.SectionsOS[2]);

            AddVerse(para, 2, 3, "ORC is here, you see, my friend.");

            // Update the paragraph contents to include the picture
            ITsStrBldr    tsStrBldr = para.Contents.UnderlyingTsString.GetBldr();
            ITsStrFactory factory   = TsStrFactoryClass.Create();

            StringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtOwnNameGuidHot,
                                          tsStrBldr, 11, 11, 0);
            para.Contents.UnderlyingTsString = tsStrBldr.GetString();

            TeScrInitializer scrInit = new TestTeScrInitializer(Cache);
            List <string>    report  = (List <string>)ReflectionHelper.GetResult(scrInit, "FixOrcsWithoutProps");

            VerifyNoOrphanedFootnotes();
            VerifyResourceForFixedOrphans();

            Assert.AreEqual(1, report.Count);
            Assert.AreEqual("EXO 2:3 - Deleted corrupted footnote marker or picture anchor", report[0]);

            Assert.AreEqual(0, exodus.FootnotesOS.Count);
        }
Exemplo n.º 13
0
		int m_wsUr; // Urdu writing system (used for Foreign style)
		#endregion

		#region Test setup
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_inMemoryCache.InitializeWritingSystemEncodings();

			// create footnote
			m_footnote = new StFootnote();
			m_book = (ScrBook)m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis");
			m_book.FootnotesOS.Append(m_footnote);
			m_footnote.FootnoteMarker.Text = "o";
			m_footnote.DisplayFootnoteMarker = true;
			m_footnote.DisplayFootnoteReference = false;

			// create one empty footnote para
			StTxtPara para = new StTxtPara();
			m_footnote.ParagraphsOS.Append(para);
			para.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph);

			m_strFact = TsStrFactoryClass.Create();
			m_vernWs = Cache.LangProject.DefaultVernacularWritingSystem;
			para.Contents.UnderlyingTsString = m_strFact.MakeString(string.Empty, m_vernWs);
			m_footnotePara = (StTxtPara)m_footnote.ParagraphsOS[0];

			m_wsUr = InMemoryFdoCache.s_wsHvos.Ur; // used with 'foreign' character style
			m_wsDe = InMemoryFdoCache.s_wsHvos.De; // used for back translations
			m_wsEs = InMemoryFdoCache.s_wsHvos.Es;
		}
Exemplo n.º 14
0
        public void OrcIsLabel()
        {
            ITsStrFactory   tsf = TsStrFactoryClass.Create();
            ParagraphParser pp  = new ParagraphParser(m_para);
            // String with embedded ORC.
            string    test1 = "This is a simple sentence";
            string    test2 = "\xfffc";
            string    test3 = " with a footnote.";
            ITsString tss   = tsf.MakeString(test1 + test2 + test3, 1);
            // To be recognized an ORC must have unique properties.
            ITsStrBldr bldr = tss.GetBldr();

            bldr.SetStrPropValue(test1.Length, test1.Length + test2.Length, (int)FwTextPropType.ktptObjData, "nonsence");
            tss = bldr.GetString();
            m_para.Contents.UnderlyingTsString = tss;
            List <int> results;
            List <int> segments = pp.CollectSegmentAnnotations(tss, out results);

            VerifyBreaks(new int[] { test1.Length, test1.Length + test2.Length + 1, test1.Length + test2.Length + test3.Length - 1 },
                         results, "multi-sentence string with ORC");
            Assert.AreEqual(3, segments.Count);
            // The segments break around the ORC.
            VerifySegment(segments[0], 0, test1.Length, m_para.Hvo, "first seg of multi-sentence w. ORC");
            VerifySegment(segments[1], test1.Length, test1.Length + test2.Length + 1, m_para.Hvo, "second seg of multi-sentence w. ORC");
            VerifySegment(segments[2], test1.Length + test2.Length + 1,
                          test1.Length + test2.Length + test3.Length, m_para.Hvo, "third seg of multi-sentence w. ORC");
        }
Exemplo n.º 15
0
        public void SetAndAccessMultiStrings()
        {
            ITsStrFactory tsf = TsStrFactoryClass.Create();

            int kflid   = XMLViewsDataCache.ktagEditColumnBase;
            int hvoRoot = 10578;
            int wsEng   = Cache.WritingSystemFactory.GetWsFromStr("en");
            XMLViewsDataCache xmlCache = new XMLViewsDataCache(Cache.MainCacheAccessor as ISilDataAccessManaged, true, new Dictionary <int, int>());
            Notifiee          recorder = new Notifiee();

            xmlCache.AddNotification(recorder);
            Assert.AreEqual(0, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng).Length);
            Assert.AreEqual(0, recorder.Changes.Count);
            ITsString test1 = tsf.MakeString("test1", wsEng);

            xmlCache.CacheMultiString(hvoRoot, kflid, wsEng, test1);
            Assert.AreEqual(0, recorder.Changes.Count);
            Assert.AreEqual(test1, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng));
            ITsString test2 = tsf.MakeString("blah", wsEng);

            xmlCache.SetMultiStringAlt(hvoRoot, kflid, wsEng, test2);
            Assert.AreEqual(test2, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng));


            recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, kflid, wsEng, 0, 0) },
                                  "expected PropChanged from setting string");
            xmlCache.RemoveNotification(recorder);

            // Enhance JohnT: a better test would verify that it doesn't intefere with other multistrings,
            // and that it can store stuff independently for different HVOs, tags, and WSs.
        }
Exemplo n.º 16
0
        /// <summary>
        /// We understand how to get a multistring for any hvo in the tagEditColumn range.
        /// We also handle the virtual property LexEntry.ReversalEntriesBulkText in a
        /// special way.  (See FWR-376.)
        /// </summary>
        public override ITsString get_MultiStringAlt(int hvo, int tag, int ws)
        {
            ITsString result1 = null;

            if (tag < ktagEditColumnBase || tag > ktagEditColumnLim)
            {
                result1 = base.get_MultiStringAlt(hvo, tag, ws);
                if (tag != m_tagReversalEntriesBulkText)
                {
                    return(result1);
                }
            }
            ITsString result;

            if (m_mlStringCache.TryGetValue(new HvoFlidWSKey(hvo, tag, ws), out result))
            {
                return(result);
            }
            if (tag == m_tagReversalEntriesBulkText && result1 != null)
            {
                return(result1);
            }
            ITsStrFactory tsf = TsStrFactoryClass.Create();

            return(tsf.MakeString("", ws));
        }
Exemplo n.º 17
0
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            switch (frag)
            {
            case AudioVisualView.kfragPathname:
                // Display the filename.
                ILgWritingSystemFactory wsf =
                    m_cache.WritingSystemFactory;
                vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                      (int)FwTextPropVar.ktpvDefault,
                                      (int)TptEditable.ktptNotEditable);
                ITsString     tss;
                ITsStrFactory tsf = m_cache.TsStrFactory;
                Debug.Assert(hvo != 0);
                Debug.Assert(m_cache != null);
                var file = m_cache.ServiceLocator.GetInstance <ICmFileRepository>().GetObject(hvo);
                Debug.Assert(file != null);
                string path = file.AbsoluteInternalPath;
                tss = tsf.MakeString(path, m_cache.WritingSystemFactory.UserWs);
                vwenv.OpenParagraph();
                vwenv.NoteDependency(new [] { m_cache.LangProject.Hvo, file.Hvo },
                                     new [] { LangProjectTags.kflidLinkedFilesRootDir, CmFileTags.kflidInternalPath }, 2);
                vwenv.AddString(tss);
                vwenv.CloseParagraph();
                break;

            default:
                throw new ArgumentException(
                          "Don't know what to do with the given frag.", "frag");
            }
        }
Exemplo n.º 18
0
            private void SetContentFromNode(FdoCache cache, string sNodeName, bool fFixName, MultiAccessor item)
            {
                ILgWritingSystemFactory wsf = cache.LanguageWritingSystemFactoryAccessor;
                ITsStrFactory           tsf = TsStrFactoryClass.Create();
                int     iWS;
                XmlNode nd;
                bool    fContentFound = false;              // be pessimistic

                foreach (ILgWritingSystem ws in cache.LangProject.CurAnalysisWssRS)
                {
                    string sWS = ws.ICULocale;
                    nd = m_node.SelectSingleNode(sNodeName + "[@ws='" + sWS + "']");
                    if (nd == null || nd.InnerText.Length == 0)
                    {
                        continue;
                    }
                    fContentFound = true;
                    string sNodeContent;
                    if (fFixName)
                    {
                        sNodeContent = NameFixer(nd.InnerText);
                    }
                    else
                    {
                        sNodeContent = nd.InnerText;
                    }
                    iWS = wsf.GetWsFromStr(sWS);
                    item.SetAlternative(tsf.MakeString(sNodeContent, iWS), iWS);
                }
                if (!fContentFound)
                {
                    iWS = cache.LangProject.DefaultAnalysisWritingSystem;
                    item.SetAlternative(tsf.MakeString("", iWS), iWS);
                }
            }
 public InnerLabeledMultiStringViewVc(int flid, List <IWritingSystem> rgws, int wsUser, bool editable,
                                      ITsStrFactory tsf, InnerLabeledMultiStringView view)
     : base(flid, rgws, wsUser, editable, view.WritingSystemFactory.GetWsFromStr("en"), tsf)
 {
     m_view = view;
     Debug.Assert(m_view != null);
 }
        public void FindNextMissingBtFootnoteMarker_BtSectionHeadToContent()
        {
            IScrSection section = m_exodus.SectionsOS[1];

            ITsStrFactory strfact     = TsStrFactoryClass.Create();
            IStTxtPara    contentPara = section.ContentOA[0];
            ITsStrBldr    strBldr     = contentPara.Contents.GetBldr();
            IStFootnote   foot        = m_exodus.InsertFootnoteAt(0, strBldr, 7);

            contentPara.Contents = strBldr.GetString();
            IScrTxtPara footPara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle(
                foot, ScrStyleNames.NormalFootnoteParagraph);

            footPara.Contents = strfact.MakeString("This is footnote text for footnote", Cache.DefaultVernWs);

            m_draftView.TeEditingHelper.SelectRangeOfChars(0, 0, ScrSectionTags.kflidHeading,
                                                           0, 1, 0, 0, true, true, false, VwScrollSelOpts.kssoDefault);

            m_draftView.CallNextMissingBtFootnoteMarker();

            SelectionHelper helper = m_draftView.EditingHelper.CurrentSelection;

            Assert.IsFalse(helper.IsRange);
            Assert.AreEqual(1, helper.GetLevelInfo(SelectionHelper.SelLimitType.Anchor)[0].ihvo, "IP should be in first non-label segment.");
            Assert.AreEqual(0, helper.IchAnchor, "IP should be at start of segment.");
            Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(1, m_draftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_draftView.ParagraphIndex);
            Assert.AreEqual(ScrSectionTags.kflidContent,
                            m_draftView.EditingHelper.CurrentSelection.LevelInfo[2].tag);
            Assert.IsTrue(m_draftView.TeEditingHelper.IsBackTranslation);
        }
Exemplo n.º 21
0
        public RegRuleFormulaVc(FdoCache cache, Mediator mediator)
            : base(cache, mediator)
        {
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
            m_ctxtProps = tpb.GetTextProps();

            tpb = TsPropsBldrClass.Create();
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 20000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, MiscUtils.StandardSansSerif);
            tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            m_charProps = tpb.GetTextProps();

            ITsStrFactory tsf    = m_cache.TsStrFactory;
            int           userWs = m_cache.DefaultUserWs;

            m_arrow      = tsf.MakeString("\u2192", userWs);
            m_slash      = tsf.MakeString("/", userWs);
            m_underscore = tsf.MakeString("__", userWs);
        }
        public void HardLineBreaks()
        {
            ITsStrFactory tsf = TsStrFactoryClass.Create();
            // String with embedded ORC.
            string    test1     = "This is a simple sentence";
            string    lineBreak = StringUtils.kChHardLB.ToString();
            string    test3     = "with a hard break.";
            ITsString tss       = tsf.MakeString(test1 + lineBreak + test3, m_wsEn);

            m_para.Contents = tss;
            List <int> results;
            var        segments = m_pp.CollectSegments(tss, out results);

            VerifyBreaks(new int[] { test1.Length, test1.Length + 1, tss.Length - 1 },
                         results, "simple string with hard break");
            Assert.AreEqual(3, segments.Count);
            // The segments break around the ORC.
            VerifySegment(segments[0], 0, test1.Length, m_para, "simple string with hard break");
            VerifySegment(segments[1], test1.Length, test1.Length + 1, m_para, "simple string with hard break");
            VerifySegment(segments[2], test1.Length + 1, tss.Length, m_para, "simple string with hard break");

            // Now try with an EOS before the hard break.
            string test1a = "This is a proper sentence?!";

            tss             = tsf.MakeString(test1a + lineBreak + test3, m_wsEn);
            m_para.Contents = tss;
            segments        = m_pp.CollectSegments(tss, out results);
            VerifyBreaks(new int[] { test1a.Length - 2, test1a.Length + 1, tss.Length - 1 },
                         results, "EOS before hard break");
            Assert.AreEqual(3, segments.Count);
            // The segments break around the ORC.
            VerifySegment(segments[0], 0, test1a.Length, m_para, "EOS before hard break");
            VerifySegment(segments[1], test1a.Length, test1a.Length + 1, m_para, "EOS before hard break");
            VerifySegment(segments[2], test1a.Length + 1, tss.Length, m_para, "EOS before hard break");
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="hvo"></param>
        /// <param name="tag"></param>
        /// <param name="ws"></param>
        /// <param name="cda"></param>
        public override void Load(int hvo, int tag, int ws, IVwCacheDa cda)
        {
            IMoMorphSynAnalysis msa = MoMorphSynAnalysis.CreateFromDBObject(m_cache, hvo);
            ITsStrFactory       tsf = TsStrFactoryClass.Create();

            cda.CacheStringProp(hvo, tag, tsf.MakeString(msa.InterlinearName, m_cache.DefaultAnalWs));
        }
Exemplo n.º 24
0
        public override void MakeRoot()
        {
            m_rootb = (IVwRootBox) new FwViews.VwRootBoxClass();
            m_rootb.SetSite(this);

            int hvoRoot = 1;

            m_sda = (ISilDataAccess) new FwViews.VwCacheDaClass();
            // Usually not here, but in some application global passed to each view.
            m_wsf = (ILgWritingSystemFactory) new FwLanguage.LgWritingSystemFactoryClass();
            m_sda.set_WritingSystemFactory(m_wsf);
            m_rootb.set_DataAccess(m_sda);

            ITsStrFactory tsf = (ITsStrFactory) new FwKernelLib.TsStrFactoryClass();
            ITsString     tss = tsf.MakeString("Hello World! This is a view", m_wsf.get_UserWs());

            IVwCacheDa cda = (IVwCacheDa)m_sda;

            cda.CacheStringProp(hvoRoot, ktagProp, tss);

            m_vVc = new HvVc();

            m_rootb.SetRootObject(hvoRoot, m_vVc, kfrText, null);
            m_fRootboxMade   = true;
            m_dxdLayoutWidth = -50000;             // Don't try to draw until we get OnSize and do layout.
        }
Exemplo n.º 25
0
        public void GoToNextPara_NextFlid()
        {
            // Add a title to the root object
            int           hvoTitle     = m_cache.MakeNewObject(SimpleRootsiteTestsConstants.kclsidStText, m_hvoRoot, SimpleRootsiteTestsConstants.kflidDocTitle, -2);
            int           hvoTitlePara = m_cache.MakeNewObject(SimpleRootsiteTestsConstants.kclsidStTxtPara, hvoTitle, SimpleRootsiteTestsConstants.kflidTextParas, 0);
            ITsStrFactory tsStrFactory = TsStrFactoryClass.Create();

            m_cache.CacheStringProp(hvoTitlePara, SimpleRootsiteTestsConstants.kflidParaContents,
                                    tsStrFactory.MakeString("The First Book of the Law given by Moses", m_wsFrn));

            ShowForm(Lng.English, SimpleViewVc.DisplayType.kNormal |
                     SimpleViewVc.DisplayType.kTitle);
            m_basicView.Show();
            m_basicView.RefreshDisplay();

            // Set the IP at the beginning of the only (0th) instance of the only (0th) paragraph
            // of the only (0th) instance of the second (1th) footnote of the book we're displaying.
            m_SelectionHelper = new DummySelectionHelper(null, m_basicView);
            SetSelection(0, 1, 0, 0, 2, 0, 0, true);
            IVwSelection vwsel = m_SelectionHelper.SetSelection(true);

            Assert.IsNotNull(vwsel, "No selection made");
            Assert.IsTrue(m_basicView.IsSelectionVisible(null), "Selection is not visible");
            m_basicView.EditingHelper.GoToNextPara();

            // We expect that the selection will be at the start of the book title.
            SelectionHelper selectionHelper = SelectionHelper.GetSelectionInfo(null, m_basicView);

            Assert.IsFalse(selectionHelper.IsRange);
            CheckSelectionHelperValues(SelectionHelper.SelLimitType.Anchor, selectionHelper, 0,
                                       0, 0, 0, false, 2, SimpleRootsiteTestsConstants.kflidDocTitle, 0, 0,
                                       SimpleRootsiteTestsConstants.kflidTextParas, 0, 0);
        }
Exemplo n.º 26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the RelatedWordsVc class.
        /// </summary>
        /// <param name="wsUser">The ws user.</param>
        /// <param name="headword">Headword of the target lexical entry.</param>
        /// ------------------------------------------------------------------------------------
        public RelatedWordsVc(int wsUser, ITsString headword)
        {
            m_wsDefault = wsUser;
            ITsStrFactory tsf = TsStrFactoryClass.Create();

            m_tssColon       = tsf.MakeString(": ", wsUser);
            m_tssComma       = tsf.MakeString(", ", wsUser);
            m_tssSdRelation  = tsf.MakeString(FdoUiStrings.ksWordsRelatedBySemanticDomain, wsUser);
            m_tssLexRelation = tsf.MakeString(FdoUiStrings.ksLexicallyRelatedWords, wsUser);

            var semanticDomainStrBuilder = m_tssSdRelation.GetBldr();
            var index = semanticDomainStrBuilder.Text.IndexOf("{0}");

            if (index > 0)
            {
                semanticDomainStrBuilder.ReplaceTsString(index, index + "{0}".Length, headword);
            }
            m_tssSdRelation = semanticDomainStrBuilder.GetString();

            var lexStrBuilder = m_tssLexRelation.GetBldr();

            index = lexStrBuilder.Text.IndexOf("{0}");
            if (index > 0)
            {
                lexStrBuilder.ReplaceTsString(index, index + "{0}".Length, headword);
            }
            m_tssLexRelation = lexStrBuilder.GetString();
        }
Exemplo n.º 27
0
        public void FindNextMissingBtFootnoteMarker_BtSectionHeadToNowhere()
        {
            IScrSection section = m_exodus.SectionsOS[1];

            ITsStrFactory strfact     = TsStrFactoryClass.Create();
            IStTxtPara    contentPara = section.ContentOA[0];
            ITsStrBldr    strBldr     = contentPara.Contents.GetBldr();
            IStFootnote   foot        = m_exodus.InsertFootnoteAt(0, strBldr, 7);

            contentPara.Contents = strBldr.GetString();
            IScrTxtPara footPara = Cache.ServiceLocator.GetInstance <IScrTxtParaFactory>().CreateWithStyle(
                foot, ScrStyleNames.NormalFootnoteParagraph);

            footPara.Contents = strfact.MakeString("This is footnote text for footnote", Cache.DefaultVernWs);

            ICmTranslation trans = contentPara.GetOrCreateBT();
            ITsStrBldr     bldr  = trans.Translation.get_String(Cache.DefaultAnalWs).GetBldr();

            TsStringUtils.InsertOrcIntoPara(foot.Guid, FwObjDataTypes.kodtNameGuidHot, bldr, 2, 2, Cache.DefaultAnalWs);
            trans.Translation.set_String(Cache.DefaultAnalWs, bldr.GetString());

            m_draftView.SetInsertionPoint(ScrSectionTags.kflidHeading, 0, 1, 0);

            m_draftView.CallNextMissingBtFootnoteMarker();

            SelectionHelper helper = m_draftView.EditingHelper.CurrentSelection;

            Assert.AreEqual(0, helper.IchAnchor);
            Assert.AreEqual(0, m_draftView.TeEditingHelper.BookIndex);
            Assert.AreEqual(1, m_draftView.TeEditingHelper.SectionIndex);
            Assert.AreEqual(0, m_draftView.ParagraphIndex);
            Assert.AreEqual(ScrSectionTags.kflidHeading, m_draftView.EditingHelper.CurrentSelection.LevelInfo[2].tag);
            Assert.IsTrue(m_draftView.TeEditingHelper.IsBackTranslation);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                Controls.Remove(m_fwTextBoxBottomMsg);
                m_fwTextBoxBottomMsg.Dispose();
                if (components != null)
                {
                    components.Dispose();
                }
            }
            m_fwTextBoxBottomMsg = null;
            m_mediator           = null;
            if (m_tsf != null)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(m_tsf);
            }
            m_tsf   = null;
            m_cache = null;

            base.Dispose(disposing);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Set up the dlg in preparation to showing it.
        /// </summary>
        /// <param name="cache">FDO cache.</param>
        /// <param name="wp">Strings used for various items in this dialog.</param>
        public void SetDlgInfo(FdoCache cache, Mediator mediator, WindowParams wp, DummyCmObject mainObj, List <DummyCmObject> mergeCandidates,
                               string guiControl, string helpTopic)
        {
            CheckDisposed();

            Debug.Assert(cache != null);

            m_mediator = mediator;
            m_cache    = cache;
            m_mainObj  = mainObj;
            m_tsf      = cache.TsStrFactory;

            m_fwTextBoxBottomMsg.WritingSystemFactory = m_cache.WritingSystemFactory;
            m_fwTextBoxBottomMsg.WritingSystemCode    = m_cache.WritingSystemFactory.UserWs;

            InitBrowseView(guiControl, mergeCandidates);

            Text        = wp.m_title;
            label2.Text = wp.m_label;

            m_helpTopic = helpTopic;

            if (m_helpTopic != null && m_helpTopicProvider != null)            // m_helpTopicProvider could be null for testing
            {
                helpProvider = new HelpProvider();
                helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile;
                helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(m_helpTopic));
                helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }

            MoveWindowToPreviousPosition();
        }
Exemplo n.º 30
0
        public DiscourseTestHelper(FdoCache cache)
        {
            m_cache = cache;

            #region Load Factories and Repositories

            m_servLoc        = m_cache.ServiceLocator;
            m_tsf            = cache.TsStrFactory;
            m_wAnalysisFact  = m_servLoc.GetInstance <IWfiAnalysisFactory>();
            m_wGlossFact     = m_servLoc.GetInstance <IWfiGlossFactory>();
            m_rowFact        = m_servLoc.GetInstance <IConstChartRowFactory>();
            m_wordGrpFact    = m_servLoc.GetInstance <IConstChartWordGroupFactory>();
            m_ccTagFact      = m_servLoc.GetInstance <IConstChartTagFactory>();
            m_mtmFact        = m_servLoc.GetInstance <IConstChartMovedTextMarkerFactory>();
            m_clauseMrkrFact = m_servLoc.GetInstance <IConstChartClauseMarkerFactory>();
            m_partRepo       = m_servLoc.GetInstance <IConstituentChartCellPartRepository>();
            m_rowRepo        = m_servLoc.GetInstance <IConstChartRowRepository>();

            #endregion

            m_text = m_servLoc.GetInstance <ITextFactory>().Create();
            //Cache.LangProject.TextsOC.Add(m_text);
            m_stText          = m_servLoc.GetInstance <IStTextFactory>().Create();
            m_text.ContentsOA = m_stText;
            m_allOccurrences  = new Dictionary <IStTxtPara, AnalysisOccurrence[]>();
            m_firstPara       = MakeParagraph();
        }
Exemplo n.º 31
0
 /// <summary>
 /// Reconstitute data.
 /// </summary>
 protected virtual void FromXml(XElement reader, ILgWritingSystemFactory wsf, ITsStrFactory tsf)
 {
     foreach (var aStrNode in reader.Elements("AStr"))
     {
         // Throwing out a string without a ws is probably better than crashing
         // and preventing a db from being opened.
         // This code currently accepts this data, only storing en, fr, and es strings.
         // <Description>
         // <AStr ws="en"><Run ws="en">***</Run></AStr>
         // <AStr><Run ws="fr">***</Run></AStr>
         // <AStr ws="du"/>
         // <AStr ws="zh"></AStr>
         // <AStr ws="ko"><Run/></AStr>
         // <AStr ws="in"><Run>bad</Run></AStr>
         // <AStr/>
         // <AStr ws="es"><Run ws="es">help</Run></AStr>
         // </Description>
         ITsString tss;
         int       wsHvo = ReadAstrElementOfMultiString(aStrNode, wsf, out tss);
         if (tss != null && wsHvo > 0 && tss.Length > 0)
         {
             Add(wsHvo, tss);
         }
     }
 }
Exemplo n.º 32
0
            private void SetContentFromNode(FdoCache cache, string sNodeName, bool fFixName, ITsMultiString item)
            {
                ILgWritingSystemFactory wsf = cache.WritingSystemFactory;
                ITsStrFactory           tsf = cache.TsStrFactory;
                int     iWS;
                XmlNode nd;
                bool    fContentFound = false;              // be pessimistic

                foreach (IWritingSystem ws in cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems)
                {
                    string sWS = ws.Id;
                    nd = m_node.SelectSingleNode(sNodeName + "[@ws='" + sWS + "']");
                    if (nd == null || nd.InnerText.Length == 0)
                    {
                        continue;
                    }
                    fContentFound = true;
                    string sNodeContent;
                    if (fFixName)
                    {
                        sNodeContent = NameFixer(nd.InnerText);
                    }
                    else
                    {
                        sNodeContent = nd.InnerText;
                    }
                    iWS = wsf.GetWsFromStr(sWS);
                    item.set_String(iWS, (tsf.MakeString(sNodeContent, iWS)));
                }
                if (!fContentFound)
                {
                    iWS = cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle;
                    item.set_String(iWS, tsf.MakeString("", iWS));
                }
            }
Exemplo n.º 33
0
		public void Dispose()
		{
			m_stText = null;
			m_tsf = null;
			m_text = null;
			m_firstPara = null;
			m_cache = null;
		}
Exemplo n.º 34
0
		public DiscourseTestHelper(FdoCache cache)
		{
			m_cache = cache;
			m_tsf = TsStrFactoryClass.Create();
			m_text = (Text)Cache.LangProject.TextsOC.Add(new Text());
			m_stText = new StText();
			m_text.ContentsOA = m_stText;
			m_firstPara = MakeParagraph();
		}
Exemplo n.º 35
0
		public void Setup()
		{
			tsf = TsStrFactoryClass.Create();
			wsf = new MockWsf();
			wsEn = wsf.GetWsFromStr("en");
			wsFrn = wsf.GetWsFromStr("fr");
			ITsPropsBldr propBldr = TsPropsBldrClass.Create();
			propBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsFrn);
			ttpFrn = propBldr.GetTextProps();
		}
Exemplo n.º 36
0
		public override void FixtureSetup()
		{
			base.FixtureSetup();

			SetupTestModel(Resources.TextCacheModel_xml);

			m_sda = new RealDataCache();
			m_sda.MetaDataCache = MetaDataCache.CreateMetaDataCache("TestModel.xml");
			//m_cache.ParaContentsFlid = kflidParaContents;
			//m_cache.ParaPropertiesFlid = kflidParaProperties;
			//m_cache.TextParagraphsFlid = kflidTextParas;

			Debug.Assert(m_wsManager == null);
			m_wsManager = Cache.ServiceLocator.GetInstance<IWritingSystemManager>();
			m_sda.WritingSystemFactory = m_wsManager;

			m_wsAnal = Cache.DefaultAnalWs;

			m_wsVern = Cache.DefaultVernWs;

			//IWritingSystem deWs;
			//m_wsManager.GetOrSet("de", out deWs);
			//m_wsDeu = deWs.Handle;

			//m_wsManager.UserWs = m_wsEng;
			//m_wsUser = m_wsManager.UserWs;

			m_tsf = TsStrFactoryClass.Create();

			m_hvoLexDb = m_sda.MakeNewObject(kclsidLexDb, 0, -1, -1);

			kflidLexDb_Entries = m_sda.MetaDataCache.GetFieldId("LexDb", "Entries", false);
			kflidEntry_Form = m_sda.MetaDataCache.GetFieldId("Entry", "Form", false);
			kflidEntry_Summary = m_sda.MetaDataCache.GetFieldId("Entry", "Summary", false);

			m_hvoKick = m_sda.MakeNewObject(kclsidEntry, m_hvoLexDb, kflidLexDb_Entries, 0);
			m_sda.SetMultiStringAlt(m_hvoKick, kflidEntry_Form, m_wsVern, m_tsf.MakeString("kick", m_wsVern));
			m_sda.SetString(m_hvoKick, kflidEntry_Summary, m_tsf.MakeString("strike with foot", m_wsAnal));

			var keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new[] { "class", "type", "name", "choiceGuid" };
			keyAttrs["group"] = new[] { "label" };
			keyAttrs["part"] = new[] { "ref" };
			var layoutInventory = new Inventory("*.fwlayout", "/LayoutInventory/*", keyAttrs, "test", "nowhere");
			layoutInventory.LoadElements(Resources.Layouts_xml, 1);

			keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["part"] = new[] { "id" };

			var partInventory = new Inventory("*Parts.xml", "/PartInventory/bin/*", keyAttrs, "test", "nowhere");
			partInventory.LoadElements(Resources.Parts_xml, 1);

			m_layouts = new LayoutCache(m_sda.MetaDataCache, layoutInventory, partInventory);
		}
Exemplo n.º 37
0
		public void FixtureSetup()
		{
			m_wsManager = new PalasoWritingSystemManager();
			IWritingSystem enWs;
			m_wsManager.GetOrSet("en", out enWs);
			m_enWs = enWs.Handle;
			IWritingSystem frWs;
			m_wsManager.GetOrSet("fr", out frWs);
			m_frWs = frWs.Handle;
			m_tsf = TsStrFactoryClass.Create();
		}
Exemplo n.º 38
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create test data for tests.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_servloc = Cache.ServiceLocator;
			m_text = AddInterlinearTextToLangProj("My Interlinear Text");
			m_stTextPara = AddParaToInterlinearTextContents(m_text, "Here is a sentence I can chart.");
			m_stText = m_text.ContentsOA;
			m_tssFact = Cache.TsStrFactory;
			m_rowFact = m_servloc.GetInstance<IConstChartRowFactory>();
			m_wordGrpFact = m_servloc.GetInstance<IConstChartWordGroupFactory>();
			m_possFact = m_servloc.GetInstance<ICmPossibilityFactory>();
			m_wfiFact = m_servloc.GetInstance<IWfiWordformFactory>();
			m_mtMrkrFact = m_servloc.GetInstance<IConstChartMovedTextMarkerFactory>();
			m_clsMrkrFact = m_servloc.GetInstance<IConstChartClauseMarkerFactory>();
		}
Exemplo n.º 39
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes for replace all: creates a view constructor to be used with replace all
		/// as well as initial settings for the pattern.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InitializeForReplaceAll()
		{
			// REVIEW: do we need to create m_vc? We don't seem to use it anywhere.
			m_vc = new TeStVc(TeStVc.LayoutViewTarget.targetDraft, 0);
			m_vc.Cache = Cache;

			m_pattern = VwPatternClass.Create();
			m_strFactory = TsStrFactoryClass.Create();

			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
		}
Exemplo n.º 40
0
		private void FixtureSetupInternal()
		{
			//IWritingSystem wsEn = Cache.WritingSystemFactory.get_Engine("en");
			// Setup default analysis ws
			//m_wsEn = Cache.ServiceLocator.GetInstance<ILgWritingSystemRepository>().GetObject(wsEn.WritingSystem);
			m_wsVern = Cache.DefaultVernWs;
			m_wsTrans = Cache.DefaultAnalWs;

			m_text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_text);
			var stText = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			m_text.ContentsOA = stText;
			m_para = Cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle(stText, ScrStyleNames.NormalParagraph);

			m_trans = m_para.GetOrCreateBT();
			Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = false;
			m_tsf = Cache.TsStrFactory;
		}
Exemplo n.º 41
0
		/// <summary>
		/// Constructor. Called by service locator factory (by reflection).
		/// </summary>
		/// <remarks>
		/// The hvo values are true 'handles' in that they are valid for one session,
		/// but may not be the same integer for another session for the 'same' object.
		/// Therefore, one should not use them for multi-session identity.
		/// CmObject identity can only be guaranteed by using their Guids (or using '==' in code).
		/// </remarks>
		internal DomainDataByFlid(ICmObjectRepository cmObjectRepository, IStTextRepository stTxtRepository,
			IFwMetaDataCacheManaged mdc, ISilDataAccessHelperInternal uowService,
			ITsStrFactory tsf, ILgWritingSystemFactory wsf)
		{
			if (cmObjectRepository == null) throw new ArgumentNullException("cmObjectRepository");
			if (stTxtRepository == null) throw new ArgumentNullException("stTxtRepository");
			if (mdc == null) throw new ArgumentNullException("mdc");
			if (uowService == null) throw new ArgumentNullException("uowService");
			if (tsf == null) throw new ArgumentNullException("tsf");
			if (wsf == null) throw new ArgumentNullException("wsf");

			m_cmObjectRepository = cmObjectRepository;
			m_stTxtRepository = stTxtRepository;
			m_mdc = mdc;
			m_uowService = uowService;
			m_tsf = tsf;
			m_wsf = wsf;
		}
Exemplo n.º 42
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			if (m_cpe != null && Marshal.IsComObject(m_cpe))
				Marshal.ReleaseComObject(m_cpe);
			m_cpe = null;
			m_settings = null;
			m_SOWrapper = null;
			m_sSegmentText = null;
			m_sMarker = null;
			m_styleProxy = null;
			m_vernParaStyleProxy = null;
			m_vernTextProps = null;
			m_analTextProps = null;
			m_styleProxies = null;
			m_notesStyleProxies = null;
			m_lastPara = null;
			m_BookTitleParaProxy = null;
			m_DefaultFootnoteParaProxy = null;
			m_TsStringFactory = null;
			m_BTFootnoteStrBldr = null;
			m_CurrParaPictures = null;
			m_CurrParaFootnotes = null;
			m_BTPendingPictures = null;
			m_CurrBTFootnote = null;
			m_sBtFootnoteParaStyle = null;
			m_BtFootnoteStrBldrs = null;
			m_PendingAnnotations = null;
			m_BTfootnoteIndex = null;
			m_sCharStyleEndMarker = null;
			m_sFootnoteEndMarker = null;
			m_sCharStyleBeginMarker = null;
			m_sFootnoteBeginMarker = null;
			m_scrTranslatorAnnotationDef = null;

			base.Dispose(disposing);
		}
Exemplo n.º 43
0
		public TsStringfactory(ITsStrFactory tsf, Dictionary<string, int> wsCache)
		{
			m_tsf = tsf;
			m_wsCache = wsCache;
		}
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				Controls.Remove(m_fwTextBoxBottomMsg);
				m_fwTextBoxBottomMsg.Dispose();
				if(components != null)
				{
					components.Dispose();
				}
			}
			m_fwTextBoxBottomMsg = null;
			m_mediator = null;
			if (m_tsf != null)
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_tsf);
			m_tsf = null;
			m_cache = null;

			base.Dispose( disposing );
		}
		/// <summary>
		/// Set up the dlg in preparation to showing it.
		/// </summary>
		/// <param name="cache">FDO cache.</param>
		/// <param name="mediator"></param>
		/// <param name="entry">LexEntry</param>
		public void SetDlgInfo(FdoCache cache, Mediator mediator, ILexEntry entry)
		{
			CheckDisposed();

			Debug.Assert(cache != null);

			m_mediator = mediator;
			m_cache = cache;
			m_entry = entry;
			m_tsf = m_cache.TsStrFactory;
			m_fwTextBoxBottomMsg.WritingSystemFactory = m_cache.WritingSystemFactory;
			//m_fwTextBoxBottomMsg.WritingSystemCode = 1; // What!? Why? No longer makes ANY sense!
			IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			// We want to do this BEFORE the text gets set, to avoid overriding its height properties.
			// However, because of putting multiple lines in the box, we also need to do it AFTER we set the text
			// (in SetBottomMessage) so it adjusts to the resulting even greater height.
			m_fwTextBoxBottomMsg.AdjustForStyleSheet(this, null, stylesheet);
			Font f = FontHeightAdjuster.GetFontForNormalStyle(
				m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle, stylesheet, m_cache.LanguageWritingSystemFactoryAccessor);
			foreach (IMoForm allo in entry.AlternateFormsOS)
			{
				ListViewItem lvi = m_lvAlloOptions.Items.Add(allo.Form.VernacularDefaultWritingSystem.Text);
				lvi.Tag = allo;
				lvi.UseItemStyleForSubItems = true;
				lvi.Font = f;
			}
			m_lvAlloOptions.Font = f;
			// Get location to the stored values, if any.
			object locWnd = m_mediator.PropertyTable.GetValue("swapDlgLocation");
			// And when I do this, it works the first time, but later times the window is
			// too small and doesn't show all the controls. Give up on smart location for now.
			//object szWnd = this.Size;
			object szWnd = null; // suppresses the smart location stuff.
			//if (locWnd != null && szWnd != null)
			//{
			//    Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
			//    ScreenUtils.EnsureVisibleRect(ref rect);
			//    DesktopBounds = rect;
			//    StartPosition = FormStartPosition.Manual;
			//}
			m_lvAlloOptions.Items[0].Selected = true;
			Text = LexEdStrings.ksSwapLexWithAllo;
			label2.Text = LexEdStrings.ksAlternateForms;

			// Determine the help file to use, if any
			m_helpTopic = "khtpSwapLexemeWithAllomorph";

			if(m_mediator.HelpTopicProvider != null)
			{
				helpProvider = new HelpProvider();
				helpProvider.HelpNamespace = m_mediator.HelpTopicProvider.HelpFile;
				helpProvider.SetHelpKeyword(this, m_mediator.HelpTopicProvider.GetHelpString(m_helpTopic));
				helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
			}
		}
Exemplo n.º 46
0
		private ITsString NameOfWs(ITsStrFactory tsf, int i)
		{
			// Don't use this, it uses the analysis default writing system which is not wanted per LT-4610.
			//tsf.MakeString(m_rgws[i].Abbreviation, m_wsUI);
			ILgWritingSystem ws = m_rgws[i];
			// Display in English if possible for now (August 2008).  See LT-8631 and LT-8574.
			ITsString result = ws.Cache.MainCacheAccessor.get_MultiStringAlt(ws.Hvo,
				(int)LgWritingSystem.LgWritingSystemTags.kflidAbbr, m_wsEn/*m_wsUI*/);

			if (result == null || result.Length == 0)
				return tsf.MakeString(m_rgws[i].Abbreviation, m_wsEn/*m_wsUI*/);
			return result;
		}
Exemplo n.º 47
0
		/// <summary>
		/// Initialize the control.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="mediator"></param>
		/// <param name="parentForm"></param>
		public void Initialize(FdoCache cache, Mediator mediator, Form parentForm, SandboxGenericMSA sandboxMSA)
		{
			CheckDisposed();

			m_parentForm = parentForm;
			m_mediator = mediator;
			m_tsf = cache.TsStrFactory;
			m_cache = cache;

			IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			int defUserWs = m_cache.ServiceLocator.WritingSystemManager.UserWs;
			IWritingSystem defAnalWs = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem;
			string defAnalWsFont = defAnalWs.DefaultFontName;

			m_fwcbAffixTypes.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_fwcbAffixTypes.WritingSystemCode = defAnalWs.Handle;
			m_fwcbAffixTypes.Items.Add(m_tsf.MakeString(LexTextControls.ksNotSure, defUserWs));
			m_fwcbAffixTypes.Items.Add(m_tsf.MakeString(LexTextControls.ksInflectional, defUserWs));
			m_fwcbAffixTypes.Items.Add(m_tsf.MakeString(LexTextControls.ksDerivational, defUserWs));
			m_fwcbAffixTypes.StyleSheet = stylesheet;
			m_fwcbAffixTypes.AdjustStringHeight = false;

			m_fwcbSlots.Font = new Font(defAnalWsFont, 10);
			m_fwcbSlots.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_fwcbSlots.WritingSystemCode = defAnalWs.Handle;
			m_fwcbSlots.StyleSheet = stylesheet;
			m_fwcbSlots.AdjustStringHeight = false;

			m_tcMainPOS.Font = new Font(defAnalWsFont, 10);
			m_tcMainPOS.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_tcMainPOS.WritingSystemCode = defAnalWs.Handle;
			m_tcMainPOS.StyleSheet = stylesheet;
			m_tcMainPOS.AdjustStringHeight = false;

			m_tcSecondaryPOS.Font = new Font(defAnalWsFont, 10);
			m_tcSecondaryPOS.WritingSystemFactory = m_cache.WritingSystemFactory;
			m_tcSecondaryPOS.WritingSystemCode = defAnalWs.Handle;
			m_tcSecondaryPOS.StyleSheet = stylesheet;
			m_tcSecondaryPOS.AdjustStringHeight = false;

			m_selectedMainPOS = sandboxMSA.MainPOS;
			m_fwcbAffixTypes.SelectedIndex = 0;
			m_fwcbAffixTypes.SelectedIndexChanged += HandleComboMSATypesChange;
			m_mainPOSPopupTreeManager = new POSPopupTreeManager(m_tcMainPOS, m_cache,
				m_cache.LanguageProject.PartsOfSpeechOA,
				defAnalWs.Handle, false, m_mediator,
				m_parentForm);
			m_mainPOSPopupTreeManager.NotSureIsAny = true;
			m_mainPOSPopupTreeManager.LoadPopupTree(m_selectedMainPOS != null ? m_selectedMainPOS.Hvo : 0);
			m_mainPOSPopupTreeManager.AfterSelect += m_mainPOSPopupTreeManager_AfterSelect;
			m_fwcbSlots.SelectedIndexChanged += HandleComboSlotChange;
			m_secPOSPopupTreeManager = new POSPopupTreeManager(m_tcSecondaryPOS, m_cache,
				m_cache.LanguageProject.PartsOfSpeechOA,
				defAnalWs.Handle, false, m_mediator,
				m_parentForm);
			m_secPOSPopupTreeManager.NotSureIsAny = true; // only used for affixes.
			m_selectedSecondaryPOS = sandboxMSA.SecondaryPOS;
			m_secPOSPopupTreeManager.LoadPopupTree(m_selectedSecondaryPOS != null ? m_selectedSecondaryPOS.Hvo : 0);
			m_secPOSPopupTreeManager.AfterSelect += m_secPOSPopupTreeManager_AfterSelect;

			// Relocate the m_tcSecondaryPOS control to overlay the m_fwcbSlots.
			// In the designer, they are offset to see them, and edit them.
			// In running code they are in the same spot, but only one is visible at a time.
			m_tcSecondaryPOS.Location = m_fwcbSlots.Location;

			if (m_selectedMainPOS != null && sandboxMSA.MsaType == MsaType.kInfl)
			{
				// This fixes LT-4677, LT-6048, and LT-6201.
				ResetSlotCombo();
			}
			MSAType = sandboxMSA.MsaType;
		}
Exemplo n.º 48
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create an ITsString in the given writing system.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static ITsString MakeTss(ITsStrFactory tsf, int wsHvo, string text)
		{
			return tsf.MakeString(text, wsHvo);
		}
Exemplo n.º 49
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		private void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				if (m_wsCache != null)
					m_wsCache.Clear();
				if (m_delayedAtomicReferences != null)
					m_delayedAtomicReferences.Clear();
				if (m_delayedVecterReferences != null)
					m_delayedVecterReferences.Clear();
				if (m_cachedFlids != null)
					m_cachedFlids.Clear();
				if (m_tsf != null)
					m_tsf.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.

			if (m_itsf != null)
			{
				if (Marshal.IsComObject(m_itsf))
					Marshal.ReleaseComObject(m_itsf);
				m_itsf = null;
			}
			m_tsf = null;
			m_metaDataCache = null;
			m_realDataCache = null;
			m_wsCache = null;
			m_delayedAtomicReferences = null;
			m_delayedVecterReferences = null;
			m_cachedFlids = null;

			m_isDisposed = true;
		}
Exemplo n.º 50
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes for replace all: creates a view constructor to be used with replace all
		/// as well as initial settings for the pattern.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InitializeForReplaceAll()
		{
			m_vc = new TeStVc(TeStVc.LayoutViewTarget.targetDraft, 0);
			m_vc.Cache = Cache;

			m_pattern = VwPatternClass.Create();
			m_strFactory = TsStrFactoryClass.Create();

			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
		}
Exemplo n.º 51
0
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			m_cache = null;
			m_tsf = null;

			base.Dispose( disposing );
		}
Exemplo n.º 52
0
		protected virtual void SetDlgInfo(FdoCache cache, WindowParams wp, Mediator mediator, int wsVern)
		{
			CheckDisposed();

			Debug.Assert(cache != null);
			m_cache = cache;

			m_mediator = mediator;

			if (m_mediator != null)
			{
				ReplaceMatchingItemsControl();

				// Reset window location.
				// Get location to the stored values, if any.
				object locWnd = m_mediator.PropertyTable.GetValue(PersistenceLabel + "DlgLocation");
				object szWnd = m_mediator.PropertyTable.GetValue(PersistenceLabel + "DlgSize");
				if (locWnd != null && szWnd != null)
				{
					Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);

					//grow it if it's too small.  This will happen when we add new controls to the dialog box.
					if(rect.Width < btnHelp.Left + btnHelp.Width + 30)
						rect.Width = btnHelp.Left + btnHelp.Width + 30;

					if(rect.Height < btnHelp.Top + btnHelp.Height + 50)
						rect.Height = btnHelp.Top + btnHelp.Height + 50;

					//rect.Height = 600;

					ScreenUtils.EnsureVisibleRect(ref rect);
					DesktopBounds = rect;
					StartPosition = FormStartPosition.Manual;
				}
			}

			SetupBasicTextProperties(wp);

			IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			InitializeMatchingEntries(cache, mediator);
			int hvoWs = wsVern;
			// Set font, writing system factory, and writing system code for the Lexical Form
			// edit box.  Also set an empty string with the proper writing system.
			m_tbForm.Font =
				new Font(cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsVern).DefaultSerif, 10);
			m_tbForm.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
			m_tbForm.WritingSystemCode = hvoWs;
			m_tsf = TsStrFactoryClass.Create();
			m_tbForm.AdjustStringHeight = false;
			m_tbForm.Tss = m_tsf.MakeString("", hvoWs);
			m_tbForm.StyleSheet = stylesheet;

			// Setup the fancy message text box.
			// Note: at 120DPI (only), it seems to be essential to set at least the WSF of the
			// bottom message even if not using it.
			SetupBottomMsg();
			SetBottomMessage();
			m_fwTextBoxBottomMsg.BorderStyle = BorderStyle.None;

			m_analHvos.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
			List<int> vernList = new List<int>(cache.LangProject.CurVernWssRS.HvoArray);
			m_vernHvos.AddRange(vernList);
			LoadWritingSystemCombo();
			int iWs = vernList.IndexOf(hvoWs);
			ILgWritingSystem lgwsCurrent;
			if (iWs < 0)
			{
				List<int> analList = new List<int>(cache.LangProject.CurAnalysisWssRS.HvoArray);
				iWs = analList.IndexOf(hvoWs);
				if (iWs < 0)
				{
					lgwsCurrent = LgWritingSystem.CreateFromDBObject(cache, hvoWs);
					m_cbWritingSystems.Items.Add(lgwsCurrent);
				}
				else
				{
					lgwsCurrent = cache.LangProject.CurAnalysisWssRS[iWs];
				}
			}
			else
			{
				lgwsCurrent = cache.LangProject.CurVernWssRS[iWs];
			}
			Debug.Assert(lgwsCurrent != null && lgwsCurrent.Hvo == hvoWs);

			m_skipCheck = true;
			m_cbWritingSystems.SelectedItem = lgwsCurrent;
			m_skipCheck = false;
			// Don't hook this up until AFTER we've initialized it; otherwise, it can
			// modify the contents of the form as a side effect of initialization.
			// Also, doing that triggers laying out the dialog prematurely, before
			// we've set WSF on all the controls.
			m_cbWritingSystems.SelectedIndexChanged += new System.EventHandler(this.m_cbWritingSystems_SelectedIndexChanged);


			// Adjust things if the form box needs to grow to accommodate its style.
			int oldHeight = m_tbForm.Height;
			int newHeight = Math.Max(oldHeight, m_tbForm.PreferredHeight);
			int delta = newHeight - oldHeight;
			if (delta != 0)
			{
				m_tbForm.Height = newHeight;
				panel1.Height += delta;
				GrowDialogAndAdjustControls(delta, panel1);
			}
		}
Exemplo n.º 53
0
			/// <summary>
			/// Clean up any resources being used.
			/// </summary>
			protected override void Dispose(bool disposing)
			{
				//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
				// Must not be run more than once.
				if (IsDisposed)
					return;

				base.Dispose(disposing);

				if (disposing)
				{
					if (m_vc != null)
						m_vc.Dispose();
					if (m_usedIndices != null)
						m_usedIndices.Clear();
				}

				m_sense = null;
				m_vc = null;
				if (m_tsf != null)
					System.Runtime.InteropServices.Marshal.ReleaseComObject(m_tsf);
				m_tsf = null;
				m_silCache = null;
				if (m_vwCache != null)
				{
					m_vwCache.ClearAllData();
					System.Runtime.InteropServices.Marshal.ReleaseComObject(m_vwCache);
					m_vwCache = null;
				}
				m_usedIndices = null;
			}
Exemplo n.º 54
0
			public ReversalIndexEntryVc(List<IReversalIndex> usedIndices, FdoCache cache)
			{
				m_cache = cache;
				m_usedIndices = usedIndices;
				m_ttpLabel = LgWritingSystem.AbbreviationTextProperties;
				m_tsf = TsStrFactoryClass.Create();
			}
Exemplo n.º 55
0
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			base.Dispose(disposing);

			if (disposing)
			{
				if (components != null)
				{
					components.Dispose();
				}
				if (m_PhoneEnvReferenceVc != null)
					m_PhoneEnvReferenceVc.Dispose();
			}
			m_validator = null; // TODO: Make m_validator disposable?
			m_realEnvs.Clear();
			m_realEnvs = null;
			m_rootObj = null;
			if (m_tsf != null)
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_tsf);
			m_tsf = null;
			m_silCache = null;
			if (m_vwCache != null)
				System.Runtime.InteropServices.Marshal.ReleaseComObject(m_vwCache);
			m_vwCache = null;
			m_PhoneEnvReferenceVc = null;
		}
Exemplo n.º 56
0
			/// <summary>
			/// Executes in two distinct scenarios.
			///
			/// 1. If disposing is true, the method has been called directly
			/// or indirectly by a user's code via the Dispose method.
			/// Both managed and unmanaged resources can be disposed.
			///
			/// 2. If disposing is false, the method has been called by the
			/// runtime from inside the finalizer and you should not reference (access)
			/// other managed objects, as they already have been garbage collected.
			/// Only unmanaged resources can be disposed.
			/// </summary>
			/// <param name="disposing"></param>
			/// <remarks>
			/// If any exceptions are thrown, that is fine.
			/// If the method is being done in a finalizer, it will be ignored.
			/// If it is thrown by client code calling Dispose,
			/// it needs to be handled by fixing the bug.
			///
			/// If subclasses override this method, they should call the base implementation.
			/// </remarks>
			protected override void Dispose(bool disposing)
			{
				//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
				// Must not be run more than once.
				if (IsDisposed)
					return;

				if (disposing)
				{
					// Dispose managed resources here.
					if (m_usedIndices != null)
						m_usedIndices.Clear();
				}

				// Dispose unmanaged resources here, whether disposing is true or false.
				m_cache = null;
				m_usedIndices = null;
				m_ttpLabel = null;
				m_tsf = null;

				base.Dispose(disposing);
			}
Exemplo n.º 57
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_footnote = null;;
			m_book = null;
			if (m_strFact != null)
				Marshal.ReleaseComObject(m_strFact);
			m_strFact = null;;

			base.Dispose(disposing);
		}
Exemplo n.º 58
0
		public void SetUp()
		{
			m_tsf = TsStrFactoryClass.Create();
		}
Exemplo n.º 59
0
		private HvoTreeNode AddTreeNodeForMsa(PopupTree popupTree, ITsStrFactory tsf, IMoMorphSynAnalysis msa)
		{
			// JohnT: as described in LT-4633, a stem can be given an allomorph that
			// is an affix. So we need some sort of way to handle this.
			//Debug.Assert(msa is MoStemMsa);
			ITsString tssLabel = msa.InterlinearNameTSS;
			if (msa is IMoStemMsa && (msa as IMoStemMsa).PartOfSpeechRA == null)
				tssLabel = tsf.MakeString(
					m_sUnknown,
					Cache.ServiceLocator.WritingSystemManager.UserWs);
			var node = new HvoTreeNode(tssLabel, msa.Hvo);
			popupTree.Nodes.Add(node);
			return node;
		}
Exemplo n.º 60
0
		public void FixtureSetup()
		{
			m_wsManager = new PalasoWritingSystemManager();
			m_comparer = new TsStringComparer(m_wsManager.Create("en"));
			m_tssFact = TsStrFactoryClass.Create();
		}