Exemple #1
0
        /// <summary>
        /// Guess where we can break words.
        /// </summary>
        /// <param name="argument"></param>
        public void OnGuessWordBreaks(object argument)
        {
            CheckDisposed();

            IVwSelection sel = RootBox.Selection;
            ITsString    tss;
            int          ichMin, hvoStart, ichLim, hvoEnd, tag, ws;
            bool         fAssocPrev;

            sel.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvoStart,
                            out tag, out ws);
            sel.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvoEnd, out tag, out ws);
            if (sel.EndBeforeAnchor)
            {
                Swap(ref ichMin, ref ichLim);
                Swap(ref hvoStart, ref hvoEnd);
            }
            WordBreakGuesser guesser = new WordBreakGuesser(m_fdoCache, hvoStart);

            if (hvoStart == hvoEnd)
            {
                if (ichMin == ichLim)
                {
                    ichMin = 0;
                    ichLim = -1;                     // do the whole paragraph for an IP.
                }
                guesser.Guess(ichMin, ichLim, hvoStart);
            }
            else
            {
                guesser.Guess(ichMin, -1, hvoStart);
                bool           fProcessing = false;
                ISilDataAccess sda         = m_fdoCache.MainCacheAccessor;
                int            hvoStText   = m_hvoRoot;
                int            cpara       = sda.get_VecSize(hvoStText, StTextTags.kflidParagraphs);
                for (int i = 0; i < cpara; i++)
                {
                    int hvoPara = sda.get_VecItem(hvoStText, StTextTags.kflidParagraphs, i);
                    if (hvoPara == hvoStart)
                    {
                        fProcessing = true;
                    }
                    else if (hvoPara == hvoEnd)
                    {
                        break;
                    }
                    else if (fProcessing)
                    {
                        guesser.Guess(0, -1, hvoPara);
                    }
                }
                guesser.Guess(0, ichLim, hvoEnd);
            }
            TurnOnShowInvisibleSpaces();
        }
Exemple #2
0
		/// <summary>
		/// Guess where we can break words.
		/// </summary>
		/// <param name="argument"></param>
		public void OnGuessWordBreaks(object argument)
		{
			CheckDisposed();

			IVwSelection sel = RootBox.Selection;
			ITsString tss;
			int ichMin, hvoStart, ichLim, hvoEnd, tag, ws;
			bool fAssocPrev;
			sel.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvoStart,
				out tag, out ws);
			sel.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvoEnd, out tag, out ws);
			if (sel.EndBeforeAnchor)
			{
				Swap(ref ichMin, ref ichLim);
				Swap(ref hvoStart, ref hvoEnd);
			}
			WordBreakGuesser guesser = new WordBreakGuesser(m_fdoCache, hvoStart);
			if (hvoStart == hvoEnd)
			{
				if (ichMin == ichLim)
				{
					ichMin = 0;
					ichLim = -1; // do the whole paragraph for an IP.
				}
				guesser.Guess(ichMin, ichLim, hvoStart);
			}
			else
			{
				guesser.Guess(ichMin, -1, hvoStart);
				bool fProcessing = false;
				ISilDataAccess sda = m_fdoCache.MainCacheAccessor;
				int hvoStText = m_hvoRoot;
				int cpara = sda.get_VecSize(hvoStText, StTextTags.kflidParagraphs);
				for (int i = 0; i < cpara; i++)
				{
					int hvoPara = sda.get_VecItem(hvoStText, StTextTags.kflidParagraphs, i);
					if (hvoPara == hvoStart)
						fProcessing = true;
					else if (hvoPara == hvoEnd)
						break;
					else if (fProcessing)
					{
						guesser.Guess(0, -1, hvoPara);
					}
				}
				guesser.Guess(0, ichLim, hvoEnd);
			}
			TurnOnShowInvisibleSpaces();
		}