Pictures in Report

I find what picture from template not copy exactly as in template. The problem is with AnchorType , it is not copy from template picture. And if picture was hided (grouped and collapsed), this picture was placed not in place where will be.

I modify code with that:

procedure TCustomFlexCelReport.ReplacePictures(var RowOffset: integer);

var

  i:integer;

  v:UTF16String;

  vwv: variant;

  vws: ByteArray;

  PictureType: TXlsImgTypes;

  RTFRuns: TRTFRunList;

  R, C: integer;

  ImgHeight, ImgWidth: extended;

  XOfsPixel, YOfsPixel: extended;

  Props: TImageProperties;

  Anchor: TClientAnchor;

  AnchorType: TFlxAnchorType; // Add

  p: TXlsImgTypes;

  ImageData: TMemoryStream;

begin

  for i:=Workbook.PicturesCount[RowOffset+1]-1 downto 0 do

  begin

    v:=Workbook.PictureName[RowOffset+1,i];

    PictureType:= GetPictureType(v);

    vwv:=GetValue(GetBandValue(v,0,-1,nil), RowOffset, 0, RTFRuns);

    if (VarType(vwv) = (varArray or varByte))  then vws := vwv else SetLength(vws, 0);

    

    if (true) and ((Length(vws) > 0) or FKeepEmptyPictures) then

    begin

      if Assigned (FOnGetImageSize) then

      begin

        Workbook.GetPicture(RowOffset+1, i, nil, p, Anchor);

        CalcImgDimentions(Workbook, Anchor, XOfsPixel, YOfsPixel, ImgWidth, ImgHeight);

        R:=Anchor.Row1;

        C:=Anchor.Col1;

        ImageData:=TMemoryStream.Create;

        try

          ImageData.Write(vws[0], Length(vws));

          FOnGetImageSize(Self,  Workbook, v, PictureType, ImageData, R, C, ImgHeight, ImgWidth);

          ImageData.Position:=0;


          SetLength(vws, ImageData.Size);

          ImageData.ReadBuffer(vws[0], length(vws));

        finally

          FreeAndNil(ImageData);

        end; //finally

        CalcImgCells(Workbook, R,C, Round(YOfsPixel), Round(XOfsPixel), ImgHeight, ImgWidth, Props);

        if(Anchor.Flag = 0) then  AnchorType :=  at_MoveAndResize;  // Add

        if(Anchor.Flag = 1) then  AnchorType :=  at_MoveAndDontResize; // Add

        if(Anchor.Flag = 2) then  AnchorType :=  at_DontMoveAndDontResize; // Add

        Workbook.AssignPictureProperties(RowOffset+1, i, Props,AnchorType); // Replace

      end;

      Workbook.AssignPicture(RowOffset+1, i, vws, PictureType);

    end;

  end;

end;

Can you add that changes in distribution?

And how I can compile component with that changes?

Now I simple replace that file on component installation.

Hi,

You are right, if you enter the event, the anchortype was being reset. We've applied the fix here, so next version will have it fixed. In the meantime, to compile the component with the changes, just replacing the file is ok. As said, in next version the changes will be in the main distribution too.

Thanks!
Adrian.