Pasting rtf content with a \par at the end is wrong

General TRichView support forum. Please post your questions here
Post Reply
csterg
Posts: 306
Joined: Fri Nov 25, 2005 9:09 pm

Pasting rtf content with a \par at the end is wrong

Post by csterg »

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
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

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.
csterg
Posts: 306
Joined: Fri Nov 25, 2005 9:09 pm

Post by csterg »

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
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1. In the current version, you can use double \par at the end
2. If you paste at the beginning of a paragraph, the style of the pasted paragraph is used. If you paste in the middle of a paragraph, the style of existing paragraph is not changed. As for me, this is a natural behavior.
csterg
Posts: 306
Joined: Fri Nov 25, 2005 9:09 pm

Post by csterg »

Sergey Tkachenko wrote:1. In the current version, you can use double \par at the end
But if i do that, then i will be creating 2 paragraphs if this same text is pasted elsewhere, so this is not an option.
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Well, I can implement adding this line break when inserting, and ignoring it when loading.
If I do it, it will b $IFDEFed, because I do not like that the same fragment in text and RVF will be inserted without line breaks, only RTF will be ended by a line break.
csterg
Posts: 306
Joined: Fri Nov 25, 2005 9:09 pm

Post by csterg »

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:

Code: Select all

Line one
Line two
Line three
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
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

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.
csterg
Posts: 306
Joined: Fri Nov 25, 2005 9:09 pm

Post by csterg »

Sergey Tkachenko wrote:Ok, I'll make processing of the final \par when inserting without IFDEF.
Thank you! Let me know if this is an easy fix that I can patch in RV14 myself.
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.
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.
Costas
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

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.
csterg
Posts: 306
Joined: Fri Nov 25, 2005 9:09 pm

Post by csterg »

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.
Thanks. Will check back here.
Post Reply