Commit aaa33623 authored by claes's avatar claes

file pointer not reused

parent c06abeb2
...@@ -69,19 +69,19 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1, ...@@ -69,19 +69,19 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1,
if ( (text2 && strcmp(text2, "") != 0) || if ( (text2 && strcmp(text2, "") != 0) ||
(text3 && strcmp(text3, "") != 0) ) { (text3 && strcmp(text3, "") != 0) ) {
if ( !in_table) { if ( !in_table && cf) {
fp << "<TABLE>" << endl; cf->f << "<TABLE>" << endl;
in_table = 1; in_table = 1;
} }
} }
else { else {
if ( in_table) { if ( in_table && cf) {
// Close table (keep if empty line) // Close table (keep if empty line)
if ( !( text1 && strcmp( text1, "") == 0 && if ( !( text1 && strcmp( text1, "") == 0 &&
(item_type == navh_eItemType_Help || (item_type == navh_eItemType_Help ||
item_type == navh_eItemType_HelpCode || item_type == navh_eItemType_HelpCode ||
item_type == navh_eItemType_HelpBold))) { item_type == navh_eItemType_HelpBold))) {
fp << "</TABLE>" << endl; cf->f << "</TABLE>" << endl;
in_table = 0; in_table = 0;
} }
} }
...@@ -92,8 +92,9 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1, ...@@ -92,8 +92,9 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1,
pwr_tFileName fname; pwr_tFileName fname;
subject_to_fname( fname, text1, 1); subject_to_fname( fname, text1, 1);
fp.open( fname); cf = new CnvFile();
fp << cf->f.open( fname);
cf->f <<
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd>" << endl << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd>" << endl <<
"<!--NewPage-->" << endl << "<!--NewPage-->" << endl <<
"<HTML>" << endl << "<HTML>" << endl <<
...@@ -110,12 +111,19 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1, ...@@ -110,12 +111,19 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1,
} }
case navh_eItemType_EndTopic: case navh_eItemType_EndTopic:
{ {
fp.close(); if ( !cf)
break;
cf->f.close();
delete cf;
cf = 0;
return NULL; return NULL;
} }
case navh_eItemType_Help: case navh_eItemType_Help:
case navh_eItemType_HelpCode: case navh_eItemType_HelpCode:
{ {
if ( !cf)
break;
if ( strcmp( link, "") != 0) { if ( strcmp( link, "") != 0) {
pwr_tFileName fname; pwr_tFileName fname;
...@@ -138,41 +146,46 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1, ...@@ -138,41 +146,46 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1,
strcat( fname, link_bookmark); strcat( fname, link_bookmark);
} }
} }
fp << "<A HREF=\"" << fname << "\">"; cf->f << "<A HREF=\"" << fname << "\">";
} }
else if ( bookmark) { else if ( bookmark) {
fp << "<A NAME=\"" << bookmark << "\">"; cf->f << "</TABLE>" << endl;
in_table = 0;
cf->f << "<A NAME=\"" << bookmark << "\">";
} }
if ( ! in_table) { if ( ! in_table) {
fp << text1; cf->f << text1;
if ( strcmp( link, "") != 0 || bookmark) if ( strcmp( link, "") != 0 || bookmark)
fp << "<BR></A>" << endl; cf->f << "<BR></A>" << endl;
else else
fp << "<BR>" << endl; cf->f << "<BR>" << endl;
} }
else { else {
fp << "<TR><TD>" << text1; cf->f << "<TR><TD>" << text1;
if ( strcmp( text2, "") != 0 || strcmp( text3, "") != 0) { if ( strcmp( text2, "") != 0 || strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text1)); i++) for ( i = 0; i < (int)(CNV_TAB - strlen(text1)); i++)
fp << "&nbsp;"; cf->f << "&nbsp;";
fp << "&nbsp;&nbsp;</TD><TD>" << text2; cf->f << "&nbsp;&nbsp;</TD><TD>" << text2;
if ( strcmp( text3, "") != 0) { if ( strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text2)); i++) for ( i = 0; i < (int)(CNV_TAB - strlen(text2)); i++)
fp << "&nbsp;"; cf->f << "&nbsp;";
fp << "&nbsp;&nbsp;</TD><TD>" << text3; cf->f << "&nbsp;&nbsp;</TD><TD>" << text3;
} }
} }
fp << "</TD></TR>"; cf->f << "</TD></TR>";
if ( strcmp( link, "") != 0 || bookmark) if ( strcmp( link, "") != 0 || bookmark)
fp << "</A>" << endl; cf->f << "</A>" << endl;
else else
fp << endl; cf->f << endl;
} }
return NULL; return NULL;
} }
case navh_eItemType_HelpBold: case navh_eItemType_HelpBold:
{ {
if ( !cf)
break;
pwr_tFileName fname; pwr_tFileName fname;
if ( strcmp( link, "") != 0) { if ( strcmp( link, "") != 0) {
if ( strncmp( link, "$web:", 5) == 0) { if ( strncmp( link, "$web:", 5) == 0) {
...@@ -193,75 +206,91 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1, ...@@ -193,75 +206,91 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, char *text1,
} }
} }
if ( !in_table) if ( !in_table)
fp << "<A HREF=\"" << fname << "\">"; cf->f << "<A HREF=\"" << fname << "\">";
} }
else if ( bookmark) { else if ( bookmark) {
if ( !in_table) if ( !in_table)
fp << "<A NAME=\"" << bookmark << "\">"; cf->f << "<A NAME=\"" << bookmark << "\">";
} }
if ( ! in_table) { if ( ! in_table) {
fp << "<B>" << text1 << "</B>"; cf->f << "<B>" << text1 << "</B>";
if ( strcmp( link, "") != 0 || bookmark) if ( strcmp( link, "") != 0 || bookmark)
fp<< "<BR></A>" << endl; cf->f<< "<BR></A>" << endl;
else else
fp<< "<BR>" << endl; cf->f<< "<BR>" << endl;
} }
else { else {
fp << "<TR><TD><B>"; cf->f << "<TR><TD><B>";
if ( strcmp( link, "") != 0) if ( strcmp( link, "") != 0)
fp << "<A HREF=\"" << fname << "\">"; cf->f << "<A HREF=\"" << fname << "\">";
else if ( bookmark != 0) else if ( bookmark != 0)
fp << "<A NAME=\"" << bookmark << "\">"; cf->f << "<A NAME=\"" << bookmark << "\">";
fp << text1; cf->f << text1;
if ( strcmp( link, "") != 0 || bookmark) if ( strcmp( link, "") != 0 || bookmark)
fp << "</A>"; cf->f << "</A>";
if ( strcmp( text2, "") != 0 || strcmp( text3, "") != 0) { if ( strcmp( text2, "") != 0 || strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text1)); i++) for ( i = 0; i < (int)(CNV_TAB - strlen(text1)); i++)
fp << "&nbsp;"; cf->f << "&nbsp;";
fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text2; cf->f << "&nbsp;&nbsp;</B></TD><TD><B>" << text2;
if ( strcmp( text3, "") != 0) { if ( strcmp( text3, "") != 0) {
for ( i = 0; i < (int)(CNV_TAB - strlen(text2)); i++) for ( i = 0; i < (int)(CNV_TAB - strlen(text2)); i++)
fp << "&nbsp;"; cf->f << "&nbsp;";
fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text3; cf->f << "&nbsp;&nbsp;</B></TD><TD><B>" << text3;
} }
} }
fp << "</B></TD></TR>"; cf->f << "</B></TD></TR>";
if ( strcmp( link, "") != 0 || bookmark) if ( strcmp( link, "") != 0 || bookmark)
fp << "</A>" << endl; cf->f << "</A>" << endl;
else else
fp << endl; cf->f << endl;
} }
return NULL; return NULL;
} }
case navh_eItemType_HelpHeader: case navh_eItemType_HelpHeader:
{ {
fp << "<H1>" << text1 << "</H1><BR>" << endl; if ( !cf)
break;
cf->f << "<H1>" << text1 << "</H1><BR>" << endl;
return NULL; return NULL;
} }
case navh_eItemType_Header: case navh_eItemType_Header:
{ {
fp << "<H3>" << text1 << "</H3><BR>" << endl; if ( !cf)
break;
cf->f << "<H3>" << text1 << "</H3><BR>" << endl;
return NULL; return NULL;
} }
case navh_eItemType_HeaderLarge: case navh_eItemType_HeaderLarge:
{ {
fp << "<H2>" << text1 << "</H2><BR>" << endl; if ( !cf)
break;
cf->f << "<H2>" << text1 << "</H2><BR>" << endl;
return NULL; return NULL;
} }
case navh_eItemType_HorizontalLine: case navh_eItemType_HorizontalLine:
{ {
fp << "<HR>" << endl; if ( !cf)
break;
cf->f << "<HR>" << endl;
return NULL; return NULL;
} }
case navh_eItemType_Image: case navh_eItemType_Image:
{ {
fp << "<IMG SRC=\"" << text1 << "\"><BR>" << endl; if ( !cf)
break;
cf->f << "<IMG SRC=\"" << text1 << "\"><BR>" << endl;
return NULL; return NULL;
} }
default: default:
return 0; return 0;
} }
return 0;
} }
......
...@@ -14,6 +14,7 @@ extern "C" { ...@@ -14,6 +14,7 @@ extern "C" {
#endif #endif
#include "pwr.h" #include "pwr.h"
#include "cnv_file.h"
#include "cnv_xtthelpto.h" #include "cnv_xtthelpto.h"
using namespace std; using namespace std;
...@@ -23,7 +24,7 @@ class CnvCtx; ...@@ -23,7 +24,7 @@ class CnvCtx;
class CnvXtthelpToHtml : public CnvXtthelpTo { class CnvXtthelpToHtml : public CnvXtthelpTo {
public: public:
CnvXtthelpToHtml( CnvCtx *cnv_ctx) : CnvXtthelpToHtml( CnvCtx *cnv_ctx) :
ctx(cnv_ctx) {} ctx(cnv_ctx), cf(0) {}
virtual ~CnvXtthelpToHtml() {} virtual ~CnvXtthelpToHtml() {}
Cnv_eXtthelpToType type() { return Cnv_eXtthelpToType_Html;} Cnv_eXtthelpToType type() { return Cnv_eXtthelpToType_Html;}
...@@ -35,7 +36,8 @@ class CnvXtthelpToHtml : public CnvXtthelpTo { ...@@ -35,7 +36,8 @@ class CnvXtthelpToHtml : public CnvXtthelpTo {
void subject_to_fname( char *fname, char *subject, int path); void subject_to_fname( char *fname, char *subject, int path);
CnvCtx *ctx; CnvCtx *ctx;
ofstream fp; CnvFile *cf;
// ofstream fp;
}; };
#if defined __cplusplus #if defined __cplusplus
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment