Which DATA or METHOD in a rtf class should be used to get the content in plain text (without changing the actual content)?
TIA
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
BCC5.82/BCC7.3
xHarbour/Harbour
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 cRtfhi,
what if you "select" hole RTF and copy into Clipboard and paste back to "Memoedit" (TMultiGet ? )
Yes, that is another possibility that I was studying
Could we access DATA oRtf.text mentioned here? https://stackoverflow.com/questions/595 ... n-rtf-text
cnavarro wrote:This is a function that does a good conversion (still not perfect though)
#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)?Have you tried using oRichEdit:GetText() ?
TIA