I am appending one WPRichText to another in a merge kind of operation, and I was wanting to delete any leading paragraphs of the slave RichText that are already in the Master RichText because they are both initialized with the same leading text. By merging the two as-is, I would end up with duplicate leading text wherever the slave was appended to the master RichText.
My thought was to loop thru the leading paragraphs of both RichTexts and compare them. If they were the same, I knew I could delete that paragraph from the slave. I was hoping the ComparePar would handle any text objects as well, because I might have a paragraph that just contains an image or linked image, so I want to be sure it compares this as well.
While looking at the code for TParagraph.ComparePar to see what was being compared, I am slightly confused, well, maybe heavily confused. Why are these two statements doing the exact same thing?
while (i<CharCount) and ((CharItem[i]=#9) or (CharItem[i]=#32)) do inc(i);
while (j<CharCount) and ((CharItem[j]=#9) or (CharItem[j]=#32)) do inc(j);
Instead of the 2nd line, you could effectively just say j := i; So, is the 2nd line supposed to be the following?
while (j<SecondPar.CharCount) and ((SecondPar.CharItem[j]=#9) or (SecondPar.CharItem[j]=#32)) do inc(j);
In any event, will ComparePar do what I need in regards to comparing text and text objects in a paragraph? If not, is there another method or do I need to write my own?
Thanks!
Eric