#include "tex2any.h"
#include "tex2rtf.h"
#include "table.h"
-
+#include <stdio.h>
#define HTML_FILENAME_PATTERN _T("%s_%s.html")
#if !WXWIN_COMPATIBILITY_2_4
bool changed = false;
int ptr = 0;
int i = 0;
- char ch = 1;
+ wxChar ch = 1;
int len = wxStrlen(chunk->value);
while (ch != 0)
{
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("<"));
i += 1;
changed = true;
}
- else if (ch == '>') // Change > to >
+ else if (ch == _T('>')) // Change > to >
{
BigBuffer[ptr] = 0;
wxStrcat(BigBuffer, _T(">"));
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:
+ before<a href="xxx&yyy">type</a>after
+
+ 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("<A HREF=\""));
+ TexOutput(texRef->refFile);
+ TexOutput(_T("#"));
+ TexOutput(label);
+ TexOutput(wxT("\">"));
+ TexOutput(typeName);
+ TexOutput(wxT("</A>"));
+ 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)
{
}
case ltFUNC:
{
- if (start && (arg_no == 1))
+ if (start && (arg_no == 1)) {
TexOutput(_T("<B>"));
+ if( CheckTypeRef() ) {
+ TexOutput(_T("</B> "));
+ return false;
+ }
+ }
if (!start && (arg_no == 1))
TexOutput(_T("</B> "));
break;
}
case ltPARAM:
- {
- if (start && (arg_no == 1))
- TexOutput(_T("<B>"));
- if (!start && (arg_no == 1))
- TexOutput(_T("</B>"));
- if (start && (arg_no == 2))
- {
- TexOutput(_T("<I>"));
- }
- if (!start && (arg_no == 2))
- {
- TexOutput(_T("</I>"));
- }
- break;
- }
case ltCPARAM:
{
- if (start && (arg_no == 1))
- TexOutput(_T("<B>"));
- if (!start && (arg_no == 1))
- TexOutput(_T("</B> ")); // This is the difference from param - one space!
+ const wxChar* pend = macroId == ltCPARAM ?
+ _T("</B> ") : _T("</B>");
+ if( arg_no == 1) {
+ if( start ) {
+ TexOutput(_T("<B>"));
+ if( CheckTypeRef() ) {
+ TexOutput(pend);
+ return false;
+ }
+ } else {
+ TexOutput(pend);
+ }
+ }
if (start && (arg_no == 2))
{
TexOutput(_T("<I>"));
}
break;
}
+
case ltHELPREF:
case ltHELPREFN:
case ltPOPREF: