Strange behavior with numbered paragraphs

  • Hi,

    Let's suppose that I have a file (created with WPTools) with the following numbering list:

    1. First item
    2. Second item
    3. Third item
    4. Forth item

    Then I put the caret at the third line and press the button with TWPANumbers action assigned. This will turn-off numbering of the third line, and the I will have:

    1. First item
    2. Second item
    Third item
    3. Forth item

    If I press the button again, the third line is re-numbered just like it was before.

    But if the file was created with MSWord, when I try to re-number the third paragraph, instead of adding 3., it adds 1., and the forth line is also changed to 1.. The result is:

    1. First item
    2. Second item
    1. Third item
    1. Forth item

    If I hit ENTER at the end of the third or forth lines, it generates two new numbered lists, so I will have something like this:

    1. First item
    2. Second item
    1. Third item
    2. After third item
    1. Forth item
    2. After forth item

    Is this the expected behavior? Shouldn't it be the same no matter if the RTF was created with WPTools or MSWord?

    Thanks

    Alessandro Fragnani

    • Offizieller Beitrag

    Hi,

    When using numbering please note, there are two kind of numbering, simple numbering and outlines.

    By default the number button creates an outline in WPTools (compiler define NUMBERACTION_SIMPLE). If you use the default numberstyles it will search for 1. and this is in level 3.

    So if you have a text which uses simple numbering and presses [1.] this will create a numbered line, but as outline. So you get the effect you see.

    in unit WPCtrRich you will see that I experimeted with LOCATENEARNUMBER as well (thats old V4 code though).

    I think this code would work fine:

    I am open for suggestions


    Julian

  • Hi Julian

    I tried use NUMBERACTION_SIMPLE define activated. The behavior was different from previous one, but also erroneous. After saving and loading the file again, selecting the third row and turning off and on, the result was:

    1. First item
    2. Second item
    1. Third item
    3. Forth item

    Then I turned off NUMBERACTION_SIMPLE define and used the coded that you posted. I worked correctly after saving and loading the file (created by WPTools and WPTools). Thanks!

    The question now is about restarting numbering, because even with FormatOptionsEx with wpfAutoRestartSimpleNumbering, instead of restarting the numbering, it continues.

    MSWord has a special behavior. It checks if exists an non-empty paragraph between the latest numbered paragrah and the actual paragraph. If exists, it restart, otherwise it continues.

    What do you think?

  • Hi Julian,

    Zitat von wpsupport


    the code change I suggested would use the previous numbering in the new (after the diable/enable process you described)


    As I wrote, using your code in WPCTRRich.pas (procedure OnToolBarIconSelection) instead of

    Code
    {$ELSE}
                            CurrAttr.OutlineStyle := wp_1;
                          {$ENDIF}


    worked perfectly, exactly as I expected. I'm able to save and reload the same file, and the suggested numbering is the same (3.). Thanks for that.

    I just used the same post to ask you another thing. How does FormatOptionsEx [wpfAutoRestartSimpleNumbering] works, because turning it on or off has the same effect, which means, none. I can turn it on, but the numbering does never restart, unless I turn on the NUMBERACTION_SIMPLE define too.

    Zitat von wpsupport


    You are also free to define your own handling, this might be better for your application. You do not have to use the default action WPTools implements.

    Well, in your previous post you say to be "open for suggestions". I just suggested you to do just like MSWord does, which is what I need to mimic. I guess I misunderstood you. Please ignore it.

    Thanks

    Alessandro Fragnani

  • Hi Julian,

    After upgrading to version 5.20.5 I changed a bit more the numbering handling and could fit the exact behavior that I need, just like MSWord does. I added the following code right below the one in WPI_CO_NUMBERS handling. Take a look and see if it is acceptable:

    With this code I have the exact same behavior than MSWord. If the previous paragraphs are empty and the first non-empty paragraph above is numbered, then the number of the current paragraph will continue. Otherwise, if while searching up it finds a non-empty paragraph that is also non-numbered, it restarts the numbering, instead of continuing.

    What do you think?

    Alessandro Fragnani

  • Hi Julian,

    Well, yes.. Unfortunatelly the "numbering" concept is a bit vague to me yet. It has different properties WPAT_NumberSTYLE, WPAT_NumberLevel, GroupItems, etc, so I still have to be learn a bit to do a clean code :).

    Right after I post that message, I noted that if it only works for arabic number (1. 2. 3.), not roman (I. II. III.), or letters (a. b. c.), so I need to change to accomplish it.

    What do you mean about "there is no way to remove the start flag"? If I use my "continue/restart numbering" operations (popupmenu) that I posted in another thread, the numbering is correctly manipulated.

    Thanks for your help

    Alessandro Fragnani

    • Offizieller Beitrag

    Hi,

    >> What do you mean about "there is no way to remove the start flag"? If I use my "continue/restart numbering" operations (popupmenu) that I posted in another thread, the numbering is correctly manipulated. <<

    Well, than it is fine.

    About NumberStyles:

    WPTools mimiks the complete RTF numbering scheme which is fact double, one for simple, onbe for outline numbering. NumberLevel selects the leveled numbering, if it is not defined simple numbering is used.

    NumberStyle is the index in the NumberStyles collection. For outlines it is only used to locate the group, the element whithin this group is controlled by numberlevel.

    NumberMode is only used in number styles, not in paragraph styles or paragraphs because RTF does not let me.

    Julian

  • Hi Julian,

    I updated a little bit my "IFDEF RESTART_ALA_MSWORD" to handle other kinds of numbering (roman and letter). It appears to be fine now. Could you take a look and if possible add it to the next release?


    Thanks in advance

    Alessandro

  • Just wanted to add my thoughts...

    Since my application combines multiple WPRichTexts to create a single WPRichText, using the numbered bullet as it stands today can be a bit of a problem...

    WPRichText1
    yada yada
    1. abc
    2. def
    3. ghi
    more yada yada

    WPRichText2
    1. jkl
    2. mno
    3. pqr

    Combined:
    yada yada
    1. abc
    2. def
    3. ghi
    more yada yada
    4. jkl
    5. mno
    6. pqr

    I'd personally like to see the default behavior be to start the sequencing at 1 anytime you set text as numbered bullets. Currently the user has to right-click the first item and do the popup menu thing mentioned in another post to set:
    ActiveParagraph.ASet( WPAT_NumberStart, 1 )

    And to my users, this has no visible effect until the two RichTexts are combined. So i know they are not going to remember to set this property since it looks correct while they are still separate.

  • Hi,

    With the code I posted, anytime you start a new numbered list, the WPAT_NumberStart attribute will be set to 1 to the paragraph, so I think that when combining your multiples WPRichTexts you will have the desired behavior.

    What I did is to try to mimic the numbered list behavior from MSWord. It has some peculiarities when using it, how it determines the current number is sometimes funny. As you can see in previous posts in this thread, if between the latest numbered paragraph and the actual one exists a non-empty paragraph, the actual numbering will restart, otherwise it will continue. Much more funny is when you have a numbered paragraph, hit ENTER twice and type anything in this new non-numbered paragraph. Now turn numbering on and hit ENTER again. The numbered list will start having an empty paragraph between each item.

    Hope this helps.

    Alessandro Fragnani

  • Thanks Alessandro... I agree with you as to how the default behavior should be and I will be integrating your mods for the moment. I hope we can convince Julian to find a way to incorporate this into the product... which is why I mentioned my problem scenario. :D

  • Alessandro,

    I added your code snippet, but it didn't affect the outcome... starting a new numbered list with several blank paragraphs and non-numbered paragraphs between them still continued the sequence numbering instead of restarting it.

    I think this is because I highlighted three lines and clicked on the toolbar's numbered bullet button in order to set all the selected lines as numbered items (each item is a separate paragraph, which is common).

    I believe your search is starting with the third line of the hightlighted lines, so the first par it sees is the 2nd line of the newly numbered list. And since it is numbered, it continues the sequence rather than restarting.

    If I just position the cursor to the first of the three lines, and click the numbered bullet button, it works... but that is not the perfect solution in my case.

    Thanks though... maybe I can play with your code to get it to work like I want it to. (Update: see my next post for a possible solution)

    2 Mal editiert, zuletzt von ehimmer (27. Mai 2006 um 02:07)

  • Alessandro,

    I added the following "if SelLength" conditional to the front of your code, and it appears to now work like I want... maybe for you too:

    Code
    if (par <> nil) then
                            begin
                              if SelLength > 0 then
                              begin
                                CPPosition := SelStart;
                                par := ActivePar.prev;
                              end;
                              // empty, and non-numbered, remains searching

    I'll play with it to be sure it doesn't mess up anything... like perhaps I should reposition the cursor back to the last selected char at the end like it was to start with.

  • Nope, 5.20.6 doesn't work properly in setting a numbered list.

    For example:

    one
    two
    three

    abcde

    four
    five
    six

    Now, select lines "four, five, six", click the numbered list toolbar button several times. With the first click you get each item numbered with "1." not 1, 2, 3. Click again and it doesn't remove the numbered list but rather just indents further.