Example #1
0
		private void MergeAnalysisString(MultiUnicodeAccessor fwString, string wsString)
		{
			if(wsString.Length >0)
				fwString.AnalysisDefaultWritingSystem = wsString;

			//MultiStringAccessor a = new MultiStringAccessor(_cache, 0, 0, null);
			//existing.LexemeFormOA.Form.MergeAlternatives();
		}
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Save information about default analysis and vernacular writing systems for fast
		/// access. This method is called when an existing Language Project is initialized. It
		/// should also be called explicitly whenever an app changes to a different default
		/// writing systems or changes the name or ICU locale of one of the existing default
		/// writing systems.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void CacheDefaultWritingSystems()
		{
			// Preload writing systems
			CmObject.LoadObjectsIntoCache(m_cache, typeof(LgWritingSystem), null,
				LgWritingSystem.kClassId);

			if (CurAnalysisWssRS == null ||
				CurAnalysisWssRS.HvoArray.Length == 0 ||
				CurVernWssRS == null ||
				CurVernWssRS.HvoArray.Length == 0)
			{
				// The database must be in the early stages of being created because it still
				// doesn't have these writing systems set. So sad!
				return;
			}

			m_iDefaultAnalysisWritingSystem = CurAnalysisWssRS.HvoArray[0];
			//new LgWritingSystem(m_cache, CurAnalysisWssRS.HvoArray[0]).Code;

			m_sDefaultAnalysisWritingSystemICULocale =
				new LgWritingSystem(m_cache, CurAnalysisWssRS.HvoArray[0]).ICULocale;

			m_DefaultAnalysisWritingSystemName =
				new LgWritingSystem(m_cache, CurAnalysisWssRS.HvoArray[0]).Name;

			m_iDefaultVernacularWritingSystem = CurVernWssRS.HvoArray[0];
			//new LgWritingSystem(m_cache, CurVernWssRS.HvoArray[0]).Code;

			m_sDefaultVernacularWritingSystemICULocale =
				new LgWritingSystem(m_cache, CurVernWssRS.HvoArray[0]).ICULocale;

			m_DefaultVernacularWritingSystemName =
				new LgWritingSystem(m_cache, CurVernWssRS.HvoArray[0]).Name;

			m_iDefaultUserWritingSystem = m_cache.DefaultUserWs;

			m_DefaultUserWritingSystemName =
				new LgWritingSystem(m_cache, m_iDefaultUserWritingSystem).Name;

			m_sDefaultUserWritingSystemICULocale =
				new LgWritingSystem(m_cache, m_iDefaultUserWritingSystem).ICULocale;
		}
Example #3
0
		private void MergeVernacularString (MultiUnicodeAccessor fwString, string wsString)
		{
			if (wsString.Length > 0)
				fwString.VernacularDefaultWritingSystem = wsString;

		}
Example #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copy one mua over another.
		/// </summary>
		/// <param name="source">The source.</param>
		/// ------------------------------------------------------------------------------------
		public void CopyAlternatives(MultiUnicodeAccessor source)
		{
			CopyAlternatives(source, false);
		}
Example #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copy one mua over another.
		/// </summary>
		/// <param name="source">The source.</param>
		/// <param name="skipIfExist">True to only copy values that aren't present, false to
		/// overwrite all values that were present</param>
		/// ------------------------------------------------------------------------------------
		public void CopyAlternatives(MultiUnicodeAccessor source, bool skipIfExist)
		{
			if (source == null)
				return; // Nothing to do.

			foreach (LgWritingSystem lws in m_cache.LanguageEncodings)
			{
				int ws = lws.Hvo;
				bool overWrite = true;
				if (skipIfExist)
				{
					ITsString tss = GetAlternativeTss(ws);
					overWrite = (tss == null || tss.Length == 0);
				}

				if (overWrite)
				{
					ITsString srcAlt = source.GetAlternativeTss(ws);
					if (srcAlt != null && srcAlt.Length != 0)
						m_cache.SetMultiStringAlt(m_hvoOwner, m_flidOwning, ws, srcAlt);
				}
			}
		}
Example #6
0
		/// <summary>
		/// Default uses space to separate.
		/// </summary>
		public void MergeAlternatives(MultiUnicodeAccessor source, bool fConcatenateIfBoth)
		{
			MergeAlternatives(source, fConcatenateIfBoth, " ");
		}
Example #7
0
		/// <summary>
		/// Merge two MultiUnicodeAccessor objects.
		/// These cases are handled:
		///		1. If an alternative exists in both objects, nothing is merged if fConcatenateIfBoth is false.
		///		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(MultiUnicodeAccessor source, bool fConcatenateIfBoth, string sep)
		{
			if (source == null)
				return; // Nothing to do.

			foreach (LgWritingSystem lws in m_cache.LanguageEncodings)
			{
				int ws = lws.Hvo;
				string myAlt = GetAlternative(ws);
				string srcAlt = source.GetAlternative(ws);
				if ((myAlt == null || myAlt == String.Empty)
					&& (srcAlt != null && srcAlt != String.Empty))
				{
					SetAlternative(srcAlt, ws);
				}
				else if (!fConcatenateIfBoth)
				{
					continue;
				}
				else if (myAlt != null && myAlt != String.Empty
					&& srcAlt != null && srcAlt != String.Empty
					&& GetAlternative(ws) != source.GetAlternative(ws))
				{
					SetAlternative(GetAlternative(ws) + sep + source.GetAlternative(ws), ws);
				}
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set string values for the given property for each writing system represented in the
		/// nodelist
		/// </summary>
		/// <param name="multiUnicodeproperty">A MultiUnicodeAccessor representing the property
		/// whose value is to be set</param>
		/// <param name="nodes">An XmlNodeList with the strings in one or more writing systems
		/// </param>
		/// ------------------------------------------------------------------------------------
		private void SetMultiUnicodeAlternatives(MultiUnicodeAccessor multiUnicodeproperty,
			XmlNodeList nodes)
		{
			foreach (XmlNode node in nodes)
			{
				int ws = GetWs(node.Attributes);
				string alternative = node.InnerText;
				if (ws > 0 && alternative != null && alternative != string.Empty)
					multiUnicodeproperty.SetAlternative(alternative, ws);
				// REVIEW: What should we do when the writing system is not defined in the database?
			}
		}
Example #9
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>
		public void MergeAlternatives(MultiUnicodeAccessor source)
		{
			MergeAlternatives(source, false);
		}
Example #10
0
		private object GetCustomFieldValue(CmObject target, string property)
		{
			try
			{
				string sClass = m_cache.MetaDataCacheAccessor.GetClassName((uint)target.ClassID);
				uint flid = m_cache.MetaDataCacheAccessor.GetFieldId(sClass, property, true);
				if (flid == 0)
					return null;
				int type = m_cache.MetaDataCacheAccessor.GetFieldType(flid);
				string sView;
				switch (type)
				{
					case (int)CellarModuleDefns.kcptString:
					case (int)CellarModuleDefns.kcptBigString:
						TsStringAccessor tsa = new TsStringAccessor(m_cache, target.Hvo, (int)flid);
						return tsa;
					case (int)CellarModuleDefns.kcptMultiUnicode:
					case (int)CellarModuleDefns.kcptMultiBigUnicode:
						sView = sClass + '_' + property;
						MultiUnicodeAccessor mua = new MultiUnicodeAccessor(m_cache, target.Hvo, (int)flid, sView);
						return mua;
					case (int)CellarModuleDefns.kcptMultiString:
					case (int)CellarModuleDefns.kcptMultiBigString:
						sView = sClass + '_' + property;
						MultiStringAccessor msa = new MultiStringAccessor(m_cache, target.Hvo, (int)flid, sView);
						return msa;
				}
			}
			catch
			{
			}
			return null;
		}
Example #11
0
		/// <summary>
		/// This goes through the collected list of WfiWordforms that do not have any analyses, and generates
		/// a guess for any whose forms exactly match a LexemeForm (or AlternateForm) of a stem/root entry.
		/// </summary>
		/// <param name="progress"></param>
		private void AddEntryGuesses(ProgressState progress)
		{
			if (m_rgEmptyWfis.Count == 0)
				return;
			MapEmptyWfToInfo();
			progress.Breath();
			if (m_mapEmptyWfInfo.Count == 0)
				return;
			foreach (EmptyWwfAnno ewa in m_rgEmptyWfis)
			{
				IWfiWordform ww = WfiWordform.CreateFromDBObject(m_cache, ewa.m_hvoWwf);
				EmptyWwfKey key = new EmptyWwfKey(ww.Hvo, ewa.m_ws);
				EmptyWwfInfo info;
				if (!m_mapEmptyWfInfo.TryGetValue(key, out info))
					continue;
				IWfiAnalysis wa;
				if (ww.AnalysesOC.Count == 0)
				{
					ITsString tssName = null;
					int wsVern = 0;
					ILexEntryRef ler = SandboxBase.GetVariantRef(m_cache, info.m_hvoEntry, true);
					int hvoEntryToDisplay = info.m_hvoEntry;
					if (ler != null)
					{
						ICmObject coRef = ler.ComponentLexemesRS[0];
						if (coRef is ILexSense)
							hvoEntryToDisplay = (coRef as ILexSense).EntryID;
						else
							hvoEntryToDisplay = coRef.Hvo;
						wsVern = StringUtils.GetWsAtOffset(m_tssPara, 0);
						tssName = InterlinDocChild.GetLexEntryTss(Cache, hvoEntryToDisplay, wsVern, ler);
						info.m_hvoSense = m_cache.MainCacheAccessor.get_VecItem(hvoEntryToDisplay,
							(int)LexEntry.LexEntryTags.kflidSenses, 0);
						info.m_hvoMsa = m_cache.MainCacheAccessor.get_ObjectProp(info.m_hvoSense,
							(int)LexSense.LexSenseTags.kflidMorphoSyntaxAnalysis);
						int clidMsa = m_cache.GetClassOfObject(info.m_hvoMsa);
						if (info.m_hvoPOS == 0)
						{
							info.m_hvoPOS = m_cache.MainCacheAccessor.get_ObjectProp(info.m_hvoMsa,
								(int)MoStemMsa.MoStemMsaTags.kflidPartOfSpeech);
						}
					}
					wa = new WfiAnalysis();
					ww.AnalysesOC.Add(wa);
					wa.CategoryRAHvo = info.m_hvoPOS;
					WfiGloss wg = new WfiGloss();
					wa.MeaningsOC.Add(wg);
					// Not all entries have senses.
					if (info.m_hvoSense != 0)
					{
						MultiUnicodeAccessor muaGloss = new MultiUnicodeAccessor(m_cache, info.m_hvoSense,	/* ls.Id */
							(int)LexSense.LexSenseTags.kflidGloss, "LexSense_Gloss");
						wg.Form.MergeAlternatives(muaGloss);
					}
					WfiMorphBundle wmb = new WfiMorphBundle();
					wa.MorphBundlesOS.Append(wmb);
					wmb.MorphRAHvo = info.m_hvoForm;
					if (tssName != null && wsVern != 0)
						wmb.Form.SetAlternative(tssName, wsVern);
					wmb.MsaRAHvo = info.m_hvoMsa;
					wmb.SenseRAHvo = info.m_hvoSense;

					// Now, set up an approved "Computer" evaluation of this generated analysis
					wa.SetAgentOpinion(m_cache.LangProject.DefaultComputerAgent, Opinions.approves);
				}
				else
				{
					// The same unanalyzed word may occur twice in a paragraph...
					wa = ww.AnalysesOC.ToArray()[0];
					Debug.Assert(ww.AnalysesOC.Count == 1);
					Debug.Assert(wa.CategoryRAHvo == info.m_hvoPOS);
					Debug.Assert(wa.MorphBundlesOS.Count == 1);
					Debug.Assert(wa.MorphBundlesOS[0].MorphRAHvo == info.m_hvoForm);
					Debug.Assert(wa.MorphBundlesOS[0].MsaRAHvo == info.m_hvoMsa);
					Debug.Assert(wa.MorphBundlesOS[0].SenseRAHvo == info.m_hvoSense);
				}
			}
			progress.Breath();
		}
Example #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Merges object into this object.
		/// if fLoseNoStringData is false:
		/// For atomic properties, if this object has something in the property, the source
		/// property is ignored. For sequence properties, the objects in the source will be
		/// moved and appended to the properties in this object. Any references to the
		/// source object will be transferred to this object. The source object is deleted
		/// at the end of this method (objSrc.DeleteUnderlyingObject() call).
		/// String properties are copied from the source if the destination (this) has no value
		/// and the source has a value.
		///
		/// if fLoseNoStringData is true, the above is modified as follows:
		/// 1. If a string property has a value in both source and destination, and the values
		/// are different, append the source onto the destination.
		/// 2. If an atomic object property has a value in both source and destination,
		/// recursively merge the value in the source with the value in the destination.
		/// </summary>
		/// <param name="objSrc">Object whose properties will be merged into this object's properties</param>
		/// <remarks>
		/// NB: The given object will be deleted in this method, so don't expect it to be valid, afterwards.
		/// </remarks>
		/// <param name="fLoseNoStringData"></param>
		/// ------------------------------------------------------------------------------------
		public virtual void MergeObject(ICmObject objSrc, bool fLoseNoStringData)
		{
			Debug.Assert(m_cache != null);
			// We don't allow merging items of different classes.
			Debug.Assert(ClassID == objSrc.ClassID);
			if (ClassID != objSrc.ClassID)
				return;

			IFwMetaDataCache mdc = m_cache.MetaDataCacheAccessor;
			PropertyInfo[] myProperties = GetType().GetProperties();
			PropertyInfo[] srcProperties = objSrc.GetType().GetProperties();
			string fieldname;
			// Process all the fields in the source.
			foreach(uint flid in DbOps.GetFieldsInClassOfType(mdc, ClassID, FieldType.kgrfcptAll))
			{
				/* These values will also be returned because they are for most of CmObject's flids.
				 * I think it will do this for each superclass, so there could be some repeats on them.
				 *
				 * pvuFields->Push(101);	// kflidCmObject_Guid
				 * pvuFields->Push(102);	// kflidCmObject_Class
				 * pvuFields->Push(103);	// kflidCmObject_Owner
				 * pvuFields->Push(104);	// kflidCmObject_OwnFlid
				 * pvuFields->Push(105);	// kflidCmObject_OwnOrd
				 * //pvuFields->Push(106);	// kflidCmObject_UpdStmp
				 * //pvuFields->Push(107);	// kflidCmObject_UpdDttm
				 *
				*/
				if (flid < 1000)
					continue; // Do nothing for the CmObject flids.
				if (flid >= (int)SpecialTagValues.ktagMinVp)
					continue;	// Do nothing for virtual properties.

				int nType = mdc.GetFieldType(flid);
				fieldname = mdc.GetFieldName(flid);
					//|| fieldname == "DateModified"
					//|| nType == (int)FieldType.kcptTime // This is handled by a separate connection, so it can time out, if another transaction is open.
				if (fieldname == "DateCreated"
					|| nType == (int)FieldType.kcptImage // FDO does not support this one.
					|| nType == (int)FieldType.kcptGenDate) // FDO does not support setter for gendate.
					continue; // Don't mess with this one.

				// Set suffixes on some of the types.
				switch (nType)
				{
					case (int)FieldType.kcptOwningAtom: // 23
					{
						fieldname += "OA";
						break;
					}
					case (int)FieldType.kcptReferenceAtom: // 24
					{
						fieldname += "RA";
						break;
					}
					case (int)FieldType.kcptOwningCollection: // 25
					{
						fieldname += "OC";
						break;
					}
					case (int)FieldType.kcptReferenceCollection: // 26
					{
						fieldname += "RC";
						break;
					}
					case (int)FieldType.kcptOwningSequence: // 27
					{
						fieldname += "OS";
						break;
					}
					case (int)FieldType.kcptReferenceSequence: // 28
					{
						fieldname += "RS";
						break;
					}
				}
				Object myCurrentValue = null;
				MethodInfo mySetMethod = null;
				Object srcCurrentValue = null;

				PropertyInfo pi = this.GetType().GetProperty(fieldname);
				if (pi != null)
				{
					myCurrentValue = pi.GetGetMethod().Invoke(this, null);
					mySetMethod = pi.GetSetMethod();
					srcCurrentValue = objSrc.GetType().GetProperty(fieldname).GetGetMethod().Invoke(objSrc, null);
				}
				else
				{
					// We must have a custom field, and it needs special treatment.
					Debug.Assert(m_cache.GetIsCustomField(flid));
					mySetMethod = null;
					string classname = mdc.GetOwnClsName(flid);
					string sView = classname + "_" + fieldname;
					switch (nType)
					{
					case (int)FieldType.kcptString:
					case (int)FieldType.kcptBigString:
						myCurrentValue = new TsStringAccessor(m_cache, m_hvo, (int)flid);
						srcCurrentValue = new TsStringAccessor(objSrc.Cache, objSrc.Hvo, (int)flid);
						break;
					case (int)FieldType.kcptMultiString:
					case (int)FieldType.kcptMultiBigString:
						myCurrentValue = new MultiStringAccessor(m_cache, m_hvo,
							(int)flid, sView);
						srcCurrentValue = new MultiStringAccessor(objSrc.Cache, objSrc.Hvo,
							(int)flid, sView);
						break;
					case (int)FieldType.kcptMultiUnicode:
					case (int)FieldType.kcptMultiBigUnicode:
						myCurrentValue = new MultiUnicodeAccessor(m_cache, m_hvo,
							(int)flid, sView);
						srcCurrentValue = new MultiUnicodeAccessor(objSrc.Cache, objSrc.Hvo,
							(int)flid, sView);
						break;
					}
				}
				if (srcCurrentValue == null)
					continue; // Nothing to merge.
				Debug.Assert(srcCurrentValue != null);

				/*
				 * NOTE: Each of the cases (except the exception, which can't be tested)
				 * is tested in the MergeObjectsTests class in the unit tests.
				 * If any additions are made, or if some currently unused cases are enabled,
				 * be sure to add them (or enable them) to that class, as well.
				 */
				switch (nType)
				{
					default:
						throw new ApplicationException("Unrecognized data type for merging: " + nType.ToString());

						/* 0 -> 9 */
					case (int)FieldType.kcptBoolean: // 1
					{
						// Can't be null, so we have to live with default of 0 (false).
						// 0 gets replaced with source data, if 1 (true).
						bool myBool = (bool)myCurrentValue;
						bool srcBool = (bool)srcCurrentValue;
						if (!myBool && srcBool)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {srcCurrentValue});
						}
						break;
					}
						//
					case (int)FieldType.kcptInteger: // 2 Fall through
					// Setter not implemented in FDO. case (int)FieldType.kcptGenDate: // 8
					{
						// Can't be null, so we have to live with default of 0.
						// Zero gets replaced with source data, if greater than 0.
						int myInt = (int)myCurrentValue;
						int srcInt = (int)srcCurrentValue;
						if (myInt == 0 && srcInt > 0)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {srcCurrentValue});
						}
						break;
					}
					case (int)FieldType.kcptTime: // 5
					{
						// If it is DateCreated, we won't even be here,
						// since we will have already skipped it.
						bool resetTime = false;
						DateTime srcTime = DateTime.Now;
						// If it is DateModified, always set it to 'now'.
						if (fieldname == "DateModified")
						{
							// Already using 'Now'.
							resetTime = true;
						}
						else
						{
						// Otherwise, a later source will replace an older target.
						DateTime myTime = (DateTime)myCurrentValue;
							srcTime = (DateTime)srcCurrentValue;
							resetTime = (myTime < srcTime);
						if (myTime < srcTime)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {srcTime});
						}
						}
						if (resetTime)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {srcTime});
						}
						break;
					}
					case (int)FieldType.kcptGuid: // 6
					{
						// May be null.
						Guid myGuidValue = (Guid)myCurrentValue;
						Guid srcGuidValue = (Guid)srcCurrentValue;
						if (myGuidValue == Guid.Empty && srcGuidValue != Guid.Empty)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {srcGuidValue});
							mySetMethod.Invoke(objSrc, new object[] {Guid.Empty});
						}
						break;
					}
					//case (int)FieldType.kcptImage: // 7 Fall through.
					case (int)FieldType.kcptBinary: // 8
					{
						if (myCurrentValue == null)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {srcCurrentValue});
						}
						break;
					}

					/* 13 -> 20 */
					case (int)FieldType.kcptString: // 13 Fall through
					case (int)FieldType.kcptBigString: // 17
					{
						if (MergeStringProp((int)flid, nType, objSrc, fLoseNoStringData, myCurrentValue, srcCurrentValue))
							break;
						TsStringAccessor myTsa = myCurrentValue as TsStringAccessor;
						myTsa.MergeString(srcCurrentValue as TsStringAccessor, fLoseNoStringData);
						break;
					}

					case (int)FieldType.kcptMultiString: // 14 Fall through.
					case (int)FieldType.kcptMultiBigString: // 18
					{
						if (MergeStringProp((int)flid, nType, objSrc, fLoseNoStringData, myCurrentValue, srcCurrentValue))
							break;
						MultiStringAccessor myMsa = myCurrentValue as MultiStringAccessor;
						myMsa.MergeAlternatives(srcCurrentValue as MultiStringAccessor, fLoseNoStringData);
						break;
					}

					case (int)FieldType.kcptUnicode: // 15 Fall through.
					case (int)FieldType.kcptBigUnicode: // 19
					{
						if (MergeStringProp((int)flid, nType, objSrc, fLoseNoStringData, myCurrentValue, srcCurrentValue))
							break;
						string myUCurrent = myCurrentValue as string;
						string srcUValue = srcCurrentValue as string;
						if ((myUCurrent == null || myUCurrent == String.Empty)
							&& srcUValue != String.Empty)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {srcUValue});
						}
						else if (fLoseNoStringData
							&& myUCurrent != null && myUCurrent != String.Empty
							&& srcUValue != null && srcUValue != String.Empty
							&& srcUValue != myUCurrent)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {myUCurrent + ' ' + srcUValue});
						}
						break;
					}

					case (int)FieldType.kcptMultiUnicode: // 16 Fall through
					case (int)FieldType.kcptMultiBigUnicode: // 20 This one isn't actually used yet, but I hope it is the same as the small MultiUnicode
					{
						if (MergeStringProp((int)flid, nType, objSrc, fLoseNoStringData, myCurrentValue, srcCurrentValue))
							break;
						MultiUnicodeAccessor myMua = myCurrentValue as MultiUnicodeAccessor;
						myMua.MergeAlternatives(srcCurrentValue as MultiUnicodeAccessor, fLoseNoStringData);
						break;
					}

					/* 23 -> 28 */
					case (int)FieldType.kcptOwningAtom:
					case (int)FieldType.kcptReferenceAtom: // 24
					{
						ICmObject srcObj = srcCurrentValue as ICmObject;
						ICmObject currentObj = myCurrentValue as ICmObject;
						if (myCurrentValue == null)
						{
							Debug.Assert(mySetMethod != null);
							mySetMethod.Invoke(this, new object[] {srcObj});
							break;
						}
						else if (fLoseNoStringData && nType == (int)FieldType.kcptOwningAtom && srcObj != null
							&& currentObj.GetType() == srcObj.GetType())
						{
							// merge the child objects.
							currentObj.MergeObject(srcObj, true);
						}
						break;
					}

					case (int)FieldType.kcptOwningCollection: // 25 Fall through, since the collection class knows how to merge itself properly.
					case (int)FieldType.kcptReferenceCollection: // 26
					{
						PropertyInfo piCol = FdoVector<ICmObject>.HvoArrayPropertyInfo(srcCurrentValue);
						MethodInfo myAddMethod = FdoCollection<ICmObject>.AddIntMethodInfo(myCurrentValue);
						foreach (int hvo in (int[])piCol.GetGetMethod().Invoke(srcCurrentValue, null))
						{
							myAddMethod.Invoke(myCurrentValue, new object[] { hvo });
						}
						break;
					}

					case (int)FieldType.kcptOwningSequence: // 27 Fall through, since the collection class knows how to merge itself properly.
					case (int)FieldType.kcptReferenceSequence: // 28
					{
						PropertyInfo piCol = FdoVector<ICmObject>.HvoArrayPropertyInfo(srcCurrentValue);
						MethodInfo myAppendMethod = FdoSequence<ICmObject>.AppendIntMethodInfo(myCurrentValue);
						foreach (int hvo in (int[])piCol.GetGetMethod().Invoke(srcCurrentValue, null))
						{
							myAppendMethod.Invoke(myCurrentValue, new object[] { hvo });
						}
						break;
					}
				}
			}

			// Now move all incoming references.
			CmObject.ReplaceReferences(m_cache, objSrc, this);
			objSrc.DeleteUnderlyingObject();
		}
Example #13
0
		private void m_lnkSpecify_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			Debug.Assert(m_clerk.CurrentObject == null || m_clerk.CurrentObject is CmAnnotation);
			if (m_fObjectConcorded)
			{
				ICmObject cmCurrent = null;
				if (m_clerk.CurrentObject as CmAnnotation != null)
					cmCurrent = (m_clerk.CurrentObject as CmAnnotation).InstanceOfRA;
				ITsString tss = null;
				int ws = 0;
				if (cmCurrent != null)
				{
					int hvoOwner = cmCurrent.OwnerHVO;
					int hvoOwner2 = m_cache.GetOwnerOfObject(hvoOwner);
					if (m_cache.GetClassOfObject(hvoOwner2) == WfiAnalysis.kclsidWfiAnalysis)
						hvoOwner2 = m_cache.GetOwnerOfObject(hvoOwner2);
					if (m_cache.GetClassOfObject(hvoOwner2) == WfiWordform.kclsidWfiWordform)
					{
						MultiUnicodeAccessor mua = new MultiUnicodeAccessor(m_cache, hvoOwner2,
							(int)WfiWordform.WfiWordformTags.kflidForm, "WfiWordform_Form");
						tss = mua.BestVernacularAlternative;
						ITsTextProps ttp = tss.get_PropertiesAt(0);
						int nVar;
						ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar);
					}
				}
				if (tss == null)
				{
					ws = m_cache.DefaultVernWs;
					tss = m_cache.MakeVernTss("");
				}
				SetDefaultVisibilityOfItems(true, String.Empty);
				m_fObjectConcorded = false;
				SetConcordanceLine(ConcordanceLines.kWord);
				SetWritingSystem(ws);
				m_tbSearchText.Tss = tss;
			}
			else if (m_hvoMatch != 0)
			{
				InitializeConcordanceSearch(CmObject.CreateFromDBObject(m_cache, m_hvoMatch));
			}
		}
		private void AddAbbrAndNameInfo(MultiUnicodeAccessor abbr, MultiUnicodeAccessor name, MultiUnicodeAccessor reverseAbbr, MultiUnicodeAccessor reverseName)
		{
			int wsActual;
			ITsString tssAnal;

			if (name != null)
			{
				string sname, snameWS, sabbr, sabbrWS;
				tssAnal = name.GetAlternativeOrBestTss(m_cache.DefaultAnalWs, out wsActual);
				sname = tssAnal.Text;
				snameWS = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(wsActual);

				cbFunction.Items.Add(sname);

				if (!m_htNameToAbbr.ContainsKey(sname))
				{
					if (abbr == null)
					{
						sabbr = sname;	// use both for the map key
						sabbrWS = snameWS;
					}
					else
					{
						tssAnal = abbr.GetAlternativeOrBestTss(m_cache.DefaultAnalWs, out wsActual);
						sabbr = tssAnal.Text;
						sabbrWS = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(wsActual);
					}
					NameWSandAbbr nwsa = new NameWSandAbbr();
					nwsa.name = sname;
					nwsa.nameWS = snameWS;
					nwsa.abbr = sabbr;
					nwsa.abbrWS = sabbrWS;
					m_htNameToAbbr.Add(sname, nwsa);
				}
			}
			if (reverseName != null)
			{
				string srname, srnameWS, srabbr, srabbrWS;
				tssAnal = reverseName.GetAlternativeOrBestTss(m_cache.DefaultAnalWs, out wsActual);
				srname = tssAnal.Text;
				srnameWS = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(wsActual);

				cbFunction.Items.Add(srname);

				if (!m_htNameToAbbr.ContainsKey(srname))
				{
					if (reverseAbbr == null)
					{
						srabbr = srname;	// use both for the map key
						srabbrWS = srnameWS;
					}
					else
					{
						tssAnal = reverseAbbr.GetAlternativeOrBestTss(m_cache.DefaultAnalWs, out wsActual);
						srabbr = tssAnal.Text;
						srabbrWS = m_cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(wsActual);
					}
					NameWSandAbbr nwsa = new NameWSandAbbr();
					nwsa.name = srname;
					nwsa.nameWS = srnameWS;
					nwsa.abbr = srabbr;
					nwsa.abbrWS = srabbrWS;
					m_htNameToAbbr.Add(srname, nwsa);
				}
			}
		}