X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae6c0ccf2625873446fd4fcfa2c447666a38b3be..709d0081619993d7162cf07128338c0a45582f46:/utils/tex2rtf/src/htmlutil.cpp diff --git a/utils/tex2rtf/src/htmlutil.cpp b/utils/tex2rtf/src/htmlutil.cpp index 550f553a0d..ec8fdfb658 100644 --- a/utils/tex2rtf/src/htmlutil.cpp +++ b/utils/tex2rtf/src/htmlutil.cpp @@ -29,7 +29,7 @@ #include "tex2any.h" #include "tex2rtf.h" #include "table.h" - +#include #define HTML_FILENAME_PATTERN _T("%s_%s.html") #if !WXWIN_COMPATIBILITY_2_4 @@ -262,7 +262,7 @@ void ProcessText2HTML(TexChunk *chunk) bool changed = false; int ptr = 0; int i = 0; - char ch = 1; + wxChar ch = 1; int len = wxStrlen(chunk->value); while (ch != 0) { @@ -277,19 +277,19 @@ void ProcessText2HTML(TexChunk *chunk) i += 2; changed = true; } - else if (!inVerbatim && ch == '`' && (len >= i+1 && chunk->value[i+1] == '`')) + else if (!inVerbatim && ch == _T('`') && (len >= i+1 && chunk->value[i+1] == '`')) { BigBuffer[ptr] = '"'; ptr ++; i += 2; changed = true; } - else if (!inVerbatim && ch == '`') // Change ` to ' + else if (!inVerbatim && ch == _T('`')) // Change ` to ' { BigBuffer[ptr] = 39; ptr ++; i += 1; changed = true; } - else if (ch == '<') // Change < to < + else if (ch == _T('<')) // Change < to < { BigBuffer[ptr] = 0; wxStrcat(BigBuffer, _T("<")); @@ -297,7 +297,7 @@ void ProcessText2HTML(TexChunk *chunk) i += 1; changed = true; } - else if (ch == '>') // Change > to > + else if (ch == _T('>')) // Change > to > { BigBuffer[ptr] = 0; wxStrcat(BigBuffer, _T(">")); @@ -1801,7 +1801,74 @@ void HTMLOnMacro(int macroId, int no_args, bool start) break; } } - +/* CheckTypeRef() + + should be called at of argument which usually is + type declaration which propably contains name of + documented class + + examples: + HTMLOnArgument + - ltFUNC, + - ltPARAM + - ltCPARAM + + checks: GetArgData() if contains Type Declaration + and can be referenced to some file + prints: + beforetypeafter + + returns: + false - if no reference was found + true - if reference was found and HREF printed +*/ +static bool CheckTypeRef() +{ + wxString typeDecl = GetArgData(); + if( !typeDecl.IsEmpty() ) { + typeDecl.Replace(wxT("\\"),wxT("")); + wxString label = typeDecl; + label.Replace(wxT("const"),wxT("")); + label.Replace(wxT("virtual"),wxT("")); + label.Replace(wxT("static"),wxT("")); + label.Replace(wxT("extern"),wxT("")); + label = label.BeforeFirst('&'); + label = label.BeforeFirst(wxT('*')); + label = label.BeforeFirst(wxT('\\')); + label.Trim(true); label.Trim(false); + wxString typeName = label; + label.MakeLower(); + TexRef *texRef = FindReference((wxChar*)label.c_str()); + + if (texRef && texRef->refFile && wxStrcmp(texRef->refFile, _T("??")) != 0) { + int a = typeDecl.Find(typeName); + wxString before = typeDecl.Mid( 0, a ); + wxString after = typeDecl.Mid( a+typeName.Length() ); + //wxFprintf(stderr,wxT("%s <%s> %s to ... %s#%s !!!!\n"), + // before.c_str(), + // typeName.c_str(), + // after.c_str(), + // texRef->refFile,label.c_str()); + TexOutput(before); + TexOutput(_T("refFile); + TexOutput(_T("#")); + TexOutput(label); + TexOutput(wxT("\">")); + TexOutput(typeName); + TexOutput(wxT("")); + TexOutput(after); + return true; + } else { + //wxFprintf(stderr,wxT("'%s' from (%s) -> label %s NOT FOUND\n"), + // typeName.c_str(), + // typeDecl.c_str(), + // label.c_str()); + return false; + } + } + return false; +} // Called on start/end of argument examination bool HTMLOnArgument(int macroId, int arg_no, bool start) { @@ -1827,8 +1894,13 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) } case ltFUNC: { - if (start && (arg_no == 1)) + if (start && (arg_no == 1)) { TexOutput(_T("")); + if( CheckTypeRef() ) { + TexOutput(_T(" ")); + return false; + } + } if (!start && (arg_no == 1)) TexOutput(_T(" ")); @@ -1889,27 +1961,21 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) break; } case ltPARAM: - { - if (start && (arg_no == 1)) - TexOutput(_T("")); - if (!start && (arg_no == 1)) - TexOutput(_T("")); - if (start && (arg_no == 2)) - { - TexOutput(_T("")); - } - if (!start && (arg_no == 2)) - { - TexOutput(_T("")); - } - break; - } case ltCPARAM: { - if (start && (arg_no == 1)) - TexOutput(_T("")); - if (!start && (arg_no == 1)) - TexOutput(_T(" ")); // This is the difference from param - one space! + const wxChar* pend = macroId == ltCPARAM ? + _T(" ") : _T(""); + if( arg_no == 1) { + if( start ) { + TexOutput(_T("")); + if( CheckTypeRef() ) { + TexOutput(pend); + return false; + } + } else { + TexOutput(pend); + } + } if (start && (arg_no == 2)) { TexOutput(_T("")); @@ -1980,6 +2046,7 @@ bool HTMLOnArgument(int macroId, int arg_no, bool start) } break; } + case ltHELPREF: case ltHELPREFN: case ltPOPREF: @@ -3383,4 +3450,4 @@ bool PrimaryAnchorOfTheFile( wxChar *file, wxChar *label ) wxString file_label; file_label.Printf( HTML_FILENAME_PATTERN, FileRoot, label ); return file_label.IsSameAs( file , false ); -} \ No newline at end of file +}