Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
ac05ff75
Commit
ac05ff75
authored
Apr 21, 2005
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conversion xtthelp -> pdf added
parent
a02c4109
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1844 additions
and
0 deletions
+1844
-0
src/exe/co_convert/src/cnv_topdf.cpp
src/exe/co_convert/src/cnv_topdf.cpp
+1066
-0
src/exe/co_convert/src/cnv_topdf.h
src/exe/co_convert/src/cnv_topdf.h
+227
-0
src/exe/co_convert/src/cnv_xtthelptopdf.cpp
src/exe/co_convert/src/cnv_xtthelptopdf.cpp
+362
-0
src/exe/co_convert/src/cnv_xtthelptopdf.h
src/exe/co_convert/src/cnv_xtthelptopdf.h
+86
-0
src/exe/co_convert/src/co_convert.cpp
src/exe/co_convert/src/co_convert.cpp
+103
-0
No files found.
src/exe/co_convert/src/cnv_topdf.cpp
0 → 100644
View file @
ac05ff75
/* cnv_topdf.cpp --
PROVIEW/R
Copyright (C) 1996-98 by Mandator AB.
Convert xtt help file to postscript. */
/*_Include files_________________________________________________________*/
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
extern
"C"
{
#include "co_cdh.h"
#include "co_dcli.h"
}
#include "cnv_topdf.h"
#include "co_lng.h"
#include "cnv_image.h"
#define CNV_TAB 18
#define pdf_cHead "%PDF-1.4"
/* 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
void
CnvPdfObj
::
print_begin
()
{
offset
=
topdf
->
fp
[
topdf
->
cf
].
tellp
();
switch
(
type
)
{
case
pdf_eObjType_Catalog
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
<<
" 0 obj"
<<
endl
<<
" << /Type /Catalog"
<<
endl
<<
" /Outlines 2 0 R"
<<
endl
<<
" /Pages "
<<
number
+
topdf
->
v_outline
.
size
()
<<
" 0 R"
<<
endl
<<
" /PageMode /UseOutlines"
<<
endl
<<
" >>"
<<
endl
<<
"endobj"
<<
endl
<<
endl
;
break
;
case
pdf_eObjType_Outline
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
<<
" 0 obj"
<<
endl
<<
" << /Type /Outlines"
<<
endl
;
if
(
first
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /First "
<<
first
+
1
<<
" 0 R"
<<
endl
;
if
(
last
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /Last "
<<
last
+
1
<<
" 0 R"
<<
endl
;
topdf
->
fp
[
topdf
->
cf
]
<<
" /Count "
<<
count
<<
endl
<<
" >>"
<<
endl
<<
"endobj"
<<
endl
<<
endl
;
break
;
case
pdf_eObjType_Pages
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
+
topdf
->
v_outline
.
size
()
<<
" 0 obj"
<<
endl
<<
" << /Type /Pages"
<<
endl
<<
" /Kids ["
<<
endl
;
for
(
int
i
=
1
;
i
<
(
int
)
topdf
->
v_pages
.
size
();
i
++
)
topdf
->
fp
[
topdf
->
cf
]
<<
" "
<<
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
[
i
].
number
<<
" 0 R"
<<
endl
;
topdf
->
fp
[
topdf
->
cf
]
<<
" ]"
<<
endl
<<
" /Count "
<<
topdf
->
v_pages
.
size
()
-
1
<<
endl
<<
" >>"
<<
endl
<<
"endobj"
<<
endl
<<
endl
;
break
;
case
pdf_eObjType_Page
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
+
topdf
->
v_outline
.
size
()
<<
" 0 obj"
<<
endl
<<
" << /Type /Page"
<<
endl
<<
" /Parent "
<<
topdf
->
v_outline
.
size
()
+
1
<<
" 0 R"
<<
endl
<<
" /Mediabox [0 0 "
<<
pdf_cPageWidth
<<
" "
<<
pdf_cPageHeight
<<
"]"
<<
endl
<<
" /Contents "
<<
number
-
1
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
<<
" 0 R"
<<
endl
;
if
(
resource
==
-
1
)
{
topdf
->
fp
[
topdf
->
cf
]
<<
" /Resources << /Procset "
<<
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
+
1
<<
" 0 R"
<<
endl
<<
" /Font <<"
<<
endl
;
for
(
int
i
=
1
;
i
<
(
int
)
topdf
->
v_font
.
size
();
i
++
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /F"
<<
topdf
->
v_font
[
i
].
number
-
1
<<
" "
<<
topdf
->
v_font
[
i
].
number
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
<<
" 0 R"
<<
endl
;
topdf
->
fp
[
topdf
->
cf
]
<<
" >>"
<<
endl
<<
" >>"
<<
endl
;
}
else
{
topdf
->
fp
[
topdf
->
cf
]
<<
" /Resources "
<<
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
+
+
topdf
->
v_font
.
size
()
+
resource
+
1
<<
" 0 R"
<<
endl
;
}
topdf
->
fp
[
topdf
->
cf
]
<<
" >>"
<<
endl
<<
"endobj"
<<
endl
<<
endl
;
break
;
case
pdf_eObjType_Content
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
<<
" 0 obj"
<<
endl
<<
" << /Length "
<<
length
<<
" >>"
<<
endl
<<
"stream"
<<
endl
;
start
=
(
int
)
topdf
->
fp
[
topdf
->
cf
].
tellp
();
break
;
case
pdf_eObjType_Process
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
<<
" 0 obj"
<<
endl
<<
" [/PDF /Text]"
<<
endl
<<
"endobj"
<<
endl
<<
endl
;
break
;
case
pdf_eObjType_Font
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
<<
" 0 obj"
<<
endl
<<
" << /Type /Font"
<<
endl
<<
" /Subtype /Type1"
<<
endl
<<
" /Name /F"
<<
number
-
1
<<
endl
<<
" /BaseFont /"
<<
fontname
<<
endl
<<
" /Encoding /WinAnsiEncoding"
<<
endl
<<
" >>"
<<
endl
<<
"endobj"
<<
endl
<<
endl
;
break
;
case
pdf_eObjType_OutlineO
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
<<
" 0 obj"
<<
endl
<<
" << /Title ("
<<
text
<<
")"
<<
endl
<<
" /Parent "
<<
parent
+
1
<<
" 0 R"
<<
endl
;
if
(
prev
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /Prev "
<<
prev
+
1
<<
" 0 R"
<<
endl
;
if
(
next
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /Next "
<<
next
+
1
<<
" 0 R"
<<
endl
;
if
(
first
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /First "
<<
first
+
1
<<
" 0 R"
<<
endl
;
if
(
last
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /Last "
<<
last
+
1
<<
" 0 R"
<<
endl
;
if
(
count
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /Count "
<<
count
<<
endl
;
topdf
->
fp
[
topdf
->
cf
]
<<
" /Dest ["
<<
dest
<<
" 0 R /XYZ null 700 null]"
<<
endl
<<
" >>"
<<
endl
<<
"endobj"
<<
endl
<<
endl
;
break
;
case
pdf_eObjType_Image
:
print_image
();
break
;
case
pdf_eObjType_Resource
:
topdf
->
fp
[
topdf
->
cf
]
<<
number
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
+
topdf
->
v_font
.
size
()
<<
" 0 obj"
<<
endl
<<
" << /ProcSet [/PDF /Text /ImageB]"
<<
endl
<<
" /XObject <<"
<<
endl
;
for
(
int
i
=
0
;
i
<
xobject_cnt
;
i
++
)
{
topdf
->
fp
[
topdf
->
cf
]
<<
" /Im"
<<
xobject
[
i
]
+
1
<<
" "
<<
xobject
[
i
]
+
1
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
+
topdf
->
v_font
.
size
()
+
topdf
->
v_resource
.
size
()
<<
" 0 R"
<<
endl
;
}
topdf
->
fp
[
topdf
->
cf
]
<<
" >>"
<<
endl
<<
" /Font <<"
<<
endl
;
for
(
int
i
=
1
;
i
<
(
int
)
topdf
->
v_font
.
size
();
i
++
)
topdf
->
fp
[
topdf
->
cf
]
<<
" /F"
<<
topdf
->
v_font
[
i
].
number
-
1
<<
" "
<<
topdf
->
v_font
[
i
].
number
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
<<
" 0 R"
<<
endl
;
topdf
->
fp
[
topdf
->
cf
]
<<
" >>"
<<
endl
<<
" >>"
<<
endl
<<
"endobj"
<<
endl
;
break
;
}
}
void
CnvPdfObj
::
print_end
()
{
switch
(
type
)
{
case
pdf_eObjType_Content
:
length
=
(
int
)
topdf
->
fp
[
topdf
->
cf
].
tellp
()
-
start
;
topdf
->
fp
[
topdf
->
cf
]
<<
"endstream"
<<
endl
<<
"endobj"
<<
endl
<<
endl
;
break
;
default:
;
}
}
int
CnvPdfObj
::
print_image
()
{
ImlibImage
*
image
;
Pixmap
pixmap
;
pwr_tFileName
fname
;
int
sts
;
int
width
,
height
;
#if 0
unsigned char *rgb;
unsigned char transp[3] = {255,0,255};
int i, j;
int grey;
#endif
char
c
;
// Try $pwr_doc/help/
strcpy
(
fname
,
"$pwr_doc/help/"
);
strcat
(
fname
,
text
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
{
// Try $pwr_exe
strcpy
(
fname
,
"$pwr_exe/"
);
strcat
(
fname
,
text
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
{
// Try $pwrp_exe
strcpy
(
fname
,
"$pwrp_exe/"
);
strcat
(
fname
,
text
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
return
0
;
}
}
width
=
image
->
rgb_width
;
height
=
image
->
rgb_height
;
topdf
->
fp
[
topdf
->
cf
]
<<
number
+
topdf
->
v_outline
.
size
()
+
topdf
->
v_pages
.
size
()
+
topdf
->
v_content
.
size
()
+
topdf
->
v_font
.
size
()
+
topdf
->
v_resource
.
size
()
<<
" 0 obj"
<<
endl
<<
" << /Type /XObject"
<<
endl
<<
" /Subtype /Image"
<<
endl
<<
" /Width "
<<
width
<<
endl
<<
" /Height "
<<
height
<<
endl
<<
" /ColorSpace /DeviceRGB"
<<
endl
<<
" /BitsPerComponent 8"
<<
endl
<<
" /Filter /DCTDecode"
<<
endl
<<
" /Length "
<<
length
<<
endl
<<
" >>"
<<
endl
<<
"stream"
<<
endl
;
start
=
(
int
)
topdf
->
fp
[
topdf
->
cf
].
tellp
();
strcpy
(
fname
,
"/tmp/pwr_cnv.jpg"
);
cnv_print_image
(
image
,
fname
);
#if 0
rgb = image->rgb_data;
j = 0;
for ( i = 0; i < image->rgb_height * image->rgb_width * 3; i+=3) {
if ( *rgb == transp[0] && *(rgb+1) == transp[1] && *(rgb+2) == transp[2]) {
grey = 255;
}
else {
grey = (int) ((0.0 + *rgb + *(rgb+1) + *(rgb+2)) / 3 + 0.5);
}
rgb += 3;
// fp[cf].width(2);
topdf->fp[topdf->cf] << (unsigned char)grey;
if ( ++j >= 40) {
j = 0;
// fp[cf] << endl;
}
}
#endif
ifstream
fimg
(
fname
);
while
(
fimg
.
get
(
c
))
topdf
->
fp
[
topdf
->
cf
].
put
(
c
);
topdf
->
fp
[
topdf
->
cf
]
<<
endl
;
length
=
(
int
)
topdf
->
fp
[
topdf
->
cf
].
tellp
()
-
start
;
topdf
->
fp
[
topdf
->
cf
]
<<
"endstream"
<<
endl
<<
"endobj"
<<
endl
;
cnv_free_image
(
image
,
pixmap
);
return
1
;
}
void
CnvToPdf
::
cnv_text
(
char
*
to
,
char
*
from
)
{
if
(
!
from
)
{
strcpy
(
to
,
""
);
return
;
}
char
*
t
=
to
;
char
*
s
=
from
;
for
(
;
*
s
;
s
++
)
{
switch
(
*
s
)
{
case
'('
:
*
t
++
=
'\\'
;
*
t
++
=
'('
;
break
;
case
')'
:
*
t
++
=
'\\'
;
*
t
++
=
')'
;
break
;
case
'\\'
:
*
t
++
=
'\\'
;
*
t
++
=
'\\'
;
default:
*
t
++
=
*
s
;
}
}
*
t
=
0
;
}
void
CnvToPdf
::
print_text
(
char
*
text
,
CnvStyle
&
style
,
int
mode
)
{
char
str
[
1000
];
cnv_text
(
str
,
text
);
if
(
style
.
sidebreak
&&
mode
&
pdf_mPrintMode_Pos
)
{
if
(
page_number
[
cf
]
==
0
)
{
// First header, no pagebreak
page_number
[
cf
]
=
1
;
}
else
{
print_pagebreak
(
0
);
}
}
else
if
(
style
.
pagebreak
&&
mode
&
pdf_mPrintMode_Pos
)
print_pagebreak
(
0
);
if
(
mode
&
pdf_mPrintMode_Pos
||
mode
&
pdf_mPrintMode_Start
)
{
y
-=
style
.
top_offset
;
if
(
y
-
style
.
bottom_offset
<
pdf_cBottomMargin
)
{
print_pagebreak
(
0
);
}
}
else
y
+=
style
.
bottom_offset
;
if
(
!
(
mode
&
pdf_mPrintMode_FixX
))
{
if
(
style
.
alignment
==
cnv_eAlignment_Center
)
{
x
=
pdf_cLeftMargin
/
2
+
(
pdf_cPageWidth
-
pdf_cLeftMargin
/
2
)
/
2
-
0.50
*
strlen
(
text
)
*
style
.
font_size
/
2
;
if
(
x
<
pdf_cLeftMargin
/
2
)
x
=
pdf_cLeftMargin
/
2
;
}
else
x
=
pdf_cLeftMargin
+
style
.
indentation
;
}
int
pmode
=
mode
&
31
;
if
(
strcmp
(
text
,
""
)
!=
0
)
{
switch
(
pmode
)
{
case
pdf_mPrintMode_Pos
:
case
pdf_mPrintMode_KeepY
:
{
// Full path with beginning and end
fp
[
cf
]
<<
" BT"
<<
endl
<<
" "
<<
fontname
(
style
)
<<
" "
<<
style
.
font_size
<<
" Tf"
<<
endl
<<
" "
<<
x
<<
" "
<<
y
<<
" Td"
<<
endl
<<
" ("
<<
str
<<
") Tj"
<<
endl
<<
" ET"
<<
endl
;
break
;
}
case
pdf_mPrintMode_Start
:
{
// Start new path
fp
[
cf
]
<<
" BT"
<<
endl
<<
" "
<<
fontname
(
style
)
<<
" "
<<
style
.
font_size
<<
" Tf"
<<
endl
<<
" "
<<
x
<<
" "
<<
y
<<
" Td"
<<
endl
<<
" ("
<<
str
<<
") Tj"
<<
endl
;
break
;
}
case
pdf_mPrintMode_Continue
:
{
// Continue current path
fp
[
cf
]
<<
" "
<<
fontname
(
style
)
<<
" "
<<
style
.
font_size
<<
" Tf"
<<
endl
<<
" "
<<
x
<<
" "
<<
y
<<
" Td"
<<
endl
<<
" ("
<<
str
<<
") Tj"
<<
endl
;
break
;
}
case
pdf_mPrintMode_End
:
{
// Continue and close current path
fp
[
cf
]
<<
" "
<<
fontname
(
style
)
<<
" "
<<
style
.
font_size
<<
" Tf"
<<
endl
<<
" ("
<<
str
<<
") Tj"
<<
endl
<<
" ET"
<<
endl
;
break
;
}
default:
;
}
}
else
{
switch
(
pmode
)
{
case
pdf_mPrintMode_Start
:
{
// Start new path
fp
[
cf
]
<<
" BT"
<<
endl
<<
" "
<<
x
<<
" "
<<
y
<<
" Td"
<<
endl
;
break
;
}
case
pdf_mPrintMode_End
:
{
// Continue and close current path
fp
[
cf
]
<<
" ET"
<<
endl
;
break
;
}
default:
;
}
}
y
-=
style
.
bottom_offset
;
}
void
CnvToPdf
::
print_pagebreak
(
int
last
)
{
if
(
page_number
[
cf
]
==
0
)
page_number
[
cf
]
=
1
;
if
(
page_number
[
cf
]
!=
1
||
last
)
{
double
page_x
;
page_x
=
pdf_cPageNumX
;
if
(
!
(
prev_ci
==
pdf_eId_TitlePage
||
prev_ci
==
pdf_eId_InfoPage
))
{
prev_ci
=
ci
;
fp
[
cf
]
<<
" 1 w"
<<
endl
<<
" "
<<
10
<<
" "
<<
pdf_cPageHeight
-
20
<<
" m"
<<
endl
<<
" "
<<
pdf_cPageWidth
+
65
<<
" "
<<
pdf_cPageHeight
-
20
<<
" l"
<<
endl
<<
" S"
<<
endl
<<
" BT"
<<
endl
<<
" /F1 10 Tf"
<<
endl
<<
" "
<<
pdf_cPageWidth
/
2
-
10
*
0.5
*
strlen
(
previous_chapter
)
<<
" "
<<
pdf_cPageNumY
<<
" Td"
<<
endl
<<
" ("
<<
previous_chapter
<<
") Tj"
<<
endl
<<
" ET"
<<
endl
<<
" BT"
<<
endl
<<
" /F1 10 Tf"
<<
endl
<<
" "
<<
page_x
<<
" "
<<
pdf_cPageNumY
<<
" Td"
<<
endl
<<
" ("
<<
page_number
[
cf
]
-
1
<<
") Tj"
<<
endl
<<
" ET"
<<
endl
;
}
v_content
[
page_number
[
cf
]
-
2
].
print_end
();
}
if
(
last
)
return
;
if
(
conf_pass
)
{
CnvPdfObj
o1
=
CnvPdfObj
(
this
,
pdf_eObjType_Page
,
v_pages
.
size
()
+
1
);
v_pages
.
push_back
(
o1
);
CnvPdfObj
o2
=
CnvPdfObj
(
this
,
pdf_eObjType_Content
,
v_content
.
size
()
+
1
);
v_content
.
push_back
(
o2
);
}
v_content
[
page_number
[
cf
]
-
1
].
print_begin
();
page_number
[
cf
]
++
;
y
=
pdf_cPageHeight
-
pdf_cTopMargin
;
}
void
CnvToPdf
::
print_content
()
{
int
size
=
content
.
tab
.
size
();
int
level
=
0
;
int
prev
[
10
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
int
current
=
v_outline
.
size
();
int
root
=
1
;
int
parent
[
4
]
=
{
0
,
0
,
0
,
0
};
int
offset
=
current
;
v_outline
[
root
].
first
=
current
;
v_outline
[
root
].
last
=
current
+
size
-
1
;
v_outline
[
root
].
count
=
size
;
parent
[
level
]
=
root
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
level
=
content
.
tab
[
i
].
header_level
;
if
(
level
<
0
)
level
=
0
;
CnvPdfObj
o1
=
CnvPdfObj
(
this
,
pdf_eObjType_OutlineO
,
current
+
1
);
strcpy
(
o1
.
text
,
content
.
tab
[
i
].
text
);
o1
.
parent
=
parent
[
level
];
if
(
parent
[
level
]
!=
root
)
{
v_outline
[
parent
[
level
]].
last
=
current
;
v_outline
[
parent
[
level
]].
count
++
;
}
if
(
i
!=
size
-
1
)
{
if
(
content
.
tab
[
i
+
1
].
header_level
>
content
.
tab
[
i
].
header_level
)
{
parent
[
level
+
1
]
=
current
;
o1
.
first
=
current
+
1
;
}
}
if
(
prev
[
level
])
{
o1
.
prev
=
prev
[
level
];
v_outline
[
o1
.
prev
].
next
=
current
;
}
o1
.
dest
=
size
+
offset
+
content
.
tab
[
i
].
page_number
;
prev
[
level
]
=
current
;
v_outline
.
push_back
(
o1
);
current
++
;
if
(
i
!=
size
-
1
)
{
int
next_level
=
content
.
tab
[
i
+
1
].
header_level
;
if
(
next_level
<
0
)
next_level
=
0
;
if
(
level
>
next_level
)
{
for
(
int
j
=
next_level
+
1
;
j
<=
level
;
j
++
)
prev
[
j
]
=
0
;
}
}
}
#if 0
ci = pdf_eId_Content;
x = pdf_cLeftMargin;
y = pdf_cPageHeight - pdf_cTopMargin;
print_pagebreak( 0);
print_text( Lng::translate("Contents"), style[ci].h1);
for ( int i = 0; i < (int)content.tab.size(); i++) {
char page_str[20];
CnvStyle *cstyle = &style[ci].boldtext;
fp[cf] <<
"gsave" << endl <<
"[1 3] 0 setdash" << endl;
sprintf( page_str, "%d", content.tab[i].page_number);
print_text( content.tab[i].header_number, *cstyle);
x = pdf_cLeftMargin + 30 + content.tab[i].header_level * 5;
y += cstyle->top_offset + cstyle->bottom_offset;
print_text( content.tab[i].text, *cstyle, pdf_mPrintMode_Start | pdf_mPrintMode_FixX);
x = pdf_cLeftMargin + 340;
fp[cf] <<
x << " " << y + cstyle->bottom_offset << " lineto" << endl <<
x << " " << y + cstyle->bottom_offset << " moveto" << endl <<
"closepath" << endl <<
"stroke" << endl <<
"grestore" << endl;
print_text( page_str, *cstyle, pdf_mPrintMode_KeepY | pdf_mPrintMode_FixX);
}
print_pagebreak(0);
#endif
}
CnvToPdf
::~
CnvToPdf
()
{
}
void
CnvToPdf
::
close
()
{
cf
=
pdf_eFile_Body
;
print_pagebreak
(
1
);
// print_content();
for
(
int
i
=
0
;
i
<
(
int
)
v_font
.
size
();
i
++
)
{
v_font
[
i
].
print_begin
();
v_font
[
i
].
print_end
();
}
for
(
int
i
=
0
;
i
<
(
int
)
v_resource
.
size
();
i
++
)
{
v_resource
[
i
].
print_begin
();
v_resource
[
i
].
print_end
();
}
for
(
int
i
=
0
;
i
<
(
int
)
v_image
.
size
();
i
++
)
{
v_image
[
i
].
print_begin
();
v_image
[
i
].
print_end
();
}
xref_offset
=
fp
[
cf
].
tellp
();
fp
[
cf
]
<<
endl
<<
"xref"
<<
endl
<<
"0 "
<<
v_outline
.
size
()
+
v_pages
.
size
()
+
v_content
.
size
()
+
v_font
.
size
()
+
v_resource
.
size
()
+
v_image
.
size
()
+
1
<<
endl
<<
"0000000000 65535 f "
<<
endl
;
for
(
int
i
=
0
;
i
<
(
int
)
v_outline
.
size
();
i
++
)
{
fp
[
cf
].
fill
(
'0'
);
fp
[
cf
].
width
(
10
);
fp
[
cf
]
<<
v_outline
[
i
].
offset
<<
" 00000 n "
<<
endl
;
}
for
(
int
i
=
0
;
i
<
(
int
)
v_pages
.
size
();
i
++
)
{
fp
[
cf
].
fill
(
'0'
);
fp
[
cf
].
width
(
10
);
fp
[
cf
]
<<
v_pages
[
i
].
offset
<<
" 00000 n "
<<
endl
;
}
for
(
int
i
=
0
;
i
<
(
int
)
v_content
.
size
();
i
++
)
{
fp
[
cf
].
fill
(
'0'
);
fp
[
cf
].
width
(
10
);
fp
[
cf
]
<<
v_content
[
i
].
offset
<<
" 00000 n "
<<
endl
;
}
for
(
int
i
=
0
;
i
<
(
int
)
v_font
.
size
();
i
++
)
{
fp
[
cf
].
fill
(
'0'
);
fp
[
cf
].
width
(
10
);
fp
[
cf
]
<<
v_font
[
i
].
offset
-
start_offset
<<
" 00000 n "
<<
endl
;
}
for
(
int
i
=
0
;
i
<
(
int
)
v_resource
.
size
();
i
++
)
{
fp
[
cf
].
fill
(
'0'
);
fp
[
cf
].
width
(
10
);
fp
[
cf
]
<<
v_resource
[
i
].
offset
-
start_offset
<<
" 00000 n "
<<
endl
;
}
for
(
int
i
=
0
;
i
<
(
int
)
v_image
.
size
();
i
++
)
{
fp
[
cf
].
fill
(
'0'
);
fp
[
cf
].
width
(
10
);
fp
[
cf
]
<<
v_image
[
i
].
offset
-
start_offset
<<
" 00000 n "
<<
endl
;
}
fp
[
cf
]
<<
endl
<<
"trailer"
<<
endl
<<
" << /Size "
<<
v_outline
.
size
()
+
v_pages
.
size
()
+
v_content
.
size
()
+
v_font
.
size
()
<<
endl
<<
" /Root 1 0 R"
<<
endl
<<
" >>"
<<
endl
<<
"startxref"
<<
endl
<<
xref_offset
-
start_offset
<<
endl
<<
"%%EOF"
<<
endl
;
fp
[
pdf_eFile_Body
].
close
();
}
void
CnvToPdf
::
print_horizontal_line
()
{
y
-=
3
;
fp
[
cf
]
<<
" 1 w"
<<
endl
<<
" "
<<
pdf_cLeftMargin
-
50
<<
" "
<<
y
<<
" m"
<<
endl
<<
" "
<<
pdf_cPageWidth
<<
" "
<<
y
<<
" l"
<<
endl
<<
" S"
<<
endl
;
y
-=
3
;
}
int
CnvToPdf
::
print_image_inline
(
char
*
filename
)
{
ImlibImage
*
image
;
Pixmap
pixmap
;
pwr_tFileName
fname
;
int
sts
;
int
width
,
height
;
unsigned
char
*
rgb
;
unsigned
char
transp
[
3
]
=
{
255
,
0
,
255
};
int
i
,
j
;
int
grey
;
double
scalex
=
0.71
;
double
scaley
=
0.78
;
x
=
pdf_cLeftMargin
;
// Try $pwr_doc/help/
strcpy
(
fname
,
"$pwr_doc/help/"
);
strcat
(
fname
,
filename
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
{
// Try $pwr_exe
strcpy
(
fname
,
"$pwr_exe/"
);
strcat
(
fname
,
filename
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
{
// Try $pwrp_exe
strcpy
(
fname
,
"$pwrp_exe/"
);
strcat
(
fname
,
filename
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
return
0
;
}
}
width
=
image
->
rgb_width
;
height
=
image
->
rgb_height
;
if
(
width
*
scalex
>
pdf_cPageWidth
-
pdf_cLeftMargin
)
{
x
=
pdf_cPageWidth
-
width
*
scalex
;
if
(
x
<
50
)
{
double
scale_factor
=
(
pdf_cPageWidth
-
50
)
/
(
width
*
scalex
);
x
=
50
;
scalex
=
scalex
*
scale_factor
;
scaley
=
scaley
*
scale_factor
;
}
}
if
(
y
-
height
*
scaley
+
20
<
pdf_cBottomMargin
)
print_pagebreak
(
0
);
fp
[
cf
]
<<
" q"
<<
endl
<<
scalex
*
width
<<
" 0 0 "
<<
scaley
*
height
<<
" "
<<
x
<<
" "
<<
y
-
scaley
*
height
<<
" cm"
<<
endl
<<
" BI"
<<
endl
<<
" /W "
<<
width
<<
endl
<<
" /H "
<<
height
<<
endl
<<
" /CS /G"
<<
endl
<<
" /BPC 8"
<<
endl
<<
#if 0
" /F /AHx" << endl <<
#endif
" ID"
<<
endl
;
rgb
=
image
->
rgb_data
;
j
=
0
;
for
(
i
=
0
;
i
<
image
->
rgb_height
*
image
->
rgb_width
*
3
;
i
+=
3
)
{
if
(
*
rgb
==
transp
[
0
]
&&
*
(
rgb
+
1
)
==
transp
[
1
]
&&
*
(
rgb
+
2
)
==
transp
[
2
])
{
grey
=
255
;
}
else
{
grey
=
(
int
)
((
0.0
+
*
rgb
+
*
(
rgb
+
1
)
+
*
(
rgb
+
2
))
/
3
+
0.5
);
}
rgb
+=
3
;
// fp[cf].width(2);
fp
[
cf
]
<<
(
unsigned
char
)
grey
;
if
(
++
j
>=
40
)
{
j
=
0
;
// fp[cf] << endl;
}
}
fp
[
cf
]
<<
endl
<<
"EI"
<<
endl
<<
" Q"
<<
endl
;
fp
[
cf
].
flags
(
((
fp
[
cf
].
flags
()
&
~
ios_base
::
hex
)
&
~
ios_base
::
uppercase
)
|
ios_base
::
dec
);
cnv_free_image
(
image
,
pixmap
);
y
-=
height
*
scaley
;
return
1
;
}
int
CnvToPdf
::
print_image
(
char
*
filename
)
{
ImlibImage
*
image
;
Pixmap
pixmap
;
pwr_tFileName
fname
;
int
sts
;
int
width
,
height
;
double
scalex
=
0.71
;
double
scaley
=
0.78
;
im_cnt
++
;
x
=
pdf_cLeftMargin
;
// Try $pwr_doc/help/
strcpy
(
fname
,
"$pwr_doc/help/"
);
strcat
(
fname
,
filename
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
{
// Try $pwr_exe
strcpy
(
fname
,
"$pwr_exe/"
);
strcat
(
fname
,
filename
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
{
// Try $pwrp_exe
strcpy
(
fname
,
"$pwrp_exe/"
);
strcat
(
fname
,
filename
);
dcli_translate_filename
(
fname
,
fname
);
sts
=
cnv_get_image
(
fname
,
&
image
,
&
pixmap
);
if
(
EVEN
(
sts
))
return
0
;
}
}
width
=
image
->
rgb_width
;
height
=
image
->
rgb_height
;
if
(
width
*
scalex
>
pdf_cPageWidth
-
pdf_cLeftMargin
)
{
x
=
pdf_cPageWidth
-
width
*
scalex
;
if
(
x
<
50
)
{
double
scale_factor
=
(
pdf_cPageWidth
-
50
)
/
(
width
*
scalex
);
x
=
50
;
scalex
=
scalex
*
scale_factor
;
scaley
=
scaley
*
scale_factor
;
}
}
if
(
y
-
height
*
scaley
+
20
<
pdf_cBottomMargin
)
print_pagebreak
(
0
);
fp
[
cf
]
<<
" q"
<<
endl
<<
" "
<<
scalex
*
width
<<
" 0 0 "
<<
scaley
*
height
<<
" "
<<
x
<<
" "
<<
y
-
scaley
*
height
<<
" cm"
<<
endl
<<
" /Im"
<<
im_cnt
<<
" Do"
<<
endl
<<
" Q"
<<
endl
;
if
(
conf_pass
)
{
if
(
v_pages
[
v_pages
.
size
()
-
1
].
resource
==
-
1
)
{
v_pages
[
v_pages
.
size
()
-
1
].
resource
=
v_resource
.
size
();
CnvPdfObj
o1
=
CnvPdfObj
(
this
,
pdf_eObjType_Resource
,
v_resource
.
size
()
+
1
);
v_resource
.
push_back
(
o1
);
}
v_resource
[
v_resource
.
size
()
-
1
].
xobject
[
v_resource
[
v_resource
.
size
()
-
1
].
xobject_cnt
]
=
v_image
.
size
();
v_resource
[
v_resource
.
size
()
-
1
].
xobject_cnt
++
;
CnvPdfObj
o2
=
CnvPdfObj
(
this
,
pdf_eObjType_Image
,
v_image
.
size
()
+
1
);
strcpy
(
o2
.
text
,
filename
);
v_image
.
push_back
(
o2
);
}
cnv_free_image
(
image
,
pixmap
);
y
-=
height
*
scaley
;
return
1
;
}
void
CnvToPdf
::
set_pageheader
(
char
*
text
)
{
strcpy
(
previous_chapter
,
current_chapter
);
strcpy
(
current_chapter
,
text
);
}
void
CnvToPdf
::
print_h1
(
char
*
text
,
int
hlevel
,
char
*
subject
)
{
char
hnum
[
40
];
if
(
ci
==
pdf_eId_Chapter
)
{
set_pageheader
(
text
);
}
if
(
style
[
ci
].
h1
.
display_number
)
{
if
(
hlevel
<
0
)
hlevel
=
0
;
if
(
hlevel
>
pdf_cMaxLevel
-
1
)
hlevel
=
pdf_cMaxLevel
-
1
;
header_number
[
hlevel
]
++
;
switch
(
hlevel
)
{
case
0
:
sprintf
(
hnum
,
"%d"
,
header_number
[
0
]);
break
;
case
1
:
sprintf
(
hnum
,
"%d.%d"
,
header_number
[
0
],
header_number
[
1
]);
break
;
case
2
:
sprintf
(
hnum
,
"%d.%d.%d"
,
header_number
[
0
],
header_number
[
1
],
header_number
[
2
]);
break
;
case
3
:
sprintf
(
hnum
,
"%d.%d.%d.%d"
,
header_number
[
0
],
header_number
[
1
],
header_number
[
2
],
header_number
[
3
]);
break
;
default:
;
}
x
=
pdf_cLeftMargin
-
50
;
print_text
(
hnum
,
style
[
ci
].
h1
,
pdf_mPrintMode_Pos
|
pdf_mPrintMode_FixX
);
double
x0
=
x
+
12.0
*
(
strlen
(
hnum
)
+
1
)
*
style
[
ci
].
h1
.
font_size
/
24
;
x
=
pdf_cLeftMargin
;
if
(
x0
>
x
)
x
=
x0
;
print_text
(
text
,
style
[
ci
].
h1
,
pdf_mPrintMode_KeepY
|
pdf_mPrintMode_FixX
);
}
else
print_text
(
text
,
style
[
ci
].
h1
);
if
(
conf_pass
&&
!
(
ci
==
pdf_eId_TitlePage
||
ci
==
pdf_eId_InfoPage
))
{
CnvContentElem
cnt
;
cnt
.
page_number
=
page_number
[
cf
];
cnt
.
header_level
=
hlevel
;
strcpy
(
cnt
.
header_number
,
hnum
);
strcpy
(
cnt
.
text
,
text
);
strcpy
(
cnt
.
subject
,
subject
);
content
.
add
(
cnt
);
}
strcpy
(
previous_chapter
,
current_chapter
);
}
void
CnvToPdf
::
print_h2
(
char
*
text
)
{
print_text
(
text
,
style
[
ci
].
h2
);
}
void
CnvToPdf
::
print_h3
(
char
*
text
)
{
print_text
(
text
,
style
[
ci
].
h3
);
}
void
CnvToPdf
::
open
()
{
y
=
pdf_cPageHeight
-
pdf_cTopMargin
;
im_cnt
=
0
;
if
(
conf_pass
)
{
fp
[
pdf_eFile_Body
].
open
(
filename
[
pdf_eFile_Body
]);
start_offset
=
fp
[
pdf_eFile_Body
].
tellp
();
}
else
{
print_content
();
conf_pass
=
true
;
page_number
[
cf
]
=
v_content
.
size
()
+
1
;
print_pagebreak
(
1
);
conf_pass
=
false
;
for
(
int
i
=
0
;
i
<
(
int
)
v_image
.
size
();
i
++
)
{
v_image
[
i
].
print_begin
();
v_image
[
i
].
print_end
();
}
// if ( v_content.size() > 0 && v_content[v_content.size()-1].length == 0)
// v_content[v_content.size()-1].length = (int) fp[pdf_eFile_Body].tellp() -
// v_content[v_content.size()-1].start;
fp
[
pdf_eFile_Body
].
seekp
(
start_offset
);
strcpy
(
previous_chapter
,
""
);
strcpy
(
current_chapter
,
""
);
}
cf
=
pdf_eFile_Body
;
page_number
[
cf
]
=
0
;
if
(
conf_pass
)
{
CnvPdfObj
o1
=
CnvPdfObj
(
this
,
pdf_eObjType_Catalog
,
v_outline
.
size
()
+
1
);
v_outline
.
push_back
(
o1
);
CnvPdfObj
o2
=
CnvPdfObj
(
this
,
pdf_eObjType_Outline
,
v_outline
.
size
()
+
1
);
v_outline
.
push_back
(
o2
);
CnvPdfObj
o3
=
CnvPdfObj
(
this
,
pdf_eObjType_Pages
,
v_pages
.
size
()
+
1
);
v_pages
.
push_back
(
o3
);
CnvPdfObj
o4
=
CnvPdfObj
(
this
,
pdf_eObjType_Process
,
v_font
.
size
()
+
1
);
v_font
.
push_back
(
o4
);
CnvPdfObj
o5
=
CnvPdfObj
(
this
,
pdf_eObjType_Font
,
v_font
.
size
()
+
1
);
strcpy
(
o5
.
fontname
,
"Helvetica"
);
v_font
.
push_back
(
o5
);
CnvPdfObj
o6
=
CnvPdfObj
(
this
,
pdf_eObjType_Font
,
v_font
.
size
()
+
1
);
strcpy
(
o6
.
fontname
,
"Helvetica-Bold"
);
v_font
.
push_back
(
o6
);
CnvPdfObj
o7
=
CnvPdfObj
(
this
,
pdf_eObjType_Font
,
v_font
.
size
()
+
1
);
strcpy
(
o7
.
fontname
,
"Helvetica-Oblique"
);
v_font
.
push_back
(
o7
);
CnvPdfObj
o8
=
CnvPdfObj
(
this
,
pdf_eObjType_Font
,
v_font
.
size
()
+
1
);
strcpy
(
o8
.
fontname
,
"TimesNewRoman"
);
v_font
.
push_back
(
o8
);
CnvPdfObj
o9
=
CnvPdfObj
(
this
,
pdf_eObjType_Font
,
v_font
.
size
()
+
1
);
strcpy
(
o9
.
fontname
,
"TimesNewRoman-Bold"
);
v_font
.
push_back
(
o9
);
CnvPdfObj
o10
=
CnvPdfObj
(
this
,
pdf_eObjType_Font
,
v_font
.
size
()
+
1
);
strcpy
(
o10
.
fontname
,
"Courier"
);
v_font
.
push_back
(
o10
);
}
fp
[
cf
]
<<
pdf_cHead
<<
endl
;
for
(
int
i
=
0
;
i
<
(
int
)
v_outline
.
size
();
i
++
)
{
v_outline
[
i
].
print_begin
();
v_outline
[
i
].
print_end
();
}
for
(
int
i
=
0
;
i
<
(
int
)
v_pages
.
size
();
i
++
)
{
v_pages
[
i
].
print_begin
();
v_pages
[
i
].
print_end
();
}
print_pagebreak
(
0
);
for
(
int
i
=
1
;
i
<
pdf_cMaxLevel
;
i
++
)
header_number
[
i
]
=
0
;
}
void
CnvToPdf
::
incr_headerlevel
()
{
ci
++
;
if
(
ci
>
pdf_eId_TopicL3
)
ci
=
pdf_eId_TopicL3
;
if
(
ci
<
pdf_eId_TopicL1
)
ci
=
pdf_eId_TopicL1
;
header_number
[
ci
-
(
int
)
pdf_eId_Chapter
]
=
0
;
}
void
CnvToPdf
::
decr_headerlevel
()
{
ci
--
;
if
(
ci
<
pdf_eId_TopicL1
)
ci
=
pdf_eId_TopicL1
;
}
void
CnvToPdf
::
reset_headernumbers
(
int
level
)
{
for
(
int
i
=
level
;
i
<
pdf_cMaxLevel
;
i
++
)
header_number
[
i
]
=
0
;
}
char
*
CnvToPdf
::
fontname
(
CnvStyle
&
style
)
{
static
char
str
[
80
];
char
name
[
80
];
strcpy
(
name
,
style
.
font
.
c_str
());
if
(
strncmp
(
name
,
"Helvetica-Bold"
,
14
)
==
0
)
strcpy
(
str
,
"/F2"
);
else
if
(
strncmp
(
name
,
"Helvetica-Oblique"
,
17
)
==
0
)
strcpy
(
str
,
"/F3"
);
else
if
(
strncmp
(
name
,
"Helvetica"
,
9
)
==
0
)
strcpy
(
str
,
"/F1"
);
else
if
(
strncmp
(
name
,
"TimesNewRoman-Bold"
,
18
)
==
0
)
strcpy
(
str
,
"/F5"
);
else
if
(
strncmp
(
name
,
"TimesNewRoman"
,
13
)
==
0
)
strcpy
(
str
,
"/F4"
);
else
if
(
strncmp
(
name
,
"Courier"
,
7
)
==
0
)
strcpy
(
str
,
"/F6"
);
else
strcpy
(
str
,
"/F1"
);
return
str
;
}
src/exe/co_convert/src/cnv_topdf.h
0 → 100644
View file @
ac05ff75
#ifndef cnv_topdf_h
#define cnv_topdf_h
/* cnv_topdf.h -- Postscript output
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
using
namespace
std
;
#include <iostream.h>
#include <vector.h>
#include <string>
#include "pwr.h"
#include "cnv_style.h"
#include "cnv_content.h"
#define pdf_cMaxLevel 4
#define pdf_cPageHeight 790
#define pdf_cPageWidth 535
#define pdf_cPageNumX (pdf_cPageWidth - 10)
#define pdf_cPageNumY (pdf_cPageHeight - 13)
#define pdf_cLeftMargin 100
#define pdf_cTopMargin 100
#define pdf_cBottomMargin 50
#define pdf_cCellSize 110
#define pdf_cTmpFile "/tmp/ptmp.ps"
typedef
enum
{
pdf_mPrintMode_Pos
=
1
<<
0
,
pdf_mPrintMode_Start
=
1
<<
1
,
pdf_mPrintMode_Continue
=
1
<<
2
,
pdf_mPrintMode_End
=
1
<<
3
,
pdf_mPrintMode_KeepY
=
1
<<
4
,
pdf_mPrintMode_FixX
=
1
<<
5
}
pdf_mPrintMode
;
typedef
enum
{
pdf_eFile_Body
,
pdf_eFile__
}
pdf_eFile
;
typedef
enum
{
pdf_eId_TitlePage
,
pdf_eId_InfoPage
,
pdf_eId_Content
,
pdf_eId_Chapter
,
pdf_eId_TopicL1
,
pdf_eId_TopicL2
,
pdf_eId_TopicL3
,
pdf_eId_Function
,
pdf_eId_Class
,
pdf_eId__
}
pdf_eId
;
typedef
enum
{
pdf_eObjType_Catalog
,
pdf_eObjType_Page
,
pdf_eObjType_Pages
,
pdf_eObjType_Outline
,
pdf_eObjType_OutlineO
,
pdf_eObjType_Content
,
pdf_eObjType_Process
,
pdf_eObjType_Font
,
pdf_eObjType_Resource
,
pdf_eObjType_Image
}
pdf_eObjType
;
class
CnvToPdf
;
class
CnvPdfObj
{
public:
CnvPdfObj
(
CnvToPdf
*
otopdf
,
pdf_eObjType
otype
,
int
onumber
)
:
topdf
(
otopdf
),
type
(
otype
),
number
(
onumber
),
length
(
0
),
offset
(
0
),
start
(
0
),
parent
(
0
),
first
(
0
),
last
(
0
),
next
(
0
),
prev
(
0
),
dest
(
0
),
count
(
0
),
resource
(
-
1
),
xobject_cnt
(
0
)
{
strcpy
(
fontname
,
""
);
strcpy
(
text
,
""
);}
void
print_begin
();
void
print_end
();
int
print_image
();
CnvToPdf
*
topdf
;
pdf_eObjType
type
;
int
number
;
int
length
;
int
offset
;
int
start
;
char
fontname
[
80
];
int
parent
;
int
first
;
int
last
;
int
next
;
int
prev
;
int
dest
;
int
count
;
char
text
[
200
];
int
resource
;
int
xobject_cnt
;
int
xobject
[
40
];
};
class
CnvToPdf
{
public:
CnvToPdf
()
:
cf
(
0
),
ci
(
0
),
prev_ci
(
0
),
conf_pass
(
false
),
xref_offset
(
0
),
im_cnt
(
0
)
{
for
(
int
i
=
0
;
i
<
pdf_cMaxLevel
;
i
++
)
header_number
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<
pdf_eFile__
;
i
++
)
page_number
[
i
]
=
0
;
style
[
pdf_eId_TitlePage
].
h1
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
35
,
0
,
100
,
20
,
cnv_eAlignment_Center
,
0
,
0
,
0
);
style
[
pdf_eId_TitlePage
].
h2
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
25
,
0
,
50
,
20
,
cnv_eAlignment_Center
,
0
,
0
,
0
);
style
[
pdf_eId_TitlePage
].
h3
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
15
,
0
,
25
,
10
,
cnv_eAlignment_Center
,
0
,
0
,
0
);
style
[
pdf_eId_TitlePage
].
text
=
CnvStyle
(
"Helvetica-ISOLatin1"
,
8
,
0
,
9
,
1
,
cnv_eAlignment_Center
,
0
,
0
,
0
);
style
[
pdf_eId_TitlePage
].
boldtext
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
8
,
0
,
9
,
1
,
cnv_eAlignment_Center
,
0
,
0
,
0
);
style
[
pdf_eId_InfoPage
].
h1
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
24
,
0
,
100
,
20
,
cnv_eAlignment_Left
,
0
,
0
,
0
);
style
[
pdf_eId_Chapter
].
h1
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
24
,
0
,
24
,
40
,
cnv_eAlignment_Left
,
0
,
1
,
1
);
style
[
pdf_eId_TopicL2
].
h1
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
12
,
0
,
20
,
10
,
cnv_eAlignment_Left
,
0
,
0
,
1
);
style
[
pdf_eId_TopicL2
].
h2
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
10
,
0
,
16
,
8
,
cnv_eAlignment_Left
,
0
,
0
,
0
);
style
[
pdf_eId_TopicL3
].
h1
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
10
,
0
,
16
,
8
,
cnv_eAlignment_Left
,
0
,
0
,
1
);
style
[
pdf_eId_TopicL3
].
h2
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
8
,
0
,
16
,
5
,
cnv_eAlignment_Left
,
0
,
0
,
0
);
style
[
pdf_eId_Function
].
h1
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
24
,
0
,
24
,
20
,
cnv_eAlignment_Left
,
1
,
0
,
1
);
style
[
pdf_eId_Class
].
h1
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
24
,
0
,
24
,
20
,
cnv_eAlignment_Left
,
1
,
0
,
1
);
style
[
pdf_eId_Class
].
h2
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
20
,
0
,
24
,
8
,
cnv_eAlignment_Left
,
0
,
0
,
0
);
style
[
pdf_eId_Class
].
h3
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
16
,
-
40
,
24
,
6
,
cnv_eAlignment_Left
,
0
,
0
,
0
);
style
[
pdf_eId_Content
].
boldtext
=
CnvStyle
(
"Helvetica-Bold-ISOLatin1"
,
10
,
0
,
11
,
1
,
cnv_eAlignment_Left
,
0
,
0
,
0
);
style
[
pdf_eId_Chapter
].
text
=
CnvStyle
(
"TimesNewRoman-ISOLatin1"
,
10
,
0
,
11
,
1
,
cnv_eAlignment_Left
,
0
,
0
,
0
);
style
[
pdf_eId_TopicL1
].
text
=
CnvStyle
(
"TimesNewRoman-ISOLatin1"
,
10
,
0
,
11
,
1
,
cnv_eAlignment_Left
,
0
,
0
,
0
);
style
[
pdf_eId_TopicL2
].
text
=
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
);
}
~
CnvToPdf
();
void
close
();
void
print_text
(
char
*
text
,
CnvStyle
&
style
,
int
mode
=
pdf_mPrintMode_Pos
);
void
print_pagebreak
(
int
print_num
);
void
print_content
();
void
print_h1
(
char
*
text
,
int
hlevel
,
char
*
subject
);
void
print_h2
(
char
*
text
);
void
print_h3
(
char
*
text
);
void
print_horizontal_line
();
int
print_image
(
char
*
filename
);
int
print_image_inline
(
char
*
filename
);
void
cnv_text
(
char
*
to
,
char
*
from
);
void
set_confpass
(
bool
conf
)
{
conf_pass
=
conf
;
if
(
!
conf
)
{
// Reset
for
(
int
i
=
0
;
i
<
pdf_cMaxLevel
;
i
++
)
header_number
[
i
]
=
0
;
for
(
int
i
=
0
;
i
<
pdf_eFile__
;
i
++
)
page_number
[
i
]
=
0
;
cf
=
0
;
ci
=
0
;
}
}
void
set_ci
(
int
val
)
{
prev_ci
=
ci
;
ci
=
val
;}
void
set_cf
(
int
val
)
{
cf
=
val
;}
void
set_filename
(
int
idx
,
char
*
name
)
{
strcpy
(
filename
[
idx
],
name
);
}
void
open
();
void
incr_headerlevel
();
void
decr_headerlevel
();
void
reset_headernumbers
(
int
level
);
void
set_pageheader
(
char
*
text
);
char
*
fontname
(
CnvStyle
&
style
);
vector
<
CnvPdfObj
>
v_pages
;
vector
<
CnvPdfObj
>
v_outline
;
vector
<
CnvPdfObj
>
v_content
;
vector
<
CnvPdfObj
>
v_font
;
vector
<
CnvPdfObj
>
v_resource
;
vector
<
CnvPdfObj
>
v_image
;
CnvContent
content
;
CnvIdStyle
style
[
pdf_eId__
];
ofstream
fp
[
pdf_eFile__
];
pwr_tFileName
filename
[
pdf_eFile__
];
int
cf
;
int
ci
;
int
prev_ci
;
double
x
;
double
y
;
int
page_number
[
pdf_eFile__
];
int
header_number
[
pdf_cMaxLevel
];
bool
conf_pass
;
char
current_chapter
[
160
];
char
previous_chapter
[
160
];
int
start_offset
;
int
xref_offset
;
int
im_cnt
;
};
#endif
src/exe/co_convert/src/cnv_xtthelptopdf.cpp
0 → 100644
View file @
ac05ff75
/* cnv_xtthelptopdf.cpp --
PROVIEW/R
Copyright (C) 1996-98 by Mandator AB.
Convert xtt help file to postscript. */
/*_Include files_________________________________________________________*/
#include <iostream.h>
#include <fstream.h>
#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_xtthelptopdf.h"
#include "cnv_image.h"
#define pdf_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
void
CnvXtthelpToPdf
::
subject_to_fname
(
char
*
fname
,
char
*
subject
,
int
path
)
{
if
(
path
)
{
strcpy
(
fname
,
ctx
->
dir
);
strcat
(
fname
,
ctx
->
rx
->
name
);
}
else
strcpy
(
fname
,
ctx
->
rx
->
name
);
strcat
(
fname
,
".pdf"
);
cdh_ToLower
(
fname
,
fname
);
}
CnvXtthelpToPdf
::~
CnvXtthelpToPdf
()
{
if
(
!
first_topic
)
{
if
(
status
&
pdf_mStatus_xtthelp
)
{
status
&=
~
pdf_mStatus_xtthelp
;
}
}
topdf
.
close
();
}
void
*
CnvXtthelpToPdf
::
insert
(
navh_eItemType
item_type
,
char
*
text1
,
char
*
text2
,
char
*
text3
,
char
*
alink
,
char
*
link_bookmark
,
char
*
file_name
,
navh_eHelpFile
file_type
,
int
help_index
,
char
*
bookmark
)
{
char
link
[
80
];
if
(
alink
)
strcpy
(
link
,
alink
);
if
(
option
&
pdf_mOption_printDisable
&&
item_type
!=
navh_eItemType_Option
)
return
NULL
;
if
(
(
text2
&&
strcmp
(
text2
,
""
)
!=
0
)
||
(
text3
&&
strcmp
(
text3
,
""
)
!=
0
)
)
{
if
(
!
(
status
&
pdf_mStatus_table
))
status
|=
pdf_mStatus_table
;
}
else
{
if
(
status
&
pdf_mStatus_table
)
{
// Close table (keep if empty line)
if
(
!
(
text1
&&
strcmp
(
text1
,
""
)
==
0
&&
(
item_type
==
navh_eItemType_Help
||
item_type
==
navh_eItemType_HelpCode
||
item_type
==
navh_eItemType_HelpBold
)))
status
&=
~
pdf_mStatus_table
;
}
}
switch
(
item_type
)
{
case
navh_eItemType_DocTitlePage
:
case
navh_eItemType_DocInfoPage
:
case
navh_eItemType_Topic
:
{
strcpy
(
current_subject
,
text1
);
if
(
item_type
==
navh_eItemType_DocTitlePage
)
{
topdf
.
set_ci
(
pdf_eId_TitlePage
);
}
else
if
(
item_type
==
navh_eItemType_DocInfoPage
)
{
topdf
.
set_ci
(
pdf_eId_InfoPage
);
topdf
.
print_pagebreak
(
0
);
}
else
{
if
(
topdf
.
ci
==
pdf_eId_Chapter
)
{
if
(
!
first_chaptertopic
)
topdf
.
set_ci
(
pdf_eId_TopicL1
);
else
{
first_chaptertopic
=
0
;
topdf
.
y
=
pdf_cPageHeight
-
pdf_cTopMargin
;
}
}
}
if
(
first_topic
)
{
pwr_tFileName
fname
;
subject_to_fname
(
fname
,
text1
,
1
);
topdf
.
set_filename
(
pdf_eFile_Body
,
fname
);
topdf
.
open
();
status
|=
pdf_mStatus_xtthelp
;
first_topic
=
0
;
}
status
|=
pdf_mStatus_topic
;
return
NULL
;
}
case
navh_eItemType_EndTopic
:
{
if
(
status
&
pdf_mStatus_table
)
status
&=
~
pdf_mStatus_table
;
if
(
status
&
pdf_mStatus_paragraph
)
status
&=
~
pdf_mStatus_paragraph
;
if
(
status
&
pdf_mStatus_topic
)
status
&=
~
pdf_mStatus_topic
;
if
(
user_style
)
{
user_style
=
0
;
topdf
.
set_ci
(
base_ci
);
}
return
NULL
;
}
case
navh_eItemType_Style
:
{
if
(
cdh_NoCaseStrcmp
(
text1
,
"function"
)
==
0
)
{
base_ci
=
topdf
.
ci
;
topdf
.
set_ci
(
pdf_eId_Function
);
user_style
=
1
;
}
return
NULL
;
}
case
navh_eItemType_EndChapter
:
{
if
(
status
&
pdf_mStatus_table
)
status
&=
~
pdf_mStatus_table
;
if
(
status
&
pdf_mStatus_paragraph
)
status
&=
~
pdf_mStatus_paragraph
;
if
(
status
&
pdf_mStatus_topic
)
status
&=
~
pdf_mStatus_topic
;
topdf
.
set_ci
(
pdf_eId_TopicL1
);
user_style
=
0
;
return
NULL
;
}
case
navh_eItemType_Chapter
:
{
if
(
status
&
pdf_mStatus_table
)
status
&=
~
pdf_mStatus_table
;
if
(
status
&
pdf_mStatus_paragraph
)
status
&=
~
pdf_mStatus_paragraph
;
if
(
status
&
pdf_mStatus_topic
)
status
&=
~
pdf_mStatus_topic
;
topdf
.
set_ci
(
pdf_eId_Chapter
);
first_chaptertopic
=
1
;
user_style
=
0
;
topdf
.
reset_headernumbers
(
1
);
return
NULL
;
}
case
navh_eItemType_HeaderLevel
:
{
if
(
user_style
)
{
user_style
=
0
;
topdf
.
set_ci
(
base_ci
);
}
topdf
.
incr_headerlevel
();
return
NULL
;
}
case
navh_eItemType_EndHeaderLevel
:
{
if
(
user_style
)
{
user_style
=
0
;
topdf
.
set_ci
(
base_ci
);
}
topdf
.
decr_headerlevel
();
return
NULL
;
}
case
navh_eItemType_PageBreak
:
{
topdf
.
print_pagebreak
(
0
);
return
NULL
;
}
case
navh_eItemType_Help
:
case
navh_eItemType_HelpCode
:
case
navh_eItemType_HelpBold
:
{
int
printmode
;
CnvStyle
*
hstyle
;
// Unable to calculate lenght because link i not known in confpass
strcpy
(
link
,
""
);
if
(
item_type
==
navh_eItemType_Help
)
hstyle
=
&
topdf
.
style
[
topdf
.
ci
].
text
;
else
if
(
item_type
==
navh_eItemType_HelpBold
)
hstyle
=
&
topdf
.
style
[
topdf
.
ci
].
boldtext
;
else
if
(
item_type
==
navh_eItemType_HelpCode
)
hstyle
=
&
topdf
.
style
[
topdf
.
ci
].
code
;
if
(
strcmp
(
link
,
""
)
!=
0
)
printmode
=
pdf_mPrintMode_Start
;
else
printmode
=
pdf_mPrintMode_Pos
;
if
(
!
(
status
&
pdf_mStatus_table
))
{
topdf
.
x
=
pdf_cLeftMargin
;
topdf
.
print_text
(
text1
,
*
hstyle
,
printmode
);
}
else
{
topdf
.
x
=
pdf_cLeftMargin
;
topdf
.
print_text
(
text1
,
*
hstyle
);
if
(
text2
&&
strcmp
(
text2
,
""
)
!=
0
)
{
topdf
.
x
=
pdf_cLeftMargin
+
pdf_cCellSize
;
topdf
.
print_text
(
text2
,
*
hstyle
,
pdf_mPrintMode_KeepY
|
pdf_mPrintMode_FixX
);
}
if
(
text3
&&
strcmp
(
text3
,
""
)
!=
0
)
{
topdf
.
x
=
pdf_cLeftMargin
+
2
*
pdf_cCellSize
;
topdf
.
print_text
(
text3
,
*
hstyle
,
pdf_mPrintMode_KeepY
|
pdf_mPrintMode_FixX
);
}
}
if
(
strcmp
(
link
,
""
)
!=
0
&&
!
conf_pass
)
{
pwr_tFileName
fname
;
char
str
[
200
];
int
page
;
if
(
strncmp
(
link
,
"$web:"
,
5
)
==
0
)
{
if
(
strncmp
(
&
link
[
5
],
"$pwrp_web/"
,
10
)
==
0
)
strcpy
(
fname
,
&
link
[
15
]);
else
strcpy
(
fname
,
&
link
[
5
]);
sprintf
(
str
,
" (%s %s)"
,
Lng
::
translate
(
"See"
),
fname
);
if
(
!
(
status
&
pdf_mStatus_table
))
topdf
.
print_text
(
str
,
topdf
.
style
[
topdf
.
ci
].
link
,
pdf_mPrintMode_End
|
pdf_mPrintMode_FixX
);
else
{
topdf
.
x
=
pdf_cLeftMargin
+
3
*
pdf_cCellSize
;
if
(
pdf_cLeftMargin
+
2
*
pdf_cCellSize
+
strlen
(
text3
)
*
hstyle
->
font_size
*
0.65
>
topdf
.
x
)
topdf
.
x
=
pdf_cLeftMargin
+
2
*
pdf_cCellSize
+
strlen
(
text3
)
*
hstyle
->
font_size
*
0.65
;
topdf
.
print_text
(
str
,
topdf
.
style
[
topdf
.
ci
].
link
,
pdf_mPrintMode_End
|
pdf_mPrintMode_FixX
);
}
}
else
if
(
(
strstr
(
link
,
".htm"
)
!=
0
)
||
(
strstr
(
link
,
".pdf"
)
!=
0
))
{
strcpy
(
fname
,
link
);
sprintf
(
str
,
" (%s %s)"
,
Lng
::
translate
(
"See"
),
fname
);
if
(
!
(
status
&
pdf_mStatus_table
))
topdf
.
print_text
(
str
,
topdf
.
style
[
topdf
.
ci
].
link
,
pdf_mPrintMode_End
|
pdf_mPrintMode_FixX
);
else
{
topdf
.
x
=
pdf_cLeftMargin
+
3
*
pdf_cCellSize
;
if
(
pdf_cLeftMargin
+
2
*
pdf_cCellSize
+
strlen
(
text3
)
*
hstyle
->
font_size
*
0.65
>
topdf
.
x
)
topdf
.
x
=
pdf_cLeftMargin
+
2
*
pdf_cCellSize
+
strlen
(
text3
)
*
hstyle
->
font_size
*
0.65
;
topdf
.
print_text
(
str
,
topdf
.
style
[
topdf
.
ci
].
link
,
pdf_mPrintMode_End
|
pdf_mPrintMode_FixX
);
}
}
else
{
char
text
[
80
];
int
sts
=
topdf
.
content
.
find_link
(
link
,
text
,
&
page
);
if
(
ODD
(
sts
))
{
sprintf
(
str
,
" (%s %s "
,
Lng
::
translate
(
"See"
),
text
);
sprintf
(
&
str
[
strlen
(
str
)],
"%s %d)"
,
Lng
::
translate
(
"page"
),
page
);
if
(
!
(
status
&
pdf_mStatus_table
))
topdf
.
print_text
(
str
,
topdf
.
style
[
topdf
.
ci
].
link
,
pdf_mPrintMode_End
|
pdf_mPrintMode_FixX
);
else
{
#if 0
if ( !(text3 && strcmp(text3, "") != 0)) {
topdf.x = pdf_cLeftMargin + 2 * pdf_cCellSize;
if ( pdf_cLeftMargin + pdf_cCellSize + strlen(text2) * hstyle->font_size * 0.5 > topdf.x)
topdf.x = pdf_cLeftMargin + pdf_cCellSize + strlen(text2) * hstyle->font_size * 0.5;
}
else {
topdf.x = pdf_cLeftMargin + 3 * pdf_cCellSize;
if ( pdf_cLeftMargin + pdf_cCellSize + strlen(text3) * hstyle->font_size * 0.5 > topdf.x)
topdf.x = pdf_cLeftMargin + 2 * pdf_cCellSize + strlen(text3) * hstyle->font_size * 0.5;
}
topdf.print_text( str, topdf.style[topdf.ci].link,
pdf_mPrintMode_KeepY | pdf_mPrintMode_FixX);
#endif
}
}
else
if
(
!
(
status
&
pdf_mStatus_table
))
topdf
.
print_text
(
""
,
topdf
.
style
[
topdf
.
ci
].
link
,
pdf_mPrintMode_End
|
pdf_mPrintMode_FixX
);
}
}
else
if
(
bookmark
)
{
// fp[cf] << tags[pdf_eTag_link].start << " name=\"" << bookmark << "\">";
}
return
NULL
;
}
case
navh_eItemType_HelpHeader
:
{
int
hlevel
;
if
(
!
user_style
)
hlevel
=
topdf
.
ci
-
(
int
)
pdf_eId_Chapter
;
else
hlevel
=
base_ci
-
(
int
)
pdf_eId_Chapter
;
topdf
.
print_h1
(
text1
,
hlevel
,
current_subject
);
return
NULL
;
}
case
navh_eItemType_Header
:
{
topdf
.
print_h3
(
text1
);
return
NULL
;
}
case
navh_eItemType_HeaderLarge
:
{
topdf
.
print_h2
(
text1
);
return
NULL
;
}
case
navh_eItemType_HorizontalLine
:
{
topdf
.
print_horizontal_line
();
return
NULL
;
}
case
navh_eItemType_Image
:
{
int
sts
=
topdf
.
print_image
(
text1
);
if
(
EVEN
(
sts
))
printf
(
"Image: %s not found
\n
"
,
text1
);
return
NULL
;
}
case
navh_eItemType_Option
:
{
if
(
strcmp
(
text1
,
"printdisable"
)
==
0
)
option
|=
pdf_mOption_printDisable
;
else
if
(
strcmp
(
text1
,
"printenable"
)
==
0
)
option
&=
~
pdf_mOption_printDisable
;
return
NULL
;
}
default:
return
0
;
}
return
0
;
}
src/exe/co_convert/src/cnv_xtthelptopdf.h
0 → 100644
View file @
ac05ff75
#ifndef cnv_xtthelptopdf_h
#define cnv_xtthelptopdf_h
/* cnv_xtthelptodf.h -- Documentation
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
using
namespace
std
;
#include <iostream.h>
#include <vector.h>
#include <string>
#include "pwr.h"
#include "cnv_xtthelpto.h"
#include "cnv_style.h"
#include "cnv_content.h"
#include "cnv_topdf.h"
class
CnvCtx
;
typedef
enum
{
pdf_mStatus_xtthelp
=
1
<<
0
,
pdf_mStatus_paragraph
=
1
<<
1
,
pdf_mStatus_table
=
1
<<
2
,
pdf_mStatus_topic
=
1
<<
3
}
pdf_mStatus
;
typedef
enum
{
pdf_mOption_printDisable
=
1
<<
0
}
pdf_mOption
;
class
CnvXtthelpToPdf
:
public
CnvXtthelpTo
{
public:
CnvXtthelpToPdf
(
CnvCtx
*
cnv_ctx
)
:
ctx
(
cnv_ctx
),
base_ci
(
0
),
first_topic
(
1
),
user_style
(
0
),
status
(
0
),
conf_pass
(
false
),
option
(
0
)
{
strcpy
(
current_subject
,
""
);
}
virtual
~
CnvXtthelpToPdf
();
Cnv_eXtthelpToType
type
()
{
return
Cnv_eXtthelpToType_Ps
;}
void
*
insert
(
navh_eItemType
item_type
,
char
*
text1
,
char
*
text2
,
char
*
text3
,
char
*
link
,
char
*
link_bookmark
,
char
*
file_name
,
navh_eHelpFile
file_type
,
int
help_index
,
char
*
bookmark
);
void
subject_to_fname
(
char
*
fname
,
char
*
subject
,
int
path
);
bool
confpass
()
{
return
true
;}
void
set_confpass
(
bool
conf
)
{
topdf
.
set_confpass
(
conf
);
conf_pass
=
conf
;
if
(
!
conf
)
{
// Reset
base_ci
=
0
;
user_style
=
0
;
first_topic
=
1
;
status
=
0
;
}
}
CnvCtx
*
ctx
;
CnvToPdf
topdf
;
int
base_ci
;
int
first_topic
;
int
first_chaptertopic
;
int
user_style
;
unsigned
int
status
;
bool
conf_pass
;
char
current_subject
[
80
];
unsigned
int
option
;
};
#endif
src/exe/co_convert/src/co_convert.cpp
View file @
ac05ff75
...
...
@@ -22,6 +22,7 @@ extern "C" {
#include "cnv_xtthelptohtml.h"
#include "cnv_xtthelptoxml.h"
#include "cnv_xtthelptops.h"
#include "cnv_xtthelptopdf.h"
typedef
char
cnv_tName
[
200
];
...
...
@@ -38,6 +39,7 @@ static void usage()
printf
(
" -t: Create html from xtthelp-file
\n
"
);
printf
(
" -m: Create xml from xtthelp-file
\n
"
);
printf
(
" -n: Create postscript from xtthelp-file
\n
"
);
printf
(
" -f: Create pdf from xtthelp-file
\n
"
);
printf
(
" -q: Create postscript from wb_load-files
\n
"
);
printf
(
" -d: Output directory
\n
"
);
printf
(
" -g: Setup file
\n
"
);
...
...
@@ -101,6 +103,7 @@ int main( int argc, char *argv[])
int
xtthelp_to_html
=
0
;
int
xtthelp_to_xml
=
0
;
int
xtthelp_to_ps
=
0
;
int
xtthelp_to_pdf
=
0
;
if
(
argc
<
2
||
argc
>
9
)
{
usage
();
...
...
@@ -185,6 +188,98 @@ int main( int argc, char *argv[])
case
'n'
:
xtthelp_to_ps
=
1
;
break
;
case
'f'
:
xtthelp_to_pdf
=
1
;
break
;
default:
usage
();
exit
(
0
);
}
s
++
;
}
}
else
strcpy
(
files
,
argv
[
i
]);
}
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
if
(
i
+
1
>=
argc
)
{
usage
();
exit
(
0
);
}
strcpy
(
ctx
->
dir
,
argv
[
i
+
1
]);
i
++
;
#if defined OS_VMS
if
(
ctx
->
dir
[
strlen
(
ctx
->
dir
)
-
1
]
!=
':'
&&
(
ctx
->
dir
[
strlen
(
ctx
->
dir
)
-
1
]
!=
'>'
&&
ctx
->
dir
[
strlen
(
ctx
->
dir
)
-
1
]
!=
']'
))
strcat
(
ctx
->
dir
,
":"
);
#else
if
(
ctx
->
dir
[
strlen
(
ctx
->
dir
)
-
1
]
!=
'/'
)
strcat
(
ctx
->
dir
,
"/"
);
#endif
}
if
(
strcmp
(
argv
[
i
],
"-g"
)
==
0
)
{
if
(
i
+
1
>=
argc
)
{
usage
();
exit
(
0
);
}
strcpy
(
ctx
->
setup_filename
,
argv
[
i
+
1
]);
i
++
;
}
if
(
strcmp
(
argv
[
i
],
"-l"
)
==
0
)
{
if
(
i
+
1
>=
argc
)
{
usage
();
exit
(
0
);
}
Lng
::
set
(
argv
[
i
+
1
]);
i
++
;
}
else
if
(
argv
[
i
][
0
]
==
'-'
)
{
s
=
&
argv
[
i
][
1
];
while
(
*
s
)
{
switch
(
*
s
)
{
case
'h'
:
help
();
exit
(
0
);
case
'w'
:
ctx
->
generate_html
=
1
;
break
;
case
'x'
:
ctx
->
generate_xtthelp
=
1
;
break
;
case
'c'
:
ctx
->
generate_src
=
1
;
break
;
case
's'
:
ctx
->
generate_struct
=
1
;
break
;
case
'q'
:
ctx
->
generate_ps
=
1
;
ctx
->
common_structfile_only
=
1
;
break
;
case
'p'
:
ctx
->
generate_struct
=
1
;
ctx
->
hpp
=
1
;
break
;
case
'o'
:
ctx
->
common_structfile_only
=
1
;
break
;
case
'v'
:
ctx
->
verbose
=
1
;
break
;
case
't'
:
xtthelp_to_html
=
1
;
break
;
case
'm'
:
xtthelp_to_xml
=
1
;
break
;
case
'n'
:
xtthelp_to_ps
=
1
;
break
;
case
'f'
:
xtthelp_to_pdf
=
1
;
break
;
default:
usage
();
exit
(
0
);
...
...
@@ -225,6 +320,14 @@ int main( int argc, char *argv[])
delete
xtthelpto
;
exit
(
0
);
}
if
(
xtthelp_to_pdf
)
{
CnvXtthelpToPdf
*
xtthelpto
=
new
CnvXtthelpToPdf
(
ctx
);
ctx
->
rx
=
new
CnvReadXtthelp
(
files
,
ctx
->
dir
,
xtthelpto
);
ctx
->
rx
->
read_xtthelp
();
delete
ctx
->
rx
;
delete
xtthelpto
;
exit
(
0
);
}
// Get the files and order them
file_cnt
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment