Beiträge von Leander

    Hello Julian,

    I'm currently using WpTools 6.25.4 with the GraphicEx library on Delphi XE2.

    I've noticed though that PNG images are no longer loaded correctly. I can add an image, save it to a RTF file. But when i load that RTF file the image is no longer visible.

    When disabling the PNGIMG compiler define in WPOBJ_Image i nog longer have problems.

    This is where i get confused though:

    WPINC.inc reads:

    Zitat

    // Activate this define to use TPNGImage to load PNG and GIF files.
    // If you use also GraphicEx you
    // should deativate the PNG support in GraphicConfiguration.inc
    // --> see unit WPObj_Image
    // (Delphi 2009+ containes PNGImage)
    {.$DEFINE PNGIMG}

    WPOBJ.Image.pas read:

    It looks like GIFIMG is not included in my setup. So the GraphicEx remains defined.
    I've then tried deactivating PNG support in GraphicConfiguration.inc as suggested, but with GraphicEx defined WpTools will then no longer compile ("undeclared identifier TPNGImage").

    I'm not really sure how it is supposed to work

    Should i disable PNGImg?
    Should i disable GraphicEx?
    Should i enable GifImg?

    Since GraphicEx supports a lot of different formats disabling it entirely for just native PNG and GIF supports doesn't seem like a very good trade.

    Just noticed when using the up and down arrow keys to loop through the paragraphs it still requires 2 clicks to jump to the next / previous paragraph. So it looks like somehow the editor still thinks there are 2 paragraphs. Typing on those lines can be a bit buggy as well.

    Consider the following scenario:

    Code
    procedure TForm1.Button1Click(Sender: TObject);begin with TWpRichText.Create(Self) do begin   Parent := Self;   Align := AlClient;   AsString := '<div>begin 3 enters</div><div></div><div></div><div></div><div>end 3 enter</div>';   AsWebPage := [wpFormatAsWebPage]; end;end;

    This will not display the 3 empty paragraphs on the TWpRichText.
    It will just output as

    Zitat

    begin 3 enters
    end 3 enters

    Now if i remove the AsWebPage := [wpFormatAsWebPage]; i will get an entirely different but still undesired result, but now it will display 6 empty lines.

    Zitat

    begin 3 enters


    end 3 enters

    I've tested this with wptools 6.13.1 and with wptools 6.25, both gave the same results.

    I have managed to fix the formatting with wpFormatAsWebPage by changing the following code inside function TParagraph.Reformat


    The issue without wpFormatAsWebPage is not important to me, so i leave that one up to you to fix.

    PS.
    I can not be sure my solution is correct until it has had extensive testing. In any case setting the height to 0 does not seem very useful to me. Defaultheight might not be sufficient either though, but it looks to be an improvement anyway.[/code][/quote]

    And it does that very well, but because it works so well i also can not go back anymore and that means it still needs a lot of work.

    If there was a way to combine the advantages of both formatting routines that would be a very powerful product. Regarding HTML the strength of wptools lies in it being an editor and not just a viewer.

    Another issue when using FormatAsWebPage
    (see also topic: http://wpcubed.com/forum/viewtopic.php?t=5817)

    The formatting routine does not apply linespacing anymore.

    I've fixed this with the following code (near the end of TParagraph.Reformat):

    Code
    function TParagraph.Reformat(Always: Boolean = FALSE; MaxW: Integer = 0; Options: Integer = 0): Integer;
    ......
        {$IFDEF OBEC}
        if AGet(WPAT_SpaceBefore, spacing) then
          inc(iHeight, MulDiv(spacing, res, 1440));
        if AGet(WPAT_SpaceAfter, spacing) then
          inc(iHeight, MulDiv(spacing, res, 1440));
        {$ENDIF}
        Lines[lmax].Height := iHeight;

    Now this is becoming pretty annoying. The formatting might be much better for HTML but on functionality it is still trailing far behind compared to the default formatting.
    I can accept that, but as a customer i would like to know what i'm getting into when i turn a feature on in WpTools. I'm now looking at a new bug report every 1 or 2 weeks.

    It seems anything i try has some bad side effect...

    After the change it writes span styles for the empty paragraphs and includes the &nbsp;. However if i load this result into wptools and then save it again as HTML it no longer contains the &nbsp. This is because the character count is now 2, (characters used for opening en closing the span object).

    This means i have to adjust the code yet again.

    this doesn't feel like a good solution anymore...

    If an empty paragraph isn't visible (i dont see why it should not be) then setting LoadedCharAttr shouldn't matter much i suppose.

    Do you mean that on writing HTML it should only write the style class and no attributes? I don't see why, because that would give the paragraph a different font setting from what it has in the editor.

    I guess i don't really see any downside to handling HTML as if it was RTF. But that may have to do with my lack of understanding on both formats.

    The issue may be that i'm mixing RTF with HTML, so if there is a difference in how both formats are "handled" then this creates inconsistencies for the user. In this case users reported this to me as a bug and i can't blame them for it.

    I had to change the code a little. It seems loadedCharAttr was now being set on the wrong paragraph.

    My new solution now also includes a CheckDivPar. I cant really explain how or why this works and i don't know wether this will create other problems, so lets call this code change experimental.

    I think i found the problem here.

    The LoadedCharAttr is not set inside the HTML reader. The RTF reader does set this variable.

    I'm not sure if this is correct, but again: it seems to work.

    I have changed the html writer slightly so it adds the font information for empty paragraphs:

    This is almost similar to the RTF writer. What is weird though is that i'm passing -1 as parameter to UpdateCharAttrEx. But at least it seems to work.

    Now all that remains is fixing the HTML reader. I have tried forcing all font style and size to Verdana 10, but the first empty paragraphs always seems to revert back to the font in the style sheet.

    I realise that all this doesn't matter if we are just displaying HTML, but i need to use it as an editor as well. For example my users are replying to an email and when they start to type what used to be the default font no longer functions and it reverts to whatever font from the stylesheet is used.

    When reading rtf -> writing html -> loading html the font switches.
    WpTools seems to behave very strange at least when using styles. Or maybe i have done some setting that confuses the reader and writer classes.

    My RTF document has the following header.

    Code
    {\rtf1\ansi\deff0\uc1\ansicpg1252\deftab254{\fonttbl{\f0\fnil\fcharset1 Verdana;}{\f1\fnil\fcharset1 Verdana;}{\f2\fnil\fcharset1 Times New Roman;}{\f3\fnil\fcharset2 Wingdings;}{\f4\fnil\fcharset2 Symbol;}{\f5\fnil\fcharset2 Webdings;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;\red128\green128\blue0;}\wpprheadfoot0\paperw11906\paperh16838\margl1882\margr1882\margt1440\margb1440\headery254\footery254\endnhere\sectdefaultcl{\*\generator WPTools_6.060;}{\info{\*\operator hvli}

    And the following stylesheet

    Code
    {\stylesheet{\s1\li0\fi0\ri0\sb0\sa0\ql\vertalt\f0\fs20 Normal;}{\s2\li0\fi0\ri0\sb0\sa0\ql\vertalt\f1\fs20 Normal;}{\s3\li0\fi0\ri0\sb0\sa0\ql\vertalt\fs20 Default Paragraph Font;}{\s4\li0\fi0\ri0\sb0\sa0\ql\vertalt\f5\fs22\snext3 @font-face;}

    The first 2 paragraphs in the document are empty:

    Code
    {\pard\plain\s4\li0\fi0\ri0\sb0\sa0\ql\vertalt\f1\fs20\par\pard\plain\s4\li0\fi0\ri0\sb0\sa0\ql\vertalt\f1\fs20\cf15\par\plain\s4\li0\fi0\ri0\sb0\sa0\ql\vertalt\f1\fs20\cf15 Vriendelijke groet, \par

    Reading this document all works well. The first paragraph have font name "Verdana" (f1) and font size 10 (fs20)

    Now when i save it to html i get the following:

    Code
    </style></head><body><div class="@font-face" style="text-indent:0.00in;text-align:left;vertical-align:top;margin:0.00in;">&nbsp;</div><div class="@font-face" style="text-indent:0.00in;margin-left:0.00in;margin-right:0.00in;">&nbsp;</div><div class="@font-face" style="text-indent:0.00in;margin-left:0.00in;margin-right:0.00in;"><font face="Verdana" size=2 color="black">Vriendelijke groet, </font></div>

    Now it lists the first 2 paragraphs as having font name = 'Webdings' and font size is 11.
    However if i type on the second empty paragraph it still shows up as Verdana 10. The first paragraph however shows up as Webdings 11.

    So both on storing HTML as well as reading HTML it makes no sense to me.

    Now if i change the html to the following:

    Code
    <div class="@font-face" style="text-indent:0.00in;text-align:left;vertical-align:top;margin:0.00in;">&nbsp;<font face="Verdana" size=3></font></div>
    <div class="@font-face" style="text-indent:0.00in;margin-left:0.00in;margin-right:0.00in;">&nbsp;<font face="Verdana" size=3></font></div>

    My first paragraph is still font size 11 (probably because of the stylesheet)
    But my second empty paragraph is font size 12.

    In my opinion the correct order for choosing the font should be:

    - font setting from the paragraph
    - stylesheet setting from the paragraph
    - default font for the document

    For some reason it seems empty paragraphs behave differently. As if they are looking at the next paragraph to tell them what the current font is.

    Again when reading RTF, not a problem at all. Add HTML to the mix and you're in big trouble.

    WPTools 6.13.1

    I'm not sure if this is important, users haven't experienced any negative effects from it, but it seems flawed.

    When debugging i noticed the FCacheCount going very high. I've traced it back to the following code inside function TWPAttrCache.GetIndex(const CharAttr: TWPCharAttr): Integer;

    Code
    if (FCache[i].MaskHash = CmpHashCode) and        CompareMem(@(FCache[i].Values[1]), @(CharAttr.Values[1]), 16 * SizeOf(word)) then      begin

    In WpTools 5 this used to be:

    Code
    if (FCache[i].MaskHash and $FFFF) = (CmpHashCode and $FFFF) then

    The WP6 condition never seems to evaluate to true because FCache[i].MaskHash <> CmpHashCode
    I haven't looked further into why this fails.

    WpTools 6.13.1

    WpTools 6.13.1

    Code
    lvStr := WpRichText1.AsAnsiString('HTML');
    WpRichText1.AsString := lvStr;

    You'll notice in the document every paragraph now ends with whitespace.
    Even empty paragraphs are no longer empty.

    The second problem, i'm not sure if this is related.
    When converting RTF -> HTML if the first paragraph contains 2 (or more) empty paragraphs then after converting the font size for the empty paragraphs gets reset to the default font size.

    Traced it back to TParagraph.Reformat

    The format routine skips the second <BR>, but the paint engine does not. Because the linecount is longer valid (set in format routine) the last line will not get painted.

    This seems like a pretty huge flaw to me.

    I have solved this in code by adding the following at the end of function TParagraph.Reformat. (look for $IFDEF OBEC)

    Code
    CharPos[i].xoff := x - lastx;
          lastx := x;
          {$IFDEF OBEC}
          if cc = #10
          then dec(i);
          {$ENDIF}
          inc(x, CharPos[i].Width);
          if CharPos[i].Height > iHeight then iHeight := CharPos[i].Height;
          if CharPos[i].Base > iBase then iBase := CharPos[i].Base;
          inc(i);

    Also note that i have only tested this with {$IFDEF NEWREFORMAT}.

    Found another problem when using wpFormatAsWebpage.
    Numbers and bullets are no longer displayed, this is because the paint engine requires the paragraphs to be formatted using ReformatStd.

    Simple steps to reproduce:

    - Add to form one TWpRichText and one TWpToolbar
    - Link the toolbar and the twprichtext. Include Sel_bullets in the Sel_OutlineIcons for the toolbar
    - Set property AsWebpage to wpFormatAsWebpage on the TWpRichText
    - Run the program and click on the Sel_Bullets button on the toolbar

    I have been able to partially fix this problem by copy - pasting about 200 lines of code from ReformatStd to ReformatHTM, but this is becoming quite annoying.
    Like i said earlier it looks like ReformatStd differs completely from RefomatHTM. It is not just a different way of formatting, it is a different format routine entirely.
    ReformatSTD itself is already some 5000 lines of code. ReformatHTM is structured differently because implementation is now partially moved to the TWPLineList class, but still it seems like the new code is only a fraction of the ReformatStd code.
    So either ReformatStd has a lot of overhead, or ReformatHTM is still lacking behind on years of development.

    Again, i am very happy with the new feature. But i'm still not sure what to expect, to me it doesn't look finished yet. Is this still something you are actively developing, or just bug fixing?