... when upgrading from WPTools 4
|Top Previous Next|
As emphasized before WPTools Version 9 is based on a new RTF Engine. (We call this RTF engine although it internally works with data structures which are much more similar to HTML/CSS than to RichText-Format)
This means that if you have modified the RTF engine before or use undocumented features the affected parts of the code must be updated. We will assist you here to make the transition easier. WPTools Version 9 contains so many new features and possibilities that it is very likely that a very elegant way to solve the problem can be found.
WPTools Version 9 uses 'delayed reformat'. This means the formatting of the text is delayed until the next idle phase. Therefore, If you are using InputString or similar it is not required to use BeginUpdate/EndUpdate to speed up the application. On the other hand, if you want to print the text (or convert it to PDF) right after loading or creation, it it is required to execute the procedure ReformatAll;
The same is required if you want to print or create a PDF file right after the use of LoadFromFile.
If you used to create an editor at runtime using TWPRichText.Create(nil) please change the code to use the constructor CreateDynamic; (C++Users call the method _MakeDynamic() after the new)
This way the editor knows it is invisible and has no parent. You need to execute ReformatAll whenever you need the text to be formatted for printing or export to PDF.
Do not create editor windows which should work interactively using this method!
Please note that the property WorkOnText used to select a completely different text (the header/footer text) in WPTools 4. In WPTools Version 9 it will simply move the cursor to that text. Esspecially the function MergeText works normally works with the body text, the property WorkOnText will not make any difference. But the MergeText function to select the modification of all text parts.
WPTools Version 9 works with text attributes which can be undefined. So it is possible that the current font has no name. In this case the font used for the text will be defined by the paragraph style or the default attributes.
To set the default font for an editor use the OnClear event:
procedure TForm1.DBWPRichText1Clear(Sender: TObject);
Please note that the properties of the reader and writer (LoadOptions, StoreOptions) are nbow defined by format strings. These format strings can be used with all IO methods. To retrieve the text as RTF string you can simply use str := WPRichText.AsANSIString('RTF');
When you convert older projects you will at least have to modify the uses clauses
remove: WPDefs, WPObj, WPRTF*, WPPrint, WPRich, WPWinCTR
add: WPRTEDefs, WPRTEPaint, WPRTEDefsConsts, WPRTEPlatform, WPRTEEdit, WPCtrMemo, WPCtrRich, WPObj_Image, WPIO
Please note that code which works with pointers (lin : PTLine, pa : PTAttr) cannot be easily converted to work with WPTools Version 9 so please do not try to update the old logic to work with WPTools Version 9. It is better to find a way to do it using the new, advanced API of WPTools. Please don't hesitate to post a question in the forum: Many problems which required hundred lines of code were converted into a few lines with "WPTools Version 9" code.
Style handling is now done inside the RTF-Engine. The WPStyleCollection is still there but it is only a container for template styles.
WPReporter works differently in V5 - please see WPReporter