Which DATA or METHOD in a rtf class should be used to get the content in plain text (without changing the actual content)?
TIA
// RichEditBox_SetRTFTextMode ( hWndControl, lRTF )
HB_FUNC ( RICHEDITBOX_SETRTFTEXTMODE )
{
HWND hWndControl = (HWND) HMG_parnl (1);
BOOL lRTF = ( HB_ISLOG (2) ? (BOOL) hb_parl (2) : TRUE );
LONG Mode = ( lRTF ? TM_RICHTEXT : TM_PLAINTEXT ) | TM_MULTILEVELUNDO | TM_MULTICODEPAGE;
SendMessage ( hWndControl, EM_SETTEXTMODE, (WPARAM) Mode, 0 );
}
TM_PLAINTEXT
TM_RICHTEXT
Sets the text mode or undo level of a rich edit control. The message fails if the control contains any text.
METHOD SaveAsHtml( cFile ) CLASS TRichEdit5
#include "Fivewin.ch"
Function Main()
? SaveRtfAsTxt( ".\Tutorial2.rtf" )
Return nil
//----------------------------------------------------------------------------//
Function SaveRtfAsTxt( cFile )
local aTags
local cTag
local cRtf
local aElems
local x
local y
if File( cFile )
cRtf := hb_MemoRead( cFile )
aTags := hb_RegExAll( "{\*?\\.+(;})|\s?\\[A-Za-z0-9]+|\s?{\s?\\[A-Za-z0-9]+\s?|\s?}\s?", cRtf )
XBrowse( aTags )
For each aElems in aTags
For x = 1 to Len( aElems )
if Valtype( aElems[ x ] ) = "A"
For y = 1 to Len( aElems[ x ] )
if Valtype( aElems[ x ][ y ] ) = "C"
cTag := aElems[ x ][ y ]
if Empty( At( "\line", cTag ) )
cRtf := StrTran( cRtf, cTag, " " )
else
cRtf := StrTran( cRtf, cTag, CRLF )
endif
else
endif
Next y
else
cTag := aElems[ x ]
if Empty( At( "\line", cTag ) )
cRtf := StrTran( cRtf, cTag, " " )
else
cRtf := StrTran( cRtf, cTag, CRLF )
endif
endif
Next x
Next
endif
Return cRtf
cnavarro wrote:This is a function that does a good conversion (still not perfect though)
- Code: Select all Expand view RUN
#include "Fivewin.ch"
Function Main()
? SaveRtfAsTxt( ".\Tutorial2.rtf" )
Return nil
//----------------------------------------------------------------------------//
Function SaveRtfAsTxt( cFile )
local aTags
local cTag
local cRtf
local aElems
local x
local y
if File( cFile )
cRtf := hb_MemoRead( cFile )
aTags := hb_RegExAll( "{\*?\\.+(;})|\s?\\[A-Za-z0-9]+|\s?{\s?\\[A-Za-z0-9]+\s?|\s?}\s?", cRtf )
XBrowse( aTags )
For each aElems in aTags
For x = 1 to Len( aElems )
if Valtype( aElems[ x ] ) = "A"
For y = 1 to Len( aElems[ x ] )
if Valtype( aElems[ x ][ y ] ) = "C"
cTag := aElems[ x ][ y ]
if Empty( At( "\line", cTag ) )
cRtf := StrTran( cRtf, cTag, " " )
else
cRtf := StrTran( cRtf, cTag, CRLF )
endif
else
endif
Next y
else
cTag := aElems[ x ]
if Empty( At( "\line", cTag ) )
cRtf := StrTran( cRtf, cTag, " " )
else
cRtf := StrTran( cRtf, cTag, CRLF )
endif
endif
Next x
Next
endif
Return cRtf
hua wrote:Which DATA or METHOD in a rtf class should be used to get the content in plain text (without changing the actual content)?
TIA
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Willi Quintana and 52 guests