public TextSegement(int beginRun, int endRun, int beginText, int endText, int beginChar, int endChar) { PositionInParagraph beginPos = new PositionInParagraph(beginRun, beginText, beginChar); PositionInParagraph endPos = new PositionInParagraph(endRun, endText, endChar); this.beginPos = beginPos; this.endPos = endPos; }
/** * this methods parse the paragraph and search for the string searched. * If it Finds the string, it will return true and the position of the String * will be saved in the parameter startPos. * @param searched * @param startPos */ public TextSegement SearchText(String searched, PositionInParagraph startPos) { int startRun = startPos.Run, startText = startPos.Text, startChar = startPos.Char; int beginRunPos = 0, candCharPos = 0; bool newList = false; for (int RunPos = startRun; RunPos < paragraph.GetRList().Count; RunPos++) { int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos = 0; CT_R ctRun = paragraph.GetRList()[RunPos]; foreach(object o in ctRun.Items) { if (o is CT_Text) { if (textPos >= startText) { String candidate = ((CT_Text)o).Value; if (RunPos == startRun) charPos = startChar; else charPos = 0; for (; charPos < candidate.Length; charPos++) { if ((candidate[charPos] == searched[0]) && (candCharPos == 0)) { beginTextPos = textPos; beginCharPos = charPos; beginRunPos = RunPos; newList = true; } if (candidate[charPos] == searched[candCharPos]) { if (candCharPos + 1 < searched.Length) candCharPos++; else if (newList) { TextSegement segement = new TextSegement(); segement.BeginRun = (beginRunPos); segement.BeginText = (beginTextPos); segement.BeginChar = (beginCharPos); segement.EndRun = (RunPos); segement.EndText = (textPos); segement.EndChar = (charPos); return segement; } } else candCharPos = 0; } } textPos++; } else if (o is CT_ProofErr) { //c.RemoveXml(); } else if (o is CT_RPr) { //do nothing } else candCharPos = 0; } } return null; }
/** * this methods parse the paragraph and search for the string searched. * If it Finds the string, it will return true and the position of the String * will be saved in the parameter startPos. * @param searched * @param startPos */ public TextSegement searchText(String searched, PositionInParagraph startPos) { //int startRun = startPos.Run, // startText = startPos.Text, // startChar = startPos.Char; //int beginRunPos = 0, candCharPos = 0; //bool newList = false; //for (int RunPos = startRun; RunPos < paragraph.RList.Size(); RunPos++) //{ // int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos = 0; // CTR ctRun = paragraph.GetRArray(RunPos); // XmlCursor c = ctRun.NewCursor(); // c.SelectPath("./*"); // while (c.ToNextSelection()) // { // XmlObject o = c.Object; // if (o is CTText) // { // if (textPos >= startText) // { // String candidate = ((CTText)o).StringValue; // if (RunPos == startRun) // charPos = startChar; // else // charPos = 0; // for (; charPos < candidate.Length(); charPos++) // { // if ((candidate[charPos] == searched[0]) && (candCharPos == 0)) // { // beginTextPos = textPos; // beginCharPos = charPos; // beginRunPos = RunPos; // newList = true; // } // if (candidate[charPos] == searched[candCharPos]) // { // if (candCharPos + 1 < searched.Length()) // candCharPos++; // else if (newList) // { // TextSegement segement = new TextSegement(); // segement.BeginRun = (beginRunPos); // segement.BeginText = (beginTextPos); // segement.BeginChar = (beginCharPos); // segement.EndRun = (RunPos); // segement.EndText = (textPos); // segement.EndChar = (charPos); // return segement; // } // } // else // candCharPos = 0; // } // } // textPos++; // } // else if (o is CTProofErr) // { // c.RemoveXml(); // } // else if (o is CTRPr) ; // //do nothing // else // candCharPos = 0; // } // c.Dispose(); //} //return null; throw new NotImplementedException(); }
public TextSegement(PositionInParagraph beginPos, PositionInParagraph endPos) { this.beginPos = beginPos; this.endPos = endPos; }
public TextSegement() { this.beginPos = new PositionInParagraph(); this.endPos = new PositionInParagraph(); }
/// <summary> /// this methods parse the paragraph and search for the string searched. /// If it finds the string, it will return true and the position of the String will be saved in the parameter startPos. /// </summary> /// <param name="searched"></param> /// <param name="startPos"></param> /// <returns></returns> public TextSegement SearchText(String searched, PositionInParagraph startPos) { int startRun = startPos.Run, startText = startPos.Text, startChar = startPos.Char; int beginRunPos = 0, candCharPos = 0; bool newList = false; for (int RunPos = startRun; RunPos < paragraph.GetRList().Count; RunPos++) { int beginTextPos = 0, beginCharPos = 0, textPos = 0, charPos = 0; CT_R ctRun = paragraph.GetRList()[RunPos]; foreach (object o in ctRun.Items) { if (o is CT_Text) { if (textPos >= startText) { String candidate = ((CT_Text)o).Value; if (RunPos == startRun) { charPos = startChar; } else { charPos = 0; } for (; charPos < candidate.Length; charPos++) { if ((candidate[charPos] == searched[0]) && (candCharPos == 0)) { beginTextPos = textPos; beginCharPos = charPos; beginRunPos = RunPos; newList = true; } if (candidate[charPos] == searched[candCharPos]) { if (candCharPos + 1 < searched.Length) { candCharPos++; } else if (newList) { TextSegement segement = new TextSegement(); segement.BeginRun = (beginRunPos); segement.BeginText = (beginTextPos); segement.BeginChar = (beginCharPos); segement.EndRun = (RunPos); segement.EndText = (textPos); segement.EndChar = (charPos); return(segement); } } else { candCharPos = 0; } } } textPos++; } else if (o is CT_ProofErr) { //c.RemoveXml(); } else if (o is CT_RPr) { //do nothing } else { candCharPos = 0; } } } return(null); }
public TextSegement searchText(string searched, PositionInParagraph startPos) { throw new NotImplementedException(); }