Commit 13f18b02 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Removed CnvFile since it was only an alias of std::ofstream.

parent bdb8a2b2
/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2018 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef cnv_file_h
#define cnv_file_h
#include <fstream>
class CnvFile {
public:
std::ofstream f;
};
#endif
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#ifndef cnv_readsrc_h #ifndef cnv_readsrc_h
#define cnv_readsrc_h #define cnv_readsrc_h
#include <fstream>
/* cnv_readsrc.h -- Read source files */ /* cnv_readsrc.h -- Read source files */
#include "cnv_ctx.h" #include "cnv_ctx.h"
......
...@@ -37,8 +37,9 @@ ...@@ -37,8 +37,9 @@
#ifndef cnv_readwbl_h #ifndef cnv_readwbl_h
#define cnv_readwbl_h #define cnv_readwbl_h
#include <fstream>
#include "pwr.h" #include "pwr.h"
#include "cnv_file.h"
class CnvCtx; class CnvCtx;
class CnvWblTo; class CnvWblTo;
......
...@@ -158,15 +158,14 @@ int CnvWblToH::class_exec() ...@@ -158,15 +158,14 @@ int CnvWblToH::class_exec()
sprintf(fname, "%s%s_c_%s.h", ctx->dir, volume_name_low, sprintf(fname, "%s%s_c_%s.h", ctx->dir, volume_name_low,
CnvCtx::low(ctx->rw->class_name)); CnvCtx::low(ctx->rw->class_name));
if (!ctx->common_structfile_only) { if (!ctx->common_structfile_only) {
cstruc = new CnvFile(); fp_cstruc.open(fname);
cstruc->f.open(fname);
} }
struct_class_open = 1; struct_class_open = 1;
sprintf( sprintf(
fname, "%s_c_%s_h", volume_name_low, CnvCtx::low(ctx->rw->class_name)); fname, "%s_c_%s_h", volume_name_low, CnvCtx::low(ctx->rw->class_name));
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << "/* Generated by co_convert */\n\n" fp_cstruc << "/* Generated by co_convert */\n\n"
<< "#ifndef " << fname << '\n' << "#ifndef " << fname << '\n'
<< "#define " << fname << '\n' << "#define " << fname << '\n'
<< '\n' << '\n'
...@@ -238,7 +237,7 @@ int CnvWblToH::body_exec() ...@@ -238,7 +237,7 @@ int CnvWblToH::body_exec()
<< "#define pwr_cClass_" << cclass_name << " " << cid << "UL\n" << "#define pwr_cClass_" << cclass_name << " " << cid << "UL\n"
<< '\n'; << '\n';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << '\n' fp_cstruc << '\n'
<< "#ifndef pwr_cClass_" << cclass_name << '\n' << "#ifndef pwr_cClass_" << cclass_name << '\n'
<< "#define pwr_cClass_" << cclass_name << " " << cid << "UL\n" << "#define pwr_cClass_" << cclass_name << " " << cid << "UL\n"
<< '\n'; << '\n';
...@@ -259,7 +258,7 @@ int CnvWblToH::body_exec() ...@@ -259,7 +258,7 @@ int CnvWblToH::body_exec()
<< " @Aref " << ctx->rw->class_name << " " << struct_name << '\n' << " @Aref " << ctx->rw->class_name << " " << struct_name << '\n'
<< "*/\n"; << "*/\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << "/* Body: " << ctx->rw->body_name << " */\n"; fp_cstruc << "/* Body: " << ctx->rw->body_name << " */\n";
if (ctx->hpp) if (ctx->hpp)
fp_struct << '\n' << "class " << struct_name << " "; fp_struct << '\n' << "class " << struct_name << " ";
...@@ -267,9 +266,9 @@ int CnvWblToH::body_exec() ...@@ -267,9 +266,9 @@ int CnvWblToH::body_exec()
fp_struct << '\n' << "typedef struct {\n"; fp_struct << '\n' << "typedef struct {\n";
if (!ctx->common_structfile_only) { if (!ctx->common_structfile_only) {
if (ctx->hpp) if (ctx->hpp)
cstruc->f << '\n' << "class " << struct_name << " "; fp_cstruc << '\n' << "class " << struct_name << " ";
else else
cstruc->f << '\n' << "typedef struct {\n"; fp_cstruc << '\n' << "typedef struct {\n";
} }
return 1; return 1;
} }
...@@ -286,7 +285,7 @@ int CnvWblToH::body_close() ...@@ -286,7 +285,7 @@ int CnvWblToH::body_close()
// Write a dummy element... // Write a dummy element...
fp_struct << " int dummy;\n"; fp_struct << " int dummy;\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " int dummy;\n"; fp_cstruc << " int dummy;\n";
} }
if (streq(CnvCtx::low(ctx->rw->body_name), "devbody")) if (streq(CnvCtx::low(ctx->rw->body_name), "devbody"))
...@@ -301,16 +300,16 @@ int CnvWblToH::body_close() ...@@ -301,16 +300,16 @@ int CnvWblToH::body_close()
if (ctx->hpp) { if (ctx->hpp) {
fp_struct << "};" << '\n'; fp_struct << "};" << '\n';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << "};" << '\n'; fp_cstruc << "};" << '\n';
} else { } else {
fp_struct << "} " << struct_name << ";" << '\n'; fp_struct << "} " << struct_name << ";" << '\n';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << "} " << struct_name << ";" << '\n'; fp_cstruc << "} " << struct_name << ";" << '\n';
} }
fp_struct << '\n'; fp_struct << '\n';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << '\n'; fp_cstruc << '\n';
return 1; return 1;
} }
...@@ -324,7 +323,7 @@ int CnvWblToH::class_close() ...@@ -324,7 +323,7 @@ int CnvWblToH::class_close()
<< ctx->rw->class_id << "UL\n" << ctx->rw->class_id << "UL\n"
<< '\n'; << '\n';
if (!ctx->common_structfile_only && struct_class_open) if (!ctx->common_structfile_only && struct_class_open)
cstruc->f << '\n' fp_cstruc << '\n'
<< "#ifndef pwr_cClass_" << ctx->rw->class_name << '\n' << "#ifndef pwr_cClass_" << ctx->rw->class_name << '\n'
<< "#define pwr_cClass_" << ctx->rw->class_name << " " << "#define pwr_cClass_" << ctx->rw->class_name << " "
<< ctx->rw->class_id << "UL\n" << ctx->rw->class_id << "UL\n"
...@@ -338,16 +337,15 @@ int CnvWblToH::class_close() ...@@ -338,16 +337,15 @@ int CnvWblToH::class_close()
fp_struct << "#endif\n" << '\n'; fp_struct << "#endif\n" << '\n';
if (!ctx->common_structfile_only && struct_class_open) if (!ctx->common_structfile_only && struct_class_open)
cstruc->f << "#endif\n" << '\n'; fp_cstruc << "#endif\n" << '\n';
struct_cclass_endwritten = 1; struct_cclass_endwritten = 1;
} }
// Close class structfile // Close class structfile
if (!ctx->common_structfile_only && struct_class_open) if (!ctx->common_structfile_only && struct_class_open)
cstruc->f << "#endif\n" << '\n'; fp_cstruc << "#endif\n" << '\n';
if (!ctx->common_structfile_only && struct_class_open) { if (!ctx->common_structfile_only && struct_class_open) {
cstruc->f.close(); fp_cstruc.close();
delete cstruc;
struct_class_open = 0; struct_class_open = 0;
} }
...@@ -455,7 +453,7 @@ int CnvWblToH::attribute_exec() ...@@ -455,7 +453,7 @@ int CnvWblToH::attribute_exec()
fp_struct << ": public " << type_name << " {\n" fp_struct << ": public " << type_name << " {\n"
<< " public:\n"; << " public:\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << type_name << " {\n" fp_cstruc << type_name << " {\n"
<< " public:\n"; << " public:\n";
attr_count++; attr_count++;
return 1; return 1;
...@@ -463,7 +461,7 @@ int CnvWblToH::attribute_exec() ...@@ -463,7 +461,7 @@ int CnvWblToH::attribute_exec()
fp_struct << " {\n" fp_struct << " {\n"
<< " public:\n"; << " public:\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " {\n" fp_cstruc << " {\n"
<< " public:\n"; << " public:\n";
} }
} }
...@@ -472,55 +470,55 @@ int CnvWblToH::attribute_exec() ...@@ -472,55 +470,55 @@ int CnvWblToH::attribute_exec()
if (ctx->rw->attr_array && ctx->rw->attr_pointer) { if (ctx->rw->attr_array && ctx->rw->attr_pointer) {
fp_struct << " " << type_name; fp_struct << " " << type_name;
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " << type_name; fp_cstruc << " " << type_name;
for (i = 0; i < int(35 - strlen(type_name)); i++) { for (i = 0; i < int(35 - strlen(type_name)); i++) {
fp_struct << ' '; fp_struct << ' ';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << ' '; fp_cstruc << ' ';
} }
fp_struct << " **" << pgmname << "P[" << ctx->rw->attr_elements << "]" fp_struct << " **" << pgmname << "P[" << ctx->rw->attr_elements << "]"
<< alignstr << ";\n"; << alignstr << ";\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " **" << pgmname << "P[" << ctx->rw->attr_elements << "]" fp_cstruc << " **" << pgmname << "P[" << ctx->rw->attr_elements << "]"
<< alignstr << ";\n"; << alignstr << ";\n";
} else if (ctx->rw->attr_array) { } else if (ctx->rw->attr_array) {
fp_struct << " " << type_name; fp_struct << " " << type_name;
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " << type_name; fp_cstruc << " " << type_name;
for (i = 0; i < int(35 - strlen(type_name)); i++) { for (i = 0; i < int(35 - strlen(type_name)); i++) {
fp_struct << ' '; fp_struct << ' ';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << ' '; fp_cstruc << ' ';
} }
fp_struct << " *" << pgmname << "P[" << ctx->rw->attr_elements << "]" fp_struct << " *" << pgmname << "P[" << ctx->rw->attr_elements << "]"
<< alignstr << ";\n"; << alignstr << ";\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " *" << pgmname << "P[" << ctx->rw->attr_elements << "]" fp_cstruc << " *" << pgmname << "P[" << ctx->rw->attr_elements << "]"
<< alignstr << ";\n"; << alignstr << ";\n";
} else if (ctx->rw->attr_pointer) { } else if (ctx->rw->attr_pointer) {
fp_struct << " " << type_name; fp_struct << " " << type_name;
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " << type_name; fp_cstruc << " " << type_name;
for (i = 0; i < int(35 - strlen(type_name)); i++) { for (i = 0; i < int(35 - strlen(type_name)); i++) {
fp_struct << ' '; fp_struct << ' ';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << ' '; fp_cstruc << ' ';
} }
fp_struct << " **" << pgmname << "P" << alignstr << ";\n"; fp_struct << " **" << pgmname << "P" << alignstr << ";\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " **" << pgmname << "P" << alignstr << ";\n"; fp_cstruc << " **" << pgmname << "P" << alignstr << ";\n";
} else { } else {
fp_struct << " " << type_name; fp_struct << " " << type_name;
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " << type_name; fp_cstruc << " " << type_name;
for (i = 0; i < int(35 - strlen(type_name)); i++) { for (i = 0; i < int(35 - strlen(type_name)); i++) {
fp_struct << ' '; fp_struct << ' ';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << ' '; fp_cstruc << ' ';
} }
fp_struct << " *" << pgmname << "P" << alignstr << ";\n"; fp_struct << " *" << pgmname << "P" << alignstr << ";\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " *" << pgmname << "P" << alignstr << ";\n"; fp_cstruc << " *" << pgmname << "P" << alignstr << ";\n";
} }
} }
...@@ -530,56 +528,56 @@ int CnvWblToH::attribute_exec() ...@@ -530,56 +528,56 @@ int CnvWblToH::attribute_exec()
fp_struct << " " fp_struct << " "
<< "pwr_tUInt64"; << "pwr_tUInt64";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " fp_cstruc << " "
<< "pwr_tUInt64"; << "pwr_tUInt64";
for (i = 0; i < int(35 - strlen("pwr_tUInt64")); i++) { for (i = 0; i < int(35 - strlen("pwr_tUInt64")); i++) {
fp_struct << ' '; fp_struct << ' ';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << ' '; fp_cstruc << ' ';
} }
fp_struct << " " << pgmname << "[" << ctx->rw->attr_elements << "]" fp_struct << " " << pgmname << "[" << ctx->rw->attr_elements << "]"
<< alignstr << ";\n"; << alignstr << ";\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " << pgmname << "[" << ctx->rw->attr_elements << "]" fp_cstruc << " " << pgmname << "[" << ctx->rw->attr_elements << "]"
<< alignstr << ";\n"; << alignstr << ";\n";
} else if (ctx->rw->attr_array) { } else if (ctx->rw->attr_array) {
fp_struct << " " << type_name; fp_struct << " " << type_name;
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " << type_name; fp_cstruc << " " << type_name;
for (i = 0; i < int(35 - strlen(type_name)); i++) { for (i = 0; i < int(35 - strlen(type_name)); i++) {
fp_struct << ' '; fp_struct << ' ';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << ' '; fp_cstruc << ' ';
} }
fp_struct << ' ' << pgmname << "[" << ctx->rw->attr_elements << "]" fp_struct << ' ' << pgmname << "[" << ctx->rw->attr_elements << "]"
<< alignstr << ";\n"; << alignstr << ";\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << pgmname << "[" << ctx->rw->attr_elements << "]" << alignstr fp_cstruc << pgmname << "[" << ctx->rw->attr_elements << "]" << alignstr
<< ";\n"; << ";\n";
} else if (ctx->rw->attr_pointer) { } else if (ctx->rw->attr_pointer) {
fp_struct << " " << type_name; fp_struct << " " << type_name;
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " << type_name; fp_cstruc << " " << type_name;
for (i = 0; i < int(35 - strlen(type_name)); i++) { for (i = 0; i < int(35 - strlen(type_name)); i++) {
fp_struct << ' '; fp_struct << ' ';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << ' '; fp_cstruc << ' ';
} }
fp_struct << " *" << pgmname << alignstr << ";\n"; fp_struct << " *" << pgmname << alignstr << ";\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " *" << pgmname << alignstr << ";\n"; fp_cstruc << " *" << pgmname << alignstr << ";\n";
} else { } else {
fp_struct << " " << type_name; fp_struct << " " << type_name;
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << " " << type_name; fp_cstruc << " " << type_name;
for (i = 0; i < int(35 - strlen(type_name)); i++) { for (i = 0; i < int(35 - strlen(type_name)); i++) {
fp_struct << ' '; fp_struct << ' ';
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << ' '; fp_cstruc << ' ';
} }
fp_struct << ' ' << pgmname << alignstr << ";\n"; fp_struct << ' ' << pgmname << alignstr << ";\n";
if (!ctx->common_structfile_only) if (!ctx->common_structfile_only)
cstruc->f << pgmname << alignstr << ";\n"; fp_cstruc << pgmname << alignstr << ";\n";
} }
attr_count++; attr_count++;
......
...@@ -55,7 +55,7 @@ class CnvWblToH : public CnvWblTo { ...@@ -55,7 +55,7 @@ class CnvWblToH : public CnvWblTo {
CnvCtx* ctx; CnvCtx* ctx;
int struct_class_open; int struct_class_open;
std::ofstream fp_struct; std::ofstream fp_struct;
CnvFile* cstruc; std::ofstream fp_cstruc;
int struct_cclass_written; int struct_cclass_written;
int struct_cclass_endwritten; int struct_cclass_endwritten;
int struct_filler_cnt; int struct_filler_cnt;
......
This diff is collapsed.
...@@ -68,7 +68,7 @@ class CnvWblToHtml : public CnvWblTo { ...@@ -68,7 +68,7 @@ class CnvWblToHtml : public CnvWblTo {
} }
CnvCtx* ctx; CnvCtx* ctx;
CnvFile* html_clf; std::ofstream fp_html_clf;
std::ofstream fp_html_index; std::ofstream fp_html_index;
std::ofstream fp_js_all; std::ofstream fp_js_all;
std::ofstream fp_tmp; std::ofstream fp_tmp;
...@@ -103,11 +103,11 @@ class CnvWblToHtml : public CnvWblTo { ...@@ -103,11 +103,11 @@ class CnvWblToHtml : public CnvWblTo {
} }
int class_open() int class_open()
{ {
return html_class_open; return fp_html_clf.is_open();
} }
int index_open() int index_open()
{ {
return html_index_open; return fp_html_index.is_open();
} }
void create_cdp_file(const char* volume_name, const char* class_name, void create_cdp_file(const char* volume_name, const char* class_name,
const char* attr_typeref); const char* attr_typeref);
......
...@@ -87,18 +87,18 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1, ...@@ -87,18 +87,18 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1,
static int in_table = 0; static int in_table = 0;
if ((text2 && !streq(text2, "")) || (text3 && !streq(text3, ""))) { if ((text2 && !streq(text2, "")) || (text3 && !streq(text3, ""))) {
if (!in_table && cf) { if (!in_table) {
cf->f << "<TABLE>\n"; fp << "<TABLE>\n";
in_table = 1; in_table = 1;
} }
} else { } else {
if (in_table && cf) { if (in_table) {
// Close table (keep if empty line) // Close table (keep if empty line)
if (!(text1 && streq(text1, "") if (!(text1 && streq(text1, "")
&& (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))) {
cf->f << "</TABLE>\n"; fp << "</TABLE>\n";
in_table = 0; in_table = 0;
} }
} }
...@@ -112,9 +112,8 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1, ...@@ -112,9 +112,8 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1,
strcpy(codingstr, "UTF-8"); strcpy(codingstr, "UTF-8");
subject_to_fname(fname, text1, 1); subject_to_fname(fname, text1, 1);
cf = new CnvFile(); fp.open(fname);
cf->f.open(fname); fp << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "
cf->f << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "
"Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd>\n" "Transitional//EN\"\"http://www.w3.org/TR/REC-html40/loose.dtd>\n"
<< "<!--NewPage-->\n" << "<!--NewPage-->\n"
<< "<HTML>\n" << "<HTML>\n"
...@@ -134,23 +133,18 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1, ...@@ -134,23 +133,18 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1,
return NULL; return NULL;
} }
case navh_eItemType_EndTopic: { case navh_eItemType_EndTopic: {
if (!cf) if (!fp.is_open())
break; break;
cf->f.close(); fp.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 (item_type == navh_eItemType_HelpCode && !in_table) { if (item_type == navh_eItemType_HelpCode && !in_table) {
cf->f << "<CODE>"; fp << "<CODE>";
for (const char* s = text1; s && *s == ' '; s++) for (const char* s = text1; s && *s == ' '; s++)
cf->f << "&nbsp;"; fp << "&nbsp;";
} }
pwr_tFileName fname; pwr_tFileName fname;
...@@ -197,52 +191,49 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1, ...@@ -197,52 +191,49 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1,
} }
} }
if (!in_table) if (!in_table)
cf->f << "<A HREF=\"" << fname << "\">"; fp << "<A HREF=\"" << fname << "\">";
} else if (bookmark) { } else if (bookmark) {
if (in_table) { if (in_table) {
cf->f << "</TABLE>\n"; fp << "</TABLE>\n";
in_table = 0; in_table = 0;
} }
cf->f << "<A NAME=\"" << bookmark << "\">"; fp << "<A NAME=\"" << bookmark << "\">";
} }
if (!in_table) { if (!in_table) {
cf->f << text1; fp << text1;
if (!streq(link, "") || bookmark) if (!streq(link, "") || bookmark)
cf->f << "<BR></A>\n"; fp << "<BR></A>\n";
else else
cf->f << "<BR>\n"; fp << "<BR>\n";
if (item_type == navh_eItemType_HelpCode) if (item_type == navh_eItemType_HelpCode)
cf->f << "</CODE>"; fp << "</CODE>";
} else { } else {
cf->f << "<TR><TD>"; fp << "<TR><TD>";
if (!streq(link, "")) if (!streq(link, ""))
cf->f << "<A HREF=\"" << fname << "\">"; fp << "<A HREF=\"" << fname << "\">";
else if (bookmark != 0) else if (bookmark != 0)
cf->f << "<A NAME=\"" << bookmark << "\">"; fp << "<A NAME=\"" << bookmark << "\">";
cf->f << text1; fp << text1;
if (!streq(text2, "") || !streq(text3, "")) { if (!streq(text2, "") || !streq(text3, "")) {
for (i = 0; i < (int)(CNV_TAB - strlen(text1)); i++) for (i = 0; i < (int)(CNV_TAB - strlen(text1)); i++)
cf->f << "&nbsp;"; fp << "&nbsp;";
cf->f << "&nbsp;&nbsp;</TD><TD>" << text2; fp << "&nbsp;&nbsp;</TD><TD>" << text2;
if (!streq(text3, "")) { if (!streq(text3, "")) {
for (i = 0; i < (int)(CNV_TAB - strlen(text2)); i++) for (i = 0; i < (int)(CNV_TAB - strlen(text2)); i++)
cf->f << "&nbsp;"; fp << "&nbsp;";
cf->f << "&nbsp;&nbsp;</TD><TD>" << text3; fp << "&nbsp;&nbsp;</TD><TD>" << text3;
} }
} }
if (!streq(link, "") || bookmark) if (!streq(link, "") || bookmark)
cf->f << "</A>\n"; fp << "</A>\n";
else else
cf->f << '\n'; fp << '\n';
cf->f << "</TD></TR>"; fp << "</TD></TR>";
} }
return NULL; return NULL;
} }
case navh_eItemType_HelpBold: { case navh_eItemType_HelpBold: {
if (!cf)
break;
pwr_tFileName fname; pwr_tFileName fname;
if (!streq(link, "")) { if (!streq(link, "")) {
if (str_StartsWith(link, "$web:")) { if (str_StartsWith(link, "$web:")) {
...@@ -274,88 +265,73 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1, ...@@ -274,88 +265,73 @@ void* CnvXtthelpToHtml::insert(navh_eItemType item_type, const char* text1,
} }
} }
if (!in_table) if (!in_table)
cf->f << "<A HREF=\"" << fname << "\">"; fp << "<A HREF=\"" << fname << "\">";
} else if (bookmark) { } else if (bookmark) {
if (!in_table) if (!in_table)
cf->f << "<A NAME=\"" << bookmark << "\">"; fp << "<A NAME=\"" << bookmark << "\">";
} }
if (!in_table) { if (!in_table) {
cf->f << "<B>" << text1 << "</B>"; fp << "<B>" << text1 << "</B>";
if (!streq(link, "") || bookmark) if (!streq(link, "") || bookmark)
cf->f << "<BR></A>\n"; fp << "<BR></A>\n";
else else
cf->f << "<BR>\n"; fp << "<BR>\n";
} else { } else {
cf->f << "<TR><TD><B>"; fp << "<TR><TD><B>";
if (!streq(link, "")) if (!streq(link, ""))
cf->f << "<A HREF=\"" << fname << "\">"; fp << "<A HREF=\"" << fname << "\">";
else if (bookmark != 0) else if (bookmark != 0)
cf->f << "<A NAME=\"" << bookmark << "\">"; fp << "<A NAME=\"" << bookmark << "\">";
cf->f << text1; fp << text1;
if (!streq(link, "") || bookmark) if (!streq(link, "") || bookmark)
cf->f << "</A>"; fp << "</A>";
if (!streq(text2, "") || !streq(text3, "")) { if (!streq(text2, "") || !streq(text3, "")) {
for (i = 0; i < (int)(CNV_TAB - strlen(text1)); i++) for (i = 0; i < (int)(CNV_TAB - strlen(text1)); i++)
cf->f << "&nbsp;"; fp << "&nbsp;";
cf->f << "&nbsp;&nbsp;</B></TD><TD><B>" << text2; fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text2;
if (!streq(text3, "")) { if (!streq(text3, "")) {
for (i = 0; i < (int)(CNV_TAB - strlen(text2)); i++) for (i = 0; i < (int)(CNV_TAB - strlen(text2)); i++)
cf->f << "&nbsp;"; fp << "&nbsp;";
cf->f << "&nbsp;&nbsp;</B></TD><TD><B>" << text3; fp << "&nbsp;&nbsp;</B></TD><TD><B>" << text3;
} }
} }
if (!streq(link, "") || bookmark) if (!streq(link, "") || bookmark)
cf->f << "</A>\n"; fp << "</A>\n";
else else
cf->f << '\n'; fp << '\n';
cf->f << "</B></TD></TR>"; fp << "</B></TD></TR>";
} }
return NULL; return NULL;
} }
case navh_eItemType_HelpHeader: { case navh_eItemType_HelpHeader: {
if (!cf) fp << "<H1>" << text1 << "</H1>\n";
break;
cf->f << "<H1>" << text1 << "</H1>\n";
return NULL; return NULL;
} }
case navh_eItemType_Header: { case navh_eItemType_Header: {
if (!cf)
break;
if (bookmark != 0) if (bookmark != 0)
cf->f << "<A NAME=\"" << bookmark << "\">"; fp << "<A NAME=\"" << bookmark << "\">";
cf->f << "<H3>" << text1 << "</H3>"; fp << "<H3>" << text1 << "</H3>";
if (bookmark != 0) if (bookmark != 0)
cf->f << "</A>"; fp << "</A>";
cf->f << '\n'; fp << '\n';
return NULL; return NULL;
} }
case navh_eItemType_HeaderLarge: { case navh_eItemType_HeaderLarge: {
if (!cf)
break;
if (bookmark != 0) if (bookmark != 0)
cf->f << "<A NAME=\"" << bookmark << "\">"; fp << "<A NAME=\"" << bookmark << "\">";
cf->f << "<H2>" << text1 << "</H2>"; fp << "<H2>" << text1 << "</H2>";
if (bookmark != 0) if (bookmark != 0)
cf->f << "</A>"; fp << "</A>";
cf->f << '\n'; fp << '\n';
return NULL; return NULL;
} }
case navh_eItemType_HorizontalLine: { case navh_eItemType_HorizontalLine: {
if (!cf) fp << "<HR>\n";
break;
cf->f << "<HR>\n";
return NULL; return NULL;
} }
case navh_eItemType_Image: { case navh_eItemType_Image: {
if (!cf) fp << "<IMG SRC=\"" << text1 << "\"><BR>\n";
break;
cf->f << "<IMG SRC=\"" << text1 << "\"><BR>\n";
return NULL; return NULL;
} }
default: default:
......
...@@ -41,14 +41,13 @@ ...@@ -41,14 +41,13 @@
extern "C" { extern "C" {
#endif #endif
#include "cnv_file.h"
#include "cnv_xtthelpto.h" #include "cnv_xtthelpto.h"
class CnvCtx; class CnvCtx;
class CnvXtthelpToHtml : public CnvXtthelpTo { class CnvXtthelpToHtml : public CnvXtthelpTo {
public: public:
CnvXtthelpToHtml(CnvCtx* cnv_ctx) : ctx(cnv_ctx), cf(0) CnvXtthelpToHtml(CnvCtx* cnv_ctx) : ctx(cnv_ctx)
{ {
} }
virtual ~CnvXtthelpToHtml() virtual ~CnvXtthelpToHtml()
...@@ -66,8 +65,7 @@ class CnvXtthelpToHtml : public CnvXtthelpTo { ...@@ -66,8 +65,7 @@ class CnvXtthelpToHtml : public CnvXtthelpTo {
void subject_to_fname(char* fname, const char* subject, int path); void subject_to_fname(char* fname, const char* subject, int path);
CnvCtx* ctx; CnvCtx* ctx;
CnvFile* cf; std::ofstream fp;
// std::ofstream fp;
}; };
#if defined __cplusplus #if defined __cplusplus
......
...@@ -67,9 +67,8 @@ void CnvXtthelpToText::subject_to_fname( ...@@ -67,9 +67,8 @@ void CnvXtthelpToText::subject_to_fname(
CnvXtthelpToText::~CnvXtthelpToText() CnvXtthelpToText::~CnvXtthelpToText()
{ {
if (cf) { if (fp.is_open()) {
cf->f.close(); fp.close();
delete cf;
} }
} }
...@@ -99,8 +98,7 @@ void* CnvXtthelpToText::insert(navh_eItemType item_type, const char* text1, ...@@ -99,8 +98,7 @@ void* CnvXtthelpToText::insert(navh_eItemType item_type, const char* text1,
pwr_tFileName fname; pwr_tFileName fname;
subject_to_fname(fname, text1, 1); subject_to_fname(fname, text1, 1);
cf = new CnvFile(); fp.open(fname);
cf->f.open(fname);
first_topic = 0; first_topic = 0;
} }
...@@ -112,7 +110,7 @@ void* CnvXtthelpToText::insert(navh_eItemType item_type, const char* text1, ...@@ -112,7 +110,7 @@ void* CnvXtthelpToText::insert(navh_eItemType item_type, const char* text1,
in_topic = 0; in_topic = 0;
break; break;
case navh_eItemType_PageBreak: { case navh_eItemType_PageBreak: {
cf->f << "\f"; fp << "\f";
return NULL; return NULL;
} }
case navh_eItemType_Help: case navh_eItemType_Help:
...@@ -121,29 +119,29 @@ void* CnvXtthelpToText::insert(navh_eItemType item_type, const char* text1, ...@@ -121,29 +119,29 @@ void* CnvXtthelpToText::insert(navh_eItemType item_type, const char* text1,
case navh_eItemType_Header: case navh_eItemType_Header:
case navh_eItemType_HeaderLarge: case navh_eItemType_HeaderLarge:
case navh_eItemType_HelpHeader: { case navh_eItemType_HelpHeader: {
cf->f << text1; fp << text1;
if (text2) { if (text2) {
cf->f << " "; fp << " ";
for (int i = 0; i < (int)(CNV_TAB - strlen(text1) - 1); i++) for (int i = 0; i < (int)(CNV_TAB - strlen(text1) - 1); i++)
cf->f << " "; fp << " ";
cf->f << text2; fp << text2;
if (text3) { if (text3) {
cf->f << " "; fp << " ";
for (int i = 0; i < (int)(CNV_TAB - strlen(text2) - 1); i++) for (int i = 0; i < (int)(CNV_TAB - strlen(text2) - 1); i++)
cf->f << " "; fp << " ";
cf->f << text3; fp << text3;
} }
} }
cf->f << '\n'; fp << '\n';
break; break;
} }
case navh_eItemType_HorizontalLine: { case navh_eItemType_HorizontalLine: {
for (int i = 0; i < 80; i++) for (int i = 0; i < 80; i++)
cf->f << "-"; fp << "-";
cf->f << '\n'; fp << '\n';
return NULL; return NULL;
} }
......
...@@ -39,14 +39,13 @@ ...@@ -39,14 +39,13 @@
#include "cnv_xtthelpto.h" #include "cnv_xtthelpto.h"
#include "cnv_content.h" #include "cnv_content.h"
#include "cnv_file.h"
class CnvCtx; class CnvCtx;
class CnvXtthelpToText : public CnvXtthelpTo { class CnvXtthelpToText : public CnvXtthelpTo {
public: public:
CnvXtthelpToText(CnvCtx* cnv_ctx) CnvXtthelpToText(CnvCtx* cnv_ctx)
: ctx(cnv_ctx), cf(0), first_topic(1), in_topic(0), print_disable(0) : ctx(cnv_ctx), first_topic(1), in_topic(0), print_disable(0)
{ {
} }
virtual ~CnvXtthelpToText(); virtual ~CnvXtthelpToText();
...@@ -62,7 +61,7 @@ class CnvXtthelpToText : public CnvXtthelpTo { ...@@ -62,7 +61,7 @@ class CnvXtthelpToText : public CnvXtthelpTo {
void subject_to_fname(char* fname, const char* subject, int path); void subject_to_fname(char* fname, const char* subject, int path);
CnvCtx* ctx; CnvCtx* ctx;
CnvFile* cf; std::ofstream fp;
int first_topic; int first_topic;
int in_topic; int in_topic;
int print_disable; int print_disable;
......
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