The header string cannot be replaced after upgrading to version 8.5

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
th9999
Posts: 35
Joined: Tue Jun 25, 2013 10:42 am

The header string cannot be replaced after upgrading to version 8.5

Post by th9999 »

Hello administrator

I upgraded ScaleRichView to version 8.5 today, but now I find that the substitution of header string cannot work properly, please help me have a look. thank you

Code: Select all

///Change the header code//////////////////////////////////////////////////
for i := 0 to SRichViewEdit1.RVHeader.ItemCount-1 do
begin
if SRichViewEdit1.RVHeader.RVData.GetItemStyle(i) = rvsTable then 
begin
TableTmp := TRVTableItemInfo(SRichViewEdit1.RVHeader.RVData.GetItem(i));
for tmpRow := 0 to TableTmp.RowCount-1 do 
begin
for tmpCol := 0 to TableTmp.ColCount-1 do 
begin
if TableTmp.Cells[tmpRow,tmpCol]<>nil then
begin
RVData := TableTmp.Cells[tmpRow,tmpCol].GetRVData;
for tmpTtemNO:=0 to RVData.ItemCount -1 do
begin
tmpCSID := Trim(RVData.GetItemTag(tmpTtemNO));
if (Trim(tmpCSID)<>'') and (Trim(tmpCSID)<>'DoctorID') then
begin
tmpCSJG := GetFieldLocation(tmpCSID);
if Trim(tmpCSJG) <> '' then
RVData.SetItemTextW(tmpTtemNO, WideString(tmpCSJG));
end;
end;
end;
end;
end;
end else begin 
tmpCSID := Trim(SRichViewEdit1.RVHeader.GetItemTag(i));
if (Trim(tmpCSID)<>'') and (Trim(tmpCSID)<>'DoctorID') then
begin
tmpCSJG := GetFieldLocation(tmpCSID);
if Trim(tmpCSJG) <> '' then
SRichViewEdit1.RVHeader.SetItemTextEdW(i, WideString(tmpCSJG));
end;
end;
end;
//Change the body code//////////////////////////////////////////////////
for i := 0 to SRichViewEdit1.RichViewEdit.ItemCount-1 do
begin
if SRichViewEdit1.RichViewEdit.RVData.GetItemStyle(i) = rvsTable then 
begin 
TableTmp := TRVTableItemInfo(SRichViewEdit1.RichViewEdit.RVData.GetItem(i));
for tmpRow := 0 to TableTmp.RowCount-1 do 
begin
for tmpCol := 0 to TableTmp.ColCount-1 do 
begin
if TableTmp.Cells[tmpRow,tmpCol]<>nil then
begin
RVData := TableTmp.Cells[tmpRow,tmpCol].GetRVData;
for tmpTtemNO:=0 to RVData.ItemCount -1 do
begin
tmpCSID := Trim(RVData.GetItemTag(tmpTtemNO));
if (Trim(tmpCSID)<>'') and (Trim(tmpCSID)<>'DoctorID') then
begin
tmpCSJG := GetFieldLocation(tmpCSID);
if Trim(tmpCSJG) <> '' then
RVData.SetItemTextW(tmpTtemNO, WideString(tmpCSJG));
end;
end;
end;
end;
end;
end else begin 
tmpCSID := Trim(SRichViewEdit1.RichViewEdit.GetItemTag(i));
if (Trim(tmpCSID)<>'') and (Trim(tmpCSID)<>'DoctorID') then
begin
tmpCSJG := GetFieldLocation(tmpCSID);
if Trim(tmpCSJG) <> '' then
SRichViewEdit1.RichViewEdit.SetItemTextEdW(i, WideString(tmpCSJG));
end;
end;
end;
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: The header string cannot be replaced after upgrading to version 8.5

Post by Sergey Tkachenko »

This code is for old version of ScaleRichView that had only one header (stored in RVHeader) and one footer (stored in RVFooter).

In newer versions of ScaleRichView, header/footer design was changed. There are up to 6 headers and footers (in addition to standard headers and footers, there are headers and footers for the first page and for even pages). In the new version, RVHeader/RVFooter contain header/footer only when they are being edited. In other time, headers and footers are stored in SubDocuments[] property.

So, you have the following options to modify headers

1) If you generate a document and do not want this operation to be undone, modify the document in SRichViewEdit1.SubDocuments[srvhftNormalHeader] instead of SRichViewEdit1.RVHeader.
SubDocuments[] are not editors, they do not have editing methods (like SetItemTextEd), but they have viewer-style methods (like SetItemText).
To modify SubDocuments[], you must be sure that this header is not being edited. You can do it before displaying document in ScaleRichView, or when the main document is being edited.

OR

2) You can modify document in RVHeader, but only when this header is being edited.
You can activate the header editing by SRichView1.StartEditing(srvrveHeader).
ScaleRichView must be formatted before calling StartEditing.

See also:
https://www.trichview.com/forums/viewto ... f=3&t=8843 - example how to generate document in ScaleRichView, including headers and footers.
th9999
Posts: 35
Joined: Tue Jun 25, 2013 10:42 am

Re: The header string cannot be replaced after upgrading to version 8.5

Post by th9999 »

Hello administrator, the version of my current project should be updated to the correct version, the current version 8.5
Image
th9999
Posts: 35
Joined: Tue Jun 25, 2013 10:42 am

Re: The header string cannot be replaced after upgrading to version 8.5

Post by th9999 »

Hello administrator, the version of my current project should be updated to the correct version, the current version 8.5
Image
Attachments
11111.png
11111.png (8.69 KiB) Viewed 96552 times
th9999
Posts: 35
Joined: Tue Jun 25, 2013 10:42 am

Re: The header string cannot be replaced after upgrading to version 8.5

Post by th9999 »

Hello administrator

I can compile the new version now, that is, which header is modified and replaced, I did not understand your meaning, please kindly give some code examples, the new function can be temporarily postponed, now this is the most urgent, thank you
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: The header string cannot be replaced after upgrading to version 8.5

Post by Sergey Tkachenko »

The example of header generation is here:
https://www.trichview.com/forums/viewto ... f=3&t=8843

If it is too complicated, here is the simplest example:

Code: Select all

srv.Clear;
srv.SubDocuments[srvhftNormalHeader].AddNL('This is a header', 0, 0);
srv.RichViewEdit.AddNL('This is the main document', 0, 0);
srv.Format;
PS: It is possible that you installed the new version in Delphi (and the Object Inspector shows the new version number), but projects are still compiled with older versions of the components, if their files are available in the project's search path.
th9999
Posts: 35
Joined: Tue Jun 25, 2013 10:42 am

Re: The header string cannot be replaced after upgrading to version 8.5

Post by th9999 »

The administrator

I'm sorry, maybe I didn't make it clear, you gave the example of creating a new header, but in my current project, the header is always changing, and there are a lot of parameters in it, I want to replace the parameter values in it, not create.


So far my project header, plain text can be replaced, the code is: SRichViewEdit1. The SubDocuments [srvhftNormalHeader] SetItemTextW (I, WideString (tmpCSJG));

The contents of the table in the header, however, cannot be replaced
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: The header string cannot be replaced after upgrading to version 8.5

Post by Sergey Tkachenko »

You can use SubDocuments[srvhftNormalHeader] not only for creating a new header, but for modifying existing header.

You old code must work if you replace all occurrences of "SRichViewEdit1.RVHeader" to "SRichViewEdit1.SubDocuments[srvhftNormalHeader]".
It does not matter if the text is inserted directly in the header or in a table.
You cannot use editing methods (SetItemTextEdW), but I believe your code uses it by a mistake (and SetItemTextW must be used).

Before making changes, you must be sure that the header is not being edited.
If the document is already displayed to the user, you can call SRichViewEdit1.StartEditing(srvrveMain) (before calling your code for modifying header!)
After making changes, call SRichViewEdit1.Format.
th9999
Posts: 35
Joined: Tue Jun 25, 2013 10:42 am

Re: The header string cannot be replaced after upgrading to version 8.5

Post by th9999 »

Hello administrator

The historical function can be restored according to the previous method. Thank you very much for your technical support today. At least the project can work normally at present. Other problems are waiting for further examination.

Thank you very much!
Post Reply