public bool Redo() { if (m_rootb != null && m_dataAccess != null) { SpellingHelper.SetSpellingStatus(m_word, m_wsText, m_dataAccess.WritingSystemFactory, true); m_rootb.PropChanged(m_hvoObj, m_tag, m_wsAlt, 1, 1); return(true); } return(false); }
// Simiulate inserting and deleting the paragraph to get it redisplayed. private static void UpdateDisplayOfPara(IStTxtPara para, IVwRootBox sourceRootBox) { if (sourceRootBox != null) { sourceRootBox.PropChanged(para.Owner.Hvo, para.OwningFlid, para.IndexInOwner, 1, 1); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public void DoIt() { m_rootb.DataAccess.BeginUndoTask(RootSiteStrings.ksUndoCorrectSpelling, RootSiteStrings.ksRedoSpellingChange); ITsString tssInput; if (m_wsAlt == 0) { tssInput = m_rootb.DataAccess.get_StringProp(m_hvoObj, m_tag); } else { tssInput = m_rootb.DataAccess.get_MultiStringAlt(m_hvoObj, m_tag, m_wsAlt); } ITsStrBldr bldr = tssInput.GetBldr(); bldr.ReplaceTsString(m_ichMin, m_ichLim, m_tssReplacement); if (m_wsAlt == 0) { m_rootb.DataAccess.SetString(m_hvoObj, m_tag, bldr.GetString()); } else { m_rootb.DataAccess.SetMultiStringAlt(m_hvoObj, m_tag, m_wsAlt, bldr.GetString()); } m_rootb.PropChanged(m_hvoObj, m_tag, m_wsAlt, 1, 1); m_rootb.DataAccess.EndUndoTask(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Reverses (or "un-does") an action. /// </summary> /// ------------------------------------------------------------------------------------ public override bool Undo() { Debug.Assert(m_paraHvo != 0); m_updatedPrompts.Remove(m_updatePropHvo); // Do a fake propchange to update the prompt m_rootbox.PropChanged(m_paraHvo, StParaTags.kflidStyleRules, 0, 1, 1); return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add the current word to the dictionary. /// </summary> /// ------------------------------------------------------------------------------------ public void AddWordToDictionary() { m_rootb.DataAccess.BeginUndoTask(RootSiteStrings.ksUndoAddToSpellDictionary, RootSiteStrings.ksRedoAddToSpellDictionary); if (m_rootb.DataAccess.GetActionHandler() != null) { m_rootb.DataAccess.GetActionHandler().AddAction(new UndoAddToSpellDictAction(m_wsText, m_word, m_rootb, m_hvoObj, m_tag, m_wsAlt)); } AddToSpellDict(m_dict, m_word, m_wsText); m_rootb.PropChanged(m_hvoObj, m_tag, m_wsAlt, 1, 1); m_rootb.DataAccess.EndUndoTask(); }
// Simiulate inserting and deleting the paragraph to get it redisplayed. private static void UpdateDisplayOfPara(IStTxtPara para, IVwRootBox sourceRootBox) { if (sourceRootBox != null) sourceRootBox.PropChanged(para.Owner.Hvo, para.OwningFlid, para.IndexInOwner, 1, 1); }
public bool Undo() { CacheObject(m_Before); RootBox.PropChanged(m_Before.Hvo, m_Before.Flid, 0, 1000, 1000); return(true); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Replace the user prompt with the text the user typed. This method is called from /// the views code when the user prompt is edited. /// </summary> /// <param name="vwsel">Current selection in rootbox where this prop was updated</param> /// <param name="hvo">Hvo of the paragraph/string/segment whose contents are being /// changed</param> /// <param name="tag">Tag (must be SimpleRootSite.kTagUserPrompt)</param> /// <param name="frag">Owning flid of the text/object that owns the paragraph/string/ /// segment whose user prompt is being replaced with typed text</param> /// <param name="tssVal">Text the user just typed</param> /// <returns>possibly modified ITsString.</returns> /// <remarks>The return value is currently ignored in production code, but we use it /// in our tests.</remarks> /// ----------------------------------------------------------------------------------- public override ITsString UpdateProp(IVwSelection vwsel, int hvo, int tag, int frag, ITsString tssVal) { Debug.Assert(tag == SimpleRootSite.kTagUserPrompt, "Got an unexpected tag"); Debug.Assert(vwsel != null, "Got a null selection!"); Debug.Assert(vwsel.IsValid, "Got an invalid selection!"); IVwRootBox rootbox = vwsel.RootBox; // If a (typically Chinese) character composition is in progress, replacing the prompt will // destroy the selection and end the composition, causing weird typing problems (TE-8267). // Ending the composition does another Commit, which ensures that this will eventually be // called when there is NOT a composition in progress. if (rootbox.IsCompositionInProgress) { return(tssVal); } // Remove the UserPrompt pseudo-property from the text the user typed. // when appropriate also ensure the correct writing system. // The correct WS is m_wsDefault in the view constructor ITsStrBldr bldr = tssVal.GetBldr(); if (frag != SegmentTags.kflidFreeTranslation) { bldr.SetIntPropValues(0, bldr.Length, (int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, m_wsDefault); } // Delete the user prompt property from the string (TE-3994) bldr.SetIntPropValues(0, bldr.Length, SimpleRootSite.ktptUserPrompt, -1, -1); tssVal = bldr.GetString(); // Get information about current selection int cvsli = vwsel.CLevels(false); cvsli--; // CLevels includes the string property itself, but AllTextSelInfo doesn't need it. int ihvoRoot; int tagTextProp_Ignore; int cpropPrevious; int ichAnchor; int ichEnd; int ihvoEnd; // Prior to the Commit in selection changed which causes this UpdateProp to be called, // earlier selection changed code has expanded the selection (because it is in a user prompt) // to the whole prompt. It is therefore a range selection, and the value of fAssocPrev we got // is useless. bool fAssocPrev_Ignore; int ws; ITsTextProps ttp; SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(vwsel, cvsli, out ihvoRoot, out tagTextProp_Ignore, out cpropPrevious, out ichAnchor, out ichEnd, out ws, out fAssocPrev_Ignore, out ihvoEnd, out ttp); int tagTextProp; ITsTextProps props = null; if (frag == SegmentTags.kflidFreeTranslation) { // If the length is zero...we need to suppress replacing the comment with a prompt. if (tssVal.Length == 0) { m_hvoOfSegmentWhoseBtPromptIsToBeSupressed = hvo; } ISegment seg = Cache.ServiceLocator.GetInstance <ISegmentRepository>().GetObject(hvo); if (seg.FreeTranslation.get_String(BackTranslationWS).Length == 0) { // Undo needs to unset suppressing the comment prompt. Cache.ActionHandlerAccessor.AddAction(new UndoSuppressBtPrompt(this, seg)); } ws = BackTranslationWS; tagTextProp = frag; seg.FreeTranslation.set_String(ws, tssVal); rootbox.PropChanged(seg.Paragraph.Owner.Hvo, StTextTags.kflidParagraphs, seg.Paragraph.IndexInOwner, 1, 1); } else { ReplacePromptUndoAction undoAction = new ReplacePromptUndoAction(hvo, rootbox, m_updatedPrompts); if (m_cache.ActionHandlerAccessor != null) { m_cache.ActionHandlerAccessor.AddAction(new UndoSelectionAction(rootbox.Site, true, vwsel)); m_cache.ActionHandlerAccessor.AddAction(undoAction); } // Mark the user prompt as having been updated - will not show prompt again. // Note: ReplacePromptUndoAction:Undo removes items from the Set. m_updatedPrompts.Add(hvo); // Replace the ITsString in the paragraph or translation props = StyleUtils.CharStyleTextProps(null, m_wsDefault); if (frag == CmTranslationTags.kflidTranslation) { ICmTranslation trans = Cache.ServiceLocator.GetInstance <ICmTranslationRepository>().GetObject(hvo); trans.Translation.set_String(m_wsDefault, tssVal); undoAction.ParaHvo = trans.Owner.Hvo; ws = BackTranslationWS; tagTextProp = frag; } else { IStTxtPara para = Cache.ServiceLocator.GetInstance <IStTxtParaRepository>().GetObject(hvo); para.Contents = tssVal; undoAction.ParaHvo = hvo; ws = 0; tagTextProp = StTxtParaTags.kflidContents; } // Do a fake propchange to update the prompt rootbox.PropChanged(undoAction.ParaHvo, StParaTags.kflidStyleRules, 0, 1, 1); } // Now request a selection at the end of the text that was just put in. rootbox.Site.RequestSelectionAtEndOfUow(rootbox, ihvoRoot, cvsli, rgvsli, tagTextProp, cpropPrevious, ichEnd, ws, true, props); return(tssVal); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Expand the item if it is collapsed. /// </summary> /// <param name="hvo">hvo of the item to expand</param> /// <param name="root">The rootbox.</param> /// ------------------------------------------------------------------------------------ public void ExpandItem(int hvo, IVwRootBox root) { if (!m_expandTable.ContainsKey(hvo)) { m_expandTable[hvo] = true; root.PropChanged(hvo, m_expansionTag, 0, 0, 0); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Toggle the expansion state of the given item /// </summary> /// <param name="hvo">The ID of the object to expand/collapse</param> /// <param name="rootbox">The rootbox of the caller, which will be notified of the change /// (hence causing the appropriate fragments in this VC to get laid out)</param> /// <returns>true if the item is expanded. Otherwise, false.</returns> /// ------------------------------------------------------------------------------------ public bool ToggleItemExpansion(int hvo, IVwRootBox rootbox) { if (m_expandTable.ContainsKey(hvo)) m_expandTable.Remove(hvo); else { m_expandTable[hvo] = true; OpenNoteFieldsWithContent(hvo, rootbox); } rootbox.PropChanged(hvo, m_expansionTag, 0, 0, 0); return m_expandTable.ContainsKey(hvo); }
public bool Redo() { EnchantHelper.SetSpellingStatus(m_word, m_wsText, m_rootb.DataAccess.WritingSystemFactory, true); m_rootb.PropChanged(m_hvoObj, m_tag, m_wsAlt, 1, 1); return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Notifies a paragraph that needs to have its highlighting refreshed. /// </summary> /// <param name="para"></param> /// <param name="rootBox"></param> /// ------------------------------------------------------------------------------------ private void NotifyParagraph(IScrTxtPara para, IVwRootBox rootBox) { // Paragraph may have been deleted and no longer be valid if (para.IsValidObject && rootBox != null) rootBox.PropChanged(para.Hvo, StParaTags.kflidStyleRules, 0, 1, 1); }