Hi,
I want to be able to select all text (including tables) inside a specified group band.
Here's my code thus far, which works fine unless there's a table immediately at the start of the group, in which case it fails to select anything. In fact, when there are one or more tables inside the group, this code doesn't work very well. Is there a better way to do this?
Code
function TWPForm.SelectGroup(const AliasName : string) : TParagraph;
var
par : TParagraph;
band : TWPBand;
st, fin : integer;
begin
Result := nil;
// iterate paragraphs looking for start of group...
par := WPRichText1.FirstPar;
while (par <> nil) do
begin
if (par.ParagraphType = wpIsReportGroup) then
begin
band := GetBandForPar(par);
if (band <> nil) and (band.Alias = AliasName) then break; // <- found it!
end;
par := par.Next;
end;
if (par = nil) then exit; // <- didn't find start of group
// if we get here, then we found the group band...
Result := par; // <- return the parent paragraph for the group band
// if the group start & end are butted up against each other, insert a child par...
if (par.ChildPar = nil) then
par.AppendChild();
st := par.ChildPar.Position;
// [2] find the end of this group...
par := par.LastChild;
fin := par.Position + par.CharCount;
WPRichText1.SelStart := st;
WPRichText1.SelLength := fin-st;
end;
Alles anzeigen
Any help would be appreciated!
Thanks in advance,
Hedley