Beiträge von krisdoff

    How do I implement the FindName functionality of TextObjects in version 5?

    This is what I currently do:

    rtf.TextObjects.FindName('HeaderObject')


    The object was inserted as TWPOImage:

    HeaderObj := TWPOImage.Create(rtf);
    HeaderObj.ObjName := 'HeaderObject';
    HeaderObj.StreamName := HeaderStream
    TextObjects.DefaultPositionMode := wpotChar;
    TextObjects.Insert(HeaderObj);

    I have used FastAddTable (the pointer version) extensively throughout a suite of programs (hence I'd like to stick with this method) but as a result of the upgrade, the newly created tables appear at the end of the text rather than at the current position.

    Here's some of my code. Many thanks

    procedure TTemplateTable.CreateTable(rtf: TWPCustomRichText);
    begin
    with rtf do
    try
    Changing;
    TableName := GetNextTableName(rtf);
    BeginTable(TableName,0,0,0); //start out table
    CalculateTableSettings(rtf);
    InsertTableHeader(rtf); //create a header if needed
    InsertTableCell(rtf); //create a table cell
    EndTable; //end our table
    finally
    Refresh;//allow it to be drawn
    end;
    end;

    procedure TTemplateTable.CalculateTableSettings(rtf:TWPCustomRichText);
    var
    i : Integer;
    iCol : Integer;
    fWidth: double;
    begin
    attribs := rtf.Attr; //get attribs

    if CellMatrix then
    begin
    if ActualCellCount > 0 then
    begin
    FreeMem(prp); //before re-initialising it
    GetMem(prp, (ActualCellCount + 1) * SizeOf(TParProps));
    FillChar(prp^, (ActualCellCount + 1) * SizeOf(TParProps), 0);
    SetLength(CWidth,ActualCellCount+1);//don't forget the header
    CWidth[0] := Round(2.55 * (MaterialWidth * 1.0));
    iCol := (255-CWidth[0]) div ActualCellCount;
    for i := 1 to ActualCellCount do
    CWidth[i] := iCol;
    end;
    end
    else
    begin
    FreeMem(prp); //before re-initialising it
    GetMem(prp, TemplateColumns.Count * SizeOf(TParProps));
    FillChar(prp^, TemplateColumns.Count * SizeOf(TParProps), 0);
    SetLength(CWidth,TemplateColumns.Count);
    fWidth := 0;
    //total width is......
    for i := 0 to TemplateColumns.Count-1 do
    fWidth := fWidth + TemplateColumns[i].Width;

    for i := 0 to TemplateColumns.Count-1 do
    begin
    //and fill the array
    CWidth[i] := Round((TemplateColumns[i].Width / fWidth)*255);
    end;
    end;

    end;

    procedure TTemplateTable.InsertTableHeader(rtf: TWPCustomRichText);
    begin
    if not TemplateColumns.isHeaderVisible then
    Exit;
    FormatTableHeader(rtf);
    rtf.FastAddTable(TemplateColumns.Count,prp);
    end;

    procedure TTemplateTable.InsertTableCell(rtf: TWPCustomRichText);
    var
    tbl : TDataSet;
    i : Integer;
    pp : PTParProps;
    begin
    tbl := nil;
    if CellMatrix then
    FormatCellMatrix(rtf,tbl)
    else
    begin
    FormatTableCell(rtf,tbl);
    pp := prp;
    for i := 0 to TemplateColumns.Count-1 do
    begin
    pp^.ParProtected := True;
    Inc(pp);
    end;
    rtf.FastAddTable(TemplateColumns.Count,prp);
    end;

    rtf.ProtectedProp := rtf.ProtectedProp +
    [ppParProtected,ppProtected,ppProtectSelectedTextToo];
    end;

    Is this forum still current. I've posted 3 items in last couple of days and have had no response. I've converted 2 very large projects from delphi 5 & 6 to Delphi 2005. WPTools is the only library that is preventing me from moving forward. Your help would be very much appreciated.

    How do I implement the FindName functionality of TextObjects in version 5?

    This is what I currently do:

    rtf.TextObjects.FindName('HeaderObject')


    The object was inserted as TWPOImage:

    HeaderObj := TWPOImage.Create(rtf);
    HeaderObj.ObjName := 'HeaderObject';
    HeaderObj.StreamName := HeaderStream
    TextObjects.DefaultPositionMode := wpotChar;
    TextObjects.Insert(HeaderObj);

    I have used FastAddTable (the pointer version) extensively throughout a suite of programs (hence I'd like to stick with this method) but as a result of the upgrade, the newly created tables appear at the end of the text rather than at the current position.

    Here's some of my code. Many thanks