Hi,
I am trying to implement a "Continue Numbering" function as you get with Word's outline/numbering. So for example, if you have the following:
1 Para 1
2 Para 2
3 Para 3
Some arbitrary text
1 2nd para 1
2 2nd Para 2
By clicking on the continue numbering function, I could make the number for 2nd para 1 be number 4 instead of number 1.
The only way I could find of implementing this was by querying the previous paragraphs before 2nd para 1. My code is as follows:
ZitatAlles anzeigen
var par:TParagraph;
ns1, ns2, nl, nl1, nl2, num:integer;
ts:TWPTextStyle;
p: TWPRTFNumberingStyle;
skip:boolean;
begin
wpRichText1.ActiveParagraph.AGet(WPAT_NumberStyle, ns1);
wpRichText1.ActiveParagraph.AGet(WPAT_NumberLevel, nl1);
par:=wpRichText1.ActiveParagraph.PrevPar;
while par<>Nil do
begin
if par.IsNumbered then
begin
par.AGet(WPAT_NumberStyle, ns2);
par.AGet(WPAT_NumberLevel, nl2);
p:=par.RTFProps.NumberStyles.FindParNumberStyle(par, nl, skip);
ts:=p.TextStyle;
ts.AGet(WPAT_NumberText, num);
if (ns2=ns1) and (nl2=nl1) then
begin
wpRichText1.ActiveParagraph.ASet(WPAT_NumberStart, num+1);
wpRichText1.DelayedReformat;
exit;
end;
end;
par:=par.PrevPar;
end;
end;
The function is failing at ts.AGet(WPAT_NumberText, num).
Questions are:
1 In principle, am I going about this the right way and
2 How should I be getting the number of the last outline as the AGet function is not working.
Thanks,
Mark