Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the sequence of selected possibilities
        /// </summary>
        /// <param name="listToUpdate">Sequence of possibilities. All possibilities that may be in
        /// this list get deleted and the new ones added.</param>
        /// <returns>True if the sequence was changed, false otherwise</returns>
        /// ------------------------------------------------------------------------------------
        public bool GetPossibilities(FdoReferenceSequence <ICmPossibility> listToUpdate)
        {
            CheckDisposed();

            Debug.Assert(listToUpdate != null);
            int[] origHvos = listToUpdate.HvoArray;

            // Clear the list first. Don't use RemoveAll in case the action needs
            // to be undone. RemoveAll dosesn't allow undo.
            while (listToUpdate.Count > 0)
            {
                listToUpdate.RemoveAt(0);
            }

            List <int> newHvos = tvPossibilities.SelectedHvos;
            bool       fSame   = (origHvos.Length == newHvos.Count);

            for (int i = 0; i < newHvos.Count; i++)
            {
                listToUpdate.Append(newHvos[i]);
                if (fSame && origHvos[i] != newHvos[i])
                {
                    fSame = false;
                }
            }

            return(fSame);
        }
        /// <summary>
        /// If a reference is removed from the ComponentLexeme list, it must also be removed
        /// from the PrimaryLexeme list (if it exists there as well).
        /// </summary>
        /// <param name="hvo"></param>
        /// <param name="tag"></param>
        /// <param name="ivMin"></param>
        /// <param name="cvIns"></param>
        /// <param name="cvDel"></param>
        public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
        {
            if (hvo != m_obj.Hvo ||
                m_obj.ClassID != LexEntryRef.kclsidLexEntryRef ||
                tag != (int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes)
            {
                return;
            }
            ILexEntryRef ler = m_obj as ILexEntryRef;
            FdoReferenceSequence <ICmObject> rgobjComponent = ler.ComponentLexemesRS;

            if (cvDel > cvIns)
            {
                int[] rghvoPrimary = ler.PrimaryLexemesRS.HvoArray;
                for (int i = 0; i < rghvoPrimary.Length; ++i)
                {
                    if (!rgobjComponent.Contains(rghvoPrimary[i]))
                    {
                        ler.PrimaryLexemesRS.Remove(rghvoPrimary[i]);
                    }
                }
            }
            else if (cvIns > cvDel && ler.ComponentLexemesRS.Count == 1 && ler.PrimaryLexemesRS.Count == 0)
            {
                ler.PrimaryLexemesRS.Append(ler.ComponentLexemesRS[0]);
            }
        }
Example #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Writes this category to the the specified annotation, creating a new category if
        /// needed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        internal void WriteToCache(IScrScriptureNote ann)
        {
            int ws = (string.IsNullOrEmpty(IcuLocale) ? ann.Cache.DefaultAnalWs :
                      ScrNoteImportManager.GetWsForLocale(IcuLocale));

            int hvo;

            if (CategoryPath.IndexOf(StringUtils.kchObject) != -1)
            {
                // The category specified the full path of the category possibility.
                hvo = ann.Cache.LangProject.TranslatedScriptureOA.NoteCategoriesOA.FindOrCreatePossibility(
                    CategoryPath, ws);
            }
            else
            {
                // The category does not contain a delimiter, so we may need to search
                // the entire possibility tree for a matching category in case it is a
                // sub-possibility.
                hvo = ann.Cache.LangProject.TranslatedScriptureOA.NoteCategoriesOA.FindOrCreatePossibility(
                    CategoryPath, ws, false);
            }

            FdoReferenceSequence <ICmPossibility> categoryList = ann.CategoriesRS;

            if (!categoryList.Contains(hvo))
            {
                categoryList.Append(hvo);
            }
        }
Example #4
0
 private void AddWritingSystemList(UIListDisplayProperties display,
                                   FdoReferenceSequence <ILgWritingSystem> list)
 {
     foreach (ILgWritingSystem ws in list)
     {
         display.List.Add(ws.ShortName, ws.Hvo.ToString(), null, null);
     }
 }
        IPhFeatureConstraint RemoveFeatureConstraint(FdoReferenceSequence <IPhFeatureConstraint> featConstrs, int hvoClosedFeature)
        {
            IPhFeatureConstraint constrToRemove = GetFeatureConstraint(featConstrs.HvoArray, hvoClosedFeature);

            if (constrToRemove != null)
            {
                featConstrs.Remove(constrToRemove);
            }
            return(constrToRemove);
        }
Example #6
0
		public void MultilingualStringBasedonStringDictionary()
		{
			FdoReferenceSequence<LgWritingSystem> systems = Cache.LangProject.CurVernWssRS;
			LexDb ld = Cache.LangProject.LexDbOA;
			LexEntry le = MakeLexEntry("xyzTest1", "xyzDefn1.1", null);
			MoForm m = MoForm.MakeMorph(le, "-is");
			// It will already have the right form.
			//m.FormAccessor.set_String(systems[1].Hvo, Cache.TsStrFactory.MakeString("iz", systems[1].Hvo));

			string t = "<entry><objAtomic objProperty='LexemeFormOA'/></entry>";
			string c = "<class name='MoForm'><multilingualStringElement name='form' simpleProperty='NamesWithMarkers'/></class>";
			string result = GetResultStringFromEntry(le, t, c);

			Assert.AreEqual(String.Format("<entry><form ws=\"fr\">-is</form>{0}<form ws=\"ur\">-iz</form>{0}</entry>", Environment.NewLine), result.Trim());
		}
Example #7
0
        public void MultilingualStringBasedonStringDictionary()
        {
            FdoReferenceSequence <ILgWritingSystem> systems = Cache.LangProject.CurVernWssRS;
            ILexDb    ld = Cache.LangProject.LexDbOA;
            ILexEntry le = MakeLexEntry(ld, "xyzTest1", "xyzDefn1.1", 0);
            IMoForm   m  = MoForm.MakeMorph(Cache, le, "-is");

            m.Form.SetAlternative("iz", systems[1].Hvo);

            string t      = "<entry><objAtomic objProperty='LexemeFormOA'/></entry>";
            string c      = "<class name='MoForm'><multilingualStringElement name='form' simpleProperty='NamesWithMarkers'/></class>";
            string result = GetResultStringFromEntry(le, t, c);

            Assert.AreEqual("<entry><form ws=\"fr\">-is</form>\r\n<form ws=\"ur\">-iz</form>\r\n</entry>", result.Trim());
        }
Example #8
0
		private void AddWritingSystemList(UIListDisplayProperties display,
			FdoReferenceSequence<ILgWritingSystem> list)
		{
			foreach (ILgWritingSystem ws in list)
			{
				display.List.Add(ws.ShortName, ws.Hvo.ToString(), null, null);
			}
		}
		/// <summary>
		/// gets a list of ws hvos, starting with the current wss, followed by remaining (non-current) active ones
		/// </summary>
		/// <param name="currentWss"></param>
		/// <param name="activeWss"></param>
		/// <param name="fAddOnlyCurrent">if true, only add the current wss, ignoring remaining active wss.</param>
		/// <returns></returns>
		internal static List<int> GetCurrentThenRemainingActiveWss(FdoReferenceSequence<ILgWritingSystem> currentWss,
			FdoReferenceCollection<ILgWritingSystem> activeWss, bool fAddOnlyCurrent)
		{
			List<int> hvoWss = new List<int>();
			// Add ordered (checked) writing system names to the list.
			foreach (ILgWritingSystem ws in currentWss)
				hvoWss.Add(ws.Hvo);
			if (fAddOnlyCurrent)
				return hvoWss;	// finished adding current wss, so return;
			// Now add the unchecked (or not current) writing systems to the list.
			foreach (ILgWritingSystem ws in activeWss)
			{
				if (!hvoWss.Contains(ws.Hvo))
					hvoWss.Add(ws.Hvo);
			}
			return hvoWss;
		}
Example #10
0
		private void FixSlots(Dictionary<int, int> slots, FdoReferenceSequence<IMoInflAffixSlot> slotList)
		{
			for (int i = 0; i < slotList.Count; i++)
			{
				IMoInflAffixSlot slot = slotList[i];
				int slotHvo = slot.Hvo;
				int hvoRep = 0;
				if (slots.ContainsKey(slotHvo))
				{
					hvoRep = slots[slotHvo];
				}
				else
				{
					// The slot is fine if it is owned by this or one of the owners of this.
					int hvoOwner = m_cache.GetOwnerOfObject(slotHvo);
					int hvoAllowedOwner = this.Hvo;
					while (hvoAllowedOwner != 0 && hvoOwner != hvoAllowedOwner)
						hvoAllowedOwner = m_cache.GetOwnerOfObject(hvoAllowedOwner);
					if (hvoAllowedOwner == 0)
					{
						// Need to copy slot!
						// This works the first time, but is not redoable.
						//hvoRep = m_cache.CopyObject(slot.Hvo, this.Hvo, (int)PartOfSpeech.PartOfSpeechTags.kflidAffixSlots);
						IMoInflAffixSlot newSlot = AffixSlotsOC.Add(new MoInflAffixSlot());
						hvoRep = newSlot.Hvo;
						newSlot.Description.CopyAlternatives(slot.Description);
						newSlot.Name.CopyAlternatives(slot.Name);
						newSlot.Optional = slot.Optional;
						// And any existing MSAs in the slot should be copied too...these are
						// incoming references, so CopyObject doesn't deal with them.
						string sql = string.Format("select src from MoInflAffMsa_Slots where dst={0}",
							slotHvo);
						foreach (int hvoMsa in DbOps.ReadIntArrayFromCommand(m_cache, sql, null))
						{
							IMoInflAffMsa msa = MoInflAffMsa.CreateFromDBObject(m_cache, hvoMsa);
							msa.SlotsRC.Add(hvoRep);
						}
					}
					else
					{
						hvoRep = slotHvo;
					}
					slots[slotHvo] = hvoRep;
				}
				if (hvoRep != slotHvo)
				{
					slotList.RemoveAt(i);
					slotList.InsertAt(hvoRep, i);
				}
			}
		}
Example #11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the sequence of selected possibilities
		/// </summary>
		/// <param name="listToUpdate">Sequence of possibilities. All possibilities that may be in
		/// this list get deleted and the new ones added.</param>
		/// <returns>True if the sequence was changed, false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		public bool GetPossibilities(FdoReferenceSequence<ICmPossibility> listToUpdate)
		{
			CheckDisposed();

			Debug.Assert(listToUpdate != null);
			int[] origHvos = listToUpdate.HvoArray;

			// Clear the list first. Don't use RemoveAll in case the action needs
			// to be undone. RemoveAll dosesn't allow undo.
			while (listToUpdate.Count > 0)
				listToUpdate.RemoveAt(0);

			List<int> newHvos = tvPossibilities.SelectedHvos;
			bool fSame = (origHvos.Length == newHvos.Count);

			for (int i = 0; i < newHvos.Count; i++)
			{
				listToUpdate.Append(newHvos[i]);
				if (fSame && origHvos[i] != newHvos[i])
					fSame = false;
			}

			return fSame;
		}
Example #12
0
		public ReferenceSequenceUi(FdoCache cache, ICmObject rootObj, int referenceFlid, int targetHvo)
			: base(cache, rootObj, referenceFlid, targetHvo)
		{
			Debug.Assert(m_iType == FieldType.kcptReferenceSequence);
			m_fdoRS = new FdoReferenceSequence<ICmObject>(m_cache, m_hvo, m_flid);
			m_iCurrent = ComputeTargetVectorIndex();
		}
		private void GetAffixSequenceContainingHvo(int hvo, out FdoReferenceSequence<IMoInflAffixSlot> seq, out int index)
		{
			List<int> listHvos = new List<int>(m_template.PrefixSlotsRS.HvoArray);
			index = listHvos.IndexOf(hvo);
			if (index >= 0)
			{
				seq = m_template.PrefixSlotsRS;
			}
			else
			{
				listHvos = new List<int>(m_template.SuffixSlotsRS.HvoArray);
				index = listHvos.IndexOf(hvo);
				if (index >= 0)
					seq = m_template.SuffixSlotsRS;
				else
					seq = null;
			}
		}
		IPhFeatureConstraint RemoveFeatureConstraint(FdoReferenceSequence<IPhFeatureConstraint> featConstrs, int hvoClosedFeature)
		{
			IPhFeatureConstraint constrToRemove = GetFeatureConstraint(featConstrs.HvoArray, hvoClosedFeature);
			if (constrToRemove != null)
				featConstrs.Remove(constrToRemove);
			return constrToRemove;
		}