diff --git a/utils/tex2rtf/src/htmlutil.cpp b/utils/tex2rtf/src/htmlutil.cpp
index 2ef296d460..550f553a0d 100644
--- a/utils/tex2rtf/src/htmlutil.cpp
+++ b/utils/tex2rtf/src/htmlutil.cpp
@@ -2,7 +2,7 @@
// Name: htmlutil.cpp
// Purpose: Converts Latex to HTML
// Author: Julian Smart
-// Modified by: Wlodzimiez ABX Skiba 2003/2004 Unicode support
+// Modified by: Wlodzimierz ABX Skiba 2003/2004 Unicode support
// Ron Lee
// Created: 7.9.93
// RCS-ID: $Id$
@@ -30,6 +30,8 @@
#include "tex2rtf.h"
#include "table.h"
+#define HTML_FILENAME_PATTERN _T("%s_%s.html")
+
#if !WXWIN_COMPATIBILITY_2_4
static inline wxChar* copystring(const wxChar* s)
{ return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); }
@@ -41,6 +43,8 @@ extern wxHashTable TexReferences;
extern void DecToHex(int, wxChar *);
void GenerateHTMLIndexFile(wxChar *fname);
+bool PrimaryAnchorOfTheFile( wxChar *file, wxChar *label );
+
void GenerateHTMLWorkshopFiles(wxChar *fname);
void HTMLWorkshopAddToContents(int level, wxChar *s, wxChar *file);
void HTMLWorkshopStartContents();
@@ -205,7 +209,7 @@ void ReopenFile(FILE **fd, wxChar **fileName, const wxChar *label)
{
if (fileId == 1)
gs_filenames.Add(wxEmptyString);
- wxSnprintf(buf, sizeof(buf), _T("%s_%s.html"), FileRoot, label);
+ wxSnprintf(buf, sizeof(buf), HTML_FILENAME_PATTERN, FileRoot, label);
gs_filenames.Add(buf);
}
if (*fileName) delete[] *fileName;
@@ -476,7 +480,7 @@ void AddBrowseButtons(wxChar *upLabel, wxChar *upFilename,
if (upLabel && upFilename)
{
- if (wxStrlen(upLabel) > 0)
+ if ( (wxStrlen(upLabel) > 0) && !PrimaryAnchorOfTheFile(upFilename, upLabel) )
wxSnprintf(buf, sizeof(buf),
_T("%s "),
ConvertCase(upFilename), upLabel, upReference);
@@ -501,9 +505,14 @@ void AddBrowseButtons(wxChar *upLabel, wxChar *upFilename,
if (previousLabel && previousFilename)
{
- wxSnprintf(buf, sizeof(buf),
- _T("%s "),
- ConvertCase(previousFilename), previousLabel, backReference);
+ if (PrimaryAnchorOfTheFile(previousFilename, previousLabel))
+ wxSnprintf(buf, sizeof(buf),
+ _T("%s "),
+ ConvertCase(previousFilename), backReference);
+ else
+ wxSnprintf(buf, sizeof(buf),
+ _T("%s "),
+ ConvertCase(previousFilename), previousLabel, backReference);
if (wxStrcmp(previousLabel, _T("contents")) == 0)
{
// TexOutput(_T(""));
@@ -550,9 +559,14 @@ void AddBrowseButtons(wxChar *upLabel, wxChar *upFilename,
if (nextLabel && nextFilename)
{
- wxSnprintf(buf, sizeof(buf),
- _T("%s "),
- ConvertCase(nextFilename), nextLabel, forwardReference);
+ if (PrimaryAnchorOfTheFile(nextFilename, nextLabel))
+ wxSnprintf(buf, sizeof(buf),
+ _T("%s "),
+ ConvertCase(nextFilename), forwardReference);
+ else
+ wxSnprintf(buf, sizeof(buf),
+ _T("%s "),
+ ConvertCase(nextFilename), nextLabel, forwardReference);
TexOutput(buf);
}
else
@@ -764,12 +778,18 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
lastTopic, lastFileName, // Last topic
topicName, ChaptersName); // This topic
- wxFprintf(Contents, _T("\n"), ConvertCase(ChaptersName), topicName);
+ if(PrimaryAnchorOfTheFile(ChaptersName, topicName))
+ wxFprintf(Contents, _T("\n"), ConvertCase(ChaptersName));
+ else
+ wxFprintf(Contents, _T("\n"), ConvertCase(ChaptersName), topicName);
if (htmlFrameContents && FrameContents)
{
SetCurrentOutput(FrameContents);
- wxFprintf(FrameContents, _T("\n"), ConvertCase(ChaptersName), topicName);
+ if(PrimaryAnchorOfTheFile(ChaptersName, topicName))
+ wxFprintf(FrameContents, _T("\n"), ConvertCase(ChaptersName));
+ else
+ wxFprintf(FrameContents, _T("\n"), ConvertCase(ChaptersName), topicName);
OutputCurrentSection();
wxFprintf(FrameContents, _T("\n"));
}
@@ -831,9 +851,19 @@ void HTMLOnMacro(int macroId, int no_args, bool start)
SetCurrentOutputs(jumpFrom, Sections);
if (DocumentStyle == LATEX_ARTICLE)
- wxFprintf(jumpFrom, _T("\n"), ConvertCase(SectionsName), topicName);
+ {
+ if(PrimaryAnchorOfTheFile(SectionsName, topicName))
+ wxFprintf(jumpFrom, _T("\n"), ConvertCase(SectionsName));
+ else
+ wxFprintf(jumpFrom, _T("\n"), ConvertCase(SectionsName), topicName);
+ }
else
- wxFprintf(jumpFrom, _T("\n"), ConvertCase(SectionsName), topicName);
+ {
+ if(PrimaryAnchorOfTheFile(SectionsName, topicName))
+ wxFprintf(jumpFrom, _T("\n"), ConvertCase(SectionsName));
+ else
+ wxFprintf(jumpFrom, _T("\n"), ConvertCase(SectionsName), topicName);
+ }
wxFprintf(Sections, _T("\n\n\n"));
@@ -3329,7 +3372,15 @@ void HTMLWorkshopStartContents()
void HTMLWorkshopEndContents()
{
- for (int i = HTMLWorkshopLastLevel; i >= 0; i--)
- wxFprintf(HTMLWorkshopContents, _T("\n"));
- fclose(HTMLWorkshopContents);
+ for (int i = HTMLWorkshopLastLevel; i >= 0; i--)
+ wxFprintf(HTMLWorkshopContents, _T("\n"));
+ fclose(HTMLWorkshopContents);
}
+
+
+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