WPCubed Product Support

Tables as 'Contents.StringValue'

Hi,

I have a merging process that, in some cases, needs to result a 'table'. To accomplish it, I'm using an additional WPRichText, in which I create the table, via code, using AppendNewTable, AppendNewRow and AppendNewCell, adding the cell contents using cell.SetText('the text', cha).

The Merged WTPRichText, that contains my template, has defined AutomaticTextAttr.TextColor as clRED, but when the merging process is called and the table created, the contents of the cell doesn't appears as RED. I also define AutomaticTextAttr.BackgroundColor as clSILVER, and the background color of the text in the cells also aren't SILVER.

Off course that I'm using UseTextColor and UseBackgroundColor as TRUE.

If instead of a table I return a simple text, the font color is RED, as expected.

Any ideas?

Thanks in advance.

Alessandro Fragnani

#1 ♥ 0
4.5k Views 2 users read 3 min
support

For speed issues the automatic attribute, which actually is no attribute anymore, is only allocoated for the current paragraph. It was never intended to color a complete inserted table.

Otherwise each single character in a document can be inside a fied which was started way before its position.

Regards,
Julian

#2 ♥ 0

Hi Julian,

Well, I don't know what kind of 'speed issues' you mean, but it if a table has ProtectedTextAttr set, with a similar color combination, the text is drawn as expected.

So, what do you suggest me to solve this issue?

Off course that I could color the text itself 'by hand' based on the color of AutomaticTextAttr, but I can't do this. Basically because while printing, I need it to be 'black' (bacause I'm using AlsoUseForPrintout = FALSE). Unless I would have a speedy routine that could be used to simulate the expected behavior.

Thanks in advance.

Alessandro Fragnani

#3 ♥ 0
support

Hi,

Well, I don't know what kind of 'speed issues' you mean, but it if a table has ProtectedTextAttr set, with a similar color combination, the text is drawn as expected.

Protected text is marked with the style afsProtected while

"automatic text" is text which is preceeded by a field starting objects. Two completely different things.

Unless I would have a speedy routine that could be used to simulate the expected behavior.

The MailMerge function will do it.

In OnMaileMergeGetText modify the current color (the text is selected) using SelectedTextAttr.

Julian

#4 ♥ 0

Hi Julian,

I tried your suggestion, but it simply has no effect. I removed the TextColor definition from "AutomaticTextAttr" and added, at the end of OnMailMergeGetText the following code:

TWPRichText(Sender).SelectedTextAttr.SetColor(clRed);

Is there anything else that must be done?

I tried another approach. I found a OnGetAttributeColor event in TWPRichText, and defined UseOnGetAttColorEvent to TRUE. The 'normal fields' are correctly drawn, but the 'table fields' are ignored.

Do you have any other idea ?

procedure TMyForm.wpRTFGetAttributeColor(Sender: TObject; var CharStyle: TCharacterAttr; par: TParagraph; posinpar: Integer;
begin
  if TWPRTFEnginePaint(Sender).RTFData.RTFProps.Environment._globale_printing = 0 then
    CharStyle.TextColor := clRed
  else
    CharStyle.TextColor := clNone;
end;

Is there any reason for this event never fires?

Thanks in advance

Alessandro Fragnani

#5 ♥ 0
support

I tried your suggestion, but it simply has no effect. I removed the TextColor definition from "AutomaticTextAttr" and added, at the end of OnMailMergeGetText the following code:

Code:
TWPRichText(Sender).SelectedTextAttr.SetColor(clRed);

Is there anything else that must be done?

You need to call MergeText before the printing. Only then set the color. You cannot insert the text AND set the color at the same time, at least not in this order.

Julian

#6 ♥ 0
This category is archived. No new posts are possible.