Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets up a TsString to be returned from the selection helper so that it will appear
        /// to the editing helper as though we're editing a string consisting of only a hyperlink.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SimulateHyperlinkOnly(SelectionHelper selHelper,
                                           IchPosition start, IchPosition end)
        {
            ITsStrBldr bldr = TsStringUtils.MakeStrBldr();

            bldr.Replace(0, 0, "Google", m_ttpHyperlink);
            selHelper.Stub(selH => selH.GetTss(Arg <SelectionHelper.SelLimitType> .Is.Anything))
            .Return(bldr.GetString());

            selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Anything))
            .Return(m_ttpHyperlink);

            int ichStart = 0;
            int ichEnd   = 0;

            switch (start)
            {
            case IchPosition.EarlyInHyperlink: ichStart = 2; break;

            case IchPosition.EndOfString:
            case IchPosition.EndOfHyperlink: ichStart = bldr.Length; break;
            }
            switch (end)
            {
            case IchPosition.LateInHyperlink: ichEnd = 4; break;

            case IchPosition.EndOfString:
            case IchPosition.EndOfHyperlink: ichEnd = bldr.Length; break;
            }
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
            selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets up a TsString to be returned from the selection helper so that it will appear
        /// to the editing helper as though we're editing a string with a hyperlink followed
        /// by some non-hyperlink text.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SimulateHyperlinkFollowedByText(SelectionHelper selHelper,
                                                     ITsTextProps ttpFollowingText, IchPosition start, IchPosition end)
        {
            ITsStrBldr bldr = TsStringUtils.MakeStrBldr();

            bldr.Replace(0, 0, "Google", m_ttpHyperlink);
            bldr.Replace(bldr.Length, bldr.Length, "some more text", ttpFollowingText);
            selHelper.Stub(selH => selH.GetTss(Arg <SelectionHelper.SelLimitType> .Is.Anything))
            .Return(bldr.GetString());

            selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                        SelectionHelper.SelLimitType.Top))).Return(m_ttpHyperlink);

            int ichStart = 0;
            int ichEnd   = 0;

            switch (start)
            {
            case IchPosition.EndOfHyperlink: ichStart = "Google".Length; break;
            }
            switch (end)
            {
            case IchPosition.EndOfString:
                selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                            SelectionHelper.SelLimitType.Bottom))).Return(ttpFollowingText);
                ichEnd = bldr.Length;
                break;

            case IchPosition.EndOfHyperlink:
                selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                            SelectionHelper.SelLimitType.Bottom))).Return(m_ttpHyperlink);
                ichEnd = "Google".Length;
                break;
            }
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
            selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
        }
Esempio n. 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets up a TsString to be returned from the selection helper so that it will appear
        /// to the editing helper as though we're editing a string with some plain text followed
        /// by a hyperlink.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SimulateTextFollowedByHyperlink(SelectionHelper selHelper,
                                                     ITsTextProps ttpPrecedingText, IchPosition start, IchPosition end)
        {
            ITsStrBldr bldr = (ITsStrBldr)TsStrBldrClass.Create();

            bldr.Replace(bldr.Length, bldr.Length, "some plain text", ttpPrecedingText);
            bldr.Replace(0, 0, "Google", m_ttpHyperlink);
            selHelper.Stub(selH => selH.GetTss(Arg <SelectionHelper.SelLimitType> .Is.Anything))
            .Return(bldr.GetString());

            int ichStart = 0;
            int ichEnd   = bldr.Length;

            switch (start)
            {
            case IchPosition.StartOfString:
                selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                            SelectionHelper.SelLimitType.Top))).Return(ttpPrecedingText);
                break;

            case IchPosition.StartOfHyperlink:
                selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                            SelectionHelper.SelLimitType.Top))).Return(m_ttpHyperlink);
                ichStart = "some plain text".Length;
                break;
            }
            switch (end)
            {
            case IchPosition.StartOfHyperlink: ichEnd = "some plain text".Length; break;
            }
            selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Equal(
                                                        SelectionHelper.SelLimitType.Bottom))).Return(m_ttpHyperlink);
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
            selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
        }
Esempio n. 4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Sets up a TsString to be returned from the selection helper so that it will appear
 /// to the editing helper as though we're editing a string with some plain text followed
 /// by a hyperlink.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void SimulatePlainTextFollowedByHyperlink(SelectionHelper selHelper,
                                                   IchPosition start, IchPosition end)
 {
     SimulateTextFollowedByHyperlink(selHelper, m_ttpNormal, start, end);
 }
Esempio n. 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets up a TsString to be returned from the selection helper so that it will appear
		/// to the editing helper as though we're editing a string consisting of only a hyperlink.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void SimulateHyperlinkOnly(SelectionHelper selHelper,
			IchPosition start, IchPosition end)
		{
			ITsStrBldr bldr = (ITsStrBldr)TsStrBldrClass.Create();
			bldr.Replace(0, 0, "Google", m_ttpHyperlink);
			selHelper.Stub(selH => selH.GetTss(Arg<SelectionHelper.SelLimitType>.Is.Anything))
				.Return(bldr.GetString());

			selHelper.Stub(selH => selH.GetSelProps(Arg<SelectionHelper.SelLimitType>.Is.Anything))
				.Return(m_ttpHyperlink);

			int ichStart = 0;
			int ichEnd = 0;
			switch (start)
			{
				case IchPosition.EarlyInHyperlink: ichStart = 2; break;
				case IchPosition.EndOfString:
				case IchPosition.EndOfHyperlink: ichStart = bldr.Length; break;
			}
			switch (end)
			{
				case IchPosition.LateInHyperlink: ichEnd = 4; break;
				case IchPosition.EndOfString:
				case IchPosition.EndOfHyperlink: ichEnd = bldr.Length; break;
			}
			selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
			selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
			selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
		}
Esempio n. 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets up a TsString to be returned from the selection helper so that it will appear
		/// to the editing helper as though we're editing a string with some plain text followed
		/// by a hyperlink.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void SimulateTextFollowedByHyperlink(SelectionHelper selHelper,
			ITsTextProps ttpPrecedingText, IchPosition start, IchPosition end)
		{
			ITsStrBldr bldr = (ITsStrBldr)TsStrBldrClass.Create();
			bldr.Replace(bldr.Length, bldr.Length, "some plain text", ttpPrecedingText);
			bldr.Replace(0, 0, "Google", m_ttpHyperlink);
			selHelper.Stub(selH => selH.GetTss(Arg<SelectionHelper.SelLimitType>.Is.Anything))
				.Return(bldr.GetString());

			int ichStart = 0;
			int ichEnd = bldr.Length;
			switch (start)
			{
				case IchPosition.StartOfString:
					selHelper.Stub(selH => selH.GetSelProps(Arg<SelectionHelper.SelLimitType>.Is.Equal(
						SelectionHelper.SelLimitType.Top))).Return(ttpPrecedingText);
					break;
				case IchPosition.StartOfHyperlink:
					selHelper.Stub(selH => selH.GetSelProps(Arg<SelectionHelper.SelLimitType>.Is.Equal(
						SelectionHelper.SelLimitType.Top))).Return(m_ttpHyperlink);
					ichStart = "some plain text".Length;
					break;
			}
			switch (end)
			{
				case IchPosition.StartOfHyperlink: ichEnd = "some plain text".Length; break;
			}
			selHelper.Stub(selH => selH.GetSelProps(Arg<SelectionHelper.SelLimitType>.Is.Equal(
				SelectionHelper.SelLimitType.Bottom))).Return(m_ttpHyperlink);
			selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
			selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
			selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
		}
Esempio n. 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets up a TsString to be returned from the selection helper so that it will appear
		/// to the editing helper as though we're editing a string with some plain text followed
		/// by a hyperlink.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void SimulatePlainTextFollowedByHyperlink(SelectionHelper selHelper,
			IchPosition start, IchPosition end)
		{
			SimulateTextFollowedByHyperlink(selHelper, m_ttpNormal, start, end);
		}