Page 1 of 1
TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 7:41 am
by cointec
Hello,
I have a TRichViewEdit control and I retrieve the rich text through a TStringStream.
var lRTF: TStringStream;
begin
lRTF := TStringStream.Create('');
try
Editor.SaveRTFToStream( lRTF, False );
Result := lRTF.DataString;
finally
lRTF.Free;
end;
If I only make the text bold, the text is not modified.
Another example, modifying only the size of a table.
Is there any TRichViewEdit option to apply those modifications?
a greeting
Re: TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 10:29 am
by Sergey Tkachenko
Sorry, I do not understand the question.
Of course, there are many operations for modifying properties of font, paragraphs and objects that do not affect text content.
However, if you save text as RTF, RTF will be different because RTF is not just a plain text, it contains information about text and table properties.
I do not understand, how do you want to apply these changes?
In Editor? or in the resulting RTF string?
Re: TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 12:23 pm
by cointec
I edit a text
- 1.png (3.09 KiB) Viewed 9054 times
Set as bold text
- 2.png (2.25 KiB) Viewed 9054 times
When i save RTF text into TStringStream, the text is not modified:
Code: Select all
function TfEditorRV.TextoRTF: string;
var lRTF: TStringStream;
begin
lRTF := TStringStream.Create('');
try
Editor.SaveRTFToStream( lRTF, False );
Result := lRTF.DataString;
finally
lRTF.Free;
end;
end;
Editor is TRichViewEdit
If i set as bold text and add a new character its ok. Like this
- 3.png (1.51 KiB) Viewed 9054 times
Re: TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 1:08 pm
by Sergey Tkachenko
When i save RTF text into TStringStream, the text is not modified:
Sorry, what do you mean?
Where is the text not modified? in Editor? In RTF string?
Re: TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 2:20 pm
by cointec
1. I put the original text in Editor.
2. With the Editor, I only put the text in bold
3. Using the method SaveRTFToStream( TStringStream, Boolean) from Editor. The text recovered have the origal texto
Code: Select all
function TfEditorRV.TextoRTF: string;
var lRTF: TStringStream;
begin
lRTF := TStringStream.Create('');
try
Editor.SaveRTFToStream( lRTF, False );
Result := lRTF.DataString;
finally
lRTF.Free;
end;
end;
"lRTF.DataString" has the original text
If in addition to making the text bold, I add a character, the RTF text contain the change to bold
Re: TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 2:40 pm
by Sergey Tkachenko
Do you mean that RTF saved at step 3 has non-bold text?
Can you create a simple project to reproduce this problem?
Re: TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 2:56 pm
by standay
I tried this and it seems to be working. I'm changing the bold this way:
Code: Select all
procedure TForm1.ToggleBold;
begin
if rve.GetItemStyle(rve.CurItemNo) <> 1 then
rve.ApplyTextStyle(1)
else
rve.ApplyTextStyle(0);
rve.Reformat;
end;
Then, using your function:
Code: Select all
function TextoRTF: string;
var lRTF: TStringStream;
begin
lRTF := TStringStream.Create('');
try
form1.rve.SaveRTFToStream( lRTF, False );
Result := lRTF.DataString;
finally
lRTF.Free;
end;
end;
And this on a button:
Code: Select all
procedure TForm1.Button4Click(Sender: TObject);
begin
ShowMessage(TextoRTF);
end;
The RTF code returned by the TexttoRTF function is correct as I set or unset bold and click the button that runs the function. When I set the text to bold I see \b in the returned RTF. When I unbold it, the \b goes away in the returned RTF.
Re: TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 4:48 pm
by Sergey Tkachenko
So, is the problem solved?
Re: TRichViewEdit. Modify bold only
Posted: Mon Apr 11, 2022 6:03 pm
by standay
My post above was just some test code to try and help the original poster. Not sure if what I tried will help him or not. Stan
Re: TRichViewEdit. Modify bold only
Posted: Tue Apr 12, 2022 7:34 am
by cointec
My mistake, it works fine.
Sorry