Ejemplo n.º 1
0
        public void GoodMultiUnicodeTest()
        {
            // Start with expected information.
            Assert.AreEqual(0, Cache.LangProject.MainCountry.StringCount, "Wrong number of alternatives for Cache.LangProject.MainCountryAccessor");

            // Create a good string.
            var           english = Cache.LangProject.CurrentAnalysisWritingSystems.First();
            ITsIncStrBldr tisb    = TsStringUtils.MakeIncStrBldr();

            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, english.Handle);
            tisb.Append("Mexico");
            Cache.LangProject.MainCountry.set_String(english.Handle, tisb.GetString());

            // Make sure it is in there now.
            Assert.AreEqual(1, Cache.LangProject.MainCountry.StringCount, "Wrong number of alternatives for Cache.LangProject.MainCountryAccessor");
            int ws;
            var mexico = Cache.LangProject.MainCountry.GetStringFromIndex(0, out ws);

            Assert.AreEqual(english.Handle, ws, "Wrong writing system.");
            Assert.AreEqual("Mexico", mexico.Text, "Wrong text.");

            // Add the same ws string, but with different text.
            tisb = TsStringUtils.MakeIncStrBldr();
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, english.Handle);
            tisb.Append("Guatemala");
            Cache.LangProject.MainCountry.set_String(english.Handle, tisb.GetString());

            // Make sure it is in there now.
            Assert.AreEqual(1, Cache.LangProject.MainCountry.StringCount, "Wrong number of alternatives for Cache.LangProject.MainCountryAccessor");
            var guatemala = Cache.LangProject.MainCountry.GetStringFromIndex(0, out ws);

            Assert.AreEqual(english.Handle, ws, "Wrong writing system.");
            Assert.AreEqual("Guatemala", guatemala.Text, "Wrong text.");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a TsString with the entry headword and a sense number if there
        /// are more than one senses.
        /// </summary>
        public ITsString OwnerOutlineNameForWs(ILexSense sense, int wsVern, HomographConfiguration.HeadwordVariant hv)
        {
            var entry = sense.Entry;
            int hn;

            if (!m_homographNumbers.TryGetValue(entry.Hvo, out hn))
            {
                hn = entry.HomographNumber;                 // unknown entry, use its own HN instead of our override
            }
            ITsIncStrBldr tisb = TsIncStrBldrClass.Create();

            tisb.AppendTsString(StringServices.HeadWordForWsAndHn(entry, wsVern, hn, "", hv));
            var hc = sense.Services.GetInstance <HomographConfiguration>();

            if (hc.ShowSenseNumber(hv) && HasMoreThanOneSense(entry))
            {
                // These int props may not be needed, but they're safe.
                tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0,
                                      Cache.DefaultAnalWs);
                tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                     HomographConfiguration.ksSenseReferenceNumberStyle);
                tisb.Append(" ");
                tisb.Append(GetSenseNumber(sense));
            }
            return(tisb.GetString());
        }
Ejemplo n.º 3
0
        private static void AddHeadwordForWsAndHn(ILexEntry entry, int wsVern, int nHomograph, HomographConfiguration.HeadwordVariant hv,
                                                  ITsIncStrBldr tisb, string citationForm, LcmCache cache)
        {
            var ws = cache?.WritingSystemFactory?.get_EngineOrNull(wsVern);

            // Audio writing systems actually store a filename and should not have homograph numbers attached
            if (IsAudioWritingSystem(ws))
            {
                tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsVern);
                tisb.Append(citationForm);
                return;
            }
            var hc = entry.Services.GetInstance <HomographConfiguration>();

            if (hc.HomographNumberBefore)
            {
                InsertHomographNumber(tisb, nHomograph, hc, hv, cache);
            }
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsVern);
            tisb.Append(citationForm);

            if (!hc.HomographNumberBefore)
            {
                InsertHomographNumber(tisb, nHomograph, hc, hv, cache);
            }
        }
Ejemplo n.º 4
0
        public void GetTextRepresentation_MultiCharStylePara()
        {
            ITsIncStrBldr strBldr = m_footnotePara.Contents.GetIncBldr();

            // run 1
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Emphasis");
            strBldr.Append("Test Text");

            // run 2
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    null);
            strBldr.Append("No char style");

            // run 3
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Quoted Text");
            strBldr.Append("Ahh!!!!!!");

            // run 4
            strBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_wsDe);
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Untranslated Word");
            strBldr.Append(" untranslated");

            m_footnotePara.Contents = strBldr.GetString();

            string result = m_footnote.TextRepresentation;

            Assert.AreEqual("<FN><M>a</M><P><PS>Note General Paragraph</PS>" +
                            "<RUN WS='fr' CS='Emphasis'>Test Text</RUN><RUN WS='fr'>No char style</RUN>" +
                            "<RUN WS='fr' CS='Quoted Text'>Ahh!!!!!!</RUN>" +
                            "<RUN WS='de' CS='Untranslated Word'> untranslated</RUN></P></FN>", result);
        }
Ejemplo n.º 5
0
        public void AppendAlternativesTest()
        {
            var           english = Cache.LangProject.CurrentAnalysisWritingSystems.ElementAt(0);
            var           spanish = Cache.LangProject.CurrentAnalysisWritingSystems.ElementAt(1);
            ITsIncStrBldr tisb    = TsStringUtils.MakeIncStrBldr();

            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, english.Handle);
            tisb.Append("Mexico");
            Cache.LangProject.MainCountry.set_String(english.Handle, tisb.GetString());

            tisb = TsStringUtils.MakeIncStrBldr();
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, spanish.Handle);
            tisb.Append("Mejico");
            Cache.LangProject.MainCountry.set_String(spanish.Handle, tisb.GetString());

            tisb = TsStringUtils.MakeIncStrBldr();
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, english.Handle);
            tisb.Append("Saltillo");
            Cache.LangProject.FieldWorkLocation.set_String(english.Handle, tisb.GetString());

            Cache.LangProject.FieldWorkLocation.AppendAlternatives(Cache.LangProject.MainCountry);
            Assert.AreEqual("Saltillo Mexico", Cache.LangProject.FieldWorkLocation.get_String(english.Handle).Text);
            Assert.AreEqual("Mejico", Cache.LangProject.FieldWorkLocation.get_String(spanish.Handle).Text);

            tisb = TsStringUtils.MakeIncStrBldr();
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, spanish.Handle);
            tisb.Append("Saltillo");
            Cache.LangProject.FieldWorkLocation.set_String(spanish.Handle, tisb.GetString());

            ((ITsMultiString)Cache.LangProject.MainCountry).set_String(english.Handle, null);

            Cache.LangProject.FieldWorkLocation.AppendAlternatives(Cache.LangProject.MainCountry);
            Assert.AreEqual("Saltillo Mexico", Cache.LangProject.FieldWorkLocation.get_String(english.Handle).Text);
            Assert.AreEqual("Saltillo Mejico", Cache.LangProject.FieldWorkLocation.get_String(spanish.Handle).Text);
        }
Ejemplo n.º 6
0
        public void SerializeTsStringToXml_MultiStringLaterRunsLessProps()
        {
            ITsIncStrBldr tisb = TsStringUtils.MakeIncStrBldr();

            tisb.SetIntValue(FwTextPropType.ktptWs, FwTextPropVar.ktpvDefault, EnWS);
            tisb.SetStringValue(FwTextPropType.ktptNamedStyle, "Monkey");
            tisb.Append("This is a ");
            tisb.ClearProps();
            tisb.SetIntValue(FwTextPropType.ktptWs, FwTextPropVar.ktpvDefault, EsWS);
            tisb.Append("Laa yra la m\u00E9n");
            ITsString tss = tisb.GetString();
            string    xml = TsStringSerializer.SerializeTsStringToXml(tss, WritingSystemManager, EnWS);

            Assert.That(StripNewLines(xml), Is.EqualTo("<AStr ws=\"en\"><Run ws=\"en\" namedStyle=\"Monkey\">This is a </Run><Run ws=\"es\">Laa yra la m\u00E9n</Run></AStr>"));
        }
Ejemplo n.º 7
0
        public void SerializeTsStringToXml_WithLinkDoesNotWriteObjData()
        {
            Guid          expectedGuid = Guid.NewGuid();
            ITsIncStrBldr tisb         = TsStringUtils.MakeIncStrBldr();

            tisb.SetIntValue(FwTextPropType.ktptWs, FwTextPropVar.ktpvDefault, EnWS);
            tisb.Append("This is a link:");
            tisb.ClearProps();
            tisb.SetIntValue(FwTextPropType.ktptWs, FwTextPropVar.ktpvDefault, EnWS);
            tisb.SetStringValue(FwTextPropType.ktptObjData, CreateObjData(FwObjDataTypes.kodtNameGuidHot, expectedGuid.ToByteArray()));
            tisb.Append(StringUtils.kChObject.ToString());
            ITsString tss = tisb.GetString();
            string    xml = TsStringSerializer.SerializeTsStringToXml(tss, WritingSystemManager, writeObjData: false);

            Assert.That(StripNewLines(xml), Is.EqualTo("<Str><Run ws=\"en\">This is a link:</Run></Str>"));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Merge two MultiUnicodeAccessor objects.
 /// These cases are handled:
 ///		1. If an alternative exists in both objects, nothing is merged.
 ///		2. If the main object (this) is missing an alternative, and the 'source' has it, then add it to 'this'.
 ///		3. If the main object has an alternative, then do nothing.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="fConcatenateIfBoth"></param>
 /// <param name="sep">separator to use if concatenating</param>
 public void MergeAlternatives(IMultiStringAccessor source, bool fConcatenateIfBoth, string sep)
 {
     if (source == null)
     {
         return;                 // Nothing to do.
     }
     foreach (var lws in m_object.Services.WritingSystemManager.WritingSystems)
     {
         var ws     = lws.Handle;
         var myAlt  = get_String(ws);
         var srcAlt = source.get_String(ws);
         if ((myAlt == null || myAlt.Length == 0) &&
             (srcAlt != null && srcAlt.Length != 0))
         {
             set_String(ws, srcAlt);
         }
         else if (!fConcatenateIfBoth)
         {
             continue;
         }
         else if (myAlt != null && myAlt.Length != 0 &&
                  srcAlt != null && srcAlt.Length != 0 &&
                  !myAlt.Equals(srcAlt))
         {
             ITsIncStrBldr newBldr = TsStringUtils.MakeIncStrBldr();
             newBldr.AppendTsString(get_String(ws));
             newBldr.Append(sep);
             newBldr.AppendTsString(source.get_String(ws));
             set_String(ws, newBldr.GetString());
         }
     }
 }
Ejemplo n.º 9
0
        private void AddNumberingNowOrDelayed(bool fDelayNumber, ITsString tss, out ITsString tssDelayedNumber)
        {
            if (fDelayNumber)
            {
                m_viewConstructor.DelayNumFlag = true;

                ITsIncStrBldr tisb = tss.GetIncBldr();
                tisb.Append("  ");                 // add some padding for separation
                tssDelayedNumber   = tisb.GetString();
                m_hvoDelayedNumber = m_hvo;
            }
            else
            {
                m_viewConstructor.DelayNumFlag = false;

                OutputItemNumber(m_vwEnv, tss);
                tssDelayedNumber = null;
            }
            // This groups senses by placing graminfo before the number, and omitting it if the same as the
            // previous sense in the entry.  This isn't yet supported by the UI, but may well be requested in
            // the future.  (See LT-9663.)
            //if (fGramInfoBeforeNumber)
            //{
            //    tssDelayedNumber = tss;
            //    if (fFirst)
            //        m_hvoGroupedValue = 0;
            //}
            //else if (!m_fDelayNumber)
            //{
            //    m_vwEnv.AddString(tss);
            //    tssDelayedNumber = null;
            //}
        }
Ejemplo n.º 10
0
        public void UpdateUserPrompt_Vern_Typing()
        {
            // Set up section head with an empty paragraph
            IScrSection section = AddSectionToMockedBook(m_book);
            IStTxtPara  para    = AddSectionHeadParaToSection(section, "",
                                                              ScrStyleNames.SectionHead);

            IVwRootBox   rootb;
            IVwSelection vwsel;
            IVwRootSite  rootsite;

            SetUpResultsForUpdateUserPromptTests(4, "t", out rootb, out vwsel, out rootsite);

            int defVernWs = Cache.DefaultVernWs;

            DummyTeStVc   stVc    = new DummyTeStVc(Cache, defVernWs, rootb);
            ITsIncStrBldr strBdlr = TsIncStrBldrClass.Create();

            strBdlr.SetIntPropValues(SimpleRootSite.ktptUserPrompt, (int)FwTextPropVar.ktpvDefault, 1);
            strBdlr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, Cache.DefaultUserWs);
            strBdlr.Append("t");
            ITsString tssTyped    = strBdlr.GetString();
            ITsString tssExpected = TsStringUtils.MakeTss("t", defVernWs);

            // Now simulate the user typing over the user prompt
            stVc.UpdateProp(vwsel, para.Hvo, SimpleRootSite.kTagUserPrompt, 0, tssTyped);

            // verify that the text is in the paragraph and that there is no longer a user prompt.
            string diff;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(tssExpected, para.Contents, out diff), diff);

            m_vwenvMock.VerifyAllExpectations();
            VerifyArgsSentToRequestSelectionAtEndOfUow(rootsite, rootb, 0, 4, StTxtParaTags.kflidContents, "t");
        }
Ejemplo n.º 11
0
        private static void AddHeadwordForWsAndHn(ILexEntry entry, int wsVern, int nHomograph,
                                                  HomographConfiguration.HeadwordVariant hv, ITsIncStrBldr tisb, string citationForm)
        {
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsVern);
            var hc = entry.Services.GetInstance <HomographConfiguration>();

            if (hc.HomographNumberBefore)
            {
                InsertHomographNumber(tisb, nHomograph, hc, hv);
            }
            tisb.Append(citationForm);

            // (EricP) Tried to automatically update the homograph number, but doing that here will
            // steal away manual changes to the HomographNumber column. Also suppressing PropChanged
            // is necessary when HomographNumber column is enabled, otherwise changing the entry index can hang.
            //using (new IgnorePropChanged(cache, PropChangedHandling.SuppressView))
            //{
            //	  ValidateExistingHomographs(CollectHomographs(cache, ShortName1StaticForWs(cache, hvo, wsVern), 0, morphType));
            //}

            if (!hc.HomographNumberBefore)
            {
                InsertHomographNumber(tisb, nHomograph, hc, hv);
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// This method will use the current homograph-number settings to insert the homograph number into the string
 /// </summary>
 public static void InsertHomographNumber(ITsIncStrBldr tisb, int nHomograph, HomographConfiguration hc,
                                          HomographConfiguration.HeadwordVariant hv, LcmCache cache)
 {
     if (nHomograph > 0 && hc.ShowHomographNumber(hv))
     {
         tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, HomographConfiguration.ksHomographNumberStyle);
         if (!string.IsNullOrEmpty(hc.WritingSystem))
         {
             tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, cache.WritingSystemFactory.GetWsFromStr(hc.WritingSystem));
         }
         else
         {
             tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, cache.DefaultVernWs);
         }
         var hnString = nHomograph.ToString();
         if (hc.CustomHomographNumbers.Count == 10)
         {
             for (var i = 0; i < 10; ++i)
             {
                 hnString = hnString.Replace(i.ToString(), hc.CustomHomographNumbers[i]);
             }
         }
         tisb.Append(hnString);
         tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
     }
 }
Ejemplo n.º 13
0
        public void GetTextRepresentation_BT_MultiCharStylePara()
        {
            CheckDisposed();
            SetupBackTrans();

            ITsIncStrBldr strBldr = TsIncStrBldrClass.Create();

            strBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_vernWs);

            // run 1
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Emphasis");
            strBldr.Append("Test Text");

            // run 2
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    null);
            strBldr.Append("No char style");

            // run 3
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Quoted Text");
            strBldr.Append("Ahh!!!!!!");

            m_footnotePara.Contents.UnderlyingTsString = strBldr.GetString();

            // Now add back translations with and without character styles.
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsEs, "Spanish", null);
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsEs, m_vernWs, " back ", ScrStyleNames.UntranslatedWord);
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsEs, " translation!", "Emphasis");

            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsDe, "German!", "Emphasis");
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsDe, m_vernWs, " back ", ScrStyleNames.UntranslatedWord);
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsDe, " translation", null);

            string result = m_footnote.GetTextRepresentation();

            Assert.AreEqual(@"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                            @"<RUN WS='fr' CS='Emphasis'>Test Text</RUN><RUN WS='fr'>No char style</RUN>" +
                            "<RUN WS='fr' CS='Quoted Text'>Ahh!!!!!!</RUN>" +
                            "<TRANS WS='es'><RUN WS='es'>Spanish</RUN><RUN WS='fr' CS='Untranslated Word'> back </RUN><RUN WS='es' CS='Emphasis'> translation!</RUN></TRANS>" +
                            "<TRANS WS='de'><RUN WS='de' CS='Emphasis'>German!</RUN><RUN WS='fr' CS='Untranslated Word'> back </RUN><RUN WS='de'> translation</RUN></TRANS>" +
                            "</P></FN>", result);
        }
Ejemplo n.º 14
0
        ITsString CreateFeatureLine(IFsClosedValue value)
        {
            ITsIncStrBldr featLine = TsStringUtils.MakeIncStrBldr();

            featLine.AppendTsString(value.ValueRA != null ? value.ValueRA.Abbreviation.BestAnalysisAlternative : m_questions);
            featLine.Append(" ");
            featLine.AppendTsString(value.FeatureRA != null ? value.FeatureRA.Abbreviation.BestAnalysisAlternative : m_questions);
            return(featLine.GetString());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// This method is called when a user selects Delete Relation on a Lexical Relation slice.
        /// For: Pair relation (eg. Antonym)
        ///     tree relation (parts/whole when deleting a Parts slice)
        /// </summary>
        /// <param name="hvo"></param>
        public void DeleteReference(int hvo)
        {
            CheckDisposed();
            if (hvo <= 0)
            {
                throw new ConfigurationException("Slice:GetObjectHvoForMenusToOperateOn is either messed up or should not have been called, because it could not find the object to be deleted.", m_configurationNode);
            }
            else
            {
                Form mainWindow = (Form)Mediator.PropertyTable.GetValue("window");
                mainWindow.Cursor = Cursors.WaitCursor;
                using (ConfirmDeleteObjectDlg dlg = new ConfirmDeleteObjectDlg())
                {
                    CmObjectUi    ui = CmObjectUi.MakeUi(m_cache, hvo);
                    ILexReference lr = LexReference.CreateFromDBObject(m_cache, hvo);

                    //We need this to determine which kind of relation we are deleting
                    LexRefType lrtOwner =
                        (LexRefType)CmObject.CreateFromDBObject(m_cache, lr.OwnerHVO);

                    int           analWs = m_cache.DefaultAnalWs;
                    int           userWs = m_cache.DefaultUserWs;
                    ITsIncStrBldr tisb   = TsIncStrBldrClass.Create();
                    tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);

                    switch ((LexRefType.MappingTypes)lrtOwner.MappingType)
                    {
                    case LexRefType.MappingTypes.kmtSenseTree:
                    case LexRefType.MappingTypes.kmtEntryTree:
                    case LexRefType.MappingTypes.kmtEntryOrSenseTree:
                        tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);
                        tisb.Append(String.Format(LexEdStrings.ksDeleteLexTree, "\x2028"));
                        dlg.SetDlgInfo(ui, m_cache, Mediator, tisb.GetString());
                        break;

                    default:
                        dlg.SetDlgInfo(ui, m_cache, Mediator);
                        break;
                    }

                    if (DialogResult.Yes == dlg.ShowDialog(mainWindow))
                    {
                        lr.DeleteUnderlyingObject();
                        //Update the display because we have removed this slice from the Lexical entry.
                        UpdateForDelete(hvo);

                        mainWindow.Cursor = Cursors.Default;
                    }
                    else                     //If the user selected Cancel in the delete dialog do nothing
                    {
                        mainWindow.Cursor = Cursors.Default;
                        return;
                    }
                }
            }
        }
Ejemplo n.º 16
0
 private static void InsertHomographNumber(ITsIncStrBldr tisb, int nHomograph, HomographConfiguration hc,
                                           HomographConfiguration.HeadwordVariant hv)
 {
     if (nHomograph > 0 && hc.ShowHomographNumber(hv))
     {
         tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, HomographConfiguration.ksHomographNumberStyle);
         tisb.Append(nHomograph.ToString());
         tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
     }
 }
Ejemplo n.º 17
0
        public void CreateFromStringRep_BT_MultiCharStylePara()
        {
            CheckDisposed();
            SetupBackTrans();

            ITsIncStrBldr strBldr = TsIncStrBldrClass.Create();

            strBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_vernWs);

            // Setup expected results for the footnote
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Emphasis");       // run 1
            strBldr.Append("Test Text");
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);             // run 2
            strBldr.Append("No char style");
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Quoted Text");    // run 3
            strBldr.Append("Ahh!!!!!!");
            m_footnotePara.Contents.UnderlyingTsString = strBldr.GetString();

            // ... and now set up the expected results for the back translations of the footnote.
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsEs, "Spanish", null);
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsEs, m_vernWs, " back ", ScrStyleNames.UntranslatedWord);
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsEs, " translation!", "Emphasis");

            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsDe, "German!", "Emphasis");
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsDe, m_vernWs, " back ", ScrStyleNames.UntranslatedWord);
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsDe, " translation", null);

            // Define text representation and create a footnote from it.
            string footnoteRep = @"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                                 @"<RUN WS='fr' CS='Emphasis'>Test Text</RUN><RUN WS='fr'>No char style</RUN>" +
                                 "<RUN WS='fr' CS='Quoted Text'>Ahh!!!!!!</RUN>" +
                                 "<TRANS WS='es'><RUN WS='es'>Spanish</RUN><RUN WS='fr' CS='Untranslated Word'> back </RUN>" +
                                 "<RUN WS='es' CS='Emphasis'> translation!</RUN></TRANS>" +
                                 "<TRANS WS='de'><RUN WS='de' CS='Emphasis'>German!</RUN>" +
                                 "<RUN WS='fr' CS='Untranslated Word'> back </RUN><RUN WS='de'> translation</RUN></TRANS></P></FN>";

            StFootnote footnote = StFootnote.CreateFromStringRep(m_book,
                                                                 (int)ScrBook.ScrBookTags.kflidFootnotes, footnoteRep, 0, "Note Marker");

            CompareFootnote(footnote);
        }
        public void FullTextSearchTest()
        {
            var searcher = new StringSearcher <int>(SearchType.FullText, m_wsManager);

            searcher.Add(0, 0, m_tsf.MakeString("test", m_enWs));
            searcher.Add(1, 0, m_tsf.MakeString("c'est une phrase", m_frWs));
            ITsIncStrBldr tisb = m_tsf.GetIncBldr();

            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, m_frWs);
            tisb.Append("C'est une sentence. ");
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, m_enWs);
            tisb.Append("We use it for testing purposes.");
            searcher.Add(2, 0, tisb.GetString());
            searcher.Add(3, 0, m_tsf.MakeString("Hello, how are you doing? I am doing fine. That is good to know.", m_enWs));

            CheckSearch(searcher, m_tsf.MakeString("test", m_enWs), new[] { 0, 2 });
            CheckSearch(searcher, m_tsf.MakeString("c'est une", m_frWs), new[] { 1, 2 });
            CheckSearch(searcher, m_tsf.MakeString("t", m_enWs), new[] { 0, 2, 3 });
            CheckSearch(searcher, m_tsf.MakeString("testing purpose", m_enWs), new[] { 2 });
        }
Ejemplo n.º 19
0
        ITsString CreateVariableLine(IPhFeatureConstraint var, bool polarity)
        {
            int varIndex = GetVarIndex(var);

            if (varIndex == -1)
            {
                return(m_questions);
            }

            ITsIncStrBldr varLine = TsIncStrBldrClass.Create();

            if (!polarity)
            {
                varLine.Append("-");
            }
            varLine.AppendTsString(m_cache.MakeUserTss(VARIABLE_NAMES[varIndex]));
            varLine.Append(" ");
            varLine.AppendTsString(var.FeatureRAHvo == 0 ? m_questions : var.FeatureRA.Abbreviation.BestAnalysisAlternative);
            return(varLine.GetString());
        }
Ejemplo n.º 20
0
        public void GetTextRepresentation_charStylePara()
        {
            ITsIncStrBldr strBldr = m_footnotePara.Contents.GetIncBldr();

            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Emphasis");
            strBldr.Append("Test Text");
            m_footnotePara.Contents = strBldr.GetString();
            Assert.AreEqual("<FN><M>a</M><P><PS>Note General Paragraph</PS>" +
                            "<RUN WS='fr' CS='Emphasis'>Test Text</RUN></P></FN>",
                            m_footnote.TextRepresentation);
        }
Ejemplo n.º 21
0
        public void GetTextRepresentation_MultiCharStylePara()
        {
            CheckDisposed();

            ITsIncStrBldr strBldr = TsIncStrBldrClass.Create();

            strBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_vernWs);

            // run 1
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Emphasis");
            strBldr.Append("Test Text");

            // run 2
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    null);
            strBldr.Append("No char style");

            // run 3
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Quoted Text");
            strBldr.Append("Ahh!!!!!!");

            // run 4
            strBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_wsDe);
            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Untranslated Word");
            strBldr.Append(" untranslated");

            m_footnotePara.Contents.UnderlyingTsString = strBldr.GetString();

            string result = m_footnote.GetTextRepresentation();

            Assert.AreEqual(@"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                            @"<RUN WS='fr' CS='Emphasis'>Test Text</RUN><RUN WS='fr'>No char style</RUN>" +
                            "<RUN WS='fr' CS='Quoted Text'>Ahh!!!!!!</RUN>" +
                            "<RUN WS='de' CS='Untranslated Word'> untranslated</RUN></P></FN>", result);
        }
Ejemplo n.º 22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the default value for a cell in the row for new records.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ITsString GetDefaultNewRowValue(int rowIndex)
        {
            int ws = GetWritingSystemHandle(rowIndex);

            if (ws <= 0)
            {
                ITsIncStrBldr strBldr = TsStringUtils.MakeIncStrBldr();
                strBldr.Append(string.Empty);
                return(strBldr.GetString());
            }

            return(TsStringUtils.EmptyString(ws));
        }
Ejemplo n.º 23
0
        public void CountTest()
        {
            // Start with expected information.
            Assert.AreEqual(2, Cache.LangProject.Description.StringCount, "Wrong number of alternatives for Cache.LangProject.DescriptionAccessor");

            // Create a good string.
            CoreWritingSystemDefinition german = Cache.ServiceLocator.WritingSystemManager.Get("de");

            ITsIncStrBldr tisb = TsStringUtils.MakeIncStrBldr();

            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, german.Handle);
            tisb.Append("Deutchland");
            Cache.LangProject.Description.set_String(german.Handle, tisb.GetString());
            //// Make sure it is in there now.
            Assert.AreEqual(3, Cache.LangProject.Description.StringCount, "Wrong number of alternatives for Cache.LangProject.DescriptionAccessor");

            //// Add the same ws string, but with different text.
            tisb = TsStringUtils.MakeIncStrBldr();
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, german.Handle);
            tisb.Append("heilige");
            Cache.LangProject.Description.set_String(german.Handle, tisb.GetString());
            //// Make sure it is in there now.
            Assert.AreEqual(3, Cache.LangProject.Description.StringCount, "Wrong number of alternatives for Cache.LangProject.DescriptionAccessor");
        }
Ejemplo n.º 24
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the default value for a cell in the row for new records.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ITsString GetDefaultNewRowValue(int rowIndex)
        {
            int ws = GetWritingSystemHandle(rowIndex);

            if (ws <= 0)
            {
                ITsIncStrBldr strBldr = TsIncStrBldrClass.Create();
                strBldr.Append(string.Empty);
                return(strBldr.GetString());
            }

            ITsStrFactory tsf = TsStrFactoryClass.Create();

            return(tsf.MakeString(string.Empty, ws));
        }
Ejemplo n.º 25
0
        public ITsString CreateFeatureLine(ITsString name, ITsString value, bool negated)
        {
            ITsIncStrBldr featLine = TsIncStrBldrClass.Create();

            featLine.AppendTsString(name);
            featLine.Append(": ");
            if (value != null)
            {
                if (negated)
                {
                    featLine.AppendTsString(m_tsf.MakeString("!", m_cache.DefaultUserWs));
                }
                featLine.AppendTsString(value);
            }
            return(featLine.GetString());
        }
Ejemplo n.º 26
0
        private static void AddHeadwordForWsAndHn(ILexEntry entry, int wsVern, int nHomograph, HomographConfiguration.HeadwordVariant hv,
                                                  ITsIncStrBldr tisb, string citationForm, LcmCache cache)
        {
            var hc = entry.Services.GetInstance <HomographConfiguration>();

            if (hc.HomographNumberBefore)
            {
                InsertHomographNumber(tisb, nHomograph, hc, hv, cache);
            }
            tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsVern);
            tisb.Append(citationForm);

            if (!hc.HomographNumberBefore)
            {
                InsertHomographNumber(tisb, nHomograph, hc, hv, cache);
            }
        }
Ejemplo n.º 27
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Display the footnote marker
        /// </summary>
        /// <param name="vwenv">View environment</param>
        /// ------------------------------------------------------------------------------------
        private void DisplayFootnoteMarker(IVwEnv vwenv)
        {
            // The footnote marker is not editable.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptNotEditable);
            vwenv.AddStringProp((int)StFootnote.StFootnoteTags.kflidFootnoteMarker, null);

            // add a read-only space after the footnote marker
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  (int)TptEditable.ktptNotEditable);
            ITsIncStrBldr strBldr = TsIncStrBldrClass.Create();

            strBldr.Append(" ");
            vwenv.AddString(strBldr.GetString());
        }
Ejemplo n.º 28
0
        public void GetTextRepresentation_charStylePara()
        {
            CheckDisposed();

            ITsIncStrBldr strBldr = TsIncStrBldrClass.Create();

            strBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                    "Emphasis");
            strBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_vernWs);
            strBldr.Append("Test Text");
            m_footnotePara.Contents.UnderlyingTsString = strBldr.GetString();
            string result = m_footnote.GetTextRepresentation();

            Assert.AreEqual(@"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                            "<RUN WS='fr' CS='Emphasis'>Test Text</RUN></P></FN>", result);
        }
Ejemplo n.º 29
0
        public ResolveKeyTermRenderingImportConflictDlg(IWin32Window owner, IChkRef occurrence,
                                                        string existingRendering, string importedRendering, IVwStylesheet ss) : this()
        {
            FdoCache     cache  = occurrence.Cache;
            IScripture   scr    = cache.LangProject.TranslatedScriptureOA;
            ScrReference scrRef = (new ScrReference(occurrence.Ref, scr.Versification));

            m_owner                = owner;
            m_lblAnalysis.Text     = occurrence.OwnerOfClass <IChkTerm>().Name.AnalysisDefaultWritingSystem.Text;
            m_lblOriginal.Text     = occurrence.KeyWord.Text;
            m_lblScrReference.Text = scrRef.ToString();
            m_btnExisting.Text     = String.Format(m_btnExisting.Text, existingRendering);
            m_btnImported.Text     = String.Format(m_btnImported.Text, importedRendering);

            // We do this outside the designer-controlled code because it does funny things
            // to FwMultiParaTextBox, owing to the need for a writing system factory, and some
            // properties it should not persist but I can't persuade it not to.
//			IStText text = new NonEditableMultiTss(TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef).ToString(true, " "));
            //m_verseTextLabel = new FwMultiParaTextBox(text, ss);
            m_verseTextLabel = new FwLabel();
            m_verseTextLabel.WritingSystemFactory = cache.WritingSystemFactory; // set ASAP.
            m_verseTextLabel.WritingSystemCode    = cache.DefaultVernWs;
            m_verseTextLabel.StyleSheet           = ss;                         // before setting text, otherwise it gets confused about height needed.
            m_verseTextLabel.Location             = new Point(0, 0);
            m_verseTextLabel.Name      = "m_textBox";
            m_verseTextLabel.Dock      = DockStyle.Fill;
            m_verseTextLabel.TabIndex  = 0;
            m_verseTextLabel.TextAlign = ContentAlignment.TopLeft;
            //m_verseTextLabel.BorderStyle = BorderStyle.None;
            //m_textBox.SuppressEnter = true;
            m_pnlActualVerseText.Controls.Add(m_verseTextLabel);
            // ENHANCE: Figure out how to get each part (paragraph) of the verse onm its own line. Using newlines or hard line breaks doesn't work.
            ITsIncStrBldr bldr = TsIncStrBldrClass.Create();

            foreach (TeEditingHelper.VerseTextSubstring verseTextSubstring in TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef))
            {
                bldr.AppendTsString(verseTextSubstring.Tss);
                bldr.Append(StringUtils.kChHardLB.ToString());
            }
            m_verseTextLabel.Tss = bldr.GetString();
            //m_verseTextLabel.Tss = TeEditingHelper.GetVerseText(cache.LangProject.TranslatedScriptureOA, scrRef).ToString(true, StringUtils.kChHardLB.ToString());
        }
Ejemplo n.º 30
0
        ITsString CreateVariableLine(IPhFeatureConstraint var, bool polarity)
        {
            int varIndex = GetVarIndex(var);

            if (varIndex == -1)
            {
                return(m_questions);
            }

            ITsIncStrBldr varLine = TsStringUtils.MakeIncStrBldr();

            if (!polarity)
            {
                varLine.AppendTsString(TsStringUtils.MakeString("-", m_cache.DefaultUserWs));
            }
            varLine.AppendTsString(TsStringUtils.MakeString(VariableNames[varIndex], m_cache.DefaultUserWs));
            varLine.Append(" ");
            varLine.AppendTsString(var.FeatureRA == null ? m_questions : var.FeatureRA.Abbreviation.BestAnalysisAlternative);
            return(varLine.GetString());
        }
Ejemplo n.º 31
0
		private void ProcessRunElement(XmlNode runNode, ITsIncStrBldr tisb)
		{
			/*
(From DTD, as of 9/18/2006)
<!ELEMENT Run (#PCDATA)>
<!ATTLIST Run
	type (chars | picture) #IMPLIED
	ownlink CDATA #IMPLIED
	contextString CDATA #IMPLIED
	backcolor CDATA #IMPLIED
	bold (invert | off | on) #IMPLIED
	ws CDATA #REQUIRED
	wsBase CDATA #IMPLIED
	externalLink CDATA #IMPLIED
	fontFamily CDATA #IMPLIED
	fontsize CDATA #IMPLIED
	fontsizeUnit CDATA #IMPLIED
	forecolor CDATA #IMPLIED
	italic (invert | off | on) #IMPLIED
	link CDATA #IMPLIED
	namedStyle CDATA #IMPLIED
	offset CDATA #IMPLIED
	offsetUnit CDATA #IMPLIED
	superscript (sub | super) #IMPLIED
	tabList CDATA #IMPLIED
	tags IDREFS #IMPLIED
	undercolor CDATA #IMPLIED
	underline (dashed | dotted | double | none | single | squiggle | strikethrough) #IMPLIED
>
Stephen McCon...	The relevant source file is FwXmlString.cpp in {FW}/Src/Cellar.  Unfortunately, this area is somewhat of a mess.
Stephen McCon...	The attr list is probably found in FwDatabase.dtd, without explanation.
Randy Regnier		If I understand it right, the various attrs will control some properties for the ts string, such as ws, bold, etc, right?
Stephen McCon...	that's correct.
Stephen McCon...	You could look at FwXmlImportData::ProcessStringStartTag(const XML_Char *, const XML_Char **) in FwXmlString.cpp to see how the attributes are scanned and stored when reading in a string in the various C++ XML parsers.
Stephen McCon...	(Of course, that calls all sorts of other methods to do the work, which you may have to look at as well)
			*/
			// Process all of the properties, before adding the string (says JohnT, personal communication).
			foreach (XmlAttribute attr in runNode.Attributes)
			{
				switch (attr.Name)
				{
					case "ws":
						// ws CDATA #REQUIRED
						tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsCache[attr.Value]);
						break;
					case "type":
						// type (chars | picture) #IMPLIED
						// <Run ws=\"en\"
						break;
					case "ownlink":
						// ownlink CDATA #IMPLIED
						// <Run ws=\"xkal\" ownlink=\"993DA544-3B38-4AB0-BFDE-9AF884571A2D\"></Run>
						break;
					case "contextString":
						// contextString CDATA #IMPLIED
						// <Run ws=\"en\" contextString=\"85EE15C6-0799-46C6-8769-F9B3CE313AE2\"></Run>
						break;
					case "backcolor":
						// backcolor CDATA #IMPLIED
						break;
					case "bold":
						// bold (invert | off | on) #IMPLIED
						break;
					case "wsBase":
						// wsBase CDATA #IMPLIED
						break;
					case "externalLink":
						// externalLink CDATA #IMPLIED
						break;
					case "fontFamily":
						// fontFamily CDATA #IMPLIED
						// <Run ws=\"en\" fontsize=\"16000\" forecolor=\"blue\" fontFamily=\"SILDoulos PigLatinDemo\">Welcome to WorldPad!</Run>
						break;
					case "fontsize":
						// fontsize CDATA #IMPLIED
						break;
					case "fontsizeUnit":
						// fontsizeUnit CDATA #IMPLIED
						break;
					case "forecolor":
						// forecolor CDATA #IMPLIED
						// <Run ws=\"en\" fontsize=\"20000\" forecolor=\"red\">French IPA: </Run>
						// <Run ws=\"xsta\" fontsize=\"20000\" forecolor=\"007f00\">We</Run>
						break;
					case "italic":
						// italic (invert | off | on) #IMPLIED
						// <Run ws=\"en\" italic=\"on\">man</Run>
						break;
					case "link":
						// link CDATA #IMPLIED
						// <Run ws=\"en\" link=\"6EBC80F8-9CE0-45D9-BB49-3869591FB1FF\"></Run>
						break;
					case "namedStyle":
						// <Run ws=\"en\" namedStyle=\"Emphasized Text\">pirana</Run>
						break;
					case "offset":
						// offset CDATA #IMPLIED
						break;
					case "offsetUnit":
						// offsetUnit CDATA #IMPLIED
						break;
					case "superscript":
						// superscript (sub | super) #IMPLIED
						break;
					case "tabList":
						// tabList CDATA #IMPLIED
						break;
					case "tags":
						// tags IDREFS #IMPLIED
						// <Run ws=\"en\" tags=\"I2BDD0E8D-F9B2-11D3-977B-00C04F186933\">Tiga</Run>
						break;
					case "undercolor":
						// undercolor CDATA #IMPLIED
						break;
					case "underline":
						// underline (dashed | dotted | double | none | single | squiggle | strikethrough) #IMPLIED
						break;
					default:
						// Unrecognized attr, so do nothing.
						Debug.WriteLine(String.Format("Unrecognized <Run> element attribute: {0}", attr.Name));
						break;
				}
			}
			tisb.Append(runNode.InnerText);
		}
Ejemplo n.º 32
0
			/// <summary>
			/// Store this segment's worth of data in the overall builder.
			/// </summary>
			private void StoreClipboardSegment(ITsIncStrBldr tisbClipBoard)
			{
				for (int i = 0; i < m_rgtsbLines.Length; ++i)
				{
					// Trim the final trailing tab on the line since it's not needed.
					int cch = m_rgtsbLines[i].Length;
					if (cch > 0 && m_rgtsbLines[i].Text.LastIndexOf('\t') == cch - 1)
						m_rgtsbLines[i].ReplaceTsString(cch - 1, cch, null);
					tisbClipBoard.AppendTsString(m_rgtsbLines[i].GetString());
					m_rgtsbLines[i].Clear();
					tisbClipBoard.Append(Environment.NewLine);
				}
				tisbClipBoard.Append(Environment.NewLine);
			}
Ejemplo n.º 33
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="captionText">The BT caption text (can be null).</param>
		/// <param name="sCopyright">The BT copyright text (can be null).</param>
		/// <param name="ws">The writing system of the BT.</param>
		/// <param name="filename">The name of the file being imported.</param>
		/// <param name="lineNumber">The line number of the first BT segment encountered for
		/// this picture.</param>
		/// <param name="segment">The first BT segment encountered for this picture.</param>
		/// <param name="reference">The Scripture reference.</param>
		/// ------------------------------------------------------------------------------------
		public BTPictureInfo(string captionText, string sCopyright, int ws, string filename,
			int lineNumber, string segment, BCVRef reference)
		{
			m_strbldrCaption = TsIncStrBldrClass.Create();
			m_strbldrCaption.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, ws);
			if (!String.IsNullOrEmpty(captionText))
				m_strbldrCaption.Append(captionText);
			m_copyright = sCopyright;
			m_ws = ws;
			m_filename = filename;
			m_lineNumber = lineNumber;
			m_segment = segment;
			m_ref = new BCVRef(reference);
		}
Ejemplo n.º 34
0
		private void AddChooserName(ITsIncStrBldr tisb)
		{
			var analWs = Cache.DefaultAnalWs;
			var pos = PartOfSpeechRA;
			tisb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, analWs);
			if (pos != null)
				tisb.Append(pos.Abbreviation.AnalysisDefaultWritingSystem.Text);
			else
				tisb.Append(Strings.ksQuestions);
		}
Ejemplo n.º 35
0
		private static void AddHeadwordForWsAndHn(ILexEntry entry, int wsVern, int nHomograph,
			HomographConfiguration.HeadwordVariant hv, ITsIncStrBldr tisb, string citationForm)
		{
			tisb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsVern);
			var hc = entry.Services.GetInstance<HomographConfiguration>();
			if (hc.HomographNumberBefore)
				InsertHomographNumber(tisb, nHomograph, hc, hv);
			tisb.Append(citationForm);

			// (EricP) Tried to automatically update the homograph number, but doing that here will
			// steal away manual changes to the HomographNumber column. Also suppressing PropChanged
			// is necessary when HomographNumber column is enabled, otherwise changing the entry index can hang.
			//using (new IgnorePropChanged(cache, PropChangedHandling.SuppressView))
			//{
			//	  ValidateExistingHomographs(CollectHomographs(cache, ShortName1StaticForWs(cache, hvo, wsVern), 0, morphType));
			//}

			if (!hc.HomographNumberBefore)
				InsertHomographNumber(tisb, nHomograph, hc, hv);
		}
Ejemplo n.º 36
0
		/// <summary>
		/// Append to the string builder text equivalent to CitationFormWithAffixTypeStatic, but
		/// with the correct writing systems.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="hvo"></param>
		/// <param name="tsb"></param>
		public static void CitationFormWithAffixTypeTss(FdoCache cache, int hvo, ITsIncStrBldr tsb)
		{
			ISilDataAccess sda = cache.MainCacheAccessor;
			int hvoType = 0;
			int hvoLexForm = sda.get_ObjectProp(hvo, (int)LexEntry.LexEntryTags.kflidLexemeForm);
			if (hvoLexForm != 0)
			{
				hvoType = sda.get_ObjectProp(hvoLexForm, (int)MoForm.MoFormTags.kflidMorphType);
			}
			else
			{
				// No type info...return simpler version of name.
				ShortName1Static(cache, hvo, tsb);
				return;
			}
			string prefix = string.Empty;
			string postfix = string.Empty;
			if (hvoType > 0) // It may be null.
			{
				prefix = sda.get_UnicodeProp(hvoType, (int)MoMorphType.MoMorphTypeTags.kflidPrefix);
				postfix = sda.get_UnicodeProp(hvoType, (int)MoMorphType.MoMorphTypeTags.kflidPostfix);
			}
			// The following code for setting Ws and FontFamily are to fix LT-6238.
			if (!String.IsNullOrEmpty(prefix))
			{
				tsb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, cache.DefaultVernWs);
				tsb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Doulos SIL");
				tsb.Append(prefix);
			}
			ShortName1Static(cache, hvo, tsb);
			if (!String.IsNullOrEmpty(postfix))
			{
				tsb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, cache.DefaultVernWs);
				tsb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Doulos SIL");
				tsb.Append(postfix);
			}
		}
Ejemplo n.º 37
0
		private static void InsertHomographNumber(ITsIncStrBldr tisb, int nHomograph, HomographConfiguration hc,
			HomographConfiguration.HeadwordVariant hv)
		{
			if (nHomograph > 0 && hc.ShowHomographNumber(hv))
			{
				tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, HomographConfiguration.ksHomographNumberStyle);
				tisb.Append(nHomograph.ToString());
				tisb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
			}
		}