'wrong' caret if copying text from internet
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
You included rvoShowSpecialCharacters in RichViewEdit.Options.
So you can see dots in place of spaces, a pilcrow character at the end of paragraph, and a paragraph level.
This text, obviously, was copied from the heading level 2 (<h2>...</h2>) of the web page, so you can see "(2)" next to a pilcrow character, because this text is pasted as a heading level 2.
How to convert it to normal text:
If you use RichViewActions, select this text, open the paragraph dialog, and choose "outline level"="body text" ( http://www.trichview.com/shots/rva/para ... elevel.png )
If you do not use RichViewAction, implement a command (paragraph style conversion) that will change OutlineLevel property of paragraph style (use ApplyParaStyleConversion + OnParaStyleConversion event)
How to hide this character:
Remove rvscParagraphAttrs from RVVisibleSpecialCharacters (global variable defined in RVStyle unit). It will hide "(2)" even in show-special-character mode. However, this text will still be a heading of level 2, and will be exported to HTML and RTF as a heading.
So you can see dots in place of spaces, a pilcrow character at the end of paragraph, and a paragraph level.
This text, obviously, was copied from the heading level 2 (<h2>...</h2>) of the web page, so you can see "(2)" next to a pilcrow character, because this text is pasted as a heading level 2.
How to convert it to normal text:
If you use RichViewActions, select this text, open the paragraph dialog, and choose "outline level"="body text" ( http://www.trichview.com/shots/rva/para ... elevel.png )
If you do not use RichViewAction, implement a command (paragraph style conversion) that will change OutlineLevel property of paragraph style (use ApplyParaStyleConversion + OnParaStyleConversion event)
How to hide this character:
Remove rvscParagraphAttrs from RVVisibleSpecialCharacters (global variable defined in RVStyle unit). It will hide "(2)" even in show-special-character mode. However, this text will still be a heading of level 2, and will be exported to HTML and RTF as a heading.
Why are wrong ?
My code:
procedure TForm1.sbTesten1Click(Sender: TObject);
begin
memo.ApplyParaStyle(PARA_OUTLINELEVEL_0);
memo.format;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
const
//rv
rv_MAKEBOLD = 1;
..
// Parameters for ApplyParaStyleConversion
PARA_ALIGNMENT = 1;
..
PARA_OUTLINELEVEL_0 = 9;
//rv-Ende
procedure TForm1.memoParaStyleConversion(Sender: TCustomRichViewEdit; StyleNo, UserData: Integer; AppliedToText: Boolean; var NewStyleNo: Integer);
var ParaInfo: TParaInfo;
Tabs: TRVTabInfos;
za, aa, bb: integer;
begin
ParaInfo := TParaInfo.Create(nil);
try
ParaInfo.Assign(rvs.ParaStyles[StyleNo]);
case UserData of
PARA_ALIGNMENT:
ParaInfo.Alignment := GetAlignmentFromUI;
.........
PARA_COLOR: ParaInfo.Background.Color := cd.Color;
PARA_OUTLINELEVEL_0: ParaInfo.outlineLevel:= 0;
end;
NewStyleNo := rvs.ParaStyles.FindSuchStyle(StyleNo,ParaInfo,RVAllParaInfoProperties);
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Do you mean this ?
PARA_COLOR: ParaInfo.Background.Color := cd.Color;
PARA_OUTLINELEVEL_0: ParaInfo.outlineLevel:= 0;
end;
NewStyleNo := rvs.ParaStyles.FindSuchStyle(StyleNo,ParaInfo,RVAllParaInfoProperties);
if NewStyleNo=-1 then begin
rvs.ParaStyles.Add;
NewStyleNo := rvs.ParaStyles.Count-1;
rvs.ParaStyles[NewStyleNo].Assign(ParaInfo);
rvs.ParaStyles[NewStyleNo].Standard := False;
end;
finally
ParaInfo.Free;
end;
PARA_COLOR: ParaInfo.Background.Color := cd.Color;
PARA_OUTLINELEVEL_0: ParaInfo.outlineLevel:= 0;
end;
NewStyleNo := rvs.ParaStyles.FindSuchStyle(StyleNo,ParaInfo,RVAllParaInfoProperties);
if NewStyleNo=-1 then begin
rvs.ParaStyles.Add;
NewStyleNo := rvs.ParaStyles.Count-1;
rvs.ParaStyles[NewStyleNo].Assign(ParaInfo);
rvs.ParaStyles[NewStyleNo].Standard := False;
end;
finally
ParaInfo.Free;
end;
j&b wrote:Do you mean this ?
PARA_COLOR: ParaInfo.Background.Color := cd.Color;
PARA_OUTLINELEVEL_0: ParaInfo.outlineLevel:= 0;
end;
NewStyleNo := rvs.ParaStyles.FindSuchStyle(StyleNo,ParaInfo,RVAllParaInfoProperties);
if NewStyleNo=-1 then begin
rvs.ParaStyles.Add;
NewStyleNo := rvs.ParaStyles.Count-1;
rvs.ParaStyles[NewStyleNo].Assign(ParaInfo);
rvs.ParaStyles[NewStyleNo].Standard := False;
end;
finally
ParaInfo.Free;
end;
YES
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
2. Solution:
procedure TForm1.memoParaStyleConversion(...)
... //in my 1. solution I called memoParaStyle(...)
PARA_OUTLINELEVEL_0: ParaInfo.outlineLevel:= 0; // Whether 0, -1 or -x I get a paragraph level
end;
NewStyleNo := rvs.ParaStyles.FindSuchStyle(StyleNo,ParaInfo,RVAllParaInfoProperties);
if NewStyleNo<0 then begin //=-1
...
procedure TForm1.sbTesten1Click(Sender: TObject);
begin
memo.ApplyParaStyleConversion (PARA_OUTLINELEVEL_0);
end;
Sergey, do you have a folder on your homepage where someone (with login) can upload the images for a topic ?
All my images for this topic are lost if I delete them after a time. I think an image often is better than a text.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
As I understand, you already found the bug: you called ApplyParaStyle instead of ApplyParaStyleConversion.
By the way, after applying this procedure, you can see a square next to pilcrow character for these paragraphs. This square is displayed because these paragraphs have rvpaoKeepWithNext in Options. Probably, it makes sense to remove this option in the same command.
Unfortunately, I cannot open ftp for uploading files, because I cannot control the content that will be uploaded there, if somebody decide to upload infected files.
By the way, after applying this procedure, you can see a square next to pilcrow character for these paragraphs. This square is displayed because these paragraphs have rvpaoKeepWithNext in Options. Probably, it makes sense to remove this option in the same command.
Unfortunately, I cannot open ftp for uploading files, because I cannot control the content that will be uploaded there, if somebody decide to upload infected files.
...
Sergey:
... you can see a square next to pilcrow character for these paragraphs.
This square is displayed because these paragraphs have rvpaoKeepWithNext in Options.
Probably, it makes sense to remove this option in the same command:
...
PARA_OUTLINELEVEL_0:
begin
ParaInfo.outlineLevel:= 0;
ParaInfo.Options := ParaInfo.Options-[rvpaoKeepWithNext];
end;
...
Thank you. All runs fine.[/b]
Sergey:
... you can see a square next to pilcrow character for these paragraphs.
This square is displayed because these paragraphs have rvpaoKeepWithNext in Options.
Probably, it makes sense to remove this option in the same command:
...
PARA_OUTLINELEVEL_0:
begin
ParaInfo.outlineLevel:= 0;
ParaInfo.Options := ParaInfo.Options-[rvpaoKeepWithNext];
end;
...
Thank you. All runs fine.[/b]