WPCubed Product Support

Strange formatting when appending

Hello,

I've got a behaviour in WPTools in don't understand. I'm building a very complex document out of a Database.
A use 2 TWPRichEdits to build the Document. In one RichEdit I build blocks which I append to the other RichEdit.
If I only build the blocks and append them together in the second TWPRichEdit everything works fine.
But as soon as I change some formatting in the second document all the font information from the first RichEdit gets lost (except the underlined property). This only happens with Text I built in code. The text the users entered (I append some text using ->SelectionAsString = TextFromDB) stays nicely formatted, though it is also in RichEdit1.

I use this to format my text:

Cardinal headline;
TWPStoredCharAttrInterface *cha_txtplain = new TWPStoredCharAttrInterface(rt_Preview->RTFData);

  cha_txtplain->Clear();
  cha_txtplain->SetFontName("Arial");
  cha_txtplain->SetFontSize(20);
  cha_txtplain->IncludeStyle(afsBold);
  cha_txtplain->ExcludeStyle(afsItalic);
  cha_txtplain->IncludeStyle(afsUnderline);
  cha_txtplain->SetColor(clBlack);
  headline = cha_txtplain->CharAttr;

  delete cha_txtplain;

  //Text input via
  par->SetText("Text",headline);

It looks like the component can't handle it if there are Cardinals from 2 different TWPRichEdits in one Document. Or is there a better way for general formatting of texts in code?

Thanks for your help!!!

Florian Fanderl

#1 ♥ 0
5k Views 2 users read 2 min
support

Hi,

If you use one cha_txtplain for both TWPRichText this can only work if the use shared TWPRTFProps object. I assume this is the case.

But here it is required to be careful with Clear()

Please call ClearEx and make sure the styles are not deleted!

procedure ClearEx(DontClearStyles, DontResetPageSize, ResetWritingAttr: Boolean);

Julian

#2 ♥ 0

Is it enough if I then initialise my styles in the FormCreate Event Handler of the form?
Should be enough if just use ClearEx and ClearBody, right?

Appending the Document works fine now btw 🙂 Thank you very much!!!

#3 ♥ 0
support

Hi,

Yes, this should be ok.

ClearBody is savest though.

Julian

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