WPCubed Product Support

How to delete hyperlink for some of the image objects?

Hi,

I am using following code to insert images with hyperlink into the editor:

// SelectInternalHyperlinkAsObject is method which creates // new TWPOImage descendant class object. So different formats  // has different classes - TdoWPSoundImage, TdoWPFlashImage etc...// lImageHyperlink is new object created by the method.lImageHyperlink:=SelectInternalHyperlinkAsObject(WorkWithRichText.Memo.RTFData);if Assigned(lImageHyperlink) thenbegin  with lImageHyperlink do  begin     //... some settings here  end;  WorkWithRichText.SelectedObject := WorkWithRichText.TextObjects.Insert(lImageHyperlink);  lHyperlinkObject := WorkWithRichText.HyperlinkAtCP;   // we need to setup also hyperlink for this new object  lPomS := CONST_HYPERLINK_GUID + TdoWPImage(lImageHyperlink).GUID;  if lHyperlinkObject <> nil then    lHyperlinkObject.Source := lPomS  else    WorkWithRichText.InputHyperlink(lPomS);end;

I need the inserted hyperlink available when showing the text inside the application.
I have also created new HTML writer class, to be able to render our own object for the web browsers as needed.

In the writer I override the method WriteObject and I am calling the appropriate code to render correct HTML for the TdoWPSoundImage and other objects. But here is the problem. Because the Hyperlink text object is always generated as A tag, I always get something like

<a href ....><embed id........></a>

the embed part is our own code. The a href part is from hyperlink object. This makes some problems for us.

I have method which is called before the rich text is generated to html. In this method I need to delete some of the hyperlinks, based on the hyperlink's inner image object class. My idea is:

  1. Iterate throught all TextObjects inside the richtext. (I know how to do it 🙂
  2. If the objref for current object is our own class (TdoWPSoundImage) then delete its text hyperlink object (I have no idea how to do this - I can select hyperlink at CP but How can I found the CP for the selected object). Or is there any other way how to solve it?

Can you help me, please?

Petr.

#1 ♥ 0
3.2k Views 2 users read 2 min
support

Hi,

WorkWithRichText.InputHyperlink(lPomS);

will create those hyperlink objects around your embedded object. In fact you have 3 objects now.

TWPHTMLWriter.WriteObject

is also used to write the hyperlinks. If you have already a descendent class, why not use the overriding method to ignore the hyperlinks which contain your object.

You have access to the current paragraph, the position and only need to check if the character after the hyperloink par.ObjRef[posinpar+1] is one of your embedded objects.

Julian

#2 ♥ 0
This category is archived. No new posts are possible.