merge items in RV17.6.2--RV22

General TRichView support forum. Please post your questions here
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

merge items in RV17.6.2--RV22

Post by jgkoehn »

Greetings Sergey,
Is there a new feature that merges items in RV later than 17.6.2 especially RV22.

Working on upgrading and somehow my items are merging. Theyhave the same font, etc but they have different tags.
For example: |The item1| cat item2| ate item3|
Has become: |The cat ate item1|

Edit:
As I dig deeper it seems related to loading RTF somehow.
It seems that in RTF an item like this is fine: {\fs20\cf0 {\field{\*\fldinst HYPERLINK "link"}{\fldrslt word}}space{...
but this is not fine: {\fs20\cf0 {\field{\*\fldinst HYPERLINK "link"}{\fldrslt spaceword}}{...
Last edited by jgkoehn on Tue Mar 26, 2024 6:04 pm, edited 1 time in total.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: merge items in RV17.6.2--RV22

Post by Sergey Tkachenko »

Do you load RTF or RVF?

If RTF (Rich Text Format, format of MS Word), then RTF does not have items. It has commands like "make bold", "apply font name", etc. Also, tags are not saved in RTF (except for hypertext targets stored in tags). So, items cannot be kept when saving and re-loading in RTF. And it does not depend on TRichView version.

If RVF (RichView format), then loaded document must be the same as the original document (if you use LoadRVF or LoadRVFromSteam method; insertion methods may optimize document by merging subsequent text items having identical properties; however, items that have different tags are never merged)
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

If it helps this works fine in RV17 but not in RV22 so no changes really on our end as best I can in this regard. I have two computers old version works fine under RV17. And new version on antoher computer under RV22 has this problem.

We are loading through RTF

Edit:
As I dig deeper it seems related to loading RTF somehow.
It seems that in RTF an item like this is fine:
{\fs20\cf0 {\field{\*\fldinst HYPERLINK "link"}{\fldrslt word}}space{...
but this is not fine:
{\fs20\cf0 {\field{\*\fldinst HYPERLINK "link"}{\fldrslt spaceword}}{...

The issue almost seems to be the placing of the space.

Note these all have links so as you said no items but I guess better would be "links"
Last edited by jgkoehn on Tue Mar 26, 2024 6:19 pm, edited 1 time in total.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

I may have changed code always possible but I am trying to be very careful with RV code:

here is what we are using for RTF could it be "Merging"?

Code: Select all

rv.RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded; {PI}
  with rv.Style do  for i:=0 to DEF_PARA_STYLES-1{ParaStyles.Count-1} do ParaStyles[i].Border.Style := rvbSingle;   //force RV to not use existing styles - BEGIN
  rvd.LoadRTFFromStream(ms);   //load the rtf
  with rv.Style do  for i:=0 to DEF_PARA_STYLES-1{ParaStyles.Count-1} do ParaStyles[i].Border.Style := rvbNone;   //force RV to not use existing styles - END
  rv.RTFReadProperties.ParaStyleMode := rvrsAddIfNeeded; //not needed any more

Hmms I tried to make sure RTF Options are the same as previous RV17
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

Based on above the "space" position should not matter?
And if this hasn't changed then it would be on my end?
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

Here is the RTF at least the part I could get easily in Delphi7.1
so technically here is the actual text that is Greek:
{\fldrslt \u915?\u945?\u912?\u8179?}}{...(Does NOT work)
{\fldrslt \u949?\u957?}} {...(Does work)

BSBGrkINT-----------------with English Does NOT work
'{\rtf1\ansi\ansicpg0\deff0\deflang0{\fonttbl{\f0\fcharset0 Palatino Linotype;}{\f1\fcharset0 Palatino Linotype;}{\f2\fcharset161 Gentium;}{\f3\fcharset177 Cardo;}{\f4\fcharset0 Palatino Linotype;}{\f5\fcharset0 Palatino Linotype;}}{\colortbl \red0\green0\blue128;\red51\green51\blue51;\red0\green0\blue127;\red73\green142\blue62;\red0\green128\blue128;\red51\green153\blue102;\red0\green0\blue0;\red70\green70\blue70;\red0\green0\blue1;\red153\green51\blue0;\red128\green128\blue0;\red0\green0\blue255;\red128\green0\blue128;}{\fs20\cf0 {\field{\*\fldinst HYPERLINK "_ORIGWORD_%E1%BD%89%5Cpar%7B%5Cb%5Cf0%5Cfs20%5Ccf0%20Transliteration%3A%20%5Cb0%5Ccf9%20%20Ho%7D%5Cpar%7B%5Cb%5Cf0%5Cfs20%20English%3A%20%7D%7B%5Cf0%5Cfs20%5Ccf12%20%20The%7D%26popup%3D1%7C_LEMMA_%E1%BD%81%7C_STRONG_G3588%7C_MORPH_Art-NMS%7C_NOLINK_%7C"}{\fldrslt \u8009?}}{\field{\*\fldinst HYPERLINK "_ORIGWORD_%20%CF%80%CF%81%CE%B5%CF%83%CE%B2%CF%8D%CF%84%CE%B5%CF%81%CE%BF%CF%82%2C%5Cpar%7B%5Cb%5Cf0%5Cfs20%5Ccf0%20Transliteration%3A%20%5Cb0%5Ccf9%20%20presbyteros%2C%7D%5Cpar%7B%5Cb%5Cf0%5Cfs20%20English%3A%20%7D%7B%5Cf0%5Cfs20%5Ccf12%20%20elder%2C%7D%26popup%3D1%7C_LEMMA_%CF%80%CF%81%CE%B5%CF%83%CE%B2%CF%8D%CF%84%CE%B5%CF%81%CE%BF%CF%82%7C_STRONG_G4245%7C_MORPH_Adj-NMS%7C_NOLINK_%7C"}{\fldrslt \u960?\u961?\u949?\u963?\u946?\u973?\u964?\u949?\u961?\u959?\u962?,}}{\field{\*\fldinst HYPERLINK "_ORIGWORD_%20%CE%93%CE%B1%CE%90%E1%BF%B3%5Cpar%7B%5Cb%5Cf0%5Cfs20%5Ccf0%20Transliteration%3A%20%5Cb0%5Ccf9%20%20Gai%C5%8D%7D%5Cpar%7B%5Cb%5Cf0%5Cfs20%20English%3A%20%7D%7B%5Cf0%5Cfs20%5Ccf12%20%20To%20Gaius%7D%26popup%3D1%7C_LEMMA_%CE%93%CE%AC%CF%8A%CE%BF%CF%82%7C_STRONG_G1050%7C_MORPH_N-DMS%7C_NOLINK_%7C"}{\fldrslt \u915?\u945?\u912?\u8179?}}{\field{\*\fldinst HYPERLINK "_ORIGWORD_%20%CF%84%E1%BF%B7%5Cpar%7B%5Cb%5Cf0%5Cfs20%5Ccf0%20Transliteration%3A%20%5Cb0%5Ccf9%20%20t%C5%8D%7D%5Cpar%7B%5Cb%5Cf0%5Cfs20%20English%3A%20%7D%7B%5Cf0%5Cfs20%5Ccf12%20%20the%7D%26popup%3D1%7C_LEMMA_%E1%BD%81%7C_STRONG_G3588%7C_MORPH_Art-DMS%7C_NOLINK_%7C"}{\fldrslt \u964?\u8183?}}{\fie

ABP----------------------------------------- Does work
'{\rtf1\ansi\ansicpg0\deff0\deflang0{\fonttbl{\f0\fcharset0 Palatino Linotype;}{\f1\fcharset0 Palatino Linotype;}{\f2\fcharset161 Gentium;}{\f3\fcharset177 Cardo;}{\f4\fcharset0 Palatino Linotype;}{\f5\fcharset0 Palatino Linotype;}}{\colortbl \red0\green0\blue128;\red51\green51\blue51;\red0\green0\blue127;\red73\green142\blue62;\red0\green128\blue128;\red51\green153\blue102;\red0\green0\blue0;\red70\green70\blue70;\red0\green0\blue1;\red153\green51\blue0;\red128\green128\blue0;\red219\green85\blue58;}{\fs20\cf0 {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G%2A%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u921?\u959?\u973?\u948?\u945?\u962?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G%2A%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u921?\u951?\u963?\u959?\u973?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G5547%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u967?\u961?\u953?\u963?\u964?\u959?\u973?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G1401%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u948?\u959?\u973?\u955?\u959?\u962?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G80%7C_STRONG2_G1161%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u945?\u948?\u949?\u955?\u966?\u972?\u962? \u948?\u949?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G%2A%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u921?\u945?\u954?\u974?\u946?\u959?\u965?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G3588%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u964?\u959?\u953?\u962?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G1722%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u949?\u957?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G2316%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u952?\u949?\u974?}} {\field{\*\fldinst HYPERLINK "_NOLINK_%7C_STRONG_G3962%7C_STRONG2_%7C_STRONG3_%7C_STRONG4_%7C_STRONG5_%7C"}{\fldrslt \u960?\u945?\u964?\u961?\u943?}} {\fie
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: merge items in RV17.6.2--RV22

Post by Sergey Tkachenko »

In your original example (|The item1| cat item2| ate item3|), are all 3 items hyperlinks with different targets?
In this case, they must not be merged into a single item.
Please send me a complete sample document for testing.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

They each have their own hyperlinks as shown in the RTF above. I will try to make the RTF above into a simple document.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

Here is a simple test file.
When I load this in RV22 directly it has troubles with the hyperlinks/text.
Attachments
versetext.rtf
(4.23 KiB) Downloaded 1727 times
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

Here is one that works well.
When I load this one directly in RV22 it works fine.
versetext - ABP.rtf
(3.45 KiB) Downloaded 2264 times
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

I tried the one that doesn't work in RV22 in RV17.6.2 ActionTestDemo and it works there but not in RV22
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

I found if I move the space out with a regex it works right but RegEx can't solve this it is often too complex.
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: merge items in RV17.6.2--RV22

Post by Sergey Tkachenko »

I confirm the bug in RTF and DocX reading.

Quick fix:
Open RVRTFProps.pas.
Change the line 2764 from

Code: Select all

if (InsertPoint > 0) and item.SameAsPrev and (item.StyleNo >= 0) and
        (CurrentRVData.GetItemStyle(InsertPoint - 1) = item.StyleNo) and
        (item.Checkpoint = nil) then
to

Code: Select all

if (InsertPoint > 0) and item.SameAsPrev and (item.StyleNo >= 0) and
        (CurrentRVData.GetItemStyle(InsertPoint - 1) = item.StyleNo) and
        (item.Checkpoint = nil) and
        RV_CompareTags(CurrentRVData.GetItemTag(InsertPoint - 1), item.Tag,
          rvoTagsArePChars in CurrentRVData.Options) then
After that, run "Install TRichView VCL in Delphi IDE" shortcut in Windows Start menu.
Or wait for the next update, this fix will be included.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

[EDIT]please ignore all is fixed
Excellent thank you sir,
The install is not picking up my Delphi 7.1 or Delphi 12 hmms
Is there a manual way to rebuild or is it complex?
Last edited by jgkoehn on Wed Mar 27, 2024 9:17 pm, edited 1 time in total.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: merge items in RV17.6.2--RV22

Post by jgkoehn »

Ah it seems to have worked right off in the Delphi 7.1/12 without the re-install
So we are good to go! Thank you again sir.
Post Reply