update all image

General TRichView support forum. Please post your questions here
Post Reply
cychia
Posts: 104
Joined: Mon Jan 16, 2006 1:52 am

update all image

Post 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
Sergey Tkachenko
Site Admin
Posts: 17604
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
cychia
Posts: 104
Joined: Mon Jan 16, 2006 1:52 am

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17604
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.)
cychia
Posts: 104
Joined: Mon Jan 16, 2006 1:52 am

Post 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
Post Reply