Page 1 of 1
'wrong' caret if copying text from internet
Posted: Sat Sep 18, 2010 9:32 am
by j&b
Posted: Sat Sep 18, 2010 11:20 am
by Sergey Tkachenko
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.
Posted: Sat Sep 18, 2010 12:30 pm
by j&b
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);
Posted: Sat Sep 18, 2010 3:27 pm
by Sergey Tkachenko
Do you have a code for creating a new paragraph style in memoParaStyleConversion, if FindSuchStyle returns -1?
Posted: Sat Sep 18, 2010 4:00 pm
by j&b
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;
Posted: Sat Sep 18, 2010 4:03 pm
by j&b
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
Posted: Sat Sep 18, 2010 4:44 pm
by Sergey Tkachenko
The code is correct.
However, red border around paragraphs means that incorrect index of paragraph style is used (<0 or >=rvs.ParaStyles.Count).
Probably, error is in some other place.
Can you create a simple project to reproduce this problem and send it to me by email?
Posted: Sun Sep 19, 2010 8:14 am
by j&b
2. Solution:
procedure TForm1.memoParaStyle
Conversion(...)
... //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.
Posted: Sun Sep 19, 2010 10:26 am
by Sergey Tkachenko
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.
Posted: Sun Sep 19, 2010 12:05 pm
by j&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]