public void OverTypingHyperlink_LinkPluSFollowingText_WholeParagraphSelected() { var selection = MakeMockSelection(); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub <SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); SimulateHyperlinkFollowedByPlainText(selHelper, IchPosition.StartOfString, IchPosition.EndOfString); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.OnKeyPress(new KeyPressEventArgs('b'), Keys.None); IList <object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(1, argsSentToSetTypingProps.Count); ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0]; Assert.AreEqual(0, ttpSentToSetTypingProps.StrPropCount); Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount); int nVar; Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar)); } }
public void TypingBeforeHyperlink_WithPrecedingItalicsText() { var selection = MakeMockSelection(false); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub <SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); ITsPropsBldr bldr = m_ttpNormal.GetBldr(); bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Italics"); SimulateTextFollowedByHyperlink(selHelper, bldr.GetTextProps(), IchPosition.StartOfHyperlink, IchPosition.StartOfHyperlink); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.OnKeyPress(new KeyPressEventArgs('b'), Keys.None); IList <object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(1, argsSentToSetTypingProps.Count); ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0]; Assert.AreEqual(1, ttpSentToSetTypingProps.StrPropCount); Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount); int nVar; Assert.AreEqual("Italics", ttpSentToSetTypingProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle)); Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar)); } }
public void DeletingHyperlink_LinkButNotPrecedingText() { var selection = MakeMockSelection(); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub <SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); SimulatePlainTextFollowedByHyperlink(selHelper, IchPosition.StartOfHyperlink, IchPosition.EndOfHyperlink); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.HandleKeyPress((char)(int)VwSpecialChars.kscDelForward, Keys.None); IList <object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(1, argsSentToSetTypingProps.Count); ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0]; Assert.AreEqual(0, ttpSentToSetTypingProps.StrPropCount); Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount); int nVar; Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the character style list of the combo box /// </summary> /// <param name="styleContext">the current Paragraph style context, usually based on /// the selection</param> /// <param name="view">The currently active view</param> /// ------------------------------------------------------------------------------------ private void RefreshCharStyleComboBoxList(ContextValues styleContext, IRootSite view) { CharStyleListHelper.IncludeStylesWithContext.Clear(); FwEditingHelper editingHelper = view.EditingHelper as FwEditingHelper; if (editingHelper != null && editingHelper.ApplicableStyleContexts != null) { CharStyleListHelper.IncludeStylesWithContext.AddRange(editingHelper.ApplicableStyleContexts); } else { CharStyleListHelper.IncludeStylesWithContext.Add(styleContext); if (!CharStyleListHelper.IncludeStylesWithContext.Contains(ContextValues.General)) { CharStyleListHelper.IncludeStylesWithContext.Add(ContextValues.General); } if (editingHelper != null && !CharStyleListHelper.IncludeStylesWithContext.Contains(editingHelper.InternalContext)) { CharStyleListHelper.IncludeStylesWithContext.Add(editingHelper.InternalContext); } } CharStyleListHelper.Refresh(); CharStyleListHelper.ActiveView = view as Control; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the paragraph style list of the combo box /// </summary> /// <param name="style">the current paragraph style where the IP is</param> /// <param name="view">The currently active view</param> /// ------------------------------------------------------------------------------------ public void RefreshParaStyleComboBoxList(IStStyle style, IRootSite view) { if (m_callbacks.PopulateParaStyleListOverride()) { return; } if (ParaStyleListHelper.ActiveView == view && style != null && m_prevParaStyleContext == style.Context) { return; } ParaStyleListHelper.IncludeStylesWithContext.Clear(); FwEditingHelper editingHelper = view.EditingHelper as FwEditingHelper; if (editingHelper != null && editingHelper.ApplicableStyleContexts != null) { ParaStyleListHelper.IncludeStylesWithContext.AddRange(editingHelper.ApplicableStyleContexts); } else { if (style != null) { ParaStyleListHelper.IncludeStylesWithContext.Add((ContextValues)style.Context); } ParaStyleListHelper.IncludeStylesWithContext.Add(ContextValues.General); } ParaStyleListHelper.Refresh(); ParaStyleListHelper.ActiveView = view as Control; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the styles combo boxes on the formatting toolbar, with the correct style name. /// </summary> /// ------------------------------------------------------------------------------------ public void UpdateStyleComboBoxValue(IRootSite rootsite) { // If we don't have a paraStyleListHelper, we can't update the paragraph or // character style combo. if (ParaStyleListHelper == null || rootsite == null || rootsite.EditingHelper == null) { return; } FwEditingHelper fwEditingHelper = rootsite.EditingHelper as FwEditingHelper; if (fwEditingHelper != null && fwEditingHelper.IsPictureReallySelected) { return; } string paraStyleName = rootsite.EditingHelper.GetParaStyleNameFromSelection(); var style = (paraStyleName == string.Empty) ? null : ParaStyleListHelper.StyleFromName(paraStyleName); RefreshParaStyleComboBoxList(style, rootsite); if (ParaStyleListHelper.SelectedStyleName != paraStyleName) { ParaStyleListHelper.SelectedStyleName = paraStyleName; } ContextValues currentContext = (style != null) ? style.Context : (fwEditingHelper != null) ? fwEditingHelper.InternalContext : ContextValues.General; if (CharStyleListHelper != null) { string charStyleName = rootsite.EditingHelper.GetCharStyleNameFromSelection(); if (CharStyleListHelper.ActiveView != rootsite as Control || m_prevParaStyleContext != currentContext || (charStyleName != null && !CharStyleListHelper.Contains(charStyleName)) || (charStyleName == null && m_prevParaStyleContext == ContextValues.Note) || (fwEditingHelper != null && fwEditingHelper.ForceCharStyleComboRefresh)) { RefreshCharStyleComboBoxList(currentContext, rootsite); } if (charStyleName == string.Empty) { charStyleName = StyleUtils.DefaultParaCharsStyleName; } if (charStyleName == null) { charStyleName = string.Empty; } if (CharStyleListHelper.SelectedStyleName != charStyleName) { CharStyleListHelper.SelectedStyleName = charStyleName; } } m_prevParaStyleContext = currentContext; }
public void AddHyperlink() { ITsStrBldr strBldr = TsStringUtils.MakeStrBldr(); LcmStyleSheet mockStylesheet = MockRepository.GenerateStub <LcmStyleSheet>(); IStStyle mockHyperlinkStyle = MockRepository.GenerateStub <IStStyle>(); mockHyperlinkStyle.Name = StyleServices.Hyperlink; mockHyperlinkStyle.Stub(x => x.InUse).Return(true); mockStylesheet.Stub(x => x.FindStyle(StyleServices.Hyperlink)).Return(mockHyperlinkStyle); Assert.IsTrue(FwEditingHelper.AddHyperlink(strBldr, Cache.DefaultAnalWs, "Click Here", "www.google.com", mockStylesheet)); Assert.AreEqual(1, strBldr.RunCount); Assert.AreEqual("Click Here", strBldr.get_RunText(0)); ITsTextProps props = strBldr.get_Properties(0); LcmTestHelper.VerifyHyperlinkPropsAreCorrect(props, Cache.DefaultAnalWs, "www.google.com"); }
public void DeletingMiddleOfHyperlink() { var selection = MakeMockSelection(); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub <SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); SimulateHyperlinkOnly(selHelper, IchPosition.EarlyInHyperlink, IchPosition.LateInHyperlink); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.HandleKeyPress((char)(int)VwSpecialChars.kscDelForward, Keys.None); // selection.AssertWasNotCalled(sel => sel.SetTypingProps(null)); IList <object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(0, argsSentToSetTypingProps.Count); } }
public void OverTypingHyperlink_LinkButNotFollowingText() { var selection = MakeMockSelection(); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub <SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); SimulateHyperlinkFollowedByPlainText(selHelper, IchPosition.StartOfHyperlink, IchPosition.EndOfHyperlink); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.OnKeyPress(new KeyPressEventArgs('b'), Keys.None); // selection.AssertWasNotCalled(sel => sel.SetTypingProps(null)); IList <object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(0, argsSentToSetTypingProps.Count); } }
public void OverTypingHyperlink_LinkPluSFollowingText_WholeParagraphSelected() { var selection = MakeMockSelection(); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub<SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); SimulateHyperlinkFollowedByPlainText(selHelper, IchPosition.StartOfString, IchPosition.EndOfString); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.OnKeyPress(new KeyPressEventArgs('b'), Keys.None); IList<object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(1, argsSentToSetTypingProps.Count); ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0]; Assert.AreEqual(0, ttpSentToSetTypingProps.StrPropCount); Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount); int nVar; Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar)); } }
public void DeletingMiddleOfHyperlink() { var selection = MakeMockSelection(); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub<SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); SimulateHyperlinkOnly(selHelper, IchPosition.EarlyInHyperlink, IchPosition.LateInHyperlink); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.HandleKeyPress((char)(int)VwSpecialChars.kscDelForward, Keys.None); // selection.AssertWasNotCalled(sel => sel.SetTypingProps(null)); IList<object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(0, argsSentToSetTypingProps.Count); } }
public void DeletingHyperlink_LinkButNotPrecedingText() { var selection = MakeMockSelection(); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub<SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); SimulatePlainTextFollowedByHyperlink(selHelper, IchPosition.StartOfHyperlink, IchPosition.EndOfHyperlink); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.HandleKeyPress((char)(int)VwSpecialChars.kscDelForward, Keys.None); IList<object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(1, argsSentToSetTypingProps.Count); ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0]; Assert.AreEqual(0, ttpSentToSetTypingProps.StrPropCount); Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount); int nVar; Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar)); } }
public void TypingBeforeHyperlink_WithPrecedingItalicsText() { var selection = MakeMockSelection(false); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub<SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); ITsPropsBldr bldr = m_ttpNormal.GetBldr(); bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Italics"); SimulateTextFollowedByHyperlink(selHelper, bldr.GetTextProps(), IchPosition.StartOfHyperlink, IchPosition.StartOfHyperlink); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.OnKeyPress(new KeyPressEventArgs('b'), Keys.None); IList<object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(1, argsSentToSetTypingProps.Count); ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0]; Assert.AreEqual(1, ttpSentToSetTypingProps.StrPropCount); Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount); int nVar; Assert.AreEqual("Italics", ttpSentToSetTypingProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle)); Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar)); } }
public void OverTypingHyperlink_LinkButNotFollowingText() { var selection = MakeMockSelection(); var selHelper = SelectionHelper.s_mockedSelectionHelper = MockRepository.GenerateStub<SelectionHelper>(); selHelper.Stub(selH => selH.Selection).Return(selection); SimulateHyperlinkFollowedByPlainText(selHelper, IchPosition.StartOfHyperlink, IchPosition.EndOfHyperlink); using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks)) { editingHelper.OnKeyPress(new KeyPressEventArgs('b'), Keys.None); // selection.AssertWasNotCalled(sel => sel.SetTypingProps(null)); IList<object[]> argsSentToSetTypingProps = selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null)); Assert.AreEqual(0, argsSentToSetTypingProps.Count); } }