Пример #1
0
		/// <summary>
		/// For each individual item,
		/// 1. remove any comment (using rsf.m_tlo.m_rgsBefore)
		/// 2. extract actual data (using rsf.m_tlo.m_rgsMarkStart/End)
		/// </summary>
		private static List<string> ApplyBeforeAndBetween(RnSfMarker rsf, List<string> rgsData)
		{
			List<string> rgsData2 = new List<string>();
			foreach (string sItem in rgsData)
			{
				string sT = sItem;
				if (rsf.m_tlo.m_fHaveBefore &&
					rsf.m_tlo.m_rgsBefore != null && sItem.Length > 0)
				{
					foreach (string sBefore in rsf.m_tlo.m_rgsBefore)
					{
						int idx = sItem.IndexOf(sBefore);
						if (idx > 0)
						{
							sT = sItem.Substring(0, idx).Trim();
						}
						else if (idx == 0)
						{
							sT = String.Empty;
						}
						if (sT.Length == 0)
							break;
					}
				}
				if (sT.Length > 0 && rsf.m_tlo.m_fHaveBetween &&
					rsf.m_tlo.m_rgsMarkStart != null && rsf.m_tlo.m_rgsMarkEnd != null)
				{
					// Ensure safe length even if the two lengths differ.
					// REVIEW: Should we complain if the lengths differ?
					int clen = rsf.m_tlo.m_rgsMarkEnd.Length;
					if (rsf.m_tlo.m_rgsMarkStart.Length < rsf.m_tlo.m_rgsMarkEnd.Length)
						clen = rsf.m_tlo.m_rgsMarkStart.Length;
					if (clen > 0)
					{
						string sT2 = String.Empty;
						for (int i = 0; i < clen; ++i)
						{
							int idx = sT.IndexOf(rsf.m_tlo.m_rgsMarkStart[i]);
							if (idx >= 0)
							{
								++idx;
								int idxEnd = sT.IndexOf(rsf.m_tlo.m_rgsMarkEnd[i], idx);
								if (idxEnd >= 0)
								{
									sT2 = sT.Substring(idx, idxEnd - idx);
									break;
								}
							}
						}
						sT = sT2;
					}
				}
				if (!String.IsNullOrEmpty(sT))
					rgsData2.Add(sT);
			}
			return rgsData2;
		}
Пример #2
0
		/// <summary>
		/// Store the information needed to make any cross reference links after all the records
		/// have been created.
		/// </summary>
		private void StoreLinkData(IRnGenericRec rec, RnSfMarker rsf, Sfm2Xml.SfmField field)
		{
			if (String.IsNullOrEmpty(field.Data))
				return;
			var pend = new PendingLink { Marker = rsf, Field = field, Record = rec };
			m_pendingLinks.Add(pend);
		}
Пример #3
0
		/// <summary>
		/// Store the data for a field that contains one or more references to a possibility
		/// list.
		/// </summary>
		private void SetListReference(IRnGenericRec rec, RnSfMarker rsf, Sfm2Xml.SfmField field)
		{
			ReconvertEncodedDataIfNeeded(field, rsf.m_tlo.m_wsId);
			string sData = field.Data;
			if (sData == null)
				sData = String.Empty;
			sData = ApplyChanges(rsf, sData);
			sData = sData.Trim();
			List<string> rgsData = null;
			if (sData.Length > 0)
			{
				if (rsf.m_tlo.m_fHaveMulti)
				{
					rgsData = SplitString(sData, rsf.m_tlo.m_rgsDelimMulti);
					rgsData = PruneEmptyStrings(rgsData);
				}
				else
				{
					rgsData = new List<string> {sData};
				}
			}
			if ((rgsData == null || rgsData.Count == 0) && rsf.m_tlo.m_default == null)
			{
				return;
			}
			if (rgsData == null)
				rgsData = new List<string>();
			rgsData = ApplyBeforeAndBetween(rsf, rgsData);
			if (rgsData.Count == 0)
				rgsData.Add(String.Empty);
			foreach (var sItem in rgsData)
			{
				switch (rsf.m_flid)
				{
					case RnGenericRecTags.kflidAnthroCodes:
						if (!StoreAnthroCode(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidConfidence:
						if (!StoreConfidence(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidLocations:
						if (!StoreLocation(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidPhraseTags:
						if (!StorePhraseTag(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidResearchers:
						if (!StoreResearcher(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidRestrictions:
						if (!StoreRestriction(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidSources:
						if (!StoreSource(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidStatus:
						if (!StoreStatus(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidTimeOfEvent:
						if (!StoreTimeOfEvent(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidType:
						if (!StoreRecType(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					case RnGenericRecTags.kflidParticipants:
						if (!StoreParticipant(rec, rsf, sItem))
							LogCannotFindListItem(sItem, field);
						break;
					default:
						// must be a custom field.
						Debug.Assert(rsf.m_flid >= (RnGenericRecTags.kClassId * 1000) + 500);
						Guid guidList = m_mdc.GetFieldListRoot(rsf.m_flid);
						if (guidList != Guid.Empty)
						{
							if (m_repoList == null)
								m_repoList = m_cache.ServiceLocator.GetInstance<ICmPossibilityListRepository>();
							ICmPossibilityList list = m_repoList.GetObject(guidList);
							if (list != null)
							{
								if (!StoreCustomListRefItem(rec, rsf, sItem, list))
									LogCannotFindListItem(sItem, field);
								break;
							}
						}
						LogMessage(
							String.Format(LexTextControls.ksCannotFindPossibilityList, field.Marker),
							field.LineNumber);
						return;
				}
			}
		}
Пример #4
0
		private bool StoreCustomListRefItem(IRnGenericRec rec, RnSfMarker rsf, string sData,
			ICmPossibilityList list)
		{
			// First, get the existing data so we can check whether the new item is needed,
			// and so that we know where to insert it (at the end) if it is.
			int chvo = m_cache.DomainDataByFlid.get_VecSize(rec.Hvo, rsf.m_flid);
			int[] hvosField;
			using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative<int>(chvo))
			{
				m_cache.DomainDataByFlid.VecProp(rec.Hvo, rsf.m_flid, chvo, out chvo, arrayPtr);
				hvosField = MarshalEx.NativeToArray<int>(arrayPtr, chvo);
			}
			ICmPossibility poss;
			List<string> rgsHier = SplitForSubitems(rsf, sData);
			if (rgsHier == null || rgsHier.Count == 0)
			{
				poss = rsf.m_tlo.m_default;
				if (poss != null && !hvosField.Contains(poss.Hvo) && poss.ClassID == list.ItemClsid)
				{
					m_cache.DomainDataByFlid.Replace(rec.Hvo, rsf.m_flid, chvo, chvo,
						new int[] { poss.Hvo }, 1);
				}
				return true;
			}
			switch (list.OwningFlid)
			{
				case LangProjectTags.kflidAnthroList:
					if (m_mapAnthroCode.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.AnthroListOA.PossibilitiesOS, m_mapAnthroCode);
					poss = FindPossibilityOrNull(rgsHier, m_mapAnthroCode);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewAnthroItem(rgsHier);
					break;
				case LangProjectTags.kflidConfidenceLevels:
					if (m_mapConfidence.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.ConfidenceLevelsOA.PossibilitiesOS, m_mapConfidence);
					poss = FindPossibilityOrNull(rgsHier, m_mapConfidence);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewConfidenceItem(rgsHier);
					break;
				case LangProjectTags.kflidLocations:
					if (m_mapLocation.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.LocationsOA.PossibilitiesOS, m_mapLocation);
					poss = FindPossibilityOrNull(rgsHier, m_mapLocation);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewLocation(rgsHier);
					break;
				case RnResearchNbkTags.kflidRecTypes:
					if (m_mapRecType.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.ResearchNotebookOA.RecTypesOA.PossibilitiesOS, m_mapRecType);
					poss = FindPossibilityOrNull(rgsHier, m_mapRecType);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewRecType(rgsHier);
					break;
				case LangProjectTags.kflidTextMarkupTags:
					if (m_mapPhraseTag.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.TextMarkupTagsOA.PossibilitiesOS, m_mapPhraseTag);
					poss = FindPossibilityOrNull(rgsHier, m_mapPhraseTag);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewPhraseTag(rgsHier);
					break;
				case LangProjectTags.kflidPeople:
					if (m_mapPeople.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.PeopleOA.PossibilitiesOS, m_mapPeople);
					poss = FindPossibilityOrNull(rgsHier, m_mapPeople);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewPerson(rgsHier);
					break;
				case LangProjectTags.kflidRestrictions:
					if (m_mapRestriction.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.RestrictionsOA.PossibilitiesOS, m_mapRestriction);
					poss = FindPossibilityOrNull(rgsHier, m_mapRestriction);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewRestriction(rgsHier);
					break;
				case LangProjectTags.kflidStatus:
					if (m_mapStatus.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.StatusOA.PossibilitiesOS, m_mapStatus);
					poss = FindPossibilityOrNull(rgsHier, m_mapStatus);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewStatus(rgsHier);
					break;
				case LangProjectTags.kflidTimeOfDay:
					if (m_mapTimeOfDay.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.TimeOfDayOA.PossibilitiesOS, m_mapTimeOfDay);
					poss = FindPossibilityOrNull(rgsHier, m_mapTimeOfDay);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						poss = CreateNewTimeOfDay(rgsHier);
					break;
				default:
					Dictionary<string, ICmPossibility> map;
					if (!m_mapListMapPossibilities.TryGetValue(list.Guid, out map))
					{
						map = new Dictionary<string, ICmPossibility>();
						FillPossibilityMap(rsf, list.PossibilitiesOS, map);
						m_mapListMapPossibilities.Add(list.Guid, map);
					}
					List<ICmPossibility> rgNew;
					if (!m_mapNewPossibilities.TryGetValue(list.Guid, out rgNew))
					{
						rgNew = new List<ICmPossibility>();
						m_mapNewPossibilities.Add(list.Guid, rgNew);
					}
					poss = FindPossibilityOrNull(rgsHier, map);
					if (poss == null && !rsf.m_tlo.m_fIgnoreNewStuff)
					{
						CmPossibilityCreator creator = null;
						switch (list.ItemClsid)
						{
							case CmPossibilityTags.kClassId:
								creator = PossibilityCreator;
								break;
							case CmLocationTags.kClassId:
								creator = LocationCreator;
								break;
							case CmPersonTags.kClassId:
								creator = PersonCreator;
								break;
							case CmAnthroItemTags.kClassId:
								creator = AnthroItemCreator;
								break;
							case CmCustomItemTags.kClassId:
								creator = CustomItemCreator;
								break;
							case CmSemanticDomainTags.kClassId:
								creator = SemanticDomainCreator;
								break;
							// These are less likely, but legal, so we have to allow for them.
							case MoMorphTypeTags.kClassId:
								creator = MorphTypeCreator;
								break;
							case PartOfSpeechTags.kClassId:
								creator = NewPartOfSpeechCreator;
								break;
							case LexEntryTypeTags.kClassId:
								creator = NewLexEntryTypeCreator;
								break;
							case LexRefTypeTags.kClassId:
								creator = NewLexRefTypeCreator;
								break;
						}
						if (creator != null)
							poss =  CreateNewPossibility(rgsHier, creator, list.PossibilitiesOS, map, rgNew);
					}
					break;
			}
			if (poss != null && !hvosField.Contains(poss.Hvo) && poss.ClassID == list.ItemClsid)
			{
				m_cache.DomainDataByFlid.Replace(rec.Hvo, rsf.m_flid, chvo, chvo,
					new int[] { poss.Hvo }, 1);
				return true;
			}
			else
			{
				return !rsf.m_tlo.m_fIgnoreNewStuff;
			}
		}
Пример #5
0
		private RnSfMarker FindOrCreateRnSfMarker(string mkr)
		{
			RnSfMarker rsf;
			if (m_mapMkrRsfFromFile.TryGetValue(mkr, out rsf))
				return rsf;
			RnSfMarker rsfNew = new RnSfMarker();
			rsfNew.m_sMkr = mkr;
			rsfNew.m_flid = 0;
			rsfNew.m_sName = LexTextControls.ksDoNotImport;
			return rsfNew;
		}
Пример #6
0
		private List<string> SplitForSubitems(RnSfMarker rsf, string sData)
		{
			List<string> rgsHier = null;
			if (sData.Length > 0)
			{
				if (rsf.m_tlo.m_fHaveSub)
				{
					rgsHier = SplitString(sData, rsf.m_tlo.m_rgsDelimSub);
					rgsHier = PruneEmptyStrings(rgsHier);
				}
				else
				{
					rgsHier = new List<string>();
					rgsHier.Add(sData);
				}
			}
			return rgsHier;
		}
Пример #7
0
		private bool StoreRecType(IRnGenericRec rec, RnSfMarker rsf, string sData)
		{
			List<string> rgsHier = SplitForSubitems(rsf, sData);
			if (rgsHier == null || rgsHier.Count == 0)
			{
				rec.TypeRA = rsf.m_tlo.m_default;
				return true;
			}
			if (m_mapRecType.Count == 0)
				FillPossibilityMap(rsf, m_cache.LangProject.ResearchNotebookOA.RecTypesOA.PossibilitiesOS, m_mapRecType);
			ICmPossibility poss = FindPossibilityOrNull(rgsHier, m_mapRecType);
			if (poss != null)
			{
				rec.TypeRA = poss;
				return true;
			}
			else if (rsf.m_tlo.m_fIgnoreNewStuff)
			{
				return false;
			}
			else
			{
				ICmPossibility item = CreateNewRecType(rgsHier);
				rec.TypeRA = item;
				return true;
			}
		}
Пример #8
0
		/// <summary>
		/// Store the data for a multi-paragraph text field.
		/// </summary>
		private void SetTextContent(IRnGenericRec rec, RnSfMarker rsf, Sfm2Xml.SfmField field)
		{
			// REVIEW: SHOULD WE WORRY ABOUT EMBEDDED CHAR MAPPINGS THAT CHANGE THE WRITING SYSTEM
			// WHEN IT COMES TO ENCODING CONVERSION???
			ReconvertEncodedDataIfNeeded(field, rsf.m_txo.m_wsId);
			List<string> rgsParas = SplitIntoParagraphs(rsf, field);
			if (rgsParas.Count == 0)
				return;
			if (m_factStText == null)
				m_factStText = m_cache.ServiceLocator.GetInstance<IStTextFactory>();
			switch (rsf.m_flid)
			{
				case RnGenericRecTags.kflidConclusions:
					if (rec.ConclusionsOA == null)
						rec.ConclusionsOA = m_factStText.Create();
					StoreTextData(rec.ConclusionsOA, rsf, rgsParas);
					break;
				case RnGenericRecTags.kflidDescription:
					if (rec.DescriptionOA == null)
						rec.DescriptionOA = m_factStText.Create();
					StoreTextData(rec.DescriptionOA, rsf, rgsParas);
					break;
				case RnGenericRecTags.kflidDiscussion:
					if (rec.DiscussionOA == null)
						rec.DiscussionOA = m_factStText.Create();
					StoreTextData(rec.DiscussionOA, rsf, rgsParas);
					break;
				case RnGenericRecTags.kflidExternalMaterials:
					if (rec.ExternalMaterialsOA == null)
						rec.ExternalMaterialsOA = m_factStText.Create();
					StoreTextData(rec.ExternalMaterialsOA, rsf, rgsParas);
					break;
				case RnGenericRecTags.kflidFurtherQuestions:
					if (rec.FurtherQuestionsOA == null)
						rec.FurtherQuestionsOA = m_factStText.Create();
					StoreTextData(rec.FurtherQuestionsOA, rsf, rgsParas);
					break;
				case RnGenericRecTags.kflidHypothesis:
					if (rec.HypothesisOA == null)
						rec.HypothesisOA = m_factStText.Create();
					StoreTextData(rec.HypothesisOA, rsf, rgsParas);
					break;
				case RnGenericRecTags.kflidPersonalNotes:
					if (rec.PersonalNotesOA == null)
						rec.PersonalNotesOA = m_factStText.Create();
					StoreTextData(rec.PersonalNotesOA, rsf, rgsParas);
					break;
				case RnGenericRecTags.kflidResearchPlan:
					if (rec.ResearchPlanOA == null)
						rec.ResearchPlanOA = m_factStText.Create();
					StoreTextData(rec.ResearchPlanOA, rsf, rgsParas);
					break;
				case RnGenericRecTags.kflidVersionHistory:
					if (rec.VersionHistoryOA == null)
						rec.VersionHistoryOA = m_factStText.Create();
					StoreTextData(rec.VersionHistoryOA, rsf, rgsParas);
					break;
				default:
					// Handle custom field (don't think any can exist yet, but...)
					Debug.Assert(rsf.m_flid >= (RnGenericRecTags.kClassId * 1000) + 500);
					IStText text;
					int hvo = m_cache.DomainDataByFlid.get_ObjectProp(rec.Hvo, rsf.m_flid);
					if (hvo == 0)
					{
						text = m_factStText.Create();
						m_cache.DomainDataByFlid.SetObjProp(rec.Hvo, rsf.m_flid, text.Hvo);
					}
					else
					{
						if (m_repoStText == null)
							m_repoStText = m_cache.ServiceLocator.GetInstance<IStTextRepository>();
						text = m_repoStText.GetObject(hvo);
					}
					StoreTextData(text, rsf, rgsParas);
					break;
			}
		}
Пример #9
0
		private void StoreTextData(IStText text, RnSfMarker rsf, List<string> rgsParas)
		{
			if (m_factPara == null)
				m_factPara = m_cache.ServiceLocator.GetInstance<IStTxtParaFactory>();
			if (rgsParas.Count == 0)
			{
				IStTxtPara para = m_factPara.Create();
				text.ParagraphsOS.Add(para);
				if (!String.IsNullOrEmpty(rsf.m_txo.m_sStyle))
					para.StyleName = rsf.m_txo.m_sStyle;
				para.Contents = MakeTsString(String.Empty, rsf.m_txo.m_ws.Handle);
			}
			else
			{
				for (int i = 0; i < rgsParas.Count; ++i)
				{
					IStTxtPara para = m_factPara.Create();
					text.ParagraphsOS.Add(para);
					if (!String.IsNullOrEmpty(rsf.m_txo.m_sStyle))
						para.StyleName = rsf.m_txo.m_sStyle;
					para.Contents = MakeTsString(rgsParas[i], rsf.m_txo.m_ws.Handle);
				}
			}
		}
Пример #10
0
		private void ReadLinkMarker(XmlNode xnMarker, RnSfMarker sfm)
		{
			foreach (XmlNode xn in xnMarker.ChildNodes)
			{
				switch (xn.Name)
				{
					case "IgnoreEmpty":
						break;
				}
			}
		}
Пример #11
0
		private void SetDefaultForListRef(RnSfMarker rsf)
		{
			string sDefault = rsf.m_tlo.m_sEmptyDefault;
			if (sDefault == null)
				return;
			sDefault = sDefault.Trim();
			if (sDefault.Length == 0)
				return;
			List<string> rgsHier;
			if (rsf.m_tlo.m_fHaveSub)
			{
				rgsHier = SplitString(sDefault, rsf.m_tlo.m_rgsDelimSub);
			}
			else
			{
				rgsHier = new List<string>();
				rgsHier.Add(sDefault);
			}
			rgsHier = PruneEmptyStrings(rgsHier);
			if (rgsHier.Count == 0)
				return;
			switch (rsf.m_flid)
			{
				case RnGenericRecTags.kflidAnthroCodes:
					if (m_mapAnthroCode.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.AnthroListOA.PossibilitiesOS, m_mapAnthroCode);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapAnthroCode);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewAnthroItem(rgsHier);
					break;
				case RnGenericRecTags.kflidConfidence:
					if (m_mapConfidence.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.ConfidenceLevelsOA.PossibilitiesOS, m_mapConfidence);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapConfidence);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewConfidenceItem(rgsHier);
					break;
				case RnGenericRecTags.kflidLocations:
					if (m_mapLocation.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.LocationsOA.PossibilitiesOS, m_mapLocation);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapLocation);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewLocation(rgsHier);
					break;
				case RnGenericRecTags.kflidPhraseTags:
					if (m_mapPhraseTag.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.TextMarkupTagsOA.PossibilitiesOS, m_mapPhraseTag);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapPhraseTag);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewPhraseTag(rgsHier);
					break;
				case RnGenericRecTags.kflidResearchers:
				case RnGenericRecTags.kflidSources:
					if (m_mapPeople.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.PeopleOA.PossibilitiesOS, m_mapPeople);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapPeople);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewPerson(rgsHier);
					break;
				case RnGenericRecTags.kflidRestrictions:
					if (m_mapRestriction.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.RestrictionsOA.PossibilitiesOS, m_mapRestriction);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapRestriction);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewRestriction(rgsHier);
					break;
				case RnGenericRecTags.kflidStatus:
					if (m_mapStatus.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.StatusOA.PossibilitiesOS, m_mapStatus);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapStatus);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewStatus(rgsHier);
					break;
				case RnGenericRecTags.kflidTimeOfEvent:
					if (m_mapTimeOfDay.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.TimeOfDayOA.PossibilitiesOS, m_mapTimeOfDay);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapTimeOfDay);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewTimeOfDay(rgsHier);
					break;
				case RnGenericRecTags.kflidType:
					if (m_mapRecType.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.ResearchNotebookOA.RecTypesOA.PossibilitiesOS, m_mapRecType);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapRecType);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewRecType(rgsHier);
					break;
				case RnGenericRecTags.kflidParticipants:
					if (m_mapPeople.Count == 0)
						FillPossibilityMap(rsf, m_cache.LangProject.PeopleOA.PossibilitiesOS, m_mapPeople);
					rsf.m_tlo.m_default = FindPossibilityOrNull(rgsHier, m_mapPeople);
					if (rsf.m_tlo.m_default == null && !rsf.m_tlo.m_fIgnoreNewStuff)
						rsf.m_tlo.m_default = CreateNewPerson(rgsHier);
					break;
				default:
					// must be a custom field.
					Debug.Assert(rsf.m_flid >= (RnGenericRecTags.kClassId * 1000) + 500);
					// We don't yet have the necessary information in the new FDO/MetaDataCache.
					break;
			}
		}
Пример #12
0
		private void ReadTextMarker(XmlNode xnMarker, RnSfMarker sfm)
		{
			foreach (XmlNode xn in xnMarker.ChildNodes)
			{
				switch (xn.Name)
				{
					case "TextStyle":
						sfm.m_txo.m_sStyle = XmlUtils.GetManditoryAttributeValue(xn, "value");
						break;
					case "StartPara":
						sfm.m_txo.m_fStartParaBlankLine = XmlUtils.GetOptionalBooleanAttributeValue(xn, "afterBlankLine", false);
						sfm.m_txo.m_fStartParaIndented = XmlUtils.GetOptionalBooleanAttributeValue(xn, "forIndentedLine", false);
						sfm.m_txo.m_fStartParaNewLine = XmlUtils.GetOptionalBooleanAttributeValue(xn, "forEachLine", false);
						sfm.m_txo.m_fStartParaShortLine = XmlUtils.GetOptionalBooleanAttributeValue(xn, "afterShortLine", false);
						sfm.m_txo.m_cchShortLim = 0;
						string sLim = XmlUtils.GetOptionalAttributeValue(xn, "shortLineLim");
						if (!String.IsNullOrEmpty(sLim))
							Int32.TryParse(sLim, out sfm.m_txo.m_cchShortLim);
						break;
					case "DefaultParaWrtSys":
						sfm.m_txo.m_wsId = XmlUtils.GetManditoryAttributeValue(xn, "ws");
						break;
				}
			}
		}
Пример #13
0
		private void ReadPossibilityMarker(XmlNode xnMarker, RnSfMarker sfm, CellarPropertyType cpt)
		{
			foreach (XmlNode xn in xnMarker.ChildNodes)
			{
				switch (xn.Name)
				{
					case "Match":
						string sMatch = XmlUtils.GetManditoryAttributeValue(xn, "value");
						switch (sMatch)
						{
							case "abbr":
								sfm.m_tlo.m_pnt = PossNameType.kpntAbbreviation;
								break;
							case "name":
								sfm.m_tlo.m_pnt = PossNameType.kpntName;
								break;
							default:
								sfm.m_tlo.m_pnt = PossNameType.kpntAbbreviation;
								break;
						}
						break;
					case "Multiple":
						if (cpt == CellarPropertyType.ReferenceCollection ||
							cpt == CellarPropertyType.ReferenceSequence ||
							cpt == CellarPropertyType.OwningCollection ||
							cpt == CellarPropertyType.OwningSequence)
						{
							sfm.m_tlo.m_fHaveMulti = true;
							sfm.m_tlo.m_sDelimMulti = XmlUtils.GetManditoryAttributeValue(xn, "sep");
						}
						break;
					case "Subchoice":
						sfm.m_tlo.m_fHaveSub = true;
						sfm.m_tlo.m_sDelimSub = XmlUtils.GetManditoryAttributeValue(xn, "sep");
						break;
					case "Default":
						sfm.m_tlo.m_sEmptyDefault = XmlUtils.GetManditoryAttributeValue(xn, "value");
						sfm.m_tlo.m_default = null;
						break;
					case "DelimitChoice":
						sfm.m_tlo.m_fHaveBetween = true;
						sfm.m_tlo.m_sMarkStart = XmlUtils.GetManditoryAttributeValue(xn, "start");
						sfm.m_tlo.m_sMarkEnd = XmlUtils.GetManditoryAttributeValue(xn, "end");
						break;
					case "StopChoices":
						sfm.m_tlo.m_fHaveBefore = true;
						sfm.m_tlo.m_sBefore = XmlUtils.GetManditoryAttributeValue(xn, "value");
						break;
					case "IgnoreNewChoices":
						sfm.m_tlo.m_fIgnoreNewStuff = XmlUtils.GetBooleanAttributeValue(xn, "value");
						break;
					case "MatchReplaceChoice":
						sfm.m_tlo.m_rgsMatch.Add(XmlUtils.GetManditoryAttributeValue(xn, "match"));
						sfm.m_tlo.m_rgsReplace.Add(XmlUtils.GetOptionalAttributeValue(xn, "replace", String.Empty));
						break;
					case "ItemWrtSys":
						sfm.m_tlo.m_wsId = XmlUtils.GetManditoryAttributeValue(xn, "ws");
						break;
				}
			}
		}
Пример #14
0
		private void ReadMarkerSetting(XmlNode xnMarker)
		{
			try
			{
				RnSfMarker sfm = new RnSfMarker();
				sfm.m_sMkr = XmlUtils.GetManditoryAttributeValue(xnMarker, "tag");
				sfm.m_flid = XmlUtils.GetMandatoryIntegerAttributeValue(xnMarker, "flid");
				sfm.m_sMkrOverThis = XmlUtils.GetOptionalAttributeValue(xnMarker, "owner");
				if (sfm.m_flid == 0)
				{
					sfm.m_sName = LexTextControls.ksDoNotImport;
				}
				else
				{
					sfm.m_sName = m_mapFlidName[sfm.m_flid];
					int clidDest = 0;
					switch ((CellarPropertyType)m_mdc.GetFieldType(sfm.m_flid))
					{
						case CellarPropertyType.Time:
						case CellarPropertyType.GenDate:
							foreach (XmlNode xn in xnMarker.SelectNodes("./DateFormat"))
							{
								string sFormat = XmlUtils.GetManditoryAttributeValue(xn, "value");
								sfm.m_dto.m_rgsFmt.Add(sFormat);
							}
							break;
						case CellarPropertyType.ReferenceAtomic:
							clidDest = m_mdc.GetDstClsId(sfm.m_flid);
							Debug.Assert(clidDest == CmPossibilityTags.kClassId);
							ReadPossibilityMarker(xnMarker, sfm, CellarPropertyType.ReferenceAtomic);
							break;
						case CellarPropertyType.ReferenceCollection:
							clidDest = m_mdc.GetDstClsId(sfm.m_flid);
							switch (clidDest)
							{
								case CmAnthroItemTags.kClassId:
								case CmLocationTags.kClassId:
								case CmPersonTags.kClassId:
								case CmPossibilityTags.kClassId:
									ReadPossibilityMarker(xnMarker, sfm, CellarPropertyType.ReferenceCollection);
									break;
								case CrossReferenceTags.kClassId:
									break;
								case ReminderTags.kClassId:
									break;
								case RnGenericRecTags.kClassId:
									break;
								default:
									break;
							}
							break;
						case CellarPropertyType.ReferenceSequence:
							clidDest = m_mdc.GetDstClsId(sfm.m_flid);
							Debug.Assert(clidDest == RnGenericRecTags.kClassId);
							break;
						case CellarPropertyType.OwningAtomic:
							clidDest = m_mdc.GetDstClsId(sfm.m_flid);
							Debug.Assert(clidDest == StTextTags.kClassId);
							ReadTextMarker(xnMarker, sfm);
							break;
						case CellarPropertyType.OwningCollection:
							clidDest = m_mdc.GetDstClsId(sfm.m_flid);
							Debug.Assert(clidDest == RnRoledParticTags.kClassId);
							ReadPossibilityMarker(xnMarker, sfm, CellarPropertyType.OwningCollection);
							break;
						case CellarPropertyType.OwningSequence:
							clidDest = m_mdc.GetDstClsId(sfm.m_flid);
							Debug.Assert(clidDest == RnGenericRecTags.kClassId);
							break;
						case CellarPropertyType.MultiString:
						case CellarPropertyType.MultiUnicode:
						case CellarPropertyType.String:
							foreach (XmlNode xn in xnMarker.SelectNodes("./StringWrtSys"))
							{
								sfm.m_sto.m_wsId = XmlUtils.GetManditoryAttributeValue(xn, "ws");
							}
							break;
						// The following types do not occur in RnGenericRec fields.
						case CellarPropertyType.Binary:
						case CellarPropertyType.Boolean:
						case CellarPropertyType.Float:
						case CellarPropertyType.Guid:
						case CellarPropertyType.Image:
						case CellarPropertyType.Integer:
						case CellarPropertyType.Numeric:
						case CellarPropertyType.Unicode:
							break;
					}
					sfm.m_nLevel = 0;
					foreach (XmlNode xn in xnMarker.ChildNodes)
					{
						if (xn.Name == "Record")
							sfm.m_nLevel = XmlUtils.GetMandatoryIntegerAttributeValue(xn, "level");
					}
				}
				if (m_mapMkrRsfFromFile.ContainsKey(sfm.m_sMkr))
					m_mapMkrRsfFromFile[sfm.m_sMkr] = sfm;
				else
					m_mapMkrRsfFromFile.Add(sfm.m_sMkr, sfm);
			}
			catch
			{
			}
		}
Пример #15
0
		private string ApplyChanges(RnSfMarker rsf, string sData)
		{
			if (rsf.m_tlo.m_rgsMatch == null || rsf.m_tlo.m_rgsReplace == null)
				return sData;
			int count = rsf.m_tlo.m_rgsMatch.Count;
			if (rsf.m_tlo.m_rgsReplace.Count < rsf.m_tlo.m_rgsMatch.Count)
				count = rsf.m_tlo.m_rgsReplace.Count;
			for (int i = 0; i < count; ++i)
				sData = sData.Replace(rsf.m_tlo.m_rgsMatch[i], rsf.m_tlo.m_rgsReplace[i]);
			return sData;
		}
Пример #16
0
		private List<string> SplitIntoParagraphs(RnSfMarker rsf, Sfm2Xml.SfmField field)
		{
			List<string> rgsParas = new List<string>();
			List<string> rgsLines = SplitIntoLines(field.Data);
			StringBuilder sbPara = new StringBuilder();
			for (int i = 0; i < rgsLines.Count; ++i)
			{
				bool fIndented = false;
				string sLine = rgsLines[i];
				if (sLine.Length > 0)
					fIndented = Char.IsWhiteSpace(sLine[0]);
				sLine = sLine.TrimStart();
				if (rsf.m_txo.m_fStartParaNewLine)
				{
					if (sLine.Length > 0)
						rgsParas.Add(sLine);
					continue;
				}
				if (sLine.Length == 0)
				{
					if (sbPara.Length > 0 &&
						(rsf.m_txo.m_fStartParaBlankLine || rsf.m_txo.m_fStartParaShortLine))
					{
						rgsParas.Add(sbPara.ToString());
						sbPara.Remove(0, sbPara.Length);
					}
					continue;
				}
				if (rsf.m_txo.m_fStartParaIndented && fIndented)
				{
					if (rsf.m_txo.m_fStartParaBlankLine && sbPara.Length > 0)
					{
						rgsParas.Add(sbPara.ToString());
						sbPara.Remove(0, sbPara.Length);
					}
					sbPara.Append(sLine);
					continue;
				}
				if (rsf.m_txo.m_fStartParaShortLine && sLine.Length < rsf.m_txo.m_cchShortLim)
				{
					if (sbPara.Length > 0)
						sbPara.Append(" ");
					sbPara.Append(sLine);
					rgsParas.Add(sbPara.ToString());
					sbPara.Remove(0, sbPara.Length);
					continue;
				}
				if (sbPara.Length > 0)
					sbPara.Append(" ");
				sbPara.Append(sLine);
			}
			if (sbPara.Length > 0)
			{
				rgsParas.Add(sbPara.ToString());
				sbPara.Remove(0, sbPara.Length);
			}
			return rgsParas;
		}
Пример #17
0
		private bool StoreSource(IRnGenericRec rec, RnSfMarker rsf, string sData)
		{
			List<string> rgsHier = SplitForSubitems(rsf, sData);
			if (rgsHier == null || rgsHier.Count == 0)
			{
				ICmPerson def = rsf.m_tlo.m_default as ICmPerson;
				if (def != null && !rec.SourcesRC.Contains(def))
					rec.SourcesRC.Add(def);
				return true;
			}
			if (m_mapPeople.Count == 0)
				FillPossibilityMap(rsf, m_cache.LangProject.PeopleOA.PossibilitiesOS, m_mapPeople);
			ICmPossibility poss = FindPossibilityOrNull(rgsHier, m_mapPeople);
			if (poss != null)
			{
				if (!rec.SourcesRC.Contains(poss as ICmPerson))
					rec.SourcesRC.Add(poss as ICmPerson);
				return true;
			}
			else if (rsf.m_tlo.m_fIgnoreNewStuff)
			{
				return false;
			}
			else
			{
				ICmPerson item = CreateNewPerson(rgsHier);
				if (item != null)
					rec.SourcesRC.Add(item);
				return true;
			}
		}
Пример #18
0
		/// <summary>
		/// Store a value for either a simple formatted string or a multilingual string.
		/// </summary>
		private void SetStringValue(IRnGenericRec rec, RnSfMarker rsf, Sfm2Xml.SfmField field,
			CellarPropertyType cpt)
		{
			// REVIEW: SHOULD WE WORRY ABOUT EMBEDDED CHAR MAPPINGS THAT CHANGE THE WRITING SYSTEM
			// WHEN IT COMES TO ENCODING CONVERSION???
			ReconvertEncodedDataIfNeeded(field, rsf.m_sto.m_wsId);
			ITsString tss = MakeTsString(field.Data, rsf.m_sto.m_ws.Handle);
			switch (rsf.m_flid)
			{
				case RnGenericRecTags.kflidTitle:
					rec.Title = tss;
					break;
				default:
					// must be a custom field.
					Debug.Assert(rsf.m_flid >= (RnGenericRecTags.kClassId * 1000) + 500);
					switch (cpt)
					{
						case CellarPropertyType.MultiString:
						case CellarPropertyType.MultiUnicode:
							m_cache.DomainDataByFlid.SetMultiStringAlt(rec.Hvo, rsf.m_flid, rsf.m_sto.m_ws.Handle, tss);
							break;
						case CellarPropertyType.String:
							m_cache.DomainDataByFlid.SetString(rec.Hvo, rsf.m_flid, tss);
							break;
					}
					break;
			}
		}
Пример #19
0
		private bool StoreTimeOfEvent(IRnGenericRec rec, RnSfMarker rsf, string sData)
		{
			List<string> rgsHier = SplitForSubitems(rsf, sData);
			if (rgsHier == null || rgsHier.Count == 0)
			{
				if (rsf.m_tlo.m_default != null && !rec.TimeOfEventRC.Contains(rsf.m_tlo.m_default))
					rec.TimeOfEventRC.Add(rsf.m_tlo.m_default);
				return true;
			}
			if (m_mapTimeOfDay.Count == 0)
				FillPossibilityMap(rsf, m_cache.LangProject.TimeOfDayOA.PossibilitiesOS, m_mapTimeOfDay);
			ICmPossibility poss = FindPossibilityOrNull(rgsHier, m_mapTimeOfDay);
			if (poss != null)
			{
				if (!rec.TimeOfEventRC.Contains(poss))
					rec.TimeOfEventRC.Add(poss);
				return true;
			}
			else if (rsf.m_tlo.m_fIgnoreNewStuff)
			{
				return false;
			}
			else
			{
				ICmPossibility item = CreateNewTimeOfDay(rgsHier);
				if (item != null)
					rec.TimeOfEventRC.Add(item);
				return true;
			}
		}
Пример #20
0
		/// <summary>
		/// Store a value with a "kcptGenDate" type value.  Try to handle incomplete data if
		/// possible, since this value is typed by hand.  The user may have substituted
		/// question marks for the date, and may even the month.
		/// </summary>
		private void SetGenDateValue(IRnGenericRec rec, RnSfMarker rsf, Sfm2Xml.SfmField field)
		{
			string sData = field.Data.Trim();
			if (sData.Length == 0)
				return;		// nothing we can do without data!
			GenDate gdt;
			if (!TryParseGenDate(sData, rsf.m_dto.m_rgsFmt, out gdt))
			{
				LogMessage(String.Format(LexTextControls.ksCannotParseGenericDate, sData, field.Marker),
					field.LineNumber);
				return;
			}
			switch (rsf.m_flid)
			{
				case RnGenericRecTags.kflidDateOfEvent:
					rec.DateOfEvent = gdt;
					break;
				default:
					// must be a custom field.
					Debug.Assert(rsf.m_flid >= (RnGenericRecTags.kClassId * 1000) + 500);
					// There's no way to pass a GenDate item into a custom field!
					break;
			}
		}
Пример #21
0
		private bool StoreParticipant(IRnGenericRec rec, RnSfMarker rsf, string sData)
		{
			var partic = rec.ParticipantsOC.FirstOrDefault(part => part.RoleRA == null);
			if (partic == null)
			{
				partic = m_cache.ServiceLocator.GetInstance<IRnRoledParticFactory>().Create();
				rec.ParticipantsOC.Add(partic);
			}
			var rgsHier = SplitForSubitems(rsf, sData);
			if (rgsHier == null || rgsHier.Count == 0)
			{
				var def = rsf.m_tlo.m_default as ICmPerson;
				if (def != null && !partic.ParticipantsRC.Contains(def))
					partic.ParticipantsRC.Add(def);
				return true;
			}
			if (m_mapPeople.Count == 0)
				FillPossibilityMap(rsf, m_cache.LangProject.PeopleOA.PossibilitiesOS, m_mapPeople);
			var poss = FindPossibilityOrNull(rgsHier, m_mapPeople);
			if (poss != null)
			{
				if (!partic.ParticipantsRC.Contains(poss as ICmPerson))
					partic.ParticipantsRC.Add(poss as ICmPerson);
				return true;
			}
			if (!rsf.m_tlo.m_fIgnoreNewStuff)
			{
				var item = CreateNewPerson(rgsHier);
				if (item != null)
				{
					partic.ParticipantsRC.Add(item);
					return true;
				}
			}
			return false;
		}
Пример #22
0
		/// <summary>
		/// Store a value with a "kcptTime" type value.  These are less forgiving than those with
		/// "kcptGenDate" values, because they are generally created by a computer program instead
		/// of typed by a user.
		/// </summary>
		private void SetDateTimeValue(IRnGenericRec rec, RnSfMarker rsf, Sfm2Xml.SfmField field)
		{
			string sData = field.Data.Trim();
			if (sData.Length == 0)
				return;		// nothing we can do without data!
			DateTime dt;
			if (!DateTime.TryParseExact(sData, rsf.m_dto.m_rgsFmt.ToArray(), null, DateTimeStyles.None, out dt))
			{
				LogMessage(String.Format(LexTextControls.ksCannotParseDateTime, field.Data, field.Marker),
					field.LineNumber);
				return;
			}
			switch (rsf.m_flid)
			{
				case RnGenericRecTags.kflidDateCreated:
					rec.DateCreated = dt;
					break;
				case RnGenericRecTags.kflidDateModified:
					rec.DateModified = dt;
					break;
				default:
					// must be a custom field.
					Debug.Assert(rsf.m_flid >= (RnGenericRecTags.kClassId * 1000) + 500);
					SilTime.SetTimeProperty(m_cache.DomainDataByFlid, rec.Hvo, rsf.m_flid, dt);
					break;
			}
		}
Пример #23
0
		private static void FillPossibilityMap(RnSfMarker rsf, IFdoOwningSequence<ICmPossibility> seq,
			Dictionary<string, ICmPossibility> map)
		{
			if (seq == null || seq.Count == 0)
				return;
			bool fAbbrev = rsf.m_tlo.m_pnt == PossNameType.kpntAbbreviation;
			foreach (ICmPossibility poss in seq)
			{
				string sKey = fAbbrev ?
					poss.Abbreviation.AnalysisDefaultWritingSystem.Text :
					poss.Name.AnalysisDefaultWritingSystem.Text;
				if (String.IsNullOrEmpty(sKey))
					continue;
				sKey = sKey.ToLowerInvariant();
				if (map.ContainsKey(sKey))
					continue;
				map.Add(sKey, poss);
				FillPossibilityMap(rsf, poss.SubPossibilitiesOS, map);
			}
		}
Пример #24
0
		private void WriteMarkerContents(XmlWriter xw, RnSfMarker rsf)
		{
			switch (FieldType(rsf.m_flid))
			{
				case SfFieldType.DateTime:
					foreach (string sFmt in rsf.m_dto.m_rgsFmt)
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("DateFormat");
						xw.WriteAttributeString("value", sFmt);
						xw.WriteEndElement();
					}
					break;
				case SfFieldType.ListRef:
					if (!String.IsNullOrEmpty(rsf.m_tlo.m_sEmptyDefault))
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("Default");
						xw.WriteAttributeString("value", rsf.m_tlo.m_sEmptyDefault);
						xw.WriteEndElement();
					}
					xw.WriteWhitespace(Environment.NewLine);
					xw.WriteStartElement("Match");
					xw.WriteAttributeString("value",
						rsf.m_tlo.m_pnt == PossNameType.kpntName ? "name" : "abbr");
					xw.WriteEndElement();
					if (rsf.m_tlo.m_fHaveMulti)
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("Multiple");
						xw.WriteAttributeString("sep", rsf.m_tlo.m_sDelimMulti);
						xw.WriteEndElement();
					}
					if (rsf.m_tlo.m_fHaveSub)
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("Subchoice");
						xw.WriteAttributeString("sep", rsf.m_tlo.m_sDelimSub);
						xw.WriteEndElement();
					}
					if (rsf.m_tlo.m_fHaveBetween)
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("DelimitChoice");
						xw.WriteAttributeString("start", rsf.m_tlo.m_sMarkStart);
						xw.WriteAttributeString("end", rsf.m_tlo.m_sMarkEnd);
						xw.WriteEndElement();
					}
					if (rsf.m_tlo.m_fHaveBefore)
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("StopChoices");
						xw.WriteAttributeString("value", rsf.m_tlo.m_sBefore);
						xw.WriteEndElement();
					}
					if (rsf.m_tlo.m_fIgnoreNewStuff)
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("IgnoreNewChoices");
						xw.WriteAttributeString("value", "true");
						xw.WriteEndElement();
					}
					Debug.Assert(rsf.m_tlo.m_rgsMatch.Count == rsf.m_tlo.m_rgsReplace.Count);
					for (int j = 0; j < rsf.m_tlo.m_rgsMatch.Count; ++j)
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("MatchReplaceChoice");
						xw.WriteAttributeString("match", rsf.m_tlo.m_rgsMatch[j]);
						xw.WriteAttributeString("replace", rsf.m_tlo.m_rgsReplace[j]);
						xw.WriteEndElement();
					}
					if (!String.IsNullOrEmpty(rsf.m_tlo.m_wsId))
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("ItemWrtSys");
						xw.WriteAttributeString("ws", rsf.m_tlo.m_wsId);
						xw.WriteEndElement();
					}
					break;
				case SfFieldType.String:
					xw.WriteWhitespace(Environment.NewLine);
					xw.WriteStartElement("StringWrtSys");
					xw.WriteAttributeString("ws", rsf.m_sto.m_wsId);
					xw.WriteEndElement();
					break;
				case SfFieldType.Text:
					if (!String.IsNullOrEmpty(rsf.m_txo.m_sStyle))
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("TextStyle");
						xw.WriteAttributeString("value", rsf.m_txo.m_sStyle);
						xw.WriteEndElement();
					}
					xw.WriteWhitespace(Environment.NewLine);
					xw.WriteStartElement("StartPara");
					if (rsf.m_txo.m_fStartParaBlankLine)
						xw.WriteAttributeString("afterBlankLine", "true");
					if (rsf.m_txo.m_fStartParaIndented)
						xw.WriteAttributeString("forIndentedLine", "true");
					if (rsf.m_txo.m_fStartParaNewLine)
						xw.WriteAttributeString("forEachLine", "true");
					if (rsf.m_txo.m_fStartParaShortLine)
					{
						xw.WriteAttributeString("afterShortLine", "true");
						xw.WriteAttributeString("shortLineLim", rsf.m_txo.m_cchShortLim.ToString());
					}
					xw.WriteEndElement();
					if (!String.IsNullOrEmpty(rsf.m_txo.m_wsId))
					{
						xw.WriteWhitespace(Environment.NewLine);
						xw.WriteStartElement("DefaultParaWrtSys");
						xw.WriteAttributeString("ws", rsf.m_txo.m_wsId);
						xw.WriteEndElement();
					}
					break;
				case SfFieldType.Link:
					break;
			}
		}