Saving and loading a RTF document containing a WPRichText.TextObjects looses it's .Name property.
Here is an example:
var _obj: TWPTextObj; _img: TWPOImage; _width, _height: Integer;begin _img := TWPOImage.Create(WPRichText1); _img.AssignBitmap(Image1.Picture.Graphic); _width := MulDiv(Image1.Picture.Width, 1440, WPScreenPixelsPerInch); _height := MulDiv( Image1.Picture.Height, 1440, WPScreenPixelsPerInch); // Create the actual WPTools image object. _obj := WPRichText1.TextObjects.Insert(_img, _width, _height, 'IMAGE_NAME');end;
Now if I display all objects name with the following code, I can see my 'IMAGE_NAME' object:
procedure TForm1.DisplayAllObjects;
var
_objType: TWPTextObjType;
_objList : TWPTextObjList;
n: Integer;
begin
// For each WPTools object type.
for _objType := Low(_objType) to High(_objType) do
begin
// Try to find the object name.
_objList := WPRichText1.CodeListTags(_objType, '*ALL*', True);
for n := 0 to _objList.Count - 1 do
begin
if assigned(_objList.Items[n].ObjRef) and (_objList.Items[n].ObjRef.Name <> '') then
ShowMessage(Format('%d: %s', [ord(_objType), _objList.Items[n].ObjRef.Name]))
else
ShowMessage(Format('%d: %s', [ord(_objType), _objList.Items[n].Name]));
end;
end;
end;
Alles anzeigen
Now, if I save this RTF document with WPRichText1.SaveAs and reload it with WPRichText1.Load, and call my DisplayAllObjects procedure, the object is found but it's name is blank.
Can you pleae tell me if this is a bug. If you think this is not a bug, then tell me what I am doing wrong. I absolutely need the retrieve the .Name property after the loading a RTF document containing an image object (the .Name property works properly for input fields and merge fields.).
Note: Using the WPRichText1.InsertGraphicDialog causes the same problem.
Michel