Header/footer save the initial state of the Label

General TRichView support forum. Please post your questions here
Post Reply
Vitalii
Posts: 61
Joined: Sat Oct 20, 2018 2:55 pm

Header/footer save the initial state of the Label

Post by Vitalii »

Hi, I have a question.

I add a descendant of Label or Math equation to the header/footer (for example, the text "a=10"). After that, I programmatically change the object's text to "a=20", which displays correctly. But when I save the document and reopen it, the text reverts to its original state of "a=10".
By the way, in the body of the main document, all changes are fixed normally. The problem only appears in the header/footer of TScaleRichView.

Please tell me, what could be the problem?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Header/footer save the initial state of the Label

Post by Sergey Tkachenko »

What code do you use to change text?
Vitalii
Posts: 61
Joined: Sat Oct 20, 2018 2:55 pm

Re: Header/footer save the initial state of the Label

Post by Vitalii »

In both cases, I change Text property due to change additional "Script" property. The object load/save "Script" property using _ExtraCustomProperty mechanism.

TRVScriptEquationItemInfo = class(TRVMathItemInfo)

Code: Select all

procedure TRVScriptEquationItemInfo.SetScript(const Value: string);
begin
  if FScript <> Value then
    begin
      FScript := Value;
      Text := '\text{' +  FScript + '}';
    end;
end;
TRVScriptTextItemInfo = class(TRVLabelItemInfo)

Code: Select all

procedure TRVScriptTextItemInfo.SetScript(const Value: string);
begin
  if FScript <> Value then
    begin
      FScript := Value;
      Text := FScript;
    end;
end;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Header/footer save the initial state of the Label

Post by Sergey Tkachenko »

Headers and footers are stored in SRV.SubDocuments[] (when they are not being edited), or in SRV.RVHeader/SRV.RVFooter (when they are being edited).

If the header/footer are not being edited, you can change properties of items in SRV.SubDocuments, and they will be saved to RVF.

If the header/footer is being edited (you can activate editing it using SRV.StartEditing()), you can change properties of items in SRV.RVHeader/SRV.RVFooter. Changes will be saved (first, to SRV.SubDocuments[], then to a file) when editing is finished (or when the document is being saved/printed). However, these changes are saved ONLY if the editor knows that they were made.
To inform the editor, you can use editing-style methods for changing properties: SetItemExtraStrPropertyExEd, SetCurrentItemExtraStrPropertyEx. Or, if you use non-editing methods, call SRV.RVHeader.Change (or SRV.RVFooter.Change) after the changes were made.
Vitalii
Posts: 61
Joined: Sat Oct 20, 2018 2:55 pm

Re: Header/footer save the initial state of the Label

Post by Vitalii »

Hi Sergey,
thanks for your help! SRV.RVFooter.Change is a simple and quick solution.
Post Reply