Bands programmatically generated

  • i have a problem with bands i generate programmatically:

    wpsupermerge.SetSourceDest(wprichtext.RTFData,nil);
    wprichtext.Clear;
    wprichtext.AsString := 'chuck';
    WPRichText.RTFData.Cursor.MoveTo(WPRichText.FirstPar);
    g := wpsupermerge.AddGroup(wpatPosition);
    g.Name := 'MAIN';
    wprichtext.RTFData.Cursor.moveto(g.childpar);
    bh := wpsupermerge.AddBand(wpmHeader);
    bd := wpsupermerge.AddBand(wpmData);
    bf := wpsupermerge.AddBand(wpmFooter);

    on screen everything looks fine, but when i try to save it, the stream(file) das not contain information about the bands (\wpmergepar.....)

    when inserting bands manually, everything works

    any idea what to do about it

    chuck

    • Offizieller Beitrag

    Hi,

    I tried this - and get this as result:

    Code
    {\rtf1\ansi\deff0\uc1\ansicpg1252\deftab720{\fonttbl{\f0\fnil\fcharset1 Arial;}{\f1\fnil\fcharset2 Wingdings;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128
    \green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;}\wpprheadfoot1\paperw12240\
    paperh15840\margl1880\margr1880\margt1440\margb1440\headery720\footery720\ftnbj\sftnbj\sftnrstcont\nocolbal\sftnnar\saftnnar\fet0\endnhere\sectdefaultcl{\*\generator WPTools_6.030-PRM;}{\plain\fs22 chuck\par
    {\*\wpmergepar{0;0;0;0;0;;;;;;;;;0;0;0}}\wpmergestart\pard\plain{\*\wpparname{MAIN}}\par
    \pard\plain\par
    {\*\wpmergepar{3;0;0;0;0;;;;;;;;;0;0;0}}\wpmergestart\pard\plain\par
    {\*\wpmergepar{2;0;0;0;0;;;;;;;;;0;0;0}}\wpmergestart\pard\plain\par
    {\*\wpmergepar{4;0;0;0;0;;;;;;;;;0;0;0}}\wpmergestart\pard\plain\par
    }}

    Please also addign an destination TWPRichText. You can use the WPReporter\Simple as starting point.

    Julian

  • if i use the code on a visible WPRichedit, everythings OK, if i use it on a WPRichedit not residing on a form (generated in code), it does not work (does not write the band infos)

    chuck

  • yes i did

    i traced the save procedure as far as i could, the problem is it does not get the object in this part of code


    if par.ParagraphType in [wpIsReportGroup, wpIsReportHeaderBand,
    wpIsReportDataBand, wpIsReportFooterBand] then
    begin
    band := par.ParagraphObjFind(WPPAROBJ_WPBAND);
    if band <> nil then
    begin
    bands := band.AsString;
    if not par.AGet(WPAT_BANDPAR_STR, i) or
    (par.ANumberToString(i) <> bands) then
    par.ASet(WPAT_BANDPAR_STR,
    par.AStringToNumber(bands));
    {$IFDEF GROUPVAR} //WP6
    bandsvar := band.ExtraAsString;
    {$ENDIF}
    end
    else
    begin
    if par.AGet(WPAT_BANDPAR_STR, i) then
    bands := par.ANumberToString(i)
    else bands := '';
    {$IFDEF GROUPVAR}
    if par.AGet(WPAT_BANDPAR_VAR, i) then
    bandsvar := par.ANumberToString(i)
    else bandsvar := '';
    {$ENDIF}
    end;
    if bands <> '' then
    begin
    WriteString('{\*\wpmergepar{');
    WriteString(bands);
    WriteString('}}');
    end;
    {$IFDEF GROUPVAR}
    if bandsvar <> '' then
    begin
    WriteString('{\*\wpmergevar{');
    WriteString(bandsvar);
    WriteString('}}');
    end;
    {$ENDIF}
    WriteString('\wpmergestart');
    FNeedSpace := TRUE;
    end;
    sty := FRTFProps.ParStyles.GetStyle(par.style);


    chuck

    [/b]

  • i tracked down the problem further, but can not get deeper in it (no source)
    It is a little strange

    saving the generated bands does only work, if the Trichtext resides on a form which is showing on screen and at least update is called (showmodal does this or a show - update sequence. After this, the bands are stored as they should

    doing it without the form showing (minimized for example), it does not work.

    Obviously the paint routine does something do get internal structures right.

    Could you have a look

    chuck

    • Offizieller Beitrag

    Hi,


    Thanks for the finding. You can replace the two lines with

    band := par.ParagraphObjFind(WPPAROBJ_WPBAND);

    with

    band := WPGetBandForPar(par);

    You need to add

    {$IFDEF WPREPORTER} ,WPRTEReport {$ENDIF}

    to the second uses clause.

    Code
    implementation
    
    
    uses Math{$IFDEF WPREPORTER} ,WPRTEReport {$ENDIF};

    This should fix this issue.

    Kind Regards,

    Julian