Function TWPCustomRtfEdit.HyperlinkConvertOldWPT3Links(OnlyIfHiddenTextWasFound:Boolean) : Integer

Unit: WPCTRMemo
Class: WPCTRMemo.TWPCustomRtfEdit

Parameters

  • OnlyIfHiddenTextWasFound:Boolean

Returns

The type of the result value is Integer.

Description

This function can be used to convert the old hyperlink syntax: double underlined text + hidden text into the new WPTools 6 Hyperlinks. Optionally, if OnlyIfHiddenTextWasFound=TRUE this procedure will leave text alone which was not followed by hidden text. This function returns the count of the converted hyperlinks.Implementation: function TWPCustomRtfEdit.HyperlinkConvertOldWPT3Links(OnlyIfHiddenTextWasFound : Boolean = FALSE):Integer; var DoubleStart, DoubleEnd, HiddenEnd, mode : Integer; Yes : Boolean; url : string; begin DoubleStart := 0; DoubleEnd := 0; HiddenEnd := 0; Result := 0; with TextCursor do begin Position := 0; SelectText := FALSE; repeat if (CurrentCharAttr.GetUnderlineMode(mode)) and (mode=WPUND_Double) then begin DoubleStart := DropMarker; repeat CurrentCharAttr.HasStyle(afsHidden,Yes); if CurrentCharAttr.HasAStyle(afsHidden) or not CurrentCharAttr.GetUnderlineMode(mode) or (modeWPUND_Double) then break; until not CPMoveNext; DoubleEnd := DropMarker; if not CurrentCharAttr.HasAStyle(afsHidden) then begin HiddenEnd := 0; url := ''; end else begin repeat if not CurrentCharAttr.HasAStyle(afsHidden) then break; until not CPMoveNext; HiddenEnd := DropMarker; SelectMarker(DoubleEnd,HiddenEnd); url := SelText; ClearSelection(true,true); end; if not OnlyIfHiddenTextWasFound or (url'') then begin SelectMarker(DoubleStart,DoubleEnd); InputCode(wpobjHyperlink, '', url, [wpinpWrapSelectedText]); end; GotoMarker(DoubleEnd); CollectAllMarker; end; until not CPMoveNext; end; if Result>0 then ReformatAll; end;