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); }
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); }
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); }
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); }
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; }
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; }
public override void SetRangeFont(OfficeRange aWordRange, string strFontName) { // this sub-class doesn't ever change the font // base.SetRangeFont(aWordRange, strFontName); }
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; }
protected override OfficeRange Duplicate(OfficeRange aParagraphRange) { return(new PubRange((PubRange)aParagraphRange)); }
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; }
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; }
protected abstract OfficeRange Duplicate(OfficeRange aParagraphRange);
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; }
public virtual void SetRangeFont(OfficeRange aWordRange, string strFontName) { aWordRange.FontName = strFontName; }
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; }
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; }
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); }
protected override OfficeRange Duplicate(OfficeRange aParagraphRange) { return new PubRange((PubRange)aParagraphRange); }
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; }
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); }
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; }