WPCubed Product Support

Numbering Demo

After looking at the numbering demo I have the following questions.

a) it appears that after each carriage return a new number is issued. If formating is done after the document is created and two carriage returns are issued to create a blank line between paragraphs, the blank line is also numbered.

Is there a mechanism to prevent numbering of blank lines between paragraphs?

b) If I use the code below and raise the speed button, the numbering is removed, but in paragraphs consisting of more than one line, all lines after the first line continue to remain indented.

Is there a mechanism to restore the entire paragraph back to its "non indented" state via code?

c) I do not think this is possible, but one does not know what one does not know. Instead of using the case statement to define the tempStyle variable (see the OnClick method below), is it possible to: a) take the text of the wwDBComboBoxNumber b) type cast the string as a TWPNumberStyle and c) eliminate the case statement? Something like the following?

var  tempString: String;  tempPointer: PChar;  tempStyle: TWPNumberStyle;begin  tempStyle := wwDBComboBoxNumberStyle.Text as TWPNumberStyle;

or

tempString := wwDBComboBoxNumberStyle.ToString;
  tempPointer := PChar(tempString);
  tempStyle := tempPointer As TWPNumberStyle;

procedure TformWordProcessor.SpeedButtonNumberParagraphsClick(Sender: TObject);
var
  tempIndent: Integer;
  tempBeforeText: String;
  tempAfterText: String;
  tempStyle: TWPNumberStyle;
begin
   tempBeforeText := '';
   tempAfterText := '';

  if SpeedButtonNumberParagraphs.Down = True then
    begin
      tempIndent := 360;

      Case wwDBComboBoxNumberStyle.ItemIndex of
        0: tempStyle := wp_none;
        1: tempStyle := wp_bullet;
        2: tempStyle := wp_circle;
        3: tempStyle := wp_1;
        4: tempStyle := wp_lg_i;
        5: tempStyle := wp_i;
        6: tempStyle := wp_lg_a;
        7: tempStyle := wp_1st;
        8: tempStyle := wp_One;
        9: tempStyle := wp_First;
        10: tempStyle := wp_unicode;
        11: tempStyle := wp_char;
        12: tempStyle := wp_01;
      end;

      WPRichText1.SelectAll;
      WPRichText1.CurrAttr.BeginUpdate;
      WPRichText1.CurrAttr.IndentLeft := tempIndent;
      WPRichText1.CurrAttr.IndentFirst:= - tempIndent;
      WPRichText1.CurrAttr.SetNumberStyle(
                           tempBeforeText,
                           tempAfterText,
                           '',   
                           tempStyle, 
                           tempIndent );
      WPRichText1.CurrAttr.EndUpdate;
      WPRichText1.HideSelection;

    end
  else
    begin
      wwDBComboBoxNumberStyle.ItemIndex := 0;

      WPRichText1.SelectAll;
      WPRichText1.CurrAttr.BeginUpdate;
      WPRichText1.CurrAttr.IndentLeft := 0;
      WPRichText1.CurrAttr.IndentFirst:= 0;
      WPRichText1.CurrAttr.SetNumberStyle(
               tempBeforeText,   
               tempAfterText, 
               '', 
               wp_none, 
               0 );
      WPRichText1.CurrAttr.EndUpdate;
      WPRichText1.HideSelection;
    end;

TIA

John

#1 ♥ 0
4.3k Views 2 users read 4 min
support

Hi,

a) does FormatOptionEx wpfAutoRestartSimpleNumbering helps here?

b) to switch OFF the numbering please do not use SetNumberStyle, Instead assign 0 to property CurrAttr.NumberStyle.

Julian

#2 ♥ 0

Julian

Your suggestions

a) does FormatOptionEx wpfAutoRestartSimpleNumbering helps here?

this had no effect;

b) to switch OFF the numbering please do not use SetNumberStyle, Instead assign 0 to property CurrAttr.NumberStyle.

Resolved the issue of multiple line paragraphs having lines > 1 continuing to be indented after numbering is turned off.

The continuing problem is that if two carriage returns are issued after a paragraph to create a blank line between paragraphs, the blank line continues to be numbered.

It appears that numbering is based on the start of a paragraph and a paragraph is defined as the characters between two carriage returns. If so, it seems logical that there would be a way to prevent numbering of a blank line (or paragraph with no text or spaces between the carriage returns)

Further suggestions?

TIA

John

#3 ♥ 0

I have solved the central question by not using SetNumberStyle but iterating through the paragraphs individually. See code below.

The question is now how to place a bullet in each paragraph. If I select a symbol from the bullet dialog the current paragraph will be indented and the selected symbol will be placed in front of the paragraph. The question is now how to capture that symbol after it is selected so I can place in the front of the paragraph as done below?

if SpeedButtonSectionNumbers.Down = True then
begin
with WPRichText1 do
begin

tempParStyle := WPRichText1.ParStyles.AddStyle('Numbering');
tempParStyle.ASet(WPAT_IndentFirst, -300);
tempParStyle.ASet(WPAT_IndentLeft, 360);

I := 1;
tempParagraph := FirstPar;

while tempParagraph <> nil do
begin
if tempParagraph.ContainsText = True then
begin
if tempParagraph.IsCharStyle(1, WPSTY_Bold) = False then
begin
tempString := IntToStr(I) + '. ';
tempString := tempString + tempParagraph.GetText(False,False);
tempParagraph.SetText(tempString, WPRichText1.AttrHelper.CharAttr);
tempParagraph.SetStyle('Numbering', False, False);

I := I + 1;
end
else
begin
I := 1;
end;
end;

tempParagraph := tempParagraph.NextPar;
end;

ReformatAll(True,True);
end;
end

TIA

John

#4 ♥ 0
This category is archived. No new posts are possible.