Beiträge von hjh

    Dear support & group,

    I have difficulties reading CurrAttr.OutlineStyle in WPTools 5.x, it always is wp_none (as far as I could test it).

    Setting the outline style in WPT5 works OK, for instance:

    WPRichText.CurrAttr.OutlineStyle := wp_bullet

    but I have difficulty retrieving the outline style for the same selection in WPT5 (which worked just fine in WPT4).

    In WPT5 the outlinestyle always seems to be wp_none, no matter what - e.g also after setting it first to wp_bullet. I have also upgraded to the newest version, before posting this, but no success.

    For instance, this line of code is always false:

    (WPRichText.CurrAttr.OutlineStyle = wp_bullet)

    Is there another way of reading CurrAttr.OutlineStyle in WPT5?

    Best regards,

    Henk Hagedoorn

    I have a question related to setting the default text cursor in WPTools4 at runtime.

    Although you can change the default text cursor at design time, you cannot effectively change the same property at runtime (it has no effect as far as I can determine).

    I found that it is possible to set the textobjectcursor and hyperlinkcursor at runtime, but not the cursor for regular text.

    For example:

    WPRichText1.hyperlinkcursor := somevalue

    Which works, but this does not have any effect:

    WPRichText1.cursor := some_other_value;

    How to set the default text cursor at runtime?

    Also, when you create a TWPRichText instance on the fly (e.g. in the formcreate handler use TWPRichText.create ), the default text cursor is always a pointer. It is not possible to change it to anything else. This problem seems to be related to the above one.

    Best regards,

    Henk Hagedoorn
    registered user of WPTools 3 + 4 + 5

    Julian,

    Thanks.

    Adding

    "if (par.CharItem[i]<#4) or ((par.CharAttr[i] and $FFFFFF) <> CharAttr) then exit;"

    indeed does the trick.

    By the way, I really need to set the local variable

    CharAttr := 1; {local variable}

    if I do

    CharAttr := 0; {local variable}

    at the beginning of the routine (see my post from March 30, 2008 in this thread), then nothing is detected as plain text.


    Best regards,

    Henk Hagedoorn

    Julian,

    Thank you!

    I'm still having some problems though.

    (1) Further testing reveals that the function does not detect underlined hyperlinks. I would also like it to detect whether the document has hidden text (mostly hyperlinks). Can't seem to find a decent method method to detect hyperlinks (and other types hidden text) which fits well into the above function.


    (2) Moreover, WPTools4 had an easy method of setting the default font for the entire document, one could use:

    rtf.DefaultFont

    How to set the default font (for plain text documents and new/empty documents) ?

    I tried using rtf.WritingAttr.GetWPCSS and SetWPCSS (as you suggested) but that does not seem to exist. There is rtf.Parstyles.GetWPCSS but it always returns an empty string.

    Best regards,

    Henk Hagedoorn

    Apparently the function from my previous posting did not come through intact. Although the preview was OK, the listing omitted parts of the function.

    I have included it in another way (wihtout PRE tags):

    function TFormMain.EditorIsPlainText(rtf: TWPCustomRtfEdit): Boolean;
    var par: TParagraph;
    i, j, CharAttr: Integer;
    begin
    Result := false;
    CharAttr := 1;
    par := rtf.FirstPar;
    while par <> nil do
    begin
    for i := 0 to par.CharCount - 1 do
    begin
    if (par.CharAttr[i] and $FFFFFF) <> CharAttr then exit;
    end;
    for j := 1 to WPAT_LastParAttr do
    begin
    if par.AGet(j, i) and (i <> 0) then exit;
    end;
    if par.ParagraphType = wpIsTable then exit;
    par := par.NextPar;
    end;

    if rtf.textobjects.count > 0 then exit;

    Result := true;
    end;

    Best regards,

    Henk Hagedoorn

    Dear support,

    Thanks, this function is very helpful.

    It detects when some part of the text has different formatting from the first part, and if so, it quits with return-value 'false'.

    However, when I select the entire text, and set it to e.g. 'bold' (or change the font name for the entire text) then the function does not detect this fact.

    I found the following solution (included below).

    (1) First I presume that the default value for par.CharAttr[i] is '1' (for 'no formatting whatsoever'). So the initial value of CharAttr is 1.

    (2) Also, I have added a detection for textobjects. If the text has no formatting but one or more images (or other types of textobjects), this function detects this as well.

    I have tested the function (not yet too extensively), but if you see any flaw in the code fragment below, please let me know.

    <pre>
    function TFormMain.EditorIsPlainText(rtf: TWPCustomRtfEdit): Boolean;
    var par: TParagraph;
    i, j, CharAttr: Integer;
    begin
    Result := false;
    CharAttr := 1;
    par := rtf.FirstPar;
    while par <> nil do
    begin
    for i := 0 to par.CharCount - 1 do
    begin
    if (par.CharAttr[i] and $FFFFFF) <> CharAttr then exit;
    end;
    for j := 1 to WPAT_LastParAttr do
    begin
    if par.AGet(j, i) and (i <0> 0 then exit;

    Result := true;
    end;
    </pre>

    Best regards,

    Henk Hagedoorn

    Dear WPTools support,

    How can one detect whether the contents of the TWPRichEdit control are plain text (i.e. there is no formatting, no images, no tables whatsoever).

    In WPTools 4 one could use these properties:

    IsPlainText
    IsPlainParProps
    MemoryFormat = fmPlainText
    Memo.IsPlainText

    but I can't find anything similar in WPTools 5.x (I have the latest version but not the source code).

    I would like to be able to store text in plain text (without all the bulky RTF formatting codes) when the text does not contain any RTF formatting. This is essential because I use a memory-based database to manage multiple texts simultaneously and a plain text of 10000 lines can become 10 times larger when RTF codes are included.

    Best regards,

    Henk Hagedoorn
    registered user since 2001