コード例 #1
0
        protected bool myWordProcessor(OfficeRange aWordRange, ref int nCharIndex)
        {
            if (m_worker.CancellationPending)
            {
                return(false);
            }

            string strFontName = aWordRange.FontName;

            System.Diagnostics.Debug.Assert(strFontName != null);
            if (!String.IsNullOrEmpty(strFontName) && !m_astrListFontNames.Contains(strFontName))
            {
                m_astrListFontNames.Add(strFontName);
                string[] aStrs = new string[] { strFontName, aWordRange.Text };
                m_worker.ReportProgress(0, aStrs);
            }

            // show some user feedback
            if ((m_nModulo != 0) && ((m_nCount++ % m_nModulo) == 0))
            {
                m_worker.ReportProgress(0);
            }

            return(true);
        }
コード例 #2
0
        protected override FormButtons ConvertProcessing(OfficeRange aWordRange, FontConverter aThisFC, string strInput, ref int nCharIndex, ref string strReplace)
        {
            // here's the meat of the RoundTripChecker engine: process the word both in the
            // forward and reverse directions and compare the 2nd output with the input
            string strOutput    = aThisFC.DirectableEncConverter.Convert(strInput);
            string strRoundtrip = aThisFC.DirectableEncConverter.ConvertDirectionOpposite(strOutput);

            // our 'form' is really a RoundTripProcessorForm (which has special methods/properties we need to call)
            RoundTripProcessorForm form = (RoundTripProcessorForm)Form;
            FormButtons            res  = FormButtons.None;

            if (!form.SkipIdenticalValues || (strInput != strRoundtrip))
            {
                if (ReplaceAll)
                {
                    strReplace = strRoundtrip;
                    res        = FormButtons.ReplaceAll;
                }
                else
                {
                    res = form.Show(aThisFC, strInput, strOutput, strRoundtrip);

                    // just in case it's Replace or ReplaceAll, our replacement string is the 'RoundTripString'
                    strReplace = form.RoundTripString;
                }
            }

            return(res);
        }
コード例 #3
0
        protected bool MixedCharacterFormatting(OfficeRange aRange)
        {
            Word.Range thisRange = ((WordRange)aRange).RangeBasedOn;

            /*
             * int nTextLen = aRange.Text.Length - 1;
             * char chRhs = aRange.Text.Substring(nTextLen - 1, 1);
             * if (chRhs == chCellBreak)
             * {
             * }
             * Word.Font aFont = thisRange.Font;
             * if	(	(aFont.Color == 9999999)
             ||  (aFont.ColorIndex == 9999999)
             ||  (aFont.Size == 9999999)
             ||  (aFont.Bold == 9999999)
             ||  (aFont.Italic == 9999999)
             ||  (aFont.Superscript == 9999999)
             ||  (aFont.Spacing == 9999999)
             ||  (aFont.Kerning == 9999999)
             ||  (aFont.Position == 9999999)
             ||  (aFont.Underline == 9999999)
             ||  (aFont.StrikeThrough == 9999999)
             ||  (aFont.Shadow == 9999999)
             ||  (aFont.Hidden == 9999999)
             ||  (aFont.SmallCaps == 9999999)
             ||  (aFont.AllCaps == 9999999)
             ||  (aFont.Outline == 9999999))
             ||{
             || return true;
             ||}
             */

            return(false);
        }
コード例 #4
0
        protected virtual FormButtons ConvertProcessing(OfficeRange aWordRange, FontConverter aThisFC, string strInput, ref int nCharIndex, ref string strReplace)
        {
            // here's the meat of the WordShowConversionDiffProcessor engine: only process
            //  the word if the input is different from the converted output
            string strOutput = aThisFC.DirectableEncConverter.Convert(strInput);

            FormButtons res = FormButtons.None;

            if (!Form.SkipIdenticalValues || (strInput != strOutput))
            {
                if (ReplaceAll)
                {
                    strReplace = strOutput;
                    res        = FormButtons.ReplaceAll;
                }
                else
                {
                    res = Form.Show(aThisFC, strInput, strOutput);

                    // just in case it's Replace or ReplaceAll, our replacement string is the 'Forward' conversion
                    strReplace = Form.ForwardString;
                }
            }

            return(res);
        }
コード例 #5
0
 public virtual void ReplaceText(OfficeRange aWordRange, Font fontTarget, ref int nCharIndex, string strNewText)
 {
     aWordRange.Text = strNewText;
     if (fontTarget != null)
     {
         SetRangeFont(aWordRange, fontTarget.Name);
     }
     nCharIndex = aWordRange.EndIndex;
 }
コード例 #6
0
        public override void ReplaceText(OfficeRange aWordRange, Font fontTarget, ref int nCharIndex, string strNewText)
        {
            PubRange thisRange = (PubRange)aWordRange;

            thisRange.ReplaceText(strNewText);

            if (fontTarget != null)
            {
                SetRangeFont(aWordRange, fontTarget.Name);
            }

            nCharIndex = aWordRange.EndIndex;
        }
コード例 #7
0
 public override void SetRangeFont(OfficeRange aWordRange, string strFontName)
 {
     // this sub-class doesn't ever change the font
     // base.SetRangeFont(aWordRange, strFontName);
 }
コード例 #8
0
		protected override FormButtons ConvertProcessing(OfficeRange aWordRange, FontConverter aThisFC, string strInput, ref int nCharIndex, ref string strReplace)
		{
			// here's the meat of the RoundTripChecker engine: process the word both in the
			// forward and reverse directions and compare the 2nd output with the input
			string strOutput = aThisFC.DirectableEncConverter.Convert(strInput);
			string strRoundtrip = aThisFC.DirectableEncConverter.ConvertDirectionOpposite(strOutput);

			// our 'form' is really a RoundTripProcessorForm (which has special methods/properties we need to call)
			RoundTripProcessorForm form = (RoundTripProcessorForm)Form;
			FormButtons res = FormButtons.None;
			if (!form.SkipIdenticalValues || (strInput != strRoundtrip))
			{
				if (ReplaceAll)
				{
					strReplace = strRoundtrip;
					res = FormButtons.ReplaceAll;
				}
				else
				{
					res = form.Show(aThisFC, strInput, strOutput, strRoundtrip);

					// just in case it's Replace or ReplaceAll, our replacement string is the 'RoundTripString'
					strReplace = form.RoundTripString;
				}
			}

			return res;
		}
コード例 #9
0
		public override void SetRangeFont(OfficeRange aWordRange, string strFontName)
		{
			// this sub-class doesn't ever change the font
			// base.SetRangeFont(aWordRange, strFontName);
		}
コード例 #10
0
 protected override OfficeRange Duplicate(OfficeRange aParagraphRange)
 {
     return(new PubRange((PubRange)aParagraphRange));
 }
コード例 #11
0
		protected bool MixedCharacterFormatting(OfficeRange aRange)
		{
			Word.Range thisRange = ((WordRange)aRange).RangeBasedOn;
			/*
			int nTextLen = aRange.Text.Length - 1;
			char chRhs = aRange.Text.Substring(nTextLen - 1, 1);
			if (chRhs == chCellBreak)
			{
			}
			Word.Font aFont = thisRange.Font;
			if	(	(aFont.Color == 9999999)
				||  (aFont.ColorIndex == 9999999)
				||  (aFont.Size == 9999999)
				||  (aFont.Bold == 9999999)
				||  (aFont.Italic == 9999999)
				||  (aFont.Superscript == 9999999)
				||  (aFont.Spacing == 9999999)
				||  (aFont.Kerning == 9999999)
				||  (aFont.Position == 9999999)
				||  (aFont.Underline == 9999999)
				||  (aFont.StrikeThrough == 9999999)
				||  (aFont.Shadow == 9999999)
				||  (aFont.Hidden == 9999999)
				||  (aFont.SmallCaps == 9999999)
				||  (aFont.AllCaps == 9999999)
				||  (aFont.Outline == 9999999))
			{
				return true;
			}
			*/

			return false;
		}
コード例 #12
0
ファイル: OfficeApp.cs プロジェクト: sillsdev/WorldPad
		public bool CompareInputOutputProcess(OfficeRange aWordRange, ref int nCharIndex)
		{
			FormButtons res = FormButtons.None;
			do
			{
				string strInput = aWordRange.Text;
				if (String.IsNullOrEmpty(strInput))
					return true;

				// not technically required, but this'll help users (but only for the font we're looking for.
				if (!SuspendUI)
					aWordRange.Select();

				// did the caller give us a set of Fonts to scan?
				string strFontName = aWordRange.FontName;
				FontConverter aThisFC = null;
				if (m_aFC != null)
					aThisFC = m_aFC;
				else if (m_aFCs != null)
				{
					if (m_aFCs.ContainsKey(strFontName))
						aThisFC = m_aFCs[strFontName];
				}
				else // otherwise, query the user directly
					aThisFC = QueryUserForFontScan(strFontName);

				res = FormButtons.None;
				if (aThisFC == null)
				{
					// not a font that we're processing
					continue;
				}

				// see if we've already checked this word
				string strReplace = null;
				if (!m_mapCheckedInputStrings.TryGetValue(strInput, out strReplace))
				{
					res = ConvertProcessing(aWordRange, aThisFC, strInput, ref nCharIndex, ref strReplace);

					if (res == FormButtons.Cancel)
						return false;
					else if ((res == FormButtons.ReplaceAll) || (res == FormButtons.ReplaceOnce) || (res == FormButtons.ReplaceEvery))
					{
						ReplaceAll |= (res == FormButtons.ReplaceAll);

						// this means replace the word in situ, with what was converted
						ReplaceText(aWordRange, aThisFC.DirectableEncConverter.TargetFont, ref nCharIndex, strReplace);

						// keep track of this word so that if it comes up again, we'll replace it as is.
						if (AutoReplaceOnNextFind || (res == FormButtons.ReplaceEvery))
							m_mapCheckedInputStrings.Add(strInput, strReplace);
					}
					else if ((aThisFC.RhsFont != null) && (res != FormButtons.Next))
					{
						// even if the string doesn't change, if we have an output font, we have to set it.
						SetRangeFont(aWordRange, aThisFC.RhsFont.Name);
					}
				}
				else
				{
					// this particular input string has already been approved for replacement
					ReplaceText(aWordRange, aThisFC.DirectableEncConverter.TargetFont, ref nCharIndex, strReplace);
				}
			} while (res == FormButtons.Redo);

			return true;
		}
コード例 #13
0
 protected abstract OfficeRange Duplicate(OfficeRange aParagraphRange);
コード例 #14
0
ファイル: OfficeApp.cs プロジェクト: sillsdev/WorldPad
		protected virtual FormButtons ConvertProcessing(OfficeRange aWordRange, FontConverter aThisFC, string strInput, ref int nCharIndex, ref string strReplace)
		{
			// here's the meat of the WordShowConversionDiffProcessor engine: only process
			//  the word if the input is different from the converted output
			string strOutput = aThisFC.DirectableEncConverter.Convert(strInput);

			FormButtons res = FormButtons.None;
			if (!Form.SkipIdenticalValues || (strInput != strOutput))
			{
				if (ReplaceAll)
				{
					strReplace = strOutput;
					res = FormButtons.ReplaceAll;
				}
				else
				{
					res = Form.Show(aThisFC, strInput, strOutput);

					// just in case it's Replace or ReplaceAll, our replacement string is the 'Forward' conversion
					strReplace = Form.ForwardString;
				}
			}

			return res;
		}
コード例 #15
0
ファイル: OfficeApp.cs プロジェクト: sillsdev/WorldPad
		public virtual void SetRangeFont(OfficeRange aWordRange, string strFontName)
		{
			aWordRange.FontName = strFontName;
		}
コード例 #16
0
ファイル: OfficeApp.cs プロジェクト: sillsdev/WorldPad
		public virtual void ReplaceText(OfficeRange aWordRange, Font fontTarget, ref int nCharIndex, string strNewText)
		{
			aWordRange.Text = strNewText;
			if (fontTarget != null)
				SetRangeFont(aWordRange, fontTarget.Name);
			nCharIndex = aWordRange.EndIndex;
		}
コード例 #17
0
ファイル: OfficeApp.cs プロジェクト: sillsdev/WorldPad
		protected bool ProcessWholeRange(OfficeDocumentProcessor aWordProcessor, OfficeRange aParagraphRange, int nCharIndex)
		{
			string strText = aParagraphRange.Text;
			int nLength = (strText != null) ? strText.Length : 0;

			while ((nCharIndex < nLength) && (strText.IndexOfAny(m_achParagraphTerminators, nCharIndex, 1) == -1))
			{
				// get a copy of the range to work with
				OfficeRange aWordRange = Duplicate(aParagraphRange);

				// skip past initial spaces
				while ((nCharIndex < nLength) && (strText.IndexOfAny(m_achWhiteSpace, nCharIndex, 1) != -1))
					nCharIndex++;

				// make sure we haven't hit the end of the paragraph (i.e. '\r') or range (beyond len)
				if (nCharIndex < nLength)
				{
					if (strText.IndexOfAny(m_achParagraphTerminators, nCharIndex, 1) == -1)
					{
						// set the start index
						aWordRange.StartIndex = nCharIndex;

						// run through the characters in the word (i.e. until, space, NL, etc)
						while ((nCharIndex < nLength) && (strText.IndexOfAny(m_achWordTerminators, nCharIndex, 1) == -1))
							nCharIndex++;

						// set the end of the range after the first space after the word (but not for NL)
						if (++nCharIndex >= nLength)
							--nCharIndex;

						aWordRange.EndIndex = nCharIndex;

						// make sure the word has text (sometimes it doesn't)
						if (aWordRange.Text == null)  // e.g. Figure "1" returns a null Text string
							// if it does, see if it's "First Character" has any text (which it does in this case)
							aWordRange.DealWithNullText();

						// finally check it.
						if (!aWordProcessor.Process(aWordRange, ref nCharIndex))
						{
							aWordProcessor.LeftOvers = aWordRange;
							return false;
						}
					}

					strText = aParagraphRange.Text; // incase of replace, we've changed it.
					nLength = (strText != null) ? strText.Length : 0;
				}
				else
					break;
			}

			return true;
		}
コード例 #18
0
ファイル: OfficeApp.cs プロジェクト: sillsdev/WorldPad
		protected abstract OfficeRange Duplicate(OfficeRange aParagraphRange);
コード例 #19
0
        protected bool ProcessWholeRange(OfficeDocumentProcessor aWordProcessor, OfficeRange aParagraphRange, int nCharIndex)
        {
            string strText = aParagraphRange.Text;
            int    nLength = (strText != null) ? strText.Length : 0;

            while ((nCharIndex < nLength) && (strText.IndexOfAny(m_achParagraphTerminators, nCharIndex, 1) == -1))
            {
                // get a copy of the range to work with
                OfficeRange aWordRange = Duplicate(aParagraphRange);

                // skip past initial spaces
                while ((nCharIndex < nLength) && (strText.IndexOfAny(m_achWhiteSpace, nCharIndex, 1) != -1))
                {
                    nCharIndex++;
                }

                // make sure we haven't hit the end of the paragraph (i.e. '\r') or range (beyond len)
                if (nCharIndex < nLength)
                {
                    if (strText.IndexOfAny(m_achParagraphTerminators, nCharIndex, 1) == -1)
                    {
                        // set the start index
                        aWordRange.StartIndex = nCharIndex;

                        // run through the characters in the word (i.e. until, space, NL, etc)
                        while ((nCharIndex < nLength) && (strText.IndexOfAny(m_achWordTerminators, nCharIndex, 1) == -1))
                        {
                            nCharIndex++;
                        }

                        // set the end of the range after the first space after the word (but not for NL)
                        if (++nCharIndex >= nLength)
                        {
                            --nCharIndex;
                        }

                        aWordRange.EndIndex = nCharIndex;

                        // make sure the word has text (sometimes it doesn't)
                        if (aWordRange.Text == null)                          // e.g. Figure "1" returns a null Text string
                        // if it does, see if it's "First Character" has any text (which it does in this case)
                        {
                            aWordRange.DealWithNullText();
                        }

                        // finally check it.
                        if (!aWordProcessor.Process(aWordRange, ref nCharIndex))
                        {
                            aWordProcessor.LeftOvers = aWordRange;
                            return(false);
                        }
                    }

                    strText = aParagraphRange.Text;                     // incase of replace, we've changed it.
                    nLength = (strText != null) ? strText.Length : 0;
                }
                else
                {
                    break;
                }
            }

            return(true);
        }
コード例 #20
0
		protected override OfficeRange Duplicate(OfficeRange aParagraphRange)
		{
			return new PubRange((PubRange)aParagraphRange);
		}
コード例 #21
0
 public virtual void SetRangeFont(OfficeRange aWordRange, string strFontName)
 {
     aWordRange.FontName = strFontName;
 }
コード例 #22
0
ファイル: PubApp.cs プロジェクト: sillsdev/WorldPad
		public override void ReplaceText(OfficeRange aWordRange, Font fontTarget, ref int nCharIndex, string strNewText)
		{
			PubRange thisRange = (PubRange)aWordRange;
			thisRange.ReplaceText(strNewText);

			if (fontTarget != null)
				SetRangeFont(aWordRange, fontTarget.Name);

			nCharIndex = aWordRange.EndIndex;
		}
コード例 #23
0
        public bool CompareInputOutputProcess(OfficeRange aWordRange, ref int nCharIndex)
        {
            FormButtons res = FormButtons.None;

            do
            {
                string strInput = aWordRange.Text;
                if (String.IsNullOrEmpty(strInput))
                {
                    return(true);
                }

                // not technically required, but this'll help users (but only for the font we're looking for.
                if (!SuspendUI)
                {
                    aWordRange.Select();
                }

                // did the caller give us a set of Fonts to scan?
                string        strFontName = aWordRange.FontName;
                FontConverter aThisFC     = null;
                if (m_aFC != null)
                {
                    aThisFC = m_aFC;
                }
                else if (m_aFCs != null)
                {
                    if (m_aFCs.ContainsKey(strFontName))
                    {
                        aThisFC = m_aFCs[strFontName];
                    }
                }
                else // otherwise, query the user directly
                {
                    aThisFC = QueryUserForFontScan(strFontName);
                }

                res = FormButtons.None;
                if (aThisFC == null)
                {
                    // not a font that we're processing
                    continue;
                }

                // see if we've already checked this word
                string strReplace = null;
                if (!m_mapCheckedInputStrings.TryGetValue(strInput, out strReplace))
                {
                    res = ConvertProcessing(aWordRange, aThisFC, strInput, ref nCharIndex, ref strReplace);

                    if (res == FormButtons.Cancel)
                    {
                        return(false);
                    }
                    else if ((res == FormButtons.ReplaceAll) || (res == FormButtons.ReplaceOnce) || (res == FormButtons.ReplaceEvery))
                    {
                        ReplaceAll |= (res == FormButtons.ReplaceAll);

                        // this means replace the word in situ, with what was converted
                        ReplaceText(aWordRange, aThisFC.DirectableEncConverter.TargetFont, ref nCharIndex, strReplace);

                        // keep track of this word so that if it comes up again, we'll replace it as is.
                        if (AutoReplaceOnNextFind || (res == FormButtons.ReplaceEvery))
                        {
                            m_mapCheckedInputStrings.Add(strInput, strReplace);
                        }
                    }
                    else if ((aThisFC.RhsFont != null) && (res != FormButtons.Next))
                    {
                        // even if the string doesn't change, if we have an output font, we have to set it.
                        SetRangeFont(aWordRange, aThisFC.RhsFont.Name);
                    }
                }
                else
                {
                    // this particular input string has already been approved for replacement
                    ReplaceText(aWordRange, aThisFC.DirectableEncConverter.TargetFont, ref nCharIndex, strReplace);
                }
            } while (res == FormButtons.Redo);

            return(true);
        }
コード例 #24
0
		protected bool myWordProcessor(OfficeRange aWordRange, ref int nCharIndex)
		{
			if (m_worker.CancellationPending)
				return false;

			string strFontName = aWordRange.FontName;
			System.Diagnostics.Debug.Assert(strFontName != null);
			if (!String.IsNullOrEmpty(strFontName) && !m_astrListFontNames.Contains(strFontName))
			{
				m_astrListFontNames.Add(strFontName);
				string[] aStrs = new string[] { strFontName, aWordRange.Text };
				m_worker.ReportProgress(0, aStrs);
			}

			// show some user feedback
			if ((m_nModulo != 0) && ((m_nCount++ % m_nModulo) == 0))
				m_worker.ReportProgress(0);

			return true;
		}