Pasting rtf content with a \par at the end is wrong
Pasting rtf content with a \par at the end is wrong
Pasting RTF text that also contains the \par at the end does not create the new line. This behavior is different than MS Word or Wordpad. You can easily repeat this by using MS Word as the source to copy text:
1. In MS Word, click the CTRL+* to display the paragraph marks in the text
2. Type a word
3. Carefully select the word without including the paragraph mark in the selection
4. Open Wordpad and paste the word 3 times: notice that each word is pasted next to each other: same happens in RVA.
5. Repeat step 3, but now in the selection INCLUDE the paragraph mark in the selection (with a clipboard debug utility notice that MS Word includes a trailing \par in the copied rtf text).
6. Paste now the text in Wordpad 3 times and notice that each word is pasted in a new line
7. Paste now in RVA and notice that the word is pasted in the same line as in previous step: the trainling \par is ignored.
It is very interesting also (once this is fixed) to decide the style of the new paragraph after the paste (more on that later)
Thanks,
Costas
1. In MS Word, click the CTRL+* to display the paragraph marks in the text
2. Type a word
3. Carefully select the word without including the paragraph mark in the selection
4. Open Wordpad and paste the word 3 times: notice that each word is pasted next to each other: same happens in RVA.
5. Repeat step 3, but now in the selection INCLUDE the paragraph mark in the selection (with a clipboard debug utility notice that MS Word includes a trailing \par in the copied rtf text).
6. Paste now the text in Wordpad 3 times and notice that each word is pasted in a new line
7. Paste now in RVA and notice that the word is pasted in the same line as in previous step: the trainling \par is ignored.
It is very interesting also (once this is fixed) to decide the style of the new paragraph after the paste (more on that later)
Thanks,
Costas
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
There is a problem...
Every normal MS Word document has an end-of-paragraph mark at the end, because the last paragraph is included completely.
If TRichView would threat it as a normal paragraph break, every RTF document would end by an empty line.
TRichView does not have end-of-paragraph marks, so compromises are necessary.
Every normal MS Word document has an end-of-paragraph mark at the end, because the last paragraph is included completely.
If TRichView would threat it as a normal paragraph break, every RTF document would end by an empty line.
TRichView does not have end-of-paragraph marks, so compromises are necessary.
I have a real problem here though:
I need to create (by code) a snippet of rtf code which, when pasted in RV, produces a new paragraph in the end: how do i do that?
And the second problem that occurs is this:
in MS Word, when one pastes a paragraph (fully formatted), as you said there is a new paragraph added which has the formatting of the previous/existing paragraph: with RV things are different: the style of the pasted paragraph is retained after the (because there is no new paragraph)! Imagine: i write text in black color and i want to past a paragraph of text in red color: after the paste, what color will i continue to write in? In MS Word it will be black, but in RV it will be red.
Costas
I need to create (by code) a snippet of rtf code which, when pasted in RV, produces a new paragraph in the end: how do i do that?
And the second problem that occurs is this:
in MS Word, when one pastes a paragraph (fully formatted), as you said there is a new paragraph added which has the formatting of the previous/existing paragraph: with RV things are different: the style of the pasted paragraph is retained after the (because there is no new paragraph)! Imagine: i write text in black color and i want to past a paragraph of text in red color: after the paste, what color will i continue to write in? In MS Word it will be black, but in RV it will be red.
Costas
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Let me insist that this is a bug to be fixed without an IFDEF. Do this test:
Open up RVA and MS Word side-by-side and in each of them type exactly 3 lines of text line that:
Open up a new RVA instance (this will be the target in our test) and in this new instance also type the same text as above. Now, I want you to do this: Place the mouse pointer at the beginning of the 'Line two' line (in the first RVA and MS Word respectively), hold down the SHIFT key and press the down arrow. This action fully selects the 'Line two' line: then press CTRL+C to copy this line. Now, Paste this line to the target RVA instance after having put the cursor at the begining of the 'Line three' line.
The idea here is the MS Word will put to the clipboard RTF text, whereas RVA will put to the clipbord RVF text. Notice the difference:
- When the target RVA pastes RTF text, the trailing \par is not pasted (e.g. no new line)
- When the target RVF pasted RVF text, the trainling paragraph gets pasted (e.g. new line is there).
Maybe i miss something, but this is indeed different behavior.
Costas
Open up RVA and MS Word side-by-side and in each of them type exactly 3 lines of text line that:
Code: Select all
Line one
Line two
Line three
The idea here is the MS Word will put to the clipboard RTF text, whereas RVA will put to the clipbord RVF text. Notice the difference:
- When the target RVA pastes RTF text, the trailing \par is not pasted (e.g. no new line)
- When the target RVF pasted RVF text, the trainling paragraph gets pasted (e.g. new line is there).
Maybe i miss something, but this is indeed different behavior.
Costas
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Ok, I'll make processing of the final \par when inserting without IFDEF.
However, MS Word uses the old (before insertion) attributes for the final inserted paragraph.
TRichViewEdit cannot do it (it may use it for the first inserted paragraph). TRichView will use attributes of the previous inserted paragraph.
However, MS Word uses the old (before insertion) attributes for the final inserted paragraph.
TRichViewEdit cannot do it (it may use it for the first inserted paragraph). TRichView will use attributes of the previous inserted paragraph.
Thank you! Let me know if this is an easy fix that I can patch in RV14 myself.Sergey Tkachenko wrote:Ok, I'll make processing of the final \par when inserting without IFDEF.
I thought about that too to be honest. I am not sure how MS Word does this. I already have code in OnPaste event that does some stuff there so I may be able to override this behavior myself if required.However, MS Word uses the old (before insertion) attributes for the final inserted paragraph.
TRichViewEdit cannot do it (it may use it for the first inserted paragraph). TRichView will use attributes of the previous inserted paragraph.
Costas
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Thanks. Will check back here.Sergey Tkachenko wrote:This is not a simple change, because it requires modifications in several files, including RTF saving (it appears that it adds a final \par inconsistently when saving selection).
We plan to upload a new version as soon as we process all bug reports.