trichview.com

trichview.support




Re: HTML links in table content


Return to index


Author

Message

Chris

Posted: 01/08/2003 20:40:09


That works as expected. The problem is setting the ItemTag in the first place.

At the moment I have to loop throgh all items to find any table with a selected

cell then use the InPlaceEditor for that cell to set the ItemTag..., see

the code snip below. I will also have to extend this to cope with nested

tables, is there a better way?


***************************************************************

procedure TForm1.btnExternalLinkClick(Sender: TObject);

var

  URL: String;

  i: integer;

  jmpStyle: integer;

  selStart, selEnd: integer;

  startOffs, endOffs: integer;

  info: TRVTableItemInfo;

  editor: TCustomRichViewEdit;

begin

  //initially assume selection is not in a table

  editor := rve;

  //go looking for tables

  for i := 0 to rve.ItemCount - 1 do

  begin

    if rve.GetItem(i).ClassName = 'TRVTableItemInfo' then

    begin

      info := rve.GetItem(i) as TRVTableItemInfo;

      //see if there is an InplaceEditor (ie at least one cell is selected)

      if info.FInplaceEditor <> nil then

      begin

        //test for a selection in InplaceEditor

        if info.FInplaceEditor.SelectionExists then

          //set the working editor to be the InplaceEditor

          editor := info.FInplaceEditor;

      end;

    end;

  end;

  if editor.SelectionExists then

  begin

    for i := 0 to editor.Style.TextStyles.Count - 1 do

    begin

      if Pos('_JUMP',editor.Style.TextStyles[i].StyleName) > 0 then

      begin

        jmpStyle := i;

        break;

      end;

    end;

    if jmpStyle <> 0 then

    begin

      URL := 'http://';

      startOffs := 0;

      endOffs := 1;

      editor.GetSelectionBounds(selStart,startOffs,selEnd,endOffs,false);

      for i := min(selStart,selEnd) to max(selStart,selEnd) do

      begin

        if Length(editor.GetItemText(i)) > 0 then

        begin

          if PChar(editor.GetItemTag(i)) <> '' then

            URL := PChar(editor.GetItemTag(i));

            break;

        end;

      end;

      if InputQuery('URL','Type in URL',URL) then

      begin

        editor.ApplyTextStyle(jmpStyle);

        //redo GetSelectionBounds because ApplyTextStyle clears the selection(?)

        editor.GetSelectionBounds(selStart,startOffs,selEnd,endOffs,true);

        for i := min(selStart,selEnd) to max(selStart,selEnd) do

        begin

          if TRVGraphicItemInfo(editor.RVData.Items.Objects[i]).StyleNo =

-3 then

          begin

            editor.ConvertToHotPicture(i);

          end;

          editor.SetItemTagEd(i,Integer(StrNew(PChar(URL))));

        end;

      end;

    end;

  end else

    MessageDlg('Please make a selection before creating a link.',mtInformation,[mbOK],0);

end;

***************************************************************


>"Sergey Tkachenko" <svt@trichview.com> wrote:

>>You need to process OnURLNeeded event. In this event you need to return

>URL

>>target:

>>

>>procedure TfrmMain.rveURLNeeded(Sender: TCustomRichView; id: Integer;

>>  var url: String);

>>var ItemNo: Integer;

>>    RVData: TCustomRVFormattedData;

>>begin

>>  rve.GetJumpPointLocation(id, RVData, ItemNo);

>>  url := PChar(RVData.GetItemTag(ItemNo));

>>end;

>>

>>

>>>

>>> When I make the contents of a table cell into a link (eg

>>rve.SetItemTagEd(i,Integer(StrNew(PChar(URL))));)

>>> I can set the tag OK but when I do SaveHTMLToStreamEx I do not get the

>>link

>>> in the HTML output. In fact if I check the tag property of the table

cell

>>> content later(outside the procedure where I set it) the tag is lost.

How

>>> can I keep the tag value and export it to HTML?

>>>

>>> A related point, how do I know if the item returned by GetCurrentItem

>is

>>> an entry in a table?

>>>

>>> Any help would be very welcome.

>>>

>>> Chris

>>

>>

>





Powered by ABC Amber Outlook Express Converter