/// <summary>
        /// Selects the contents of the whole rootbox.
        /// </summary>
        /// <param name="rootb"></param>
        /// <param name="fEditable">if set to <c>true</c> tries to start and end the selection in an editable field.</param>
        /// <param name="fInstall">if set to <c>true</c> installs the selection.</param>
        /// <returns></returns>
        internal static IVwSelection SelectAll(IVwRootBox rootb, bool fEditable, bool fInstall)
        {
            IVwSelection selDocument = null;
            IVwSelection selStart    = rootb.MakeSimpleSel(true, fEditable, false, false);
            IVwSelection selEnd      = rootb.MakeSimpleSel(false, fEditable, false, false);

            if (selStart != null && selEnd != null)
            {
                selDocument = rootb.MakeRangeSelection(selStart, selEnd, fInstall);
            }
            return(selDocument);
        }
		/// <summary>
		/// Selects the contents of the whole rootbox.
		/// </summary>
		/// <param name="rootb"></param>
		/// <param name="fEditable">if set to <c>true</c> tries to start and end the selection in an editable field.</param>
		/// <param name="fInstall">if set to <c>true</c> installs the selection.</param>
		/// <returns></returns>
		internal static IVwSelection SelectAll(IVwRootBox rootb, bool fEditable, bool fInstall)
		{
			IVwSelection selDocument = null;
			IVwSelection selStart = rootb.MakeSimpleSel(true, fEditable, false, false);
			IVwSelection selEnd = rootb.MakeSimpleSel(false, fEditable, false, false);
			if (selStart != null && selEnd != null)
				selDocument = rootb.MakeRangeSelection(selStart, selEnd, fInstall);
			return selDocument;
		}
Exemplo n.º 3
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Make a range selection based upon our saved selection info.
		/// NOTE: Installing the selection may trigger side effects that will invalidate the selection.
		/// Callers should check to make sure the selection is still valid before using it.
		/// </summary>
		/// <param name="rootBox"></param>
		/// <param name="fInstall"></param>
		/// <exception cref="Exception">throws if unable to make an end selection</exception>
		/// <returns>a range selection (could become invalid as a side-effect of installing.)</returns>
		/// -----------------------------------------------------------------------------------
		public IVwSelection MakeRangeSelection(IVwRootBox rootBox, bool fInstall)
		{
			int iAnchor = 0;
			int iEnd = 1;
			if (!m_fEndSet)
			{	// No end information set, so use iAnchor as end
				iEnd = iAnchor;
			}
			if (m_selInfo[iEnd] == null)
			{
				m_selInfo[iEnd] = new SelInfo(m_selInfo[iAnchor]);
			}

			// This change was proposed in change set 37331 but it's not clear what crash sometimes happens if it's not done.
			// Apparently it doesn't always crash because some TeDllTests fail if we do this.
			// Don't make a selection if the property indicates not to: see comment about -2 in InterlinDocForAnalysis.HandleSelectionChange
			//if (m_selInfo[iAnchor].tagTextProp == -2)
			//    return null;  // crashes if allowed to continue

			// we want to pass fInstall=false to MakeTextSelection so that it doesn't notify
			// the RootSite of the selection change.
			IVwSelection vwSelAnchor;
			try
			{
				vwSelAnchor = rootBox.MakeTextSelection(
					m_selInfo[iAnchor].ihvoRoot, m_selInfo[iAnchor].rgvsli.Length,
					m_selInfo[iAnchor].rgvsli, m_selInfo[iAnchor].tagTextProp,
					m_selInfo[iAnchor].cpropPrevious, m_selInfo[iAnchor].ich, m_selInfo[iAnchor].ich,
					m_selInfo[iAnchor].ws, m_selInfo[iAnchor].fAssocPrev, m_selInfo[iAnchor].ihvoEnd,
					null, false);
			}
			catch (Exception e)
			{
				Debug.Assert(m_selInfo[iEnd].rgvsli.Length > 0 || m_selInfo[iAnchor].rgvsli.Length == 0,
					"Making the anchor selection failed, this is probably an empty editable field.");
				throw;
			}
			IVwSelection vwSelEnd;
			try
			{
				vwSelEnd = rootBox.MakeTextSelection(
					m_selInfo[iEnd].ihvoRoot, m_selInfo[iEnd].rgvsli.Length,
					m_selInfo[iEnd].rgvsli, m_selInfo[iEnd].tagTextProp,
					m_selInfo[iEnd].cpropPrevious, m_selInfo[iEnd].ich, m_selInfo[iEnd].ich,
					m_selInfo[iEnd].ws, m_selInfo[iEnd].fAssocPrev, m_selInfo[iEnd].ihvoEnd,
					null, false);

			}
			catch (Exception)
			{
				Debug.Assert(m_selInfo[iEnd].rgvsli.Length > 0 || m_selInfo[iAnchor].rgvsli.Length == 0,
					"The anchor has rgvsli but the end does not; since making the end selection failed, this is probably a mistake.");
				throw;
			}
			return rootBox.MakeRangeSelection(vwSelAnchor, vwSelEnd, fInstall);
		}
Exemplo n.º 4
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Make a range selection based upon our saved selection info.
		/// NOTE: Installing the selection may trigger side effects that will invalidate the selection.
		/// Callers should check to make sure the selection is still valid before using it.
		/// </summary>
		/// <param name="rootBox"></param>
		/// <param name="fInstall"></param>
		/// <returns>a range selection (could become invalid as a side-effect of installing.)</returns>
		/// -----------------------------------------------------------------------------------
		public IVwSelection MakeRangeSelection(IVwRootBox rootBox, bool fInstall)
		{
			int iAnchor = 0;
			int iEnd = 1;
			if (!m_fEndSet)
			{	// No end information set, so use iAnchor as end
				iEnd = iAnchor;
			}
			if (m_selInfo[iEnd] == null)
			{
				m_selInfo[iEnd] = new SelInfo(m_selInfo[iAnchor]);
			}

			// we want to pass fInstall=false to MakeTextSelection so that it doesn't notify
			// the RootSite of the selection change.
			IVwSelection vwSelAnchor = rootBox.MakeTextSelection(
				m_selInfo[iAnchor].ihvoRoot, m_selInfo[iAnchor].rgvsli.Length,
				m_selInfo[iAnchor].rgvsli, m_selInfo[iAnchor].tagTextProp,
				m_selInfo[iAnchor].cpropPrevious, m_selInfo[iAnchor].ich, m_selInfo[iAnchor].ich,
				m_selInfo[iAnchor].ws, m_selInfo[iAnchor].fAssocPrev, m_selInfo[iAnchor].ihvoEnd,
				null, false);
			IVwSelection vwSelEnd = rootBox.MakeTextSelection(
				m_selInfo[iEnd].ihvoRoot, m_selInfo[iEnd].rgvsli.Length,
				m_selInfo[iEnd].rgvsli, m_selInfo[iEnd].tagTextProp,
				m_selInfo[iEnd].cpropPrevious, m_selInfo[iEnd].ich, m_selInfo[iEnd].ich,
				m_selInfo[iEnd].ws, m_selInfo[iEnd].fAssocPrev, m_selInfo[iEnd].ihvoEnd,
				null, false);
			return rootBox.MakeRangeSelection(vwSelAnchor, vwSelEnd, fInstall);
		}