WPTools - ERangeError

  • Hello,

    I have a ERangeError occurring randomly when saving documents.

    Here is the EurekaLog stack :

    Code
    WPRTEDefs              |TWPAttrCache            |GetFontCharsetList                 |30754[28] |
    System                 |                        |DynArraySetLength                  |          |
    WPIOWriteRTF           |TWPRTFWriter            |InitializeWriting                  |2615[52]  |
    WPIORTFPremium         |TWPRTFWriterEx          |InitializeWriting                  |226[1]    |
    WPRTEDefs              |TWPCustomTextWriter     |WriteText                          |61074[8]  |
    WPRTEDefs              |TWPRTFDataCollection    |SaveToStream                       |28503[51] |
    WPRTEDefs              |TWPRTFEngineBasis       |SaveToStream                       |59339[12] |
    WPCTRMemo              |TWPCustomRtfEdit        |SaveToStream                       |19544[1]  |

    I would like to ask if you have any suggestion regarding this error, becaus I'm trying to solve this since a few days without success. I can save my documents a few times, and suddenly I get this error and after that it becomes impossible to save the document which is very annoying.

    My version is V 6.21 +premiumX, and unfortunately at the moment I don't have the possibility to upgrade to 6.27 which seems to be the latest version (by the way, is there a changelog available before downloading a new version ?).

    Thank you for your help and suggestions !

    • Offizieller Beitrag

    This is the changelog since 6.21 - I strongly recommend to use the latest edition.

    26.9.2012 - WPTools 6.27'
    The PRO Version now supports Delphi XE3


    3.8.2012 - WPTools 6.27
    - fix for wrong display of tables with header and footer rows. Sometimes both wer painted without any data.
    + to load old Hiedit templates as RTF code use the formatstring -HiEditFields. This will create merge fields for ALL fields.
    - NL sign was not shown right after CTRL+ENTER was pressed (requires ShowNL)
    - fix for rangecheck exception with paintpages array
    - fix for footer and page mirror
    - doubleclick word selection now stops at NL
    - Workaround for Windows Spooler problems - some images would get lost
    - sections use footer and header of previous section, not general
    - ASetBorder did change all border types


    12.3.2012 - WPTools 6.25.4
    * allows changing of column width in redonly editors. Can be switchoed off in EditOptions or set
    compiler define TOTALREADONLY
    + wpDisableSelectAll in EditOptionsEx2
    * changed reformat/repaint after Undo/Redo
    - pro and premium: Due to a problem with precompiler cursoir selection did not work correctly


    8.3.2012 - WPTools 6.25.3'
    - borders for paragraphs with multiple lines were not drawn correctly
    - change in DBWPRich.pas to use LoadFromString instead of Text
    - fix possible range check error
    - change in WPTbar.pas to use different default for BevelOuter
    - change in WPIOHTML to use default charattr of paragraph is a paragraph is empty


    9.2.2012 - WPTools 6.25.2
    * new 2-pass painting triggers CustomPaint event only on second loop (when the text is painted)
    * changed protection of empty paragraph to WPTools 5 way
    + inside of the OnPrepareImageForSaving event it is now possible to set Writer.CurrentImageName
    to the name of the file which should be saved. This is only useful if ObjRef = nil and so no ObjRef.Filename can be set.
    + TParagraph.GetSubText now has optional parameter to disable the object reference char codes #1, #2 and #3
    * HTML writer ignores #13 codes when writing the text.
    * additional savety code in HTML writer
    * HTML reader sets image width and height to contents, (if possible)
    * HTML reader: changes UTF8 handling for UTF8Sequence=1
    * HTML reader does not stop on \0 anymore
    * HTML writer writes img tag also for empty images IF a name is provided in event PrepareImageforSaving
    * HTML reader does not add space at end anymore
    - the UNICODE reader uses attribute of current paragraph. This is important for consistent
    behaviour between ANSI and UNICODE version
    - when writing HTML background color is not set to white when shading is 0. 0 is treated as default value.
    - image align center and right now works in HTML
    - fix an endless loop when image was too large
    - improvement of table border drawing
    - improvement for right align in table cells
    + numbering will be used when wpFormatAsWebpage was set in AsWebpage


    10.1.2012 - WPTools 6.25
    + HTML reader reads cell heighs
    - RTF writer writes background color easier to understand by Word
    * improved XML reader/writer (unit WPIOXml1)
    * improved word wise cursor movement when fields are used
    + new "paint attributes" mode.
    Use WPRichText1.BrushStart to select this mode.
    - dashes were not painted using the current font color
    - some stability improvements


    7.11.2011 - WPTools 6.22
    + procedure TParagraph.CellSelectionAdd;
    + procedure CellSelectionRemove;
    + EditOptionsEx2: wpCellMultiSelect - allows multiselection in tables when CTRL is pressed
    + improved XML import/export (unit WPIOXML1.PAS)
    - some smaller bugs fixed


    3.11.2011 - WPTools 6.21.2
    - fix problem with TWPToolButton
    - improved HTML writer to write parameters in ""
    - improved display of arabic text


    24.10.2011 - WPTools 6.21.1
    - fix problem when painting insertpoints after tab stops. They were painted two times.
    - fix in XML and HTML writer. Close <div> tags when extracting text from fields


    19.10.2011 - WPTools 6.21
    + CodeLocate can now also accessed in non-visual TWPRTFDataCollection and not just TWPCustomRtfEdit
    + CodeSelect can now also accessed in non-visual TWPRTFDataCollection and not just TWPCustomRtfEdit
    + TWPRTFDataCollection.CodeLocatePair( FormatName : String; var spar, epar : TParagraph; var spos, epos, : Integer ) :Integer;
    - solves problem with integrated Bin64 decoder
    + DeleteField now has optional "Contents" parameter to delete a certain field with contents
    + the text writer now understand the option -softlinebreaks to create a \n at the end of
    every line. In fact all soft line breaks will be handled like the #10 code.
    + CodeLoadSaveEmbeddedText - load or save text in fields, bookmarks, hyperlinks
    + the regular save and load methods (LoadFromFile, SaveToFile) can now access text wrapped by paired objects.
    specify the fieldname in the format string, i.e. "f:name=RTF" to save or load the contents of the field "name".
    + There is an overloaded LoadFromString which expects a WideString as parameter (Delphi 6+)
    - The Setup named the Delphi 2009 files "Delphi 2005" due to a typo. (Delphi 2005 units are not included anymore)
    - fix probable range check error in WPRTEDEFS

  • Hello,

    The problem is not solved in version 6.27, but I have more details :

    File: WPRTEDefs.pas
    Procedure: TWPAttrCache.GetFontCharsetList

    In my example, the table FCache goes from 0 to 1000, and FCacheCount = 1001.
    The line FCache[1001].MaskHash raises a ERangeError.

    Is it safe to simply change the for loop to FCacheCount-1 ?

    • Offizieller Beitrag

    Hello,

    The array goes really to FCacheCount.

    I wonder why the count is so large though. It is increased by TWPAttrCache.GetIndex and there new caches are allocated.

    You can of course innitialize FCacheMax with a higher value than 1000, but that will only cure the symptom.

    The cache is allocated by SetLength(FCache, FCacheMax + 1); - I cannot see an error here.