Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
        internal static void DisplayEntries(FdoCache cache, IWin32Window owner, Mediator mediatorIn,
                                            IHelpTopicProvider helpProvider, string helpFileKey, ITsString tssWfIn)
        {
            ITsString  tssWf = tssWfIn;
            List <int> rghvo = LexEntryUi.FindEntriesForWordform(cache, tssWf);

            // if we do not find a match for the word then try converting it to lowercase and see if there
            // is an entry in the lexicon for the Wordform in lowercase. This is needed for occurences of
            // words which are capitalized at the beginning of sentences.  LT-7444 RickM
            if (rghvo == null || rghvo.Count == 0)
            {
                //We need to be careful when converting to lowercase therefore use Icu.ToLower()
                //get the WS of the tsString
                int wsWf = StringUtils.GetWsAtOffset(tssWf, 0);
                //use that to get the locale for the WS, which is used for
                string        wsLocale = cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsWf).IcuLocale;
                string        sLower   = Icu.ToLower(tssWf.Text, wsLocale);
                ITsTextProps  ttp      = tssWf.get_PropertiesAt(0);
                ITsStrFactory tsf      = TsStrFactoryClass.Create();
                tssWf = tsf.MakeStringWithPropsRgch(sLower, sLower.Length, ttp);
                rghvo = LexEntryUi.FindEntriesForWordform(cache, tssWf);
            }

            StringTable   stOrig;
            Mediator      mediator;
            IVwStylesheet styleSheet;
            bool          fRestore = EnsureFlexTypeSetup(cache, mediatorIn, out stOrig, out mediator, out styleSheet);

            if (rghvo == null || rghvo.Count == 0)
            {
                int hvoLe = ShowFindEntryDialog(cache, mediator, tssWf, owner);
                if (hvoLe == 0)
                {
                    // Restore the original string table in the mediator if needed.
                    if (fRestore)
                    {
                        mediator.StringTbl = stOrig;
                    }
                    return;
                }
                rghvo = new List <int>(1);
                rghvo.Add(hvoLe);
            }
            using (SummaryDialogForm form =
                       new SummaryDialogForm(rghvo, tssWf, helpProvider, helpFileKey, styleSheet, cache, mediator))
            {
                form.ShowDialog(owner);
                if (form.ShouldLink)
                {
                    form.LinkToLexicon();
                }
            }
            // Restore the original string table in the mediator if needed.
            if (fRestore)
            {
                mediator.StringTbl = stOrig;
            }
        }
Ejemplo n.º 3
0
        public void GetKeyTermFromTSS()
        {
            ITsStrFactory tsf = TsStrFactoryClass.Create();
            ITsString     tss = tsf.MakeStringWithPropsRgch("angel", "angel".Length,
                                                            StyleUtils.CharStyleTextProps("Emphasis", m_cache.DefaultVernWs));

            Assert.AreEqual("angel", StringUtils.CleanTSS(tss, m_stylesToRemove, true,
                                                          m_cache.LanguageWritingSystemFactoryAccessor));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates an <see cref="ITsString"/> with the specified text and properties.
 /// </summary>
 public static ITsString MakeStringWithProps(this ITsStrFactory tsf, string text, ITsTextProps textProps)
 {
     return(tsf.MakeStringWithPropsRgch(text, text == null ? 0 : text.Length, textProps));
 }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
0
        internal static void DisplayEntry(FdoCache cache, IWin32Window owner, Mediator mediatorIn,
                                          IHelpTopicProvider helpProvider, string helpFileKey, ITsString tssWfIn)
        {
            ITsString  tssWf = tssWfIn;
            LexEntryUi leui  = LexEntryUi.FindEntryForWordform(cache, tssWf);

            // if we do not find a match for the word then try converting it to lowercase and see if there
            // is an entry in the lexicon for the Wordform in lowercase. This is needed for occurences of
            // words which are capitalized at the beginning of sentences.  LT-7444 RickM
            if (leui == null)
            {
                //We need to be careful when converting to lowercase therefore use Icu.ToLower()
                //get the WS of the tsString
                int wsWf = StringUtils.GetWsAtOffset(tssWf, 0);
                //use that to get the locale for the WS, which is used for
                string        wsLocale = cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsWf).IcuLocale;
                string        sLower   = Icu.ToLower(tssWf.Text, wsLocale);
                ITsTextProps  ttp      = tssWf.get_PropertiesAt(0);
                ITsStrFactory tsf      = TsStrFactoryClass.Create();
                tssWf = tsf.MakeStringWithPropsRgch(sLower, sLower.Length, ttp);
                leui  = LexEntryUi.FindEntryForWordform(cache, tssWf);
            }

            // Ensure that we have a valid mediator with the proper string table.
            bool        fRestore = false;
            StringTable stOrig   = null;
            Mediator    mediator = EnsureValidMediator(mediatorIn, out fRestore, out stOrig);
            FdoCache    cache2   = (FdoCache)mediator.PropertyTable.GetValue("cache");

            if (cache2 != cache)
            {
                mediator.PropertyTable.SetProperty("cache", cache);
            }
            EnsureWindowConfiguration(mediator);
            EnsureFlexVirtuals(cache, mediator);
            IVwStylesheet styleSheet = GetStyleSheet(cache, mediator);

            if (leui == null)
            {
                int hvoLe = ShowFindEntryDialog(cache, mediator, tssWf, owner);
                if (hvoLe == 0)
                {
                    // Restore the original string table in the mediator if needed.
                    if (fRestore)
                    {
                        mediator.StringTbl = stOrig;
                    }
                    return;
                }
                leui = new LexEntryUi(new LexEntry(cache, hvoLe));
            }
            if (mediator != null)
            {
                leui.Mediator = mediator;
            }
            leui.ShowSummaryDialog(owner, tssWf, helpProvider, helpFileKey, styleSheet);
            // Restore the original string table in the mediator if needed.
            if (fRestore)
            {
                mediator.StringTbl = stOrig;
            }
        }