?? rtf2html3.bas
字號(hào):
ClearCodes
strHTML = ""
gPlain = False
gBOL = True
'setup +CR option
If InStr(strOptions, "+CR") <> 0 Then strCR = vbCrLf Else strCR = ""
'setup +HTML option
If InStr(strOptions, "+I") <> 0 Then gHTML = True Else gHTML = False
strRTFTmp = TrimAll(strRTF)
If Left(strRTFTmp, 1) = "{" And Right(strRTFTmp, 1) = "}" Then strRTFTmp = Mid(strRTFTmp, 2, Len(strRTFTmp) - 2)
'setup color table
lBOS = InStr(strRTFTmp, "\colortbl")
If lBOS > 0 Then
strSecTmp = NabSection(strRTFTmp, lBOS)
GetColorTable strSecTmp, strColorTable()
End If
'setup font table
lBOS = InStr(strRTFTmp, "\fonttbl")
If lBOS > 0 Then
strSecTmp = NabSection(strRTFTmp, lBOS)
GetFontTable strSecTmp, strFontTable()
End If
'setup stylesheets
lBOS = InStr(strRTFTmp, "\stylesheet")
If lBOS > 0 Then
strSecTmp = NabSection(strRTFTmp, lBOS)
'ignore stylesheets for now
End If
'setup info
lBOS = InStr(strRTFTmp, "\info")
If lBOS > 0 Then
strSecTmp = NabSection(strRTFTmp, lBOS)
'ignore info for now
End If
'list table
lBOS = InStr(strRTFTmp, "\listtable")
If lBOS > 0 Then
strSecTmp = NabSection(strRTFTmp, lBOS)
'ignore info for now
End If
'list override table
lBOS = InStr(strRTFTmp, "\listoverridetable")
If lBOS > 0 Then
strSecTmp = NabSection(strRTFTmp, lBOS)
'ignore info for now
End If
While Len(strRTFTmp) > 0
strSecTmp = NabNextLine(strRTFTmp)
While Len(strSecTmp) > 0
strWordTmp = NabNextWord(strSecTmp)
If Len(strWordTmp) > 0 Then ProcessWord strWordTmp
Wend
Wend
'get any remaining codes in stack
Next2Codes
strEndText = strEndText & GetAllCodes
strBeforeText2 = rtf2html_replace(strBeforeText2, "<br>", "")
strBeforeText2 = rtf2html_replace(strBeforeText2, vbCrLf, "")
strCurPhrase = strCurPhrase & strBeforeText & strBeforeText2 & strEndText
strBeforeText = ""
strBeforeText2 = ""
strBeforeText3 = ""
strHTML = strHTML & strCurPhrase
strCurPhrase = ""
Dim strTitel As String
If InStr(strOptions, "+T=") > 0 Then
strTitel = GetTitel(0, "+T=", strOptions)
End If
If InStr(strOptions, "+H") > 0 Then
strHtmlBody = strHtmlBody + "<HTML>" + strCR
strHtmlBody = strHtmlBody + "<HEAD>" + strCR
strHtmlBody = strHtmlBody + "<TITLE>" + strTitel + "</TITLE>" + strCR
strHtmlBody = strHtmlBody + "</HEAD>" + strCR
strHtmlBody = strHtmlBody + "<BODY bgcolor=" + "white" + " text=" + "black" + ">" + strCR
rtf2html = strHtmlBody + strHTML + "</BODY>" + strCR + "</HTML>"
Else
rtf2html = strHTML
End If
End Function
Public Function GetTitel(intPosition As Long, SearchStr As String, ByRef strarray As String) As String
Dim strTemp As String
Dim strValue As String
Dim Counter As Integer
Dim StartPosi As Integer
On Error GoTo error
StartPosi = InStr(LCase$(strarray), SearchStr) + Len(SearchStr)
Do
strValue = strValue + strTemp
strTemp = Mid$(strarray, StartPosi + Counter, 1)
Counter = Counter + 1
Loop Until strTemp = vbCrLf Or Counter = Len(strarray)
'Remove the ""
If Left$(strValue, 1) = Chr$(34) Then strValue = Right$(strValue, Len(strValue) - 1)
If Right$(strValue, 1) = Chr$(34) Then strValue = Left$(strValue, Len(strValue) - 1)
GetTitel = Replace(strValue, " ", "")
Exit Function
error:
GetTitel = ""
End Function
Function ShowCodes()
Dim strTmp As String
Dim l As Long
strTmp = "Codes: "
For l = 1 To UBound(Codes)
strTmp = strTmp & Codes(l) & ", "
Next l
strTmp = strTmp & vbCrLf & "BegCodes: "
For l = 1 To UBound(CodesBeg)
strTmp = strTmp & CodesBeg(l) & ", "
Next l
strTmp = strTmp & vbCrLf & "NextCodes: "
For l = 1 To UBound(NextCodes)
strTmp = strTmp & NextCodes(l) & ", "
Next l
strTmp = strTmp & vbCrLf & "NextBegCodes: "
For l = 1 To UBound(NextCodesBeg)
strTmp = strTmp & NextCodesBeg(l) & ", "
Next l
MsgBox (strTmp)
End Function
Function TrimAll(ByVal strTmp As String) As String
Dim l As Long
strTmp = Trim(strTmp)
l = Len(strTmp) + 1
While l <> Len(strTmp)
l = Len(strTmp)
If Right(strTmp, 1) = vbCrLf Then strTmp = Left(strTmp, Len(strTmp) - 1)
If Left(strTmp, 1) = vbCrLf Then strTmp = Right(strTmp, Len(strTmp) - 1)
If Right(strTmp, 1) = vbCr Then strTmp = Left(strTmp, Len(strTmp) - 1)
If Left(strTmp, 1) = vbCr Then strTmp = Right(strTmp, Len(strTmp) - 1)
If Right(strTmp, 1) = vbLf Then strTmp = Left(strTmp, Len(strTmp) - 1)
If Left(strTmp, 1) = vbLf Then strTmp = Right(strTmp, Len(strTmp) - 1)
Wend
TrimAll = strTmp
End Function
Function HTMLCode(strRTFCode As String) As String
'given rtf code return html code
Select Case strRTFCode
Case "00"
HTMLCode = " "
Case "a9"
HTMLCode = "©"
Case "b4"
HTMLCode = "´"
Case "ab"
HTMLCode = "«"
Case "bb"
HTMLCode = "»"
Case "a1"
HTMLCode = "¡"
Case "bf"
HTMLCode = "¿"
Case "c0"
HTMLCode = "À"
Case "e0"
HTMLCode = "à"
Case "c1"
HTMLCode = "Á"
Case "e1"
HTMLCode = "á"
Case "c2"
HTMLCode = "Â"
Case "e2"
HTMLCode = "â"
Case "c3"
HTMLCode = "Ã"
Case "e3"
HTMLCode = "ã"
Case "c4"
HTMLCode = "Ä"
Case "e4"
HTMLCode = "<FONT SIZE=""-1""><SUP>TM</SUP></FONT>"
Case "c5"
HTMLCode = "Å"
Case "e5"
HTMLCode = "å"
Case "c6"
HTMLCode = "Æ"
Case "e6"
HTMLCode = "æ"
Case "c7"
HTMLCode = "Ç"
Case "e7"
HTMLCode = "ç"
Case "d0"
HTMLCode = "Ð"
Case "f0"
HTMLCode = "ð"
Case "c8"
HTMLCode = "È"
Case "e8"
HTMLCode = "è"
Case "c9"
HTMLCode = "É"
Case "e9"
HTMLCode = "é"
Case "ca"
HTMLCode = "Ê"
Case "ea"
HTMLCode = "ê"
Case "cb"
HTMLCode = "Ë"
Case "eb"
HTMLCode = "ë"
Case "cc"
HTMLCode = "Ì"
Case "ec"
HTMLCode = "ì"
Case "cd"
HTMLCode = "Í"
Case "ed"
HTMLCode = "í"
Case "ce"
HTMLCode = "Î"
Case "ee"
HTMLCode = "î"
Case "cf"
HTMLCode = "Ï"
Case "ef"
HTMLCode = "ï"
Case "d1"
HTMLCode = "Ñ"
Case "f1"
HTMLCode = "ñ"
Case "d2"
HTMLCode = "Ò"
Case "f2"
HTMLCode = "ò"
Case "d3"
HTMLCode = "Ó"
Case "f3"
HTMLCode = "ó"
Case "d4"
HTMLCode = "Ô"
Case "f4"
HTMLCode = "ô"
Case "d5"
HTMLCode = "Õ"
Case "f5"
HTMLCode = "õ"
Case "d6"
HTMLCode = "Ö"
Case "f6"
HTMLCode = "ö"
Case "d8"
HTMLCode = "Ø"
Case "f8"
HTMLCode = "ø"
Case "d9"
HTMLCode = "Ù"
Case "f9"
HTMLCode = "ù"
Case "da"
HTMLCode = "Ú"
Case "fa"
HTMLCode = "ú"
Case "db"
HTMLCode = "Û"
Case "fb"
HTMLCode = "û"
Case "dc"
HTMLCode = "Ü"
Case "fc"
HTMLCode = "ü"
Case "dd"
HTMLCode = "Ý"
Case "fd"
HTMLCode = "ý"
Case "ff"
HTMLCode = "ÿ"
Case "de"
HTMLCode = "Þ"
Case "fe"
HTMLCode = "þ"
Case "df"
HTMLCode = "ß"
Case "a7"
HTMLCode = "§"
Case "b6"
HTMLCode = "¶"
Case "b5"
HTMLCode = "µ"
Case "a6"
HTMLCode = "¦"
Case "b1"
HTMLCode = "±"
Case "b7"
HTMLCode = "·"
Case "a8"
HTMLCode = "¨"
Case "b8"
HTMLCode = "¸"
Case "aa"
HTMLCode = "ª"
Case "ba"
HTMLCode = "º"
Case "ac"
HTMLCode = "¬"
Case "ad"
HTMLCode = "­"
Case "af"
HTMLCode = "¯"
Case "b0"
HTMLCode = "°"
Case "b9"
HTMLCode = "¹"
Case "b2"
HTMLCode = "²"
Case "b3"
HTMLCode = "³"
Case "bc"
HTMLCode = "¼"
Case "bd"
HTMLCode = "½"
Case "be"
HTMLCode = "¾"
Case "d7"
HTMLCode = "×"
Case "f7"
HTMLCode = "÷"
Case "a2"
HTMLCode = "¢"
Case "a3"
HTMLCode = "£"
Case "a4"
HTMLCode = "¤"
Case "a5"
HTMLCode = "¥"
Case "85"
HTMLCode = "..."
End Select
End Function
Function TrimifCmd(ByVal strTmp As String) As String
Dim l As Long
l = 1
While Mid(strTmp, l, 1) = " "
l = l + 1
Wend
If Mid(strTmp, l, 1) = "\" Or Mid(strTmp, l, 1) = "{" Then
strTmp = Trim(strTmp)
Else
If Left(strTmp, 1) = " " Then strTmp = Mid(strTmp, 2)
strTmp = RTrim(strTmp)
End If
TrimifCmd = strTmp
End Function
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -