Hyperlinks not saved

General TRichView support forum. Please post your questions here
Post Reply
lbreysse
Posts: 11
Joined: Sat Apr 09, 2011 12:31 am

Hyperlinks not saved

Post by lbreysse »

Hello,

I have defined a standard set of styles with style templates. ParaStyle and TextStyle are not saved, to keep the file size as small as possible.
Everything works fine when saving and loading documents, except for hyperlinks:
When I set and hyperlink with the code below, the 'Hyperlink' style template is applied and I can then click the hyperlink on the richview component.
Once saved and reloaded, the hyperlink is read as a Normal style, not Hyperlink style.
The Tag is correctly set, saved and reloaded, but it seems the Hyperlink style and the jump property of the style are not loaded.

Any idea on what is wrong?

My code to set the hyperlink (that works correctly on another software):
rve.ApplyTextStyleTemplate(5, True, True); // style 5 is hyperlink style, both on style templates and text styles. text style jump property is true
rve.ApplyTextStyle(5);
rve.SetItemTag(ItemNo, aurl); // New TRVTag type

Richview options are:
ARichView.UseStyleTemplates := True;
ARichView.RVFParaStylesReadMode := rvf_sInsertMap;
ARichView.RVFTextStylesReadMode := rvf_sInsertMap;
ARichView.RVFOptions := [
rvfoConvUnknownStylesToZero,
rvfoSaveBinary,
// rvfoSaveParaStyles,
// rvfoSaveTextStyles,
rvfoSaveDocProperties,
rvfoSavePicturesBody
];

Many thanks,
Laurent
lbreysse
Posts: 11
Joined: Sat Apr 09, 2011 12:31 am

Re: Hyperlinks not saved

Post by lbreysse »

Hello,

The RVF file saved for the hyperlink is:
-8 1 3 1
-9 0 0 0 0 0 7
29 1 0 8 0 "http://www.link.com"
t e x t )

It seems that the hyperlink style (code 5) is replaced by a new style number 29. Any idea why?

Thanks,
Laurent
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Hyperlinks not saved

Post by Sergey Tkachenko »

When you call ApplyStyleTemplates (and also ApplyStyleConversion and ApplyParaStyleConversion), new styles may be added. If you do not save them in RVF, they will be lost. So I suggest to include rvfoSaveTextStyles and rvfoSaveParaStyles in RVFOptions, and change ReadMode properties back to sInsertMerge.
The only thing that you can do to reduce file sizes is including rvfoSaveStyleTemplatesOnlyNames in RVFOptions. In this case, StyleTemplates will not be saved in RVF, you will need to save them separately. Of course, it makes sense only if you use the same StyleTemplates for multiple documents.
----
If you want to use a fixed unchanged collection of TextStyles, ParaStyles and ListStyles, you cannot use StyleTemplates (as well as commands like "Make bold", "Apply font name". In this case, your UI must have only commands for applying predefined TextStyles and ParaStyles). In this mode, you can store TextStyles and ParaStyles externally, and store RVF without them.
lbreysse
Posts: 11
Joined: Sat Apr 09, 2011 12:31 am

Re: Hyperlinks not saved

Post by lbreysse »

Thank you Sergey
I though I could use Style Templates to easily apply text and para styles, but will revert to regular text and para styles only.

Best regards,
Laurent
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Hyperlinks not saved

Post by Sergey Tkachenko »

There is still a possibility of using StyleTemplates and standard editor UI for changing text and paragraph attributes, without saving style collections in documents, see my answer in http://www.trichview.com/forums/viewtop ... 911#p33945
Post Reply