Commit ba705e5f authored by Claes Sjofors's avatar Claes Sjofors

co_convert conversion from xtt help to text

parent d3e70ab4
......@@ -85,6 +85,7 @@ typedef enum {
pdf_eId_TopicL3,
pdf_eId_Function,
pdf_eId_Class,
pdf_eId_Report,
pdf_eId__
} pdf_eId;
......@@ -188,6 +189,8 @@ class CnvToPdf {
CnvStyle( "TimesNewRoman-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
style[pdf_eId_TopicL3].text =
CnvStyle( "TimesNewRoman-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
style[pdf_eId_Report].h1 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 20, 0, 14, 20, cnv_eAlignment_Left, 0, 0, 0);
}
~CnvToPdf();
......
......@@ -338,6 +338,8 @@ page_x << " " << ps_cPageNumY << " moveto" << endl <<
void CnvToPs::print_content()
{
if ( !content.tab.size())
return;
cf = ps_eFile_Info;
ci = ps_eId_Content;
......@@ -382,10 +384,15 @@ CnvToPs::~CnvToPs()
void CnvToPs::close()
{
cf = ps_eFile_Body;
print_pagebreak( 1);
cf = ps_eFile_Info;
print_content();
if ( ci != ps_eId_Report) {
cf = ps_eFile_Body;
print_pagebreak( 1);
cf = ps_eFile_Info;
print_content();
}
else
fp[cf] << "showpage" << endl;
if ( !conf_pass) {
fp[ps_eFile_Info].close();
fp[ps_eFile_Body].close();
......@@ -560,7 +567,7 @@ void CnvToPs::print_h1( const char *text, int hlevel, char *subject)
else
print_text( text, style[ci].h1);
if ( conf_pass) {
if ( conf_pass && ci != ps_eId_Report) {
CnvContentElem cnt;
cnt.page_number = page_number[cf];
cnt.header_level = hlevel;
......
......@@ -86,6 +86,7 @@ typedef enum {
ps_eId_TopicL3,
ps_eId_Function,
ps_eId_Class,
ps_eId_Report,
ps_eId__
} ps_eId;
......@@ -140,6 +141,8 @@ class CnvToPs {
CnvStyle( "Times-Roman-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_TopicL3].text =
CnvStyle( "Times-Roman-ISOLatin1", 10, 0, 11, 1, cnv_eAlignment_Left, 0, 0, 0);
style[ps_eId_Report].h1 =
CnvStyle( "Helvetica-Bold-ISOLatin1", 24, 0, 24, 20, cnv_eAlignment_Left, 0, 0, 0);
}
~CnvToPs();
......
......@@ -52,7 +52,9 @@ class CnvReadXtthelp;
typedef enum {
Cnv_eXtthelpToType_Html,
Cnv_eXtthelpToType_Xml,
Cnv_eXtthelpToType_Ps
Cnv_eXtthelpToType_Ps,
Cnv_eXtthelpToType_Pdf,
Cnv_eXtthelpToType_Text
} Cnv_eXtthelpToType;
class CnvXtthelpTo {
......
......@@ -144,6 +144,8 @@ void *CnvXtthelpToPdf::insert( navh_eItemType item_type, const char *text1,
topdf.y = pdf_cPageHeight - pdf_cTopMargin;
}
}
else
topdf.set_ci( pdf_eId_TopicL1);
}
if ( first_topic) {
......@@ -178,6 +180,10 @@ void *CnvXtthelpToPdf::insert( navh_eItemType item_type, const char *text1,
topdf.set_ci( pdf_eId_Function);
user_style = 1;
}
else if ( cdh_NoCaseStrcmp( text1, "report") == 0) {
base_ci = topdf.ci;
topdf.set_ci( pdf_eId_Report);
}
return NULL;
}
case navh_eItemType_EndChapter: {
......
......@@ -140,6 +140,9 @@ void *CnvXtthelpToPs::insert( navh_eItemType item_type, const char *text1,
else
first_chaptertopic = 0;
}
else
tops.set_ci( ps_eId_TopicL1);
if ( tops.cf == ps_eFile_Info)
tops.y = ps_cPageHeight - ps_cTopMargin;
tops.set_cf( ps_eFile_Body);
......@@ -178,6 +181,10 @@ void *CnvXtthelpToPs::insert( navh_eItemType item_type, const char *text1,
tops.set_ci( ps_eId_Function);
user_style = 1;
}
else if ( cdh_NoCaseStrcmp( text1, "report") == 0) {
base_ci = tops.ci;
tops.set_ci( ps_eId_Report);
}
return NULL;
}
case navh_eItemType_EndChapter: {
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. 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
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview 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 Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
/* cnv_xtthelptotext.cpp --
Convert xtt help file to TEXT. */
/*_Include files_________________________________________________________*/
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
extern "C" {
#include "co_cdh.h"
#include "co_dcli.h"
}
#include "co_nav_help.h"
#include "co_lng.h"
#include "cnv_ctx.h"
#include "cnv_readxtthelp.h"
#include "cnv_xtthelptotext.h"
#include "cnv_image.h"
#define text_cCellSize 110
/* Nice functions */
#define ODD(a) (((int)(a) & 1) != 0)
#define EVEN(a) (((int)(a) & 1) == 0)
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
#ifndef __ALPHA
#define abs(Dragon) ((Dragon) >= 0 ? (Dragon) : (-(Dragon)))
#endif
#define CNV_TAB 25
void CnvXtthelpToText::subject_to_fname( char *fname, const char *subject, int path)
{
if ( path) {
strcpy( fname, ctx->dir);
strcat( fname, ctx->rx->name);
}
else
strcpy( fname, ctx->rx->name);
strcat( fname, ".txt");
cdh_ToLower( fname, fname);
}
CnvXtthelpToText::~CnvXtthelpToText()
{
if ( cf) {
cf->f.close();
delete cf;
}
}
void *CnvXtthelpToText::insert( navh_eItemType item_type, const char *text1,
const char *text2, const char *text3, const char *alink,
const char *link_bookmark, const char *file_name,
navh_eHelpFile file_type, int help_index,
const char *bookmark, int coding)
{
if ( print_disable)
return NULL;
if ( item_type != navh_eItemType_Topic && !in_topic)
return NULL;
switch ( item_type) {
case navh_eItemType_DocTitlePage:
case navh_eItemType_DocInfoPage:
case navh_eItemType_Style:
case navh_eItemType_EndChapter:
case navh_eItemType_Chapter:
case navh_eItemType_HeaderLevel:
case navh_eItemType_EndHeaderLevel:
case navh_eItemType_Image:
return NULL;
case navh_eItemType_Topic: {
if ( first_topic) {
pwr_tFileName fname;
subject_to_fname( fname, text1, 1);
cf = new CnvFile();
cf->f.open( fname);
first_topic = 0;
}
in_topic = 1;
return NULL;
}
case navh_eItemType_EndTopic:
in_topic = 0;
break;
case navh_eItemType_PageBreak: {
cf->f << "\f";
return NULL;
}
case navh_eItemType_Help:
case navh_eItemType_HelpCode:
case navh_eItemType_HelpBold:
case navh_eItemType_Header:
case navh_eItemType_HeaderLarge:
case navh_eItemType_HelpHeader: {
cf->f << text1;
if ( text2) {
cf->f << " ";
for ( int i = 0; i < (int)(CNV_TAB - strlen(text1) - 1); i++)
cf->f << " ";
cf->f << text2;
if ( text3) {
cf->f << " ";
for ( int i = 0; i < (int)(CNV_TAB - strlen(text2) - 1); i++)
cf->f << " ";
cf->f << text3;
}
}
cf->f << endl;
break;
}
case navh_eItemType_HorizontalLine: {
for ( int i = 0; i < 80; i++)
cf->f << "-";
cf->f << endl;
return NULL;
}
case navh_eItemType_Option: {
if ( strcmp( text1, "printdisable") == 0)
print_disable = 1;
else if ( strcmp( text1, "printenable") == 0)
print_disable = 0;
return NULL;
}
default:
return 0;
}
return 0;
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund AB.
*
* This file is part of Proview.
*
* 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 Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. 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
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview 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 Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef cnv_xtthelptotext_h
#define cnv_xtthelptotext_h
using namespace std;
#include <iostream>
#include <vector>
#include <string>
#include "pwr.h"
#include "cnv_xtthelpto.h"
#include "cnv_style.h"
#include "cnv_content.h"
#include "cnv_file.h"
class CnvCtx;
class CnvXtthelpToText : public CnvXtthelpTo {
public:
CnvXtthelpToText( CnvCtx *cnv_ctx) :
ctx(cnv_ctx), cf(0), first_topic(1), in_topic(0), print_disable(0) {}
virtual ~CnvXtthelpToText();
Cnv_eXtthelpToType type() { return Cnv_eXtthelpToType_Text;}
void *insert( navh_eItemType item_type, const char *text1,
const char *text2, const char *text3, const char *link,
const char *link_bookmark, const char *file_name,
navh_eHelpFile file_type, int help_index,
const char *bookmark, int coding);
void subject_to_fname( char *fname, const char *subject, int path);
CnvCtx *ctx;
CnvFile *cf;
int first_topic;
int in_topic;
int print_disable;
};
#endif
......@@ -60,6 +60,7 @@ extern "C" {
#include "cnv_xtthelptoxml.h"
#include "cnv_xtthelptops.h"
#include "cnv_xtthelptopdf.h"
#include "cnv_xtthelptotext.h"
#include "cnv_pwgtoxtthelp.h"
#include "cnv_classdep.h"
#include "cnv_changelog.h"
......@@ -119,6 +120,7 @@ int main( int argc, char *argv[])
int xtthelp_to_xml = 0;
int xtthelp_to_ps = 0;
int xtthelp_to_pdf = 0;
int xtthelp_to_text = 0;
int pwg_to_xtthelp = 0;
int changelog = 0;
char from[80] = "";
......@@ -213,6 +215,9 @@ int main( int argc, char *argv[])
case 'f':
xtthelp_to_pdf = 1;
break;
case 'j':
xtthelp_to_text = 1;
break;
case 'a':
pwg_to_xtthelp = 1;
break;
......@@ -282,6 +287,14 @@ int main( int argc, char *argv[])
delete xtthelpto;
exit(0);
}
if ( xtthelp_to_text) {
CnvXtthelpToText *xtthelpto = new CnvXtthelpToText( ctx);
ctx->rx = new CnvReadXtthelp( files, ctx->dir, xtthelpto);
ctx->rx->read_xtthelp();
delete ctx->rx;
delete xtthelpto;
exit(0);
}
if ( ctx->generate_cdp) {
CnvClassDep *classdep = new CnvClassDep( ctx);
classdep->read();
......
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