private void m_btnInsert_Click(object sender, System.EventArgs e) { IVwSelection sel = m_view.RootBox.Selection; if (sel == null) { return; } string undo; string redo; ResourceHelper.MakeUndoRedoLabels("kstidUndoRedoInsertRelatedWord", out undo, out redo); using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(m_cache.MainCacheAccessor, m_view.RootBox.Site != null ? m_view.RootBox.Site : null, undo, redo, true)) { ITsString tss; sel.GetSelectionString(out tss, ""); m_sel.ReplaceWithTsString(tss); // TE-5754: The selection is not the installed selection so the commits that happen // as part of the data monitoring process are not committed to the database. We have // to perform an explicit commit on the selection. m_sel.Commit(); } }
private void m_btnInsert_Click(object sender, System.EventArgs e) { IVwSelection sel = m_view.RootBox.Selection; if (sel == null) { return; } string undo; string redo; ResourceHelper.MakeUndoRedoLabels("kstidUndoRedoInsertRelatedWord", out undo, out redo); using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(m_cache.ActionHandlerAccessor, m_view.RootBox.Site, undo, redo)) { ITsString tss; sel.GetSelectionString(out tss, ""); m_sel.ReplaceWithTsString(tss); undoTaskHelper.RollBack = false; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Perform a single instance of a text replace /// </summary> /// <param name="sel">The current (new) selection in the view where we just did a find. /// Presumably, this matches the Find Text string.</param> /// <param name="tssReplace">The tss string that the user entered in the Replace box /// </param> /// <param name="fUseWS"></param> /// <param name="fEmptySearch"></param> /// <remarks>TODO TE-973: searching for writing systems.</remarks> /// ------------------------------------------------------------------------------------ protected void DoReplacement(IVwSelection sel, ITsString tssReplace, bool fUseWS, bool fEmptySearch) { // Get the properties we will apply, except for the writing system/ows and/or sStyleName. ITsString tssSel; bool fGotItAll; sel.GetFirstParaString(out tssSel, " ", out fGotItAll); if (!fGotItAll) return; // desperate defensive programming. // Get ORCs from selection so that they can be appended after the text has been replaced. ITsStrBldr stringBldr = tssSel.GetBldr(); ReplaceAllCollectorEnv.ReplaceString(stringBldr, tssSel, 0, tssSel.Length, tssReplace, 0, fEmptySearch, fUseWS); // finally - do the replacement sel.ReplaceWithTsString( stringBldr.GetString().get_NormalizedForm(FwNormalizationMode.knmNFD)); }