Beispiel #1
0
		readonly int m_ws; // if m_flid is multilingual, ws of alternative; otherwise, zero.

		public ParaChangeInfo(RespellUndoAction action, int hvoTarget, int flid, int ws)
		{
			m_action = action;
			m_hvoTarget = hvoTarget;
			m_flid = flid;
			m_ws = ws;
		}
Beispiel #2
0
		private void MakeUndoAction()
		{
			m_respellUndoaction = new RespellUndoAction(
				m_specialSda,
				m_cache,
				m_vernWs,
				m_srcwfiWordform.Form.get_String(m_vernWs).Text,
				m_cbNewSpelling.Text)
									{
										PreserveCase = m_cbMaintainCase.Checked
									};
			var tagEnabled = m_sourceSentences.BrowseViewer.PreviewEnabledTag;
			foreach (int hvo in m_sourceSentences.BrowseViewer.CheckedItems)
			{
				if (m_specialSda.get_IntProp(hvo, tagEnabled) == 1)
					m_respellUndoaction.AddOccurrence(hvo);
			}
		}
Beispiel #3
0
		private void m_btnApply_Click(object sender, EventArgs e)
		{
			if (m_sourceSentences.CheckedItems.Count <= 0)
				return;

			using (new WaitCursor(this))
			{
				// NB: occurrence may ref. wf, anal, or gloss.
				// NB: Need to support selective spelling change.
				//	(gunaa->gwnaa when it means woman, but not for gu-naa, IMP+naa)
				if (m_respellUndoaction == null)
					MakeUndoAction();
				bool someWillChange;
				if (AllWillChange(out someWillChange))
				{
					// No point in letting the user think they can make more changes.
					m_cbNewSpelling.Enabled = false;

					m_respellUndoaction.AllChanged = true;
					m_respellUndoaction.KeepAnalyses = !m_rbDiscardAnalyses.Checked;
					m_respellUndoaction.UpdateLexicalEntries = m_cbUpdateLexicon.Checked;
				}
				else
				{
					m_respellUndoaction.CopyAnalyses = m_cbCopyAnalyses.Checked;
				}

				m_respellUndoaction.DoIt(m_mediator);

				// On the other hand, we don't want to update the new wordform until after DoIt...it might not exist before,
				// and we won't be messing up any existing occurrences.
				m_mediator.SendMessage("ItemDataModified", m_cache.ServiceLocator.GetObject(m_respellUndoaction.NewWordform));

				ChangesWereMade = true;


				// Reloads the conc. virtual prop for the old wordform,
				// so the old values are removed.
				// This will allow .CanDelete' to return true.
				// Otherwise, it won't be deletable,
				// as it will still have those occurrences pointing at it.
				//FirePropChanged(m_srcwfiWordform.Hvo);
				//UpdateDisplay();
				m_respellUndoaction.RemoveChangedItems(m_enabledItems, m_sourceSentences.BrowseViewer.PreviewEnabledTag);
				// If everything changed remember the new wordform.
				if (m_respellUndoaction.AllChanged)
					m_hvoNewWordform = m_respellUndoaction.NewWordform;
				if (m_previewOn)
					EnsurePreviewOff(); // will reconstruct
				else
				{
					m_respellUndoaction = null; // Make sure we use a new one for any future previews or Apply's.
					m_sourceSentences.BrowseViewer.ReconstructView(); // ensure new offsets used.
				}
				SetEnabledState();
			}
		}
Beispiel #4
0
		private void MakeUndoAction()
		{
			m_respellUndoaction = new RespellUndoAction(m_cache, m_vernWs, m_srcwfiWordform.Form.GetAlternativeTss(m_vernWs).Text,
				m_cbNewSpelling.Text);
			m_respellUndoaction.PreserveCase = m_cbMaintainCase.Checked;
			int tagEnabled = m_sourceSentences.BrowseViewer.PreviewEnabledTag;
			foreach (int hvo in m_sourceSentences.BrowseViewer.CheckedItems)
			{
				if (m_cache.GetIntProperty(hvo, tagEnabled) == 1)
					m_respellUndoaction.AddOccurrence(hvo);
			}
		}
Beispiel #5
0
		void m_btnPreviewClear_Click(object sender, EventArgs e)
		{
			if (m_previewOn)
			{
				m_previewOn = false;
				m_sourceSentences.BrowseViewer.PreviewColumn = -1;
				m_sourceSentences.BrowseViewer.ReplaceColumn("Occurrence", m_oldOccurrenceColumn);
				m_btnPreviewClear.Text = m_previewButtonText;
				m_respellUndoaction = null;
			}
			else
			{
				m_previewOn = true;
				var previewTag = m_sourceSentences.BrowseViewer.PreviewValuesTag;
				// Initialize PrecedingContext etc for each occurrence (text up to and including old spelling)
				MakeUndoAction();
				m_respellUndoaction.SetupPreviews(RespellingSda.kflidSpellingPreview,
					previewTag,
					RespellingSda.kflidAdjustedBeginOffset,
					RespellingSda.kflidAdjustedEndOffset,
					m_sourceSentences.BrowseViewer.PreviewEnabledTag,
					m_sourceSentences.BrowseViewer.AllItems,
					m_sourceSentences.BrowseViewer.BrowseView.RootBox);
				// Create m_previewOccurrenceColumn if needed
				EnsurePreviewColumn();
				m_oldOccurrenceColumn = m_sourceSentences.BrowseViewer.ReplaceColumn("Occurrence", m_previewOccurrenceColumn);
				m_previewButtonText = m_btnPreviewClear.Text;
				m_btnPreviewClear.Text = MEStrings.ksClear;
			}
		}
Beispiel #6
0
		/// <summary>
		/// Figure what the new contents needs to be. (Also sets OldContents.)
		/// </summary>
		/// <param name="cache"></param>
		public void MakeNewContents(FdoCache cache, string oldSpelling, string newSpelling, RespellUndoAction action)
		{
			m_oldContents = RespellUndoAction.AnnotationTargetString(m_hvoTarget, m_flid, m_ws, cache);
			ITsStrBldr bldr = m_oldContents.GetBldr();
			SortChanges(cache);
			for (int i = m_changes.Count - 1; i >= 0; i--)
			{
				int ichMin = cache.GetIntProperty(m_changes[i], (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset);
				int ichLim = cache.GetIntProperty(m_changes[i], (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidEndOffset);
				string replacement = action.Replacement(action.OldOccurrence(m_changes[i]));
				bldr.Replace(ichMin, ichLim, replacement, null);
			}
			m_newContents = bldr.GetString();
		}
Beispiel #7
0
		void m_btnPreviewClear_Click(object sender, EventArgs e)
		{
			if (m_previewOn)
			{
				m_previewOn = false;
				m_sourceSentences.BrowseViewer.PreviewColumn = -1;
				m_sourceSentences.BrowseViewer.ReplaceColumn("Occurrence", m_oldOccurrenceColumn);
				m_btnPreviewClear.Text = m_previewButtonText;
				m_respellUndoaction = null;
			}
			else
			{
				m_previewOn = true;
				int previewTag = m_sourceSentences.BrowseViewer.PreviewValuesTag;
				// Create dummy virtual properties as needed by the SpellingPreview Occurrences column
				int adjustedBeginTag = DummyVirtualHandler.InstallDummyHandler(m_cache.VwCacheDaAccessor,
					"CmBaseAnnotation", "AdjustedBeginOffset", (int)CellarModuleDefns.kcptInteger).Tag;
				int adjustedEndTag = DummyVirtualHandler.InstallDummyHandler(m_cache.VwCacheDaAccessor,
					"CmBaseAnnotation", "AdjustedEndOffset", (int)CellarModuleDefns.kcptInteger).Tag;
				int spellingPreviewTag = DummyVirtualHandler.InstallDummyHandler(m_cache.VwCacheDaAccessor,
					"CmBaseAnnotation", "SpellingPreview", (int)CellarModuleDefns.kcptString).Tag;
				// Initialize PrecedingContext etc for each occurrence (text up to and including old spelling)
				MakeUndoAction();
				m_respellUndoaction.SetupPreviews(spellingPreviewTag, previewTag, adjustedBeginTag, adjustedEndTag,
					m_sourceSentences.BrowseViewer.PreviewEnabledTag,
					m_sourceSentences.BrowseViewer.AllItems);
				// Create m_previewOccurrenceColumn if needed
				EnsurePreviewColumn();
				m_oldOccurrenceColumn = m_sourceSentences.BrowseViewer.ReplaceColumn("Occurrence", m_previewOccurrenceColumn);
				m_previewButtonText = m_btnPreviewClear.Text;
				m_btnPreviewClear.Text = MEStrings.ksClear;
			}
		}
Beispiel #8
0
		private void AddAllOccurrences(RespellUndoAction action, List<int> occurrences)
		{
			foreach (int hvo in occurrences)
				action.AddOccurrence(hvo);
		}
Beispiel #9
0
		public void ApplyAllAndKeepAnalyses()
		{
			MakeMonoAnalyses();
			MakeMultiAnalyses();
			RespellUndoAction action = new RespellUndoAction(Cache, "axx", "byy");
			AddAllOccurrences(action, m_para1Occurrences);
			AddAllOccurrences(action, m_para2Occurrences);
			action.AllChanged = true;
			action.KeepAnalyses = true;
			action.DoIt();
			VerifyDoneStateApplyAllAndKeepAnalyses();
			Assert.IsTrue(m_fdoCache.CanUndo, "undo should be possible after respelling");
			UndoResult ures;
			m_fdoCache.Undo(out ures);
			VerifyStartingState();
			m_fdoCache.Redo(out ures);
			VerifyDoneStateApplyAllAndKeepAnalyses();
		}
Beispiel #10
0
		public void ApplyTwoAndCopyAnalyses()
		{
			MakeMonoAnalyses();
			MakeMultiAnalyses();
			// Makes one more analysis, which (having no human approval) should NOT get copied.
			m_wfAxx.AnalysesOC.Add(new WfiAnalysis());
			m_cAnalyses++;

			RespellUndoAction action = new RespellUndoAction(Cache, "axx", "ayyy");
			action.AddOccurrence(m_para2Occurrences[1]);
			action.AddOccurrence(m_para2Occurrences[2]);
			action.CopyAnalyses = true;
			action.DoIt();
			VerifyDoneStateApplyTwoAndCopyAnalyses();
			Assert.IsTrue(m_fdoCache.CanUndo, "undo should be possible after respelling");
			UndoResult ures;
			m_fdoCache.Undo(out ures);
			VerifyStartingState();
			m_fdoCache.Redo(out ures);
			VerifyDoneStateApplyTwoAndCopyAnalyses();
		}
Beispiel #11
0
		public void ApplyTwo()
		{
			RespellUndoAction action = new RespellUndoAction(Cache, "axx", "ayyy");
			action.AddOccurrence(m_para2Occurrences[1]);
			action.AddOccurrence(m_para2Occurrences[2]);
			action.DoIt();
			VerifyDoneStateApplyTwo();
			Assert.IsTrue(m_fdoCache.CanUndo, "undo should be possible after respelling");
			UndoResult ures;
			m_fdoCache.Undo(out ures);
			VerifyStartingState();
			m_fdoCache.Redo(out ures);
			VerifyDoneStateApplyTwo();
		}
Beispiel #12
0
		public void PreserveCase()
		{
			Assert.AreEqual(6, m_axxOccurrences.Count);
			int ich2ndOcc = Cache.GetIntProperty(m_para1Occurrences[1], kflidBeginOffset);
			RespellUndoAction action = new RespellUndoAction(Cache, "axx", "ayyy");
			action.AddOccurrence(m_para1Occurrences[0]);
			action.AddOccurrence(m_para1Occurrences[1]);
			action.SetupPreviews(tagPrecedingContext, tagPreview, tagAdjustedBegin, tagAdjustedEnd, tagEnabled, m_axxOccurrences);
			Assert.AreEqual("Axx", Cache.GetTsStringProperty(m_para1Occurrences[0], tagPrecedingContext).Text,
				"Old value at start without preserve case");
			Assert.AreEqual("ayyy simplexx testxx withxx axx", Cache.GetTsStringProperty(m_para1Occurrences[1], tagPrecedingContext).Text,
				"Preceding context without preserve case has LC");
			action.PreserveCase = true;
			action.UpdatePreviews();
			Assert.AreEqual("Axx", Cache.GetTsStringProperty(m_para1Occurrences[0], tagPrecedingContext).Text,
				"Old value at start with preserver case");
			Assert.AreEqual("Ayyy simplexx testxx withxx axx", Cache.GetTsStringProperty(m_para1Occurrences[1], tagPrecedingContext).Text,
				"Preceding context with preserve case has UC");
		}
Beispiel #13
0
		public void Previews()
		{
			Assert.AreEqual(6, m_axxOccurrences.Count);
			int ich2ndOcc = Cache.GetIntProperty(m_para2Occurrences[1], kflidBeginOffset);
			int ich3rdOcc = Cache.GetIntProperty(m_para2Occurrences[2], kflidBeginOffset);
			RespellUndoAction action = new RespellUndoAction(Cache, "axx", "ayyy");
			action.AddOccurrence(m_para2Occurrences[1]);
			action.AddOccurrence(m_para2Occurrences[2]);
			action.SetupPreviews(tagPrecedingContext, tagPreview, tagAdjustedBegin, tagAdjustedEnd, tagEnabled, m_axxOccurrences);
			Assert.AreEqual(m_para1.Contents.Text, Cache.GetTsStringProperty(m_para1Occurrences[1], tagPrecedingContext).Text,
				"Unselected occurrences should have unchanged previews");
			Assert.AreEqual(0, Cache.GetIntProperty(m_para1Occurrences[0], tagAdjustedBegin),
				"Unselected occurrences should still have adjustedBegin set");
			Assert.AreEqual(3, Cache.GetIntProperty(m_para1Occurrences[0], tagAdjustedEnd),
				"Unselected occurrences should still have adjustedEnd set");
			AssertTextProp(m_para1Occurrences[0], tagPrecedingContext, 0, RespellUndoAction.SecondaryTextProp, -1, "prop should not be set on unchanged occurrence");

			Assert.AreEqual("axx sentencexx axx", Cache.GetTsStringProperty(m_para2Occurrences[1], tagPrecedingContext).Text,
				"First occurrence should have only part of para 2");
			Assert.AreEqual(ich2ndOcc, Cache.GetIntProperty(m_para2Occurrences[1], tagAdjustedBegin),
				"First occurrence in para has no begin adjustment");
			Assert.AreEqual(ich2ndOcc + 3, Cache.GetIntProperty(m_para2Occurrences[1], tagAdjustedEnd),
				"First occurrence in para has no end adjustment");
			Assert.AreEqual("ayyy havingxx ayyy lotxx ofxx axx", Cache.GetTsStringProperty(m_para2Occurrences[1], tagPreview).Text,
				"First occurrence should have correct following context");
			AssertTextProp(m_para2Occurrences[1], tagPrecedingContext, 0, RespellUndoAction.SecondaryTextProp, -1, "prop should not be set on unchanged occurrence- 2");
			AssertTextProp(m_para2Occurrences[1], tagPrecedingContext, 5, RespellUndoAction.SecondaryTextProp, -1, "prop should not be set on other words");
			AssertTextProp(m_para2Occurrences[1], tagPreview, "ayyy havingxx ".Length, RespellUndoAction.SecondaryTextProp,
				RespellUndoAction.SecondaryTextVal, "prop should be set on changed occurrence in Preview");
			AssertTextProp(m_para2Occurrences[1], tagPreview, "ayyy havingxx ".Length - 1, RespellUndoAction.SecondaryTextProp,
				-1, "prop should not be set on other text in Preview");
			AssertTextProp(m_para2Occurrences[1], tagPreview, "ayyy havingxx ".Length + 4, RespellUndoAction.SecondaryTextProp,
				-1, "prop should not be set on other text in Preview");
			AssertTextProp(m_para2Occurrences[1], tagPreview, "ayyy havingxx ayyy lotxx ofxx a".Length, RespellUndoAction.SecondaryTextProp,
				-1, "prop should not be set on unchanged occurrence in Preview");
			AssertTextProp(m_para2Occurrences[1], tagPreview, 0, (int)FwTextPropType.ktptBold,
				(int)FwTextToggleVal.kttvForceOn, "bold should be set at start of preview");
			AssertTextProp(m_para2Occurrences[1], tagPreview, 4, (int)FwTextPropType.ktptBold,
				-1, "bold should not be set except on changed word");
			// no longer action responsibility. Assert.IsTrue(Cache.GetIntProperty(m_para2Occurrences[1], tagEnabled) != 0);

			Assert.AreEqual("axx sentencexx ayyy havingxx axx", Cache.GetTsStringProperty(m_para2Occurrences[2], tagPrecedingContext).Text,
				"Second occurrence should have more of para 2 with first occurrence corrected");
			Assert.AreEqual(ich3rdOcc + 1, Cache.GetIntProperty(m_para2Occurrences[2], tagAdjustedBegin),
				"Second occurrence in para has begin adjustment");
			Assert.AreEqual(ich3rdOcc + 1 + 3, Cache.GetIntProperty(m_para2Occurrences[2], tagAdjustedEnd),
				"Second occurrence in para has end adjustment");
			Assert.AreEqual("ayyy lotxx ofxx axx", Cache.GetTsStringProperty(m_para2Occurrences[2], tagPreview).Text,
				"Second occurrence should have correct following context");
			AssertTextProp(m_para2Occurrences[2], tagPrecedingContext, 0, RespellUndoAction.SecondaryTextProp, -1, "prop should not be set on unchanged occurrence- 3");
			AssertTextProp(m_para2Occurrences[2], tagPrecedingContext, "axx sentencexx a".Length, RespellUndoAction.SecondaryTextProp,
				RespellUndoAction.SecondaryTextVal, "prop should be set on changed occurrence in preceding context");
			AssertTextProp(m_para2Occurrences[2], tagPrecedingContext, "axx sentencexx".Length, RespellUndoAction.SecondaryTextProp,
				-1, "prop should not be set on other text in preceding context");
			AssertTextProp(m_para2Occurrences[2], tagPrecedingContext, "axx sentencexx ayyy".Length, RespellUndoAction.SecondaryTextProp,
				-1, "prop should not be set on other text in preceding context - 2");
			AssertTextProp(m_para2Occurrences[2], tagPreview, 0, (int)FwTextPropType.ktptBold,
				(int)FwTextToggleVal.kttvForceOn, "bold should be set at start of preview - 2");
			AssertTextProp(m_para2Occurrences[2], tagPreview, 4, (int)FwTextPropType.ktptBold,
				-1, "bold should not be set except on changed word - 2");

			Assert.AreEqual("axx sentencexx ayyy havingxx ayyy lotxx ofxx axx", Cache.GetTsStringProperty(m_para2Occurrences[3], tagPrecedingContext).Text,
				"Unselected occurrences should have full-length preview");
			Assert.AreEqual("axx sentencexx axx havingxx axx lotxx ofxx ".Length + 2, Cache.GetIntProperty(m_para2Occurrences[3], tagAdjustedBegin),
				"Unselected occurrences after changed ones should have adjusted begin");
			Assert.AreEqual("axx sentencexx axx havingxx axx lotxx ofxx ".Length + 2 + 3, Cache.GetIntProperty(m_para2Occurrences[3], tagAdjustedEnd),
				"Unselected occurrences after changed ones should have adjustedEnd set");

			//-----------------------------------------------------------------------------------
			// This is rather a 'greedy' test, but tests on the real database are expensive.
			// Now we want to try changing the status of an occurrence to see whether it updates correctly.
			action.UpdatePreview(m_para2Occurrences[0], true);
			Assert.AreEqual("axx", Cache.GetTsStringProperty(m_para2Occurrences[0], tagPrecedingContext).Text,
				"Newly selected item at start of sentence has null preceding context");
			Assert.AreEqual("ayyy sentencexx ayyy havingxx ayyy lotxx ofxx axx", Cache.GetTsStringProperty(m_para2Occurrences[0], tagPreview).Text,
				"After select at start occ(0) should have correct preview");
			AssertTextProp(m_para2Occurrences[0], tagPreview, 0, (int)FwTextPropType.ktptBold,
				(int)FwTextToggleVal.kttvForceOn, "After select at start occ(0) bold should be set at start of preview");
			AssertTextProp(m_para2Occurrences[0], tagPreview, 4, (int)FwTextPropType.ktptBold,
				-1, "After select at start occ(0) bold should not be set except on changed word");

			Assert.AreEqual("ayyy sentencexx axx", Cache.GetTsStringProperty(m_para2Occurrences[1], tagPrecedingContext).Text,
				"After select at start occ(1) should have new preceding context.");
			Assert.AreEqual(ich2ndOcc + 1, Cache.GetIntProperty(m_para2Occurrences[1], tagAdjustedBegin),
				"After select at start occ(1) should have changed begin adjustment");
			Assert.AreEqual(ich2ndOcc + 4, Cache.GetIntProperty(m_para2Occurrences[1], tagAdjustedEnd),
				"After select at start occ(1) should have changed end adjustment");
			Assert.AreEqual("ayyy havingxx ayyy lotxx ofxx axx", Cache.GetTsStringProperty(m_para2Occurrences[1], tagPreview).Text,
				"After select at start occ(1) should have correct following context");
			AssertTextProp(m_para2Occurrences[1], tagPrecedingContext, 0, RespellUndoAction.SecondaryTextProp,
				RespellUndoAction.SecondaryTextVal, "after select at start prop should be set on initial (new) occurrence");
			AssertTextProp(m_para2Occurrences[1], tagPrecedingContext, 5, RespellUndoAction.SecondaryTextProp, -1,
				"after select at start prop should not be set on other words");
			AssertTextProp(m_para2Occurrences[1], tagPreview, "ayyy havingxx ".Length, RespellUndoAction.SecondaryTextProp,
				RespellUndoAction.SecondaryTextVal, "after select at start prop should be set on changed occurrence in Preview");
			AssertTextProp(m_para2Occurrences[1], tagPreview, "ayyy havingxx ".Length - 1, RespellUndoAction.SecondaryTextProp,
				-1, "after select at start prop should not be set on other text in Preview");
			// no longer action responsibilty. Assert.IsTrue(Cache.GetIntProperty(m_para2Occurrences[1], tagEnabled) != 0);
			Assert.AreEqual(ich3rdOcc + 2, Cache.GetIntProperty(m_para2Occurrences[2], tagAdjustedBegin),
				"After one change occ(2) should have appropriate begin adjustment");
			Assert.AreEqual(ich3rdOcc + 2 + 3, Cache.GetIntProperty(m_para2Occurrences[2], tagAdjustedEnd),
				"After one change occ(2) should have appropriate end adjustment");

			//------------------------------------------------------------------------
			// And now try turning one off.
			action.UpdatePreview(m_para2Occurrences[1], false);
			Assert.AreEqual("ayyy sentencexx axx havingxx ayyy lotxx ofxx axx", Cache.GetTsStringProperty(m_para2Occurrences[1], tagPrecedingContext).Text,
				"Turned-off occurrence should have full-length preview");
			Assert.AreEqual("ayyy sentencexx ".Length, Cache.GetIntProperty(m_para2Occurrences[1], tagAdjustedBegin),
				"Turned-off occurrence should still have adjusted begin");
			Assert.AreEqual("ayyy sentencexx axx havingxx axx", Cache.GetTsStringProperty(m_para2Occurrences[2], tagPrecedingContext).Text,
				"After two changes occ(2) should have appropriate preceding context");
			Assert.AreEqual(ich3rdOcc + 1, Cache.GetIntProperty(m_para2Occurrences[2], tagAdjustedBegin),
				"After two changes occ(2) should have appropriate begin adjustment");
			Assert.AreEqual(ich3rdOcc + 1 + 3, Cache.GetIntProperty(m_para2Occurrences[2], tagAdjustedEnd),
				"After two changes occ(2) should have appropriate end adjustment");

		}
Beispiel #14
0
		private RespellUndoAction SetUpParaAndRespellUndoAction_MultiMorphemic(string sParaText,
			string sWordToReplace, string sNewWord, string[] morphsToCreate, int clidPara,
			out IStTxtPara para)
		{
			List<IParaFragment> paraFrags = new List<IParaFragment>();
			IStTxtPara paraT = null;
			IStText stText = null;
			UndoableUnitOfWorkHelper.Do("Undo create book", "Redo create book", m_actionHandler, () =>
			{
				var lp = Cache.LanguageProject;
				if (clidPara == ScrTxtParaTags.kClassId)
				{
					IScrBook book = Cache.ServiceLocator.GetInstance<IScrBookFactory>().Create(1, out stText);
					paraT = Cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle(stText, "Monkey");
					paraT.Contents = TsStringUtils.MakeTss(sParaText, Cache.DefaultVernWs);
					object owner = ReflectionHelper.CreateObject("FDO.dll", "SIL.FieldWorks.FDO.Infrastructure.Impl.CmObjectId", BindingFlags.NonPublic,
						new object[] { book.Guid });
					ReflectionHelper.SetField(stText, "m_owner", owner);
				}
				else
				{
					var proj = Cache.LangProject;
					var text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create();
					stText = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
					text.ContentsOA = stText;
					paraT = Cache.ServiceLocator.GetInstance<IStTxtParaFactory>().Create();
					stText.ParagraphsOS.Add(paraT);
					paraT.Contents = TsStringUtils.MakeTss(sParaText, Cache.DefaultVernWs);
				}
				foreach (ISegment seg in paraT.SegmentsOS)
				{
					FdoTestHelper.CreateAnalyses(seg, paraT.Contents, seg.BeginOffset, seg.EndOffset, true);
					var thisSegParaFrags = GetParaFragmentsInSegmentForWord(seg, sWordToReplace);
					SetMultimorphemicAnalyses(thisSegParaFrags, morphsToCreate);
					paraFrags.AddRange(thisSegParaFrags);
				}
			});

			var rsda = new RespellingSda((ISilDataAccessManaged)Cache.MainCacheAccessor, null, Cache.ServiceLocator);
			InterestingTextList dummyTextList = MockRepository.GenerateStub<InterestingTextList>(null, Cache.ServiceLocator.GetInstance<ITextRepository>(),
			Cache.ServiceLocator.GetInstance<IStTextRepository>());
			if (clidPara == ScrTxtParaTags.kClassId)
				dummyTextList.Stub(tl => tl.InterestingTexts).Return(new IStText[0]);
			else
				dummyTextList.Stub(t1 => t1.InterestingTexts).Return(new IStText[1] { stText });
			ReflectionHelper.SetField(rsda, "m_interestingTexts", dummyTextList);
			rsda.SetCache(Cache);
			rsda.SetOccurrences(0, paraFrags);
			ObjectListPublisher publisher = new ObjectListPublisher(rsda, kObjectListFlid);
			XMLViewsDataCache xmlCache = MockRepository.GenerateStub<XMLViewsDataCache>(publisher, true, new Dictionary<int, int>());

			xmlCache.Stub(c => c.get_IntProp(paraT.Hvo, CmObjectTags.kflidClass)).Return(ScrTxtParaTags.kClassId);
			xmlCache.Stub(c => c.VecProp(Arg<int>.Is.Anything, Arg<int>.Is.Anything)).Do(new Func<int, int, int[]>(publisher.VecProp));
			xmlCache.MetaDataCache = new RespellingMdc((IFwMetaDataCacheManaged)Cache.MetaDataCacheAccessor);
			xmlCache.Stub(c => c.get_ObjectProp(Arg<int>.Is.Anything, Arg<int>.Is.Anything)).Do(new Func<int, int, int>(publisher.get_ObjectProp));
			xmlCache.Stub(c => c.get_IntProp(Arg<int>.Is.Anything, Arg<int>.Is.Anything)).Do(new Func<int, int, int>(publisher.get_IntProp));

			var respellUndoaction = new RespellUndoAction(xmlCache, Cache, Cache.DefaultVernWs, sWordToReplace, sNewWord);
			foreach (int hvoFake in rsda.VecProp(0, ConcDecorator.kflidConcOccurrences))
				respellUndoaction.AddOccurrence(hvoFake);

			para = paraT;
			return respellUndoaction;
		}