Page 1 of 1

update all image

Posted: Mon Jul 09, 2012 11:24 am
by cychia
how can i update all images in the content to stay in its own line? for example, this is my content:

abc[picture]xyz

i want it to be:

abc
[picture]
xyz

Posted: Mon Jul 09, 2012 12:40 pm
by Sergey Tkachenko
Assuming that this operation do not need to be undone:

Code: Select all

uses RVTable, CRVData;

procedure MoveImagesToNewLine(RVData:TCustomRVData);
var i,r,c: Integer;
    Table: TRVTableItemInfo;
begin
  for i := 0 to RVData.ItemCount-1 do
    case RVData.GetItemStyle(i) of
      rvsPicture, rvsHotPicture:
        begin
          if (i>0) and (RVData.GetItemStyle(i-1)<>rvsListMarker) then
            RVData.GetItem(i).SameAsPrev := False;
          if i+1<RVData.ItemCount then
            RVData.GetItem(i+1).SameAsPrev := False;
        end;
      rvsTable:
        begin
          Table := TRVTableItemInfo(RVData.GetItem(i));
          for r := 0 to Table.RowCount-1 do
            for c := 0 to Table.ColCount-1 do
              if Table.Cells[r,c]<>nil then
                MoveImagesToNewLine(Table.Cells[r,c].GetRVData);
        end;
    end;
end;

procedure TForm3.ToolButton68Click(Sender: TObject);
begin
  RichViewEdit1.ClearUndo;
  MoveImagesToNewLine(RichViewEdit1.RVData);
  RichViewEdit1.Format;
end;

Posted: Thu Jul 12, 2012 11:05 am
by cychia
Sergey Tkachenko wrote:Assuming that this operation do not need to be undone:

Code: Select all

uses RVTable, CRVData;

procedure MoveImagesToNewLine(RVData:TCustomRVData);
var i,r,c: Integer;
    Table: TRVTableItemInfo;
begin
  for i := 0 to RVData.ItemCount-1 do
    case RVData.GetItemStyle(i) of
      rvsPicture, rvsHotPicture:
        begin
          if (i>0) and (RVData.GetItemStyle(i-1)<>rvsListMarker) then
            RVData.GetItem(i).SameAsPrev := False;
          if i+1<RVData.ItemCount then
            RVData.GetItem(i+1).SameAsPrev := False;
        end;
      rvsTable:
        begin
          Table := TRVTableItemInfo(RVData.GetItem(i));
          for r := 0 to Table.RowCount-1 do
            for c := 0 to Table.ColCount-1 do
              if Table.Cells[r,c]<>nil then
                MoveImagesToNewLine(Table.Cells[r,c].GetRVData);
        end;
    end;
end;

procedure TForm3.ToolButton68Click(Sender: TObject);
begin
  RichViewEdit1.ClearUndo;
  MoveImagesToNewLine(RichViewEdit1.RVData);
  RichViewEdit1.Format;
end;
it works, but i need one more changes to the image para which is alignment will be changed to rvaCenter.

Posted: Thu Jul 12, 2012 12:11 pm
by Sergey Tkachenko
Do you want to keep all other paragraph properties (such as indents or background) and simple make this paragraph centered?
Or may be you want to apply some specific paragraph style (centered, no indents, no background color, etc.)

Posted: Fri Jul 13, 2012 11:42 am
by cychia
Sergey Tkachenko wrote:Do you want to keep all other paragraph properties (such as indents or background) and simple make this paragraph centered?
Or may be you want to apply some specific paragraph style (centered, no indents, no background color, etc.)
now the picture is on para of its own right? i want the picture to be aligned to center. there will no other things are allowed in the same para with the picture