function Rtf2text( cRtf )
static hDLL, oWnd, oRich
local cText
if ValType( cRtf ) == 'C'
if hDLL == nil
hDLL := LoadLibrary( "riched20.dll" )
DEFINE WINDOW oWnd
@ 0,0 RICHEDIT oRich VAR cRtf OF oWnd SIZE 50,50 PIXEL
cText := oRich:GetText()
ACTIVATE WINDOW oWnd HIDDEN
else
oRich:LoadRTF( cRTF )
cText := oRich:GetText()
endif
else
if hDLL != nil
oWnd:End()
oWnd := nil
oRich := nil
FreeLibrary( hDLL )
hDLL := nil
endif
endif
return cText
//----------------------------------------------------------------------------//
*---------------------------------------------------------------------------------------------
#DEFINE _cREGEX "\{?\\([a-z]{1,32}[0-9]* ?)([A-z, ]*;)?|}" //includes fonts
function GetTextFromRTF( cRtfText, lKeepCRLFs )
local aRet
local cStrip, i
DEFAULT cRtfText := ""
DEFAULT lKeepCRLFs := .t.
aRet := hb_RegExAll( _cREGEX, cRtfText, .f. )
if aRet == Nil ;return cRtfText ;endif
aSort( aRet,,, { |x,y| len( x[1] ) > len( y[1] ) } )
for i := 1 to len( aRet )
cRtfText := StrTran( cRtfText, aRet[ i, 1 ], "" )
Next
if !lKeepCRLFs
cRtfText := StrTran( cRtfText, CRLF, " " )
endif
Return cRtfText
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 ARIAL;}}
\viewkind4\uc1\pard\f0\fs20 The specimen is received fresh, wrapped in plastic, is labeled "LEFT LEG BELOW AMPUTATION" and consists of a below the knee amputation specimen measuring 30 cm from tibial amputation site to medial malleolus. The specimen is notable for gangrenous ulcers involving all toes and anterior aspect of the dorsum of the foot. The proximal soft tissue is beefy red and viable. Sections through the vessels show atheromatous plaque. (RSS 1 CASS) VCV\par
\pard\fs20\par
}
function GetTextFromRTF( cRtfText, lKeepCRLFs )
local aRet
local cStrip, i
DEFAULT cRtfText := ""
DEFAULT lKeepCRLFs := .t.
aRet := hb_RegExAll( _cREGEX, cRtfText, .f. )
if aRet == Nil ;return cRtfText ;endif
aSort( aRet,,, { |x,y| len( x[1] ) > len( y[1] ) } )
for i := 1 to len( aRet )
cRtfText := StrTran( cRtfText, aRet[ i, 1 ], "" )
Next
if !lKeepCRLFs
cRtfText := StrTran( cRtfText, CRLF, " " )
endif
//International chars
cRtfText := StrTran( cRtfText, "'ec", chr(141) ) //inverted accented i
cRtfText := StrTran( cRtfText, "'e8", chr(138) ) //inverted accented e
cRtfText := StrTran( cRtfText, "'e0", chr(133) ) //inverted accented a
Return cRtfText
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 32 guests