Menu

JADD compiling with Delphi 7

Help
Anonymous
2007-05-19
2013-04-02
  • Anonymous

    Anonymous - 2007-05-19

    From the various javadoc lookalikes for pascal I choose to make JADD my standard. One of the impotant features is the possibility to generate neat pdf documents without the need for postprocessing and tricks.

    However, I would like to make the big fonts for headings smaller. So I downloaded the sources (DelphiDoc.1.7.6.395.src.zip) and thought this could be achieved by changing in UPDFDoc.pas:
    const     Sizes: array[0..3] of TPDFValue =
                      (1.5, 1.3, 1.1, 1.0);
    into:
    const     Sizes: array[0..3] of TPDFValue =
                      (1.3, 1.2, 1.1, 1.0);

    If I compile (Delphi 7 build 8.1) the freshly downloaded sources directly, I get a functioning program but as soon as I change something (even introducing a space and deleting it) the program generates an exception EAccesViolation. This apparently occurs in UBaseIdents:
    function TPascalFile.GetLineCommentAtEnd(Index: Integer): String;
    begin
    Result := ExtractComment(FLines[Index], FComments[Index], True);
    end;

    It seems that FLines is not created and that Index has an arbitrary value.
    Generating documentation other than pdf works fine as far as I have tested.

    Being from the ages of ALGOL-60 and never having learnt to properly use objects, the structure of the program is to complex for me to solve this problem.

    Can any body help me?
    Thanks,
    Janwillem

     
    • G. Veith

      G. Veith - 2007-05-20

      Hello,

      <quote>
      However, I would like to make the big fonts for headings smaller. So I downloaded the sources (DelphiDoc.1.7.6.395.src.zip) and thought this could be achieved by changing in UPDFDoc.pas:
      const Sizes: array[0..3] of TPDFValue =
      (1.5, 1.3, 1.1, 1.0);
      into:
      const Sizes: array[0..3] of TPDFValue =
      (1.3, 1.2, 1.1, 1.0);
      </quote>

      this would actually change the sizes of the entries in the table of contents at the beginning of the PDF files.

      To change the sizes of the headings throughout the PDF file the four methods WriteNewMainSection, WriteNewSection, WriteNewSubSection and WriteNewItemSection of the class TBasePDFDoc in unit UBasePDFDoc have to be changed. The size factor is currently hard coded in them. Each of the methods contains a line like:

      SetFont(FDefaultFontType, FNormalFontSize * 2, [pfsBold]);

      The scaling factor of the size is in this case the "2", the others would be 1.6, 1.25 and 1.1.

      In the next release the PDF generator will be transformed to the new internal system. Then the above mentioned constant array will (also) be declared twice, in the methods WriteTitleText and WriteTableOfContents in the new file UPDFTextWriter, just as a side node for the future.

      <quote>
      If I compile (Delphi 7 build 8.1) the freshly downloaded sources directly, I get a functioning program but as soon as I change something (even introducing a space and deleting it) the program generates an exception EAccesViolation. This apparently occurs in UBaseIdents:
      function TPascalFile.GetLineCommentAtEnd(Index: Integer): String;
      begin
      Result := ExtractComment(FLines[Index], FComments[Index], True);
      end;

      It seems that FLines is not created and that Index has an arbitrary value.
      Generating documentation other than pdf works fine as far as I have tested.
      </quote>

      Hm, this is strange.
      I assume this happens when generating the documentation. The progress window should show the current file or class. Is there anything complex/special about these?

      The Index looking wrong may be a debug issue, I remember have a problem in one of those comment methods at one point, and the much too high shown Index wasn't the problem. The only
      place where this might occur anyway (but should not), is when parsing a file named "System", but I guess you don't do that, right?

      FLines not being created is more helpful. As FLines is created when the file-object is created, it has to exist. So the file reference ("Self" in this context) either is nil or otherwise invalid (or it is also a debug issue). Are you using the {$INCLUDE } / {$I } directive somewhere in your code? That would probably be the best reason of an invalid file reference. Although I hope that is not the case, as it should work.

      Another possibility is a memory corruption by some code located at a completely different position. As this error occurs with the PDF generator, it would imply the memory is corrupted by some of its code.

      A call stack trace at the time of the exception would be another good starting point to search for the error. And the value of (Self.)FInternalFileName at the position would tell whether the file reference is valid.

      As for the problem with this error only/even occuring when only changing a white space, the only reason for that I can think of, is a different order of unit initialization in the resulting program, as opposed when compiling from scratch.
      As far as I know, there is only one such problem, and that is with the generators of the new internal system, and should always kill the programm at start-up time with a run time error, and I specifically "used" a unit just to circumvent it.
      Anyway, you could try to do a "Build All", in Delphi's menu "Project" the entry "Build DelphiDoc", then all units should be initialized in the same order as when compiling the first time.
      Maybe that will fix it.

      Sadly, that is all I can say about that without further information.

      Best regards,
         Gerold Veith

       
    • Anonymous

      Anonymous - 2007-05-20

      Dear Gerold, thanks for your assistance. The "Build All" suggestion solves the problem. Using your remaks on where font sizes are set, I added a small unit with scaling constants and replaced all hard coded scaling with these.

      unit UFontSizes;
      {Patch for more flexible adjustment of (relative) font sizes for PDF output
      Janwillem van Dijk 20 May 2007}

      interface

      const
        //originally in UPDFDoc for scaling font sizes in table of contents
        Sizes: array[0..3] of single = (1.3, 1.2, 1.1, 1.0);
        //originally in UBasePDFDoc as default font size
        StandardFontSize = 10;

        //janwillem van dijk 20 May 2007 replaces hard coded font scaling in
        //  UPDFDoc and UBasePDFDoc
        FontScaling: array[0..3] of single = (1.4, 1.3, 1.2, 1.1);

      implementation

      end.

      This works fine for my current purposes so thanks again for the help
      Janwillem

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.