Page 1 of 1

Header/footer save the initial state of the Label

Posted: Sun Jan 30, 2022 10:19 pm
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?

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

Posted: Mon Jan 31, 2022 4:00 pm
by Sergey Tkachenko
What code do you use to change text?

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

Posted: Mon Jan 31, 2022 5:38 pm
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;

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

Posted: Tue Feb 01, 2022 6:47 am
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.

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

Posted: Wed Feb 02, 2022 12:42 pm
by Vitalii
Hi Sergey,
thanks for your help! SRV.RVFooter.Change is a simple and quick solution.