Page 1 of 1

Hyperlinks not saved

Posted: Tue Oct 17, 2017 5:39 pm
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

Re: Hyperlinks not saved

Posted: Tue Oct 17, 2017 6:02 pm
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

Re: Hyperlinks not saved

Posted: Tue Oct 17, 2017 6:31 pm
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.

Re: Hyperlinks not saved

Posted: Tue Oct 17, 2017 6:38 pm
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

Re: Hyperlinks not saved

Posted: Tue Oct 17, 2017 7:06 pm
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